@RequestScoped public class App { final ApplicationContext context; @Inject App(ApplicationContext context) { this.context = context; } }
@Override public void init(FilterConfig filterConfig) throws ServletException { this.wrapped.init(filterConfig); }
@Override public void destroy() { this.wrapped.destroy(); }
@Override protected void configureServlets() { serve("/*").with(GuiceRestliServlet.class); } });
@Override protected void configureServlets() { binder().requireExplicitBindings(); bind(GuiceFilter.class); //Bind web server bind(WebServer.class); //Bind resource classes here bind(MetricsResource.class).in(Scopes.SINGLETON); bind(MetadataResource.class).in(Scopes.SINGLETON); bind(FeaturesResource.class).in(Scopes.SINGLETON); bind(GuiceContainer.class); bind(LoggingFilter.class).in(Scopes.SINGLETON); filter("/*").through(LoggingFilter.class); // hook Jackson into Jersey as the POJO <-> JSON mapper bind(JacksonJsonProvider.class).in(Scopes.SINGLETON); serve("/*").with(GuiceContainer.class); // bind(InvalidServerTypeExceptionMapper.class).in(Scopes.SINGLETON); } }
@Override protected void configureServlets() { filter(pattern).through(GuiceShiroFilter.class); } };
@Override public void contextDestroyed(ServletContextEvent servletContextEvent) { close(); super.contextDestroyed(servletContextEvent); }
@Override public void contextInitialized(ServletContextEvent servletContextEvent) { contextPath = servletContextEvent.getServletContext().getContextPath(); // websocket enabled servlet containers populate this attribute with JSR 356 // we save it here so we can inject it later into guice if (SwissKnife.doesClassExist( WebsocketGuiceModuleCreator.WEBSOCKET_SERVER_CONTAINER_CLASSNAME, this)) { this.webSocketModule = WebsocketGuiceModuleCreator.getWebsocketServerContainerIfPossible( servletContextEvent.getServletContext()); } super.contextInitialized(servletContextEvent); }
public NinjaServletFilter() { this.wrapped = new GuiceFilter(); }
@Override protected Injector getInjector() { return Guice.createInjector( new ServletModule() { @Override protected void configureServlets() { serve("/index.html").with(IndexController.class); } }, new ListModule()); }
@Override protected void configureServlets() { Map<String, String> params = new HashMap<>(); params.put(PackagesResourceConfig.PROPERTY_PACKAGES, "unbound"); params.put("com.sun.jersey.config.property.packages", "com.netflix.priam.resources"); params.put(ServletContainer.PROPERTY_FILTER_CONTEXT_PATH, "/REST"); serve("/REST/*").with(GuiceContainer.class, params); } }
@Override protected void configureServlets() { bind(ConsumerTokenStore.class).toInstance(m_tokenStore); bind(OAuthFilter.class).in(Singleton.class); filter("/api/*").through(OAuthFilter.class); } }
@RequestScoped public class TestClass2 { @Inject public TestClass2(String unassisted, @Assisted String assisted) { } }
@Override public void contextDestroyed(ServletContextEvent servletContextEvent) { ninjaBootstrap.shutdown(); super.contextDestroyed(servletContextEvent); }
@Override public void contextInitialized(ServletContextEvent servletContextEvent) { ServletContext context = servletContextEvent.getServletContext(); Enumeration<String> parameters = context.getInitParameterNames(); Map<String, String> configMap = Maps.newHashMap(); while (parameters.hasMoreElements()) { String key = parameters.nextElement(); configMap.put(key, context.getInitParameter(key)); } initialize(ConfigFactory.parseMap(configMap)); super.contextInitialized(servletContextEvent); }
@Override protected void configureServlets() { bind(NinjaServletDispatcher.class).asEagerSingleton(); serve("/*").with(NinjaServletDispatcher.class); }
@Override protected void configureServlets() { bind(MetricReporterService.class).in(Singleton.class); bind(MonitorFilter.class).in(Scopes.SINGLETON); filter("/*").through(MonitorFilter.class); bind(DataPointsMonitor.class).in(Scopes.SINGLETON); KairosMetricReporterListProvider reporterProvider = new KairosMetricReporterListProvider(); bind(KairosMetricReporterListProvider.class).toInstance(reporterProvider); bindListener(Matchers.any(), reporterProvider); } }
@Path("status") @RequestScoped public class StatusResource { private static final Logger logger = LoggerFactory.getLogger( StatusResource.class );
@Override public void contextDestroyed(ServletContextEvent servletContextEvent) { try { for (Scheduler scheduler : injector.getInstance(SchedulerFactory.class).getAllSchedulers()) { scheduler.shutdown(); } } catch (SchedulerException e) { throw new RuntimeException(e); } super.contextDestroyed(servletContextEvent); }
@Override protected void configureServlets() { Binder binder = binder(); JsonConfigProvider.bind(binder, "druid.server.http", ServerConfig.class); JsonConfigProvider.bind(binder, "druid.server.https", TLSServerConfig.class); binder.bind(GuiceContainer.class).to(DruidGuiceContainer.class); binder.bind(DruidGuiceContainer.class).in(Scopes.SINGLETON); binder.bind(CustomExceptionMapper.class).in(Singleton.class); binder.bind(ForbiddenExceptionMapper.class).in(Singleton.class); serve("/*").with(DruidGuiceContainer.class); Jerseys.addResource(binder, StatusResource.class); binder.bind(StatusResource.class).in(LazySingleton.class); // Adding empty binding for ServletFilterHolders and Handlers so that injector returns an empty set if none // are provided by extensions. Multibinder.newSetBinder(binder, Handler.class); Multibinder.newSetBinder(binder, ServletFilterHolder.class); MetricsModule.register(binder, JettyMonitor.class); }