com.sun.jersey.guice.JerseyServletModule Java Examples

The following examples show how to use com.sun.jersey.guice.JerseyServletModule. 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: SimpleContextListener.java    From dagger-servlet with Apache License 2.0 6 votes vote down vote up
@Override
protected Injector getInjector() {
    return Guice.createInjector(new JerseyServletModule() {
        @Override
        protected void configureServlets() {
            bind(SimpleService.class);
            bind(SimpleResource.class);

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

        @Provides
        String provideDisplay() {
            return "SimpleDisplay";
        }
    });
}
 
Example #2
Source File: GuiceServletConfig.java    From staash with Apache License 2.0 6 votes vote down vote up
@Override
protected Injector getInjector() {
    return LifecycleInjector.builder()
            .withModules(
                new EurekaModule(),
                 new PaasPropertiesModule(),   
                new JerseyServletModule() {
                    @Override
                    protected void configureServlets() {
                        bind(GuiceContainer.class).asEagerSingleton();
                        bind(StaashAdminResourceImpl.class);
                        bind(StaashDataResourceImpl.class);
                        serve("/*").with(GuiceContainer.class);
                    }
                }
            )
            .createInjector();
}
 
Example #3
Source File: NewPaasGuiceServletConfig.java    From staash with Apache License 2.0 6 votes vote down vote up
@Override
protected Injector getInjector() {
    return LifecycleInjector.builder()
        .withModules(
            new MetaModule(),
            //new EurekaModule(),
            new JerseyServletModule() {
                @Override
                protected void configureServlets() {
                    // Route all requests through GuiceContainer
                    bind(GuiceContainer.class).asEagerSingleton();
                    serve("/*").with(GuiceContainer.class);
                }
            },
            new AbstractModule() {
                @Override
                protected void configure() {
                    bind(MetaCassandraBootstrap.class).asEagerSingleton();
                 }
            }
        )
        .createInjector();
}
 
Example #4
Source File: GuiceServletConfig.java    From staash with Apache License 2.0 6 votes vote down vote up
@Override
protected Injector getInjector() {
    return LifecycleInjector.builder()
            .withModules(
                new EurekaModule(),
                 new PaasPropertiesModule(),   
                new JerseyServletModule() {
                    @Override
                    protected void configureServlets() {
                        bind(GuiceContainer.class).asEagerSingleton();
                        bind(StaashAdminResourceImpl.class);
                        bind(StaashDataResourceImpl.class);
                        serve("/*").with(GuiceContainer.class);
                    }
                }
            )
            .createInjector();
}
 
Example #5
Source File: PaasGuiceServletConfig.java    From staash with Apache License 2.0 5 votes vote down vote up
@Override
protected Injector getInjector() {
    return LifecycleInjector.builder()
        .withModules(
            new AbstractModule() {
                @Override
                protected void configure() {
                    bind(String.class).annotatedWith(Names.named("groupName")).toInstance("UnitTest1");
                    bind(String.class).annotatedWith(Names.named("clustername")).toInstance("localhost");
                }
            },
            new CassandraPaasModule(),
            new MetaModule(),
            //new EurekaModule(),
            new PaasModule(),
            new JerseyServletModule() {
                @Override
                protected void configureServlets() {
                    // Route all requests through GuiceContainer
                    bind(GuiceContainer.class).asEagerSingleton();
                    serve("/*").with(GuiceContainer.class);
                }
            },
            new AbstractModule() {
                @Override
                protected void configure() {
                    bind(MetaCassandraBootstrap.class).asEagerSingleton();
                    bind(PaasBootstrap.class).asEagerSingleton();
                    bind(PaasCassandraBootstrap.class).asEagerSingleton();
                }
            }
        )
        .createInjector();
}
 
Example #6
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 #7
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");
}