@Override public void run(final T config, final Environment environment) throws Exception { Module bootstrapModule = new AbstractModule() { @Override protected void configure() { install(new DropwizardModule()); if (mainModule != null) install(mainModule); bind(Configuration.class).toInstance(config); bind(configClass).toInstance(config); bind(Environment.class).toInstance(environment); } }; environment.servlets() // .addFilter("guice-request-scope", new GuiceFilter()) // .addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); Guice.createInjector(bootstrapModule).getInstance(applicationClass).run(); }
@Before public void startJetty() throws Exception { servletTester = new ServletTester(); servletTester.getContext().addEventListener(new GuiceServletContextListener() { final Injector injector = Guice.createInjector(new TestModule()); @Override protected Injector getInjector() { return injector; } }); url = servletTester.createConnector(true) + TestModule.MOUNT_POINT; servletTester.addFilter(GuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); servletTester.addServlet(DummyServlet.class, "/*"); servletTester.start(); client = ClientBuilder.newClient(); }
@Override protected void configure() { // we will look these up later... requireBinding(GuiceFilter.class); requireBinding(BeanManager.class); bind(ManagedLifecycleManager.class).to(NexusLifecycleManager.class); bind(ServletContext.class).toInstance(servletContext); bind(ParameterKeys.PROPERTIES).toInstance(nexusProperties); install(new StateGuardModule()); install(new TransactionModule()); install(new TimeTypeConverter()); install(new WebSecurityModule(servletContext)); // enable OSGi service lookup of Karaf components final MutableBeanLocator locator = new DefaultBeanLocator(); locator.add(new ServiceBindings(bundleContext, ALLOW_SERVICES, IGNORE_SERVICES, Integer.MIN_VALUE)); bind(MutableBeanLocator.class).toInstance(locator); }
public void run() { try { Server server = new Server(); ServerConnector connector = new ServerConnector(server); connector.setPort(port); server.addConnector(connector); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); context.setContextPath(contextPath); context.addFilter(GuiceFilter.class, "/api/*", null); server.setHandler(context); ServerContainer wsContainer = WebSocketServerContainerInitializer.configureContext(context); KafkaWebsocketEndpoint.Configurator.setKafkaProps(consumerProps, producerProps); wsContainer.addEndpoint(KafkaWebsocketEndpoint.class); server.start(); server.join(); } catch (Exception e) { logger.error("Failed to start the server: ", e); } }
public void startServer() throws Exception { int serverPort = propertiesConfiguration.getInt("server.port.http"); Server server = new Server(serverPort); ResourceHandler resourceHandler = new ResourceHandler(); resourceHandler.setBaseResource(Resource.newClassPathResource("/web")); ServletContextHandler servletContextHandler = new ServletContextHandler(server, "/api"); servletContextHandler.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class)); initGuiceInjector(); HandlerList handlerList = new HandlerList(); handlerList.addHandler(resourceHandler); handlerList.addHandler(servletContextHandler); server.setHandler(handlerList); server.start(); server.join(); }
public static void main(String[] args) throws Exception { final Server server = new Server(); ServerConnector connector = new ServerConnector(server); connector.setPort(PORT); server.setConnectors(new Connector[] { connector }); // Configure the Guice application. ServletContextHandler servletHandler = new ServletContextHandler(); servletHandler.addFilter(GuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); servletHandler.addEventListener(new SampleServletContextListener()); server.setHandler(servletHandler); // Start the server and wait for it. server.start(); server.join(); }
protected void execute1(String component) throws Exception { System.out.println("Starting codeine "+component+" at version " + CodeineVersion.get()); injector = Guice.createInjector(getModules(component)); FilterHolder guiceFilter = new FilterHolder(injector.getInstance(GuiceFilter.class)); ServletContextHandler handler = createServletContextHandler(); handler.setContextPath("/"); FilterHolder crossHolder = new FilterHolder(new CrossOriginFilter()); crossHolder.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET, POST, PUT, DELETE"); crossHolder.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "X-Requested-With,Origin,Content-Type,Accept,api_token"); handler.addFilter(crossHolder, "/api/*", EnumSet.allOf(DispatcherType.class)); handler.addFilter(crossHolder, "/api-with-token/*", EnumSet.allOf(DispatcherType.class)); handler.addFilter(guiceFilter, "/*", EnumSet.allOf(DispatcherType.class)); createAdditionalServlets(handler); ContextHandlerCollection contexts = createFileServerContexts(); contexts.addHandler(handler); int port = startServer(contexts); log.info("jetty started on port " + port); injector.getInstance(CodeineRuntimeInfo.class).setPort(port); execute(); }
public Server build() { ServiceLocator locator = BootstrapUtils.newServiceLocator(); Injector injector = BootstrapUtils.newInjector(locator, Arrays.asList(new ServletModule(), new MyModule())); BootstrapUtils.install(locator); Server server = new Server(port); ResourceConfig config = ResourceConfig.forApplication(new MyApplication()); ServletContainer servletContainer = new ServletContainer(config); ServletHolder sh = new ServletHolder(servletContainer); ServletContextHandler context = new ServletContextHandler( ServletContextHandler.SESSIONS); context.setContextPath("/"); FilterHolder filterHolder = new FilterHolder(GuiceFilter.class); context.addFilter(filterHolder, "/*", EnumSet.allOf(DispatcherType.class)); context.addServlet(sh, "/*"); server.setHandler(context); return server; }
@Test public void testInvokeResourceWithCategory() throws Exception { final Map<String, String> initParams = new HashMap<>(); initParams.put(NewRelicResourceFilterFactory.TRANSACTION_CATEGORY_PROP, "someCategory"); initParams.put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES, NewRelicResourceFilterFactory.class.getCanonicalName()); server = getServer(getInjector(initParams).getInstance(GuiceFilter.class)); server.start(); Response response = httpClient.prepareGet("http://localhost:" + PORT + "/foo").execute().get(); assertEquals(200, response.getStatusCode()); assertEquals(newArrayList("someCategory:/foo GET"), wrapper.getNames()); assertTrue(wrapper.getThrowables().isEmpty()); }
@Test public void testInvokeResourceWithoutCategory() throws Exception { final Map<String, String> initParams = new HashMap<>(); initParams.put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES, NewRelicResourceFilterFactory.class.getCanonicalName()); server = getServer(getInjector(initParams).getInstance(GuiceFilter.class)); server.start(); Response response = httpClient.prepareGet("http://localhost:" + PORT + "/foo").execute().get(); assertEquals(200, response.getStatusCode()); assertEquals(newArrayList("/foo GET"), wrapper.getNames()); assertTrue(wrapper.getThrowables().isEmpty()); }
@Test public void testInvokeThrowsResource() throws Exception { final Map<String, String> initParams = new HashMap<>(); initParams.put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES, NewRelicResourceFilterFactory.class.getCanonicalName()); server = getServer(getInjector(initParams).getInstance(GuiceFilter.class)); server.start(); Response response = httpClient.prepareGet("http://localhost:" + PORT + "/foo/throw").execute().get(); assertEquals(500, response.getStatusCode()); assertEquals(newArrayList("/foo/throw GET"), wrapper.getNames()); assertEquals(1, wrapper.getThrowables().size()); assertEquals("zomg", wrapper.getThrowables().get(0).getMessage()); }
@Test public void testInvokeThrowsMappedResource() throws Exception { final Map<String, String> initParams = new HashMap<>(); initParams.put(ResourceConfig.PROPERTY_RESOURCE_FILTER_FACTORIES, NewRelicResourceFilterFactory.class.getCanonicalName()); server = getServer(getInjector(initParams).getInstance(GuiceFilter.class)); server.start(); Response response = httpClient.prepareGet("http://localhost:" + PORT + "/foo/throwMapped").execute().get(); assertEquals(javax.ws.rs.core.Response.Status.NOT_ACCEPTABLE.getStatusCode(), response.getStatusCode()); assertEquals(newArrayList("/foo/throwMapped GET"), wrapper.getNames()); assertEquals(1, wrapper.getThrowables().size()); assertEquals("asdf", wrapper.getThrowables().get(0).getMessage()); }
private Server getServer(GuiceFilter filter) { Server server = new Server(PORT); ServletContextHandler servletHandler = new ServletContextHandler(); servletHandler.addServlet(new ServletHolder(new HttpServlet() { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); resp.setContentType("text/plain"); resp.setContentType("UTF-8"); resp.getWriter().append("404"); } }), "/*"); // add guice servlet filter servletHandler.addFilter(new FilterHolder(filter), "/*", EnumSet.allOf(DispatcherType.class)); server.setHandler(servletHandler); return server; }
@Test public void testWorksWithoutBindingAnyWrapperFactories() throws Exception { Injector injector = getInjector(new AbstractModule() { @Override protected void configure() { // no op } }); server = getServer(injector.getInstance(GuiceFilter.class)); server.start(); FooResource resource = injector.getInstance(FooResource.class); com.ning.http.client.Response response = httpClient.preparePost("http://localhost:" + PORT + "/foo").execute().get(); assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatusCode()); assertEquals(1, resource.counter.get()); }
private static Injector getInjector(final Module module) { return Guice.createInjector(new AbstractModule() { @Override protected void configure() { binder().requireExplicitBindings(); install(new ResourceMethodWrappedDispatchModule()); install(new ServletModule() { @Override protected void configureServlets() { serve("/*").with(GuiceContainer.class); } }); install(new JerseyServletModule()); bind(GuiceFilter.class); bind(GuiceContainer.class); bind(FooResource.class); install(module); } }); }
public void start() throws Exception { server = new Server(port); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); context.addFilter(GuiceFilter.class, "/*", null); context.addEventListener(guiceConfig); // ServletHolder servletHolder = new ServletHolder(ServletContainer.class); // servletHolder.setInitParameter("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.PackagesResourceConfig"); // servletHolder.setInitParameter("com.sun.jersey.config.property.packages", "com.gdiama"); // servletHolder.setInitParameter("com.sun.jersey.config.feature.Debug", "true"); // servletHolder.setInitParameter("com.sun.jersey.config.feature.Trace", "true"); // servletHolder.setInitParameter("com.sun.jersey.spi.container.ContainerRequestFilters", "com.sun.jersey.api.container.filter.LoggingFilter"); // servletHolder.setInitParameter("com.sun.jersey.spi.container.ContainerResponseFilters", "com.sun.jersey.api.container.filter.LoggingFilter"); // context.addServlet(servletHolder, "/rest/*"); context.setServer(server); ServerContainer wscontainer = WebSocketServerContainerInitializer.configureContext(context); wscontainer.addEndpoint(WebsocketEndpoint.class); server.setHandler(context); server.start(); }
@Override final protected void configureServlets() { // GuiceFilter is instantiated here instead of configured in // web.xml to allow for more than one servlet per servlet // container. // See documentation of web.xml for details. bind(GuiceFilter.class); configureJoynrServlets(); // Route all requests through GuiceContainer bindStaticWebResources(); bindJoynrServletClass(); bindAnnotatedFilters(); }
@Override public void run(final T configuration, final Environment environment) { final Iterable<Module> configedModules = configureModules(configuration, modules); final DropwizardModule<T> dwModule = new DropwizardModule<T>(configuration, environment); final Injector injector = parentInjector.or(Guice.createInjector()) .createChildInjector(Iterables.concat(of(dwModule), configedModules)); environment.addFilter(injector.getInstance(GuiceFilter.class), "*"); // Support Module definition of health checks if (!injector.findBindingsByType(healthChecksKey.getTypeLiteral()).isEmpty()) { final Set<HealthCheck> healthChecks = injector.getInstance(healthChecksKey); for (HealthCheck hc : healthChecks) { environment.addHealthCheck(hc); } } }
@BeforeClass public void init() throws Exception { System.setProperty("archaius.deployment.applicationId","scriptmanager-app"); System.setProperty("archaius.deployment.environment","dev"); server = new Server(TEST_LOCAL_PORT); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath("/"); context.addEventListener(new KaryonGuiceContextListener()); context.addFilter(GuiceFilter.class, "/*", 1); context.addServlet(DefaultServlet.class, "/"); server.setHandler(context); server.start(); }
public static void compose(Server server) { //Servlets + Guice ServletContextHandler servletContextHandler = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); servletContextHandler.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class)); servletContextHandler.addServlet(DefaultServlet.class, "/"); //JMX stuff... MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer()); server.addEventListener(mbContainer); server.addBean(mbContainer); server.addBean(Log.getLog()); }
public Handler get() { ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); handler.setContextPath("/"); handler.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class)); handler.addServlet(servletHolder, "/*"); return handler; }
@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(GuiceContainer.class); ImmutableMap<String, String> params = new ImmutableMap.Builder<String, String>() .put("mimeTypes", MediaType.APPLICATION_JSON) .put("methods", "GET,POST") .build(); bind(GzipFilter.class).in(Scopes.SINGLETON); filter("/*").through(GzipFilter.class, params); 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); }
public synchronized void start(int port, boolean join) throws Exception { if(server != null) { throw new IllegalStateException("Server is already running"); } Guice.createInjector(sm); //Swagger String resourceBasePath = Main.class.getResource("/swagger-ui").toExternalForm(); this.server = new Server(port); ServletContextHandler context = new ServletContextHandler(); context.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class)); context.setResourceBase(resourceBasePath); context.setWelcomeFiles(new String[] { "index.html" }); server.setHandler(context); DefaultServlet staticServlet = new DefaultServlet(); context.addServlet(new ServletHolder(staticServlet), "/*"); server.start(); System.out.println("Started server on http://localhost:" + port + "/"); try { boolean create = Boolean.getBoolean("loadSample"); if(create) { System.out.println("Creating kitchensink workflow"); createKitchenSink(port); } }catch(Exception e) { logger.error(e.getMessage(), e); } if(join) { server.join(); } }
@BeforeClass public static void beforeClass() throws Exception { server = new Server(port); final ServletContextHandler sch = new ServletContextHandler(server, "/"); sch.addEventListener(new CCOWContextListener(commonContext, new InlinedContextAgentRepositoryModule())); sch.addFilter(GuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); sch.addServlet(DefaultServlet.class, "/"); server.start(); }
public static void main(String[] args) throws Exception { // This object will create our webapp's configuration for us WebAppConfigurationBuilder configBuilder = new WebAppConfigurationBuilder(); // register our servlet to respond to the "/bar" pattern configBuilder.addFilter(GuiceFilter.class, "/*"); configBuilder.addServlet(BasicServlet.class, "/bar"); // we need to be able to return a directory // when javax.servlet.ServletContext.getRealPath("/") is called // hence the need for a context directory File contextDir = new File(System.getProperty("java.io.tmpdir")); // We want "" to be returned by // javax.servlet.http.HttpServletRequest.getContextPath() (ie. the root context) // so we use the "ROOT" context name (this is so we can have files called ROOT.war and not // "".war String context = "ROOT"; // create a collection of webapps that just contains a single webapp WebAppCollection webapps = WebAppCollectionFactory.createWebAppCollectionWithOneContext(contextDir, context, configBuilder.getConfiguration()); // start all of the webapps webapps.startAll(); // create servlet engine configuration object ServletEngineConfiguration config = ServletEngineConfigurationImpl.create(PORT, MAX_THREADS); // the collection of webapps is our "request sink" (just done to illustrate) FilterChain requestSink = webapps; // create an engine using the engine configuration and send all requests // to our request sink ServletEngine engine = ServletEngineImpl.create(requestSink, config); // run it engine.run(); }
/** * Register our dynamic filter with the bootstrap listener. */ private void registerNexusFilter() { if (registration == null) { final Filter filter = injector.getInstance(GuiceFilter.class); final Dictionary<String, ?> filterProperties = new Hashtable<>(singletonMap("name", "nexus")); registration = bundleContext.registerService(Filter.class, filter, filterProperties); } }
@Override protected void configure() { bind(GuiceFilter.class).to(DynamicGuiceFilter.class); // our configuration needs to be first-most when calculating order (some fudge room for edge-cases) final Binder highPriorityBinder = binder().withSource(Sources.prioritize(0x70000000)); highPriorityBinder.install(new ServletModule() { @Override protected void configureServlets() { bind(HeaderPatternFilter.class); bind(EnvironmentFilter.class); bind(ErrorPageFilter.class); filter("/*").through(HeaderPatternFilter.class); filter("/*").through(EnvironmentFilter.class); filter("/*").through(ErrorPageFilter.class); bind(ErrorPageServlet.class); serve("/error.html").with(ErrorPageServlet.class); serve("/throw.html").with(ThrowServlet.class); } }); highPriorityBinder.install(new MetricsModule()); install(new OrientModule()); }
protected DeploymentManager createFathomDeploymentManager() throws ServletException { DeploymentInfo info = Servlets.deployment(); info.setDeploymentName("Fathom"); info.setClassLoader(this.getClass().getClassLoader()); info.setContextPath(settings.getContextPath()); info.setIgnoreFlush(true); info.setDefaultEncoding("UTF-8"); FilterInfo guiceFilter = new FilterInfo("GuiceFilter", GuiceFilter.class); guiceFilter.setAsyncSupported(true); info.addFilterUrlMapping("GuiceFilter", "/*", DispatcherType.REQUEST); info.addFilters(guiceFilter); ServletInfo defaultServlet = new ServletInfo("DefaultServlet", DefaultServlet.class); defaultServlet.setAsyncSupported(true); defaultServlet.addMapping("/"); ServletContextListener fathomListener = new ServletContextListener(settings); info.addListeners(new ListenerInfo(ServletContextListener.class, new ImmediateInstanceFactory<>(fathomListener))); MultipartConfigElement multipartConfig = new MultipartConfigElement(settings.getUploadFilesLocation(), settings.getUploadFilesMaxSize(), -1L, 0); defaultServlet.setMultipartConfig(multipartConfig); info.addServlets(defaultServlet); DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(info); deploymentManager.deploy(); return deploymentManager; }
public MyPetStoreServer(int portNumber) { this.portNumber = portNumber; server = new Server(portNumber); Context root = new Context(server, "/", Context.SESSIONS); root.addFilter(GuiceFilter.class, "/*", 0); root.addServlet(DefaultServlet.class, "/"); }
@Inject public PetStoreServer(int portNumber) { server = new Server(portNumber); Context root = new Context(server, "/", Context.SESSIONS); root.addFilter(GuiceFilter.class, "/*", 0); root.addServlet(DefaultServlet.class, "/"); }
private void install(Plugin plugin) { GuiceFilter filter = load(plugin); final String name = plugin.getName(); final PluginHolder holder = new PluginHolder(plugin, filter); plugin.add( new RegistrationHandle() { @Override public void remove() { plugins.remove(name, holder); } }); plugins.put(name, holder); }
private void install(Plugin plugin) { if (!plugin.getName().equals(pluginName)) { return; } final GuiceFilter guiceFilter = load(plugin); plugin.add( new RegistrationHandle() { @Override public void remove() { filter.compareAndSet(guiceFilter, null); } }); filter.set(guiceFilter); }
private void createGuiceFilter(Context context) { FilterDef filterDefinition = new FilterDef(); filterDefinition.setFilterName(GuiceFilter.class.getSimpleName()); filterDefinition.setFilterClass(GuiceFilter.class.getName()); context.addFilterDef(filterDefinition); FilterMap filterMapping = new FilterMap(); filterMapping.setFilterName(GuiceFilter.class.getSimpleName()); filterMapping.addURLPattern("/*"); context.addFilterMap(filterMapping); }
public Server run() throws Exception{ Server server = new Server(port); FunsteroidModule funsteroidModule=new FunsteroidModule() .withFilter(filterConfiguration) .withFilter(filter) .withRoutes(route) .withRoutes(routeProvider) .withMacros(macroRegister) .withMacros(macroRegisterInstance); HandlerList handlers = new HandlerList(); ResourceHandler resourceHandler=new ResourceHandler(){ protected void doDirectory(HttpServletRequest request,HttpServletResponse response, Resource resource) throws IOException{ response.sendError(HttpStatus.NOT_FOUND_404); } }; resourceHandler.setDirectoriesListed(false); resourceHandler.setResourceBase(getWebAppPath()); WebAppContext context = new WebAppContext(); //TODO: Locate path before setup depending on enviroment execution context.setResourceBase(getWebAppPath()); context.setContextPath("/"); context.setParentLoaderPriority(true); context.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false"); context.addEventListener(new GuiceConfigListener(funsteroidModule)); context.addFilter(GuiceFilter.class, "/*", null); handlers.addHandler(resourceHandler); handlers.addHandler(context); server.setHandler(handlers); server.start(); server.join(); return server; }
@Override protected void withInjector(final Injector injector) { final FilterHolder guiceFilterHolder = new FilterHolder( injector.getInstance(GuiceFilter.class)); MoodcatHandler.this.addFilter(guiceFilterHolder, "/*", EnumSet.allOf(DispatcherType.class)); MoodcatHandler.this.app.getInjectorAtomicReference().set(injector); }
public static void main(final String[] args) throws Exception { SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); final Server server = new Server(9090); final ServletContextHandler sch = new ServletContextHandler(server, "/"); sch.addEventListener(new ContextListener()); sch.addFilter(GuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); sch.addServlet(DefaultServlet.class, "/"); server.start(); // Service is now accessible through // http://localhost:9090/model/Practitioner }
@Override public void run(final T configuration, final Environment environment) { if (configurationClass.isPresent()) { dropwizardEnvironmentModule = new DropwizardEnvironmentModule<T>(configurationClass.get(), configuration, environment); } else { dropwizardEnvironmentModule = new DropwizardEnvironmentModule<Configuration>(Configuration.class, configuration, environment); } // setEnvironment(configuration, environment); container = new GuiceContainer(); JerseyContainerModule jerseyContainerModule = new JerseyContainerModule(container); modules.add(jerseyContainerModule); modules.add(dropwizardEnvironmentModule); initInjector(); container.setResourceConfig(environment.jersey().getResourceConfig()); environment.jersey().replace(new Function<ResourceConfig, ServletContainer>() { @Nullable @Override public ServletContainer apply(ResourceConfig resourceConfig) { return container; } }); environment.servlets().addFilter("Guice Filter", GuiceFilter.class) .addMappingForUrlPatterns(null, false, environment.getApplicationContext().getContextPath() + "*"); }
@Provides @Singleton protected ServletContextHandler providesServletContextHandler() { ServletContextHandler servletContextHandler = new ServletContextHandler(); servletContextHandler.addServlet(DefaultServlet.class, "/*"); servletContextHandler.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class)); return servletContextHandler; }