com.sun.jersey.api.core.PackagesResourceConfig Java Examples

The following examples show how to use com.sun.jersey.api.core.PackagesResourceConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NettyClientTest.java    From ribbon with Apache License 2.0 6 votes vote down vote up
@BeforeClass 
public static void init() throws Exception {
    PackagesResourceConfig resourceConfig = new PackagesResourceConfig("com.netflix.ribbon.test.resources");
    port = (new Random()).nextInt(1000) + 4000;
    SERVICE_URI = "http://localhost:" + port + "/";
    ExecutorService service = Executors.newFixedThreadPool(20);
    try{
        server = HttpServerFactory.create(SERVICE_URI, resourceConfig);           
        server.setExecutor(service);
        server.start();
    } catch(Exception e) {
        e.printStackTrace();
        fail("Unable to start server");
    }
    // LogManager.getRootLogger().setLevel(Level.DEBUG);
}
 
Example #2
Source File: ServerProvider.java    From angulardemorestful with MIT License 6 votes vote down vote up
public void createServer() throws IOException {
    System.out.println("Starting grizzly...");

    Injector injector = Guice.createInjector(new ServletModule() {
        @Override
        protected void configureServlets() {
            bind(UserService.class).to(UserServiceImpl.class);
            bind(UserRepository.class).to(UserMockRepositoryImpl.class);
            bind(DummyService.class).to(DummyServiceImpl.class);
            bind(DummyRepository.class).to(DummyMockRepositoryImpl.class);

            // hook Jackson into Jersey as the POJO <-> JSON mapper
            bind(JacksonJsonProvider.class).in(Scopes.SINGLETON);
        }
    });

    ResourceConfig rc = new PackagesResourceConfig("ngdemo.web");
    IoCComponentProviderFactory ioc = new GuiceComponentProviderFactory(rc, injector);
    server = GrizzlyServerFactory.createHttpServer(BASE_URI + "web/", rc, ioc);

    System.out.println(String.format("Jersey app started with WADL available at "
            + "%srest/application.wadl\nTry out %sngdemo\nHit enter to stop it...",
            BASE_URI, BASE_URI));
}
 
Example #3
Source File: NgDemoApplicationSetup.java    From angulardemorestful with MIT License 6 votes vote down vote up
@Override
protected Injector getInjector() {
    return Guice.createInjector(new ServletModule() {

        @Override
        protected void configureServlets() {

            super.configureServlets();

            // Configuring Jersey via Guice:
            ResourceConfig resourceConfig = new PackagesResourceConfig("ngdemo/web");
            for (Class<?> resource : resourceConfig.getClasses()) {
                bind(resource);
            }

            // hook Jackson into Jersey as the POJO <-> JSON mapper
            bind(JacksonJsonProvider.class).in(Scopes.SINGLETON);

            serve("/web/*").with(GuiceContainer.class);

            filter("/web/*").through(ResponseCorsFilter.class);
        }
    }, new UserModule());
}
 
Example #4
Source File: BaseNettyServer.java    From recipes-rss with Apache License 2.0 6 votes vote down vote up
public void start() {
    this.host = ConfigurationManager.getConfigInstance().getString("netty.http.host", "not-found-in-configuration");
    this.port = ConfigurationManager.getConfigInstance().getInt("netty.http.port", Integer.MIN_VALUE);

    final PackagesResourceConfig rcf = new PackagesResourceConfig(ConfigurationManager.getConfigInstance().getString("jersey.resources.package","not-found-in-configuration"));

    nettyServer = NettyServer
            .builder()
            .host(host)
            .port(port)
            .addHandler(
                    "jerseyHandler",
                    ContainerFactory.createContainer(
                            NettyHandlerContainer.class, rcf))
                            .numBossThreads(NettyServer.cpus)
                            .numWorkerThreads(NettyServer.cpus * 4).build();
    try {
        karyonServer.start();
    } catch (Exception exc) {
        throw new RuntimeException("Cannot start karyon server.", exc);
    }
}
 
Example #5
Source File: AppModule.java    From jerseyoauth2 with MIT License 6 votes vote down vote up
@Override
	protected void configureServlets() {
    	bind(IUserService.class).to(DefaultPrincipalUserService.class);
    	bind(ITokenGenerator.class).to(MD5TokenGenerator.class);
    	bind(IClientIdGenerator.class).to(UUIDClientIdGenerator.class);
    	
    	bind(IConfiguration.class).to(Configuration.class);
    	bind(IRSConfiguration.class).to(Configuration.class);
    	bind(IAuthorizationFlow.class).to(TestAuthorizationFlow.class);
    	
    	bind(IClientService.class).to(DatabaseClientService.class);
    	bind(IAccessTokenStorageService.class).to(DatabaseAccessTokenStorage.class);
    	
    	serve("/oauth2/auth").with(AuthorizationServlet.class);
    	serve("/oauth2/allow").with(AllowServlet.class);
    	serve("/oauth2/accessToken").with(IssueAccessTokenServlet.class);
    	
       Map<String, String> params = new HashMap<String, String>();
       params.put(PackagesResourceConfig.PROPERTY_PACKAGES, "com.burgmeier.jerseyoauth2.sample.resources");
//see http://java.net/jira/browse/JERSEY-630	            
       params.put(PackagesResourceConfig.FEATURE_DISABLE_WADL, "true");
       params.put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES, OAuth20FilterFactory.class.getName());
       // Route all requests for rest resources through GuiceContainer
       serve("/rest/*").with(GuiceContainer.class, params);		
	}
 
Example #6
Source File: PropertiesBasedResourceConfig.java    From karyon with Apache License 2.0 6 votes vote down vote up
private synchronized void initIfRequired() {
    if (initialized) {
        return;
    }
    initialized = true;
    String pkgNamesStr = getConfigInstance().getString(PackagesResourceConfig.PROPERTY_PACKAGES, null);
    if (null == pkgNamesStr) {
        logger.warn("No property defined with name: " + PackagesResourceConfig.PROPERTY_PACKAGES +
                    ", this means that jersey can not find any of your resource/provider classes.");
    } else {
        String[] pkgNames = getElements(new String[]{pkgNamesStr}, ResourceConfig.COMMON_DELIMITERS);
        logger.info("Packages to scan by jersey {}", Arrays.toString(pkgNames));
        init(new PackageNamesScanner(pkgNames));
    }
    Map<String, Object> jerseyProperties = createPropertiesMap();
    setPropertiesAndFeatures(jerseyProperties);
}
 
Example #7
Source File: AdminResourcesFilter.java    From karyon with Apache License 2.0 6 votes vote down vote up
@Override
protected ResourceConfig getDefaultResourceConfig(Map<String, Object> props,
                                                  WebConfig webConfig) throws ServletException {
    HashMap<String, Object> mergedProps = new HashMap<>(props);
    mergedProps.putAll(this.props);
    return new PackagesResourceConfig(mergedProps) {
        @Override
        public Set<Class<?>> getProviderClasses() {
            Set<Class<?>> providers = super.getProviderClasses();
            // remove conflicting provider if present
            providers.remove(FreemarkerTemplateProvider.class);
            providers.add(AdminFreemarkerTemplateProvider.class);
            providers.add(WebApplicationExceptionMapper.class);
            return providers;
        }
    };
}
 
Example #8
Source File: Main.java    From hbase-indexer with Apache License 2.0 6 votes vote down vote up
private void startHttpServer() throws Exception {
    server = new Server();
    SelectChannelConnector selectChannelConnector = new SelectChannelConnector();
    selectChannelConnector.setPort(11060);
    server.setConnectors(new Connector[]{selectChannelConnector});

    PackagesResourceConfig packagesResourceConfig = new PackagesResourceConfig("com/ngdata/hbaseindexer/rest");

    ServletHolder servletHolder = new ServletHolder(new ServletContainer(packagesResourceConfig));
    servletHolder.setName("HBase-Indexer");


    Context context = new Context(server, "/", Context.NO_SESSIONS);
    context.addServlet(servletHolder, "/*");
    context.setContextPath("/");
    context.setAttribute("indexerModel", indexerModel);
    context.setAttribute("indexerSupervisor", indexerSupervisor);

    server.setHandler(context);
    server.start();
}
 
Example #9
Source File: RestModule.java    From AisAbnormal with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void configureServlets() {
    ResourceConfig rc = new PackagesResourceConfig(
            "dk.dma.ais.abnormal.event.rest",
            "dk.dma.ais.abnormal.stat.rest",
            "dk.dma.commons.web.rest.defaults",
            "org.codehaus.jackson.jaxrs"
    );

    for ( Class<?> resource : rc.getClasses() ) {
        String packageName = resource.getPackage().getName();
        if (packageName.equals("dk.dma.commons.web.rest.defaults") || packageName.equals("org.codehaus.jackson.jaxrs")) {
            bind(resource).in(Scopes.SINGLETON);
        } else {
            bind(resource);
        }
    }

    serve("/rest/*").with( GuiceContainer.class );
}
 
Example #10
Source File: ExampleAppWithLocalResource.java    From ribbon with Apache License 2.0 6 votes vote down vote up
@edu.umd.cs.findbugs.annotations.SuppressWarnings
public final void runApp() throws Exception {
    PackagesResourceConfig resourceConfig = new PackagesResourceConfig("com.netflix.ribbon.examples.server");
    ExecutorService service = Executors.newFixedThreadPool(50);
    try{
        server = HttpServerFactory.create(SERVICE_URI, resourceConfig);           
        server.setExecutor(service);
        server.start();
        run();
    } finally {
        System.err.println("Shut down server ...");
        if (server != null) {
            server.stop(1);
        }
        service.shutdownNow();
    }
    System.exit(0);
}
 
Example #11
Source File: AggregatorApplication.java    From ambari-metrics with Apache License 2.0 6 votes vote down vote up
protected HttpServer createHttpServer() throws Exception {
  ResourceConfig resourceConfig = new PackagesResourceConfig("org.apache.hadoop.metrics2.host.aggregator");
  HashMap<String, Object> params = new HashMap();
  params.put("com.sun.jersey.api.json.POJOMappingFeature", "true");
  resourceConfig.setPropertiesAndFeatures(params);
  HttpServer server = HttpServerFactory.create(getURI(), resourceConfig);

  if (webServerProtocol.equalsIgnoreCase("https")) {
    HttpsServer httpsServer = (HttpsServer) server;
    SslContextFactory sslContextFactory = new SslContextFactory();
    String keyStorePath = configuration.get("ssl.server.keystore.location");
    String keyStorePassword = configuration.get("ssl.server.keystore.password");
    String keyManagerPassword = configuration.get("ssl.server.keystore.keypassword");
    String trustStorePath = configuration.get("ssl.server.truststore.location");
    String trustStorePassword = configuration.get("ssl.server.truststore.password");

    sslContextFactory.setKeyStorePath(keyStorePath);
    sslContextFactory.setKeyStorePassword(keyStorePassword);
    sslContextFactory.setKeyManagerPassword(keyManagerPassword);
    sslContextFactory.setTrustStorePath(trustStorePath);
    sslContextFactory.setTrustStorePassword(trustStorePassword);

    sslContextFactory.start();
    SSLContext sslContext = sslContextFactory.getSslContext();
    sslContextFactory.stop();
    HttpsConfigurator httpsConfigurator = new HttpsConfigurator(sslContext);
    httpsServer.setHttpsConfigurator(httpsConfigurator);
    server = httpsServer;
  }
  return server;
}
 
Example #12
Source File: AppServletModule.java    From appstart with Apache License 2.0 6 votes vote down vote up
@Override
protected void configureServlets() {
	
	// filters
	// Objectify filter
	filter("/*").through(ObjectifyFilter.class);

	// servlets
	serve("/home").with(HomeServlet.class);
	
	// Jersey restful servlet
    HashMap<String, String> params = new HashMap<String, String>();
       params.put(PackagesResourceConfig.PROPERTY_PACKAGES, "uk.co.inetria.appstart.frontend.rest");
       params.put(JSONConfiguration.FEATURE_POJO_MAPPING, "true");
       // speed up jersey startup under appengine
       params.put(ResourceConfig.FEATURE_DISABLE_WADL, "true");
       
       serve("/api/*").with(GuiceContainer.class, params);
	
	
}
 
Example #13
Source File: WebServer.java    From AthenaX with Apache License 2.0 6 votes vote down vote up
public WebServer(URI endpoint) throws IOException {
  this.server = GrizzlyServerFactory.createHttpServer(endpoint, new HttpHandler() {

    @Override
    public void service(Request rqst, Response rspns) throws Exception {
      rspns.setStatus(HttpStatus.NOT_FOUND_404.getStatusCode(), "Not found");
      rspns.getWriter().write("404: not found");
    }
  });

  WebappContext context = new WebappContext("WebappContext", BASE_PATH);
  ServletRegistration registration = context.addServlet("ServletContainer", ServletContainer.class);
  registration.setInitParameter(ServletContainer.RESOURCE_CONFIG_CLASS,
      PackagesResourceConfig.class.getName());

  StringJoiner sj = new StringJoiner(",");
  for (String s : PACKAGES) {
    sj.add(s);
  }

  registration.setInitParameter(PackagesResourceConfig.PROPERTY_PACKAGES, sj.toString());
  registration.addMapping(BASE_PATH);
  context.deploy(server);
}
 
Example #14
Source File: ConsoleEndPointServer.java    From db with GNU Affero General Public License v3.0 6 votes vote down vote up
@PostConstruct
private void init() {
    final Map<String, List<String>> portConfigData = ConfigUtil.getConfigData(Constants.APP_CONFIG_FILE, "/config/ports/port");
    final int port = Integer.parseInt(portConfigData.get(this.getClass().getName()).get(0));
    final Map<String, List<String>> packageConfigData = ConfigUtil.getConfigData(Constants.APP_CONFIG_FILE, "/config/resources/package");
    final List<String> packageList = packageConfigData.get(this.getClass().getName());

    try {
        final ResourceConfig resourceConfig = new PackagesResourceConfig(packageList.toArray(new String[packageList.size()]));
        final String serverAddress = "localhost";

        logger.debug("Attempting to start CLI listener at address {} with port {}", serverAddress, port);
        new Thread(new ConsoleEndPointServerSocket(port)).start();
        logger.info("CLI listener has started. CLI end point for database is ready."); // this is obviously non complete code
    } catch (ContainerException ex) {
        logger.error("CLI specified by {} couldn't be started because no root resource classes could be found in the listed packages ({}). Confirm if the packages have been refactored.", this.getClass(), packageList);
    }
}
 
Example #15
Source File: PrimeConnectionsTest.java    From ribbon with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setup(){
       PackagesResourceConfig resourceConfig = new PackagesResourceConfig("com.netflix.niws.client.http");
       SERVICE_URI = "http://localhost:" + port + "/";
       try{
           server = HttpServerFactory.create(SERVICE_URI, resourceConfig);           
           server.start();
       } catch (Exception e) {
           e.printStackTrace();
           fail(e.getMessage());
       }
   }
 
Example #16
Source File: GetPostTest.java    From ribbon with Apache License 2.0 5 votes vote down vote up
@BeforeClass 
public static void init() throws Exception {
    PackagesResourceConfig resourceConfig = new PackagesResourceConfig("com.netflix.niws.http", "com.netflix.niws.client");
    int port = (new Random()).nextInt(1000) + 4000;
    SERVICE_URI = "http://localhost:" + port + "/";
    try{
        server = HttpServerFactory.create(SERVICE_URI, resourceConfig);           
        server.start();
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    client = (RestClient) ClientFactory.getNamedClient("GetPostTest");
}
 
Example #17
Source File: InjectedWebListener.java    From Raigad with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureServlets() {
    Map<String, String> params = new HashMap<String, String>();
    params.put(PackagesResourceConfig.PROPERTY_PACKAGES, "unbound");
    params.put("com.sun.jersey.config.property.packages", "com.netflix.raigad.resources");
    params.put(ServletContainer.PROPERTY_FILTER_CONTEXT_PATH, "/REST");
    serve("/REST/*").with(GuiceContainer.class, params);
}
 
Example #18
Source File: StartServer.java    From EVCache with Apache License 2.0 5 votes vote down vote up
@Override
    protected ServletModule getServletModule() {
        return new JerseyServletModule() {
            @Override
            protected void configureServlets() {
                logger.info("########## CONFIGURING SERVLETS ##########");

                // initialize NFFilter
                Map<String, String> initParams = new HashMap<String,String>();
//                initParams.put(ServletContainer.JSP_TEMPLATES_BASE_PATH, "/WEB-INF/jsp");
//                initParams.put(ServletContainer.FEATURE_FILTER_FORWARD_ON_404, "true");
//                initParams.put("requestId.accept", "true");
//                initParams.put("requestId.require", "true");
                initParams.put(ResourceConfig.FEATURE_DISABLE_WADL, "true");
                initParams.put(PackagesResourceConfig.PROPERTY_PACKAGES, "com.netflix.evcache.service.resources");
                filter("/*").through(NFFilter.class, initParams);
                filter("/healthcheck", "/status").through(NFFilter.class, initParams);
                serve("/Status", "/status").with(BaseStatusPage.class);
                serve("/healthcheck", "/Healthcheck").with(BaseHealthCheckServlet.class);
                serve("/*").with(GuiceContainer.class, initParams);
                bind(EVCacheRESTService.class).asEagerSingleton();
                binder().bind(GuiceContainer.class).asEagerSingleton();
                
                install(new EVCacheServiceModule());
            }
        };
    }
 
Example #19
Source File: ServerApplication.java    From eagle with Apache License 2.0 5 votes vote down vote up
@Override
public void run(ServerConfig configuration, Environment environment) throws Exception {
    environment.getApplicationContext().setContextPath(ServerConfig.getContextPath());
    environment.jersey().register(RESTExceptionMapper.class);
    environment.jersey().setUrlPattern(ServerConfig.getApiBasePath());
    environment.getObjectMapper().setFilters(TaggedLogAPIEntity.getFilterProvider());
    environment.getObjectMapper().registerModule(new EntityJsonModule());

    // Automatically scan all REST resources
    new PackagesResourceConfig(ServerConfig.getResourcePackage()).getClasses().forEach(environment.jersey()::register);

    // Swagger resources
    environment.jersey().register(ApiListingResource.class);

    BeanConfig swaggerConfig = new BeanConfig();
    swaggerConfig.setTitle(ServerConfig.getServerName());
    swaggerConfig.setVersion(ServerConfig.getServerVersion().version);
    swaggerConfig.setBasePath(ServerConfig.getApiBasePath());
    swaggerConfig.setResourcePackage(ServerConfig.getResourcePackage());
    swaggerConfig.setLicense(ServerConfig.getLicense());
    swaggerConfig.setLicenseUrl(ServerConfig.getLicenseUrl());
    swaggerConfig.setDescription(Version.str());
    swaggerConfig.setScan(true);

    // Simple CORS filter
    environment.servlets().addFilter(SimpleCORSFiler.class.getName(), new SimpleCORSFiler())
        .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");

    // Register authentication provider
    BasicAuthBuilder authBuilder = new BasicAuthBuilder(configuration.getAuthConfig(), environment);
    environment.jersey().register(authBuilder.getBasicAuthProvider());
    if (configuration.getAuthConfig().isEnabled()) {
        environment.jersey().getResourceConfig().getResourceFilterFactories()
            .add(new BasicAuthResourceFilterFactory(authBuilder.getBasicAuthenticator()));
    }
    registerAppServices(environment);
}
 
Example #20
Source File: ResourceTestAuthUtil.java    From emodb with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private static void addResourceFilterFactories(ResourceTestRule.Builder test, JerseyAuthConfiguration config) {
    // The ability to add properties is normally protected so we need to break in to update the resource filter
    // factories.
    Map<String, Object> properties;
    try {
        Field field = ResourceTestRule.Builder.class.getDeclaredField("properties");
        field.setAccessible(true);
        properties = (Map<String, Object>) field.get(test);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }

    List resourceFilterFactories;

    // Add the new resource filter factories to any existing values
    Object existing = properties.get(PackagesResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES);
    if (existing == null) {
        resourceFilterFactories = config.getResourceFilterFactories();
    } else {
        resourceFilterFactories = Lists.newArrayList();
        if (existing.getClass().isArray()) {
            resourceFilterFactories.addAll(Arrays.asList((Object[]) existing));
        } else if (Iterable.class.isAssignableFrom(existing.getClass())) {
            Iterables.addAll(resourceFilterFactories, (Iterable) existing);
        } else {
            resourceFilterFactories.add(existing);
        }
        resourceFilterFactories.addAll(config.getResourceFilterFactories());
    }

    properties.put(PackagesResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES, resourceFilterFactories);
}
 
Example #21
Source File: JerseyModule.java    From conductor with Apache License 2.0 5 votes vote down vote up
@Override
  protected void configureServlets() {
  	filter("/*").through(apiOriginFilter());
      
      Map<String, String> jerseyParams = new HashMap<>();	
jerseyParams.put("com.sun.jersey.config.feature.FilterForwardOn404", "true");
jerseyParams.put("com.sun.jersey.config.property.WebPageContentRegex", "/(((webjars|api-docs|swagger-ui/docs|manage)/.*)|(favicon\\.ico))");
jerseyParams.put(PackagesResourceConfig.PROPERTY_PACKAGES, "com.netflix.conductor.server.resources;io.swagger.jaxrs.json;io.swagger.jaxrs.listing");
jerseyParams.put(ResourceConfig.FEATURE_DISABLE_WADL, "false");
serve("/api/*").with(GuiceContainer.class, jerseyParams);
  }
 
Example #22
Source File: AppModule.java    From jerseyoauth2 with MIT License 5 votes vote down vote up
@Override
    protected void configureServlets() {
    	bind(IAccessTokenStorageService.class).to(CachingAccessTokenStorage.class);
    	bind(IClientService.class).to(DatabaseClientService.class);
    	bind(IConfiguration.class).to(Configuration.class);
    	bind(IRSConfiguration.class).to(Configuration.class);
    	bind(IAuthorizationFlow.class).to(TestAuthorizationFlow.class);
    	
    	bind(IUserService.class).to(DefaultPrincipalUserService.class);
    	bind(ITokenGenerator.class).to(MD5TokenGenerator.class);
    	bind(IClientIdGenerator.class).to(UUIDClientIdGenerator.class);
    	
    	bind(EntityManagerFactory.class).toProvider(new PersistenceProvider());
    	bind(CacheManager.class).toProvider(new DefaultCacheManagerProvider());
    	
    	serve("/oauth2/auth").with(AuthorizationServlet.class);
    	serve("/oauth2/accessToken").with(IssueAccessTokenServlet.class);
    	
    	filter("/oauth2/*").through(StrictSecurityFilter.class);
    	
       Map<String, String> params = new HashMap<String, String>();
       params.put(PackagesResourceConfig.PROPERTY_PACKAGES, "com.github.hburgmeier.jerseyoauth2.testsuite.resource;" +
       		"com.github.hburgmeier.jerseyoauth2.testsuite.base.resource");
//see http://java.net/jira/browse/JERSEY-630	            
       params.put(PackagesResourceConfig.FEATURE_DISABLE_WADL, "true");
       params.put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES, OAuth20FilterFactory.class.getName());
// Route all requests for rest resources through GuiceContainer
       serve("/rest/*").with(GuiceContainer.class, params);
    }
 
Example #23
Source File: ScriptManagerBootstrap.java    From Nicobar with Apache License 2.0 5 votes vote down vote up
@Override
protected void beforeInjectorCreation(@SuppressWarnings("unused") LifecycleInjectorBuilder builderToBeUsed) {

   JerseyServletModule jerseyServletModule = new JerseyServletModule() {
        @Override
        protected void configureServlets() {
            bind(String.class).annotatedWith(Names.named("explorerAppName")).toInstance("scriptmanager");
            bind(GsonMessageBodyHandler.class).in(Scopes.SINGLETON);
            bind(GlobalModelContext.class).to(AppConfigGlobalModelContext.class);
            bind(ExplorerManager.class).to(ExplorersManagerImpl.class);
            bind(ScriptManagerExplorer.class);

            bind(GuiceContainer.class).asEagerSingleton();

            Map<String, String> params = new HashMap<String, String>();
            params.put(PackagesResourceConfig.PROPERTY_PACKAGES,
                // pytheas resources
                "com.netflix.explorers.resources;" +
                "com.netflix.explorers.providers;" +
                // nicobar resources
                "com.netflix.nicobar.manager.explorer.resources");

            // Route all requests through GuiceContainer
            serve("/*").with(GuiceContainer.class, params);
        }
    };
    builderToBeUsed.withAdditionalModules(jerseyServletModule);
    LOG.debug("HelloWorldBootstrap injected jerseyServletModule in LifecycleInjectorBuilder");
}
 
Example #24
Source File: RestfulServer.java    From shardingsphere-elasticjob-cloud with Apache License 2.0 5 votes vote down vote up
private ServletHolder getServletHolder(final String packages) {
    ServletHolder result = new ServletHolder(ServletContainer.class);
    result.setInitParameter(PackagesResourceConfig.PROPERTY_PACKAGES, Joiner.on(",").join(RestfulServer.class.getPackage().getName(), packages));
    result.setInitParameter("com.sun.jersey.config.property.resourceConfigClass", PackagesResourceConfig.class.getName());
    result.setInitParameter("com.sun.jersey.api.json.POJOMappingFeature", Boolean.TRUE.toString());
    result.setInitParameter("resteasy.scan.providers", Boolean.TRUE.toString());
    result.setInitParameter("resteasy.use.builtin.providers", Boolean.FALSE.toString());
    return result;
}
 
Example #25
Source File: RestServer.java    From ecs-sync with Apache License 2.0 4 votes vote down vote up
protected ResourceConfig createResourceConfig() {
    return new PackagesResourceConfig(RestServer.class.getPackage().getName());
}