List of usage examples for javax.servlet DispatcherType REQUEST
DispatcherType REQUEST
To view the source code for javax.servlet DispatcherType REQUEST.
Click Source Link
From source file:org.apache.hadoop.gateway.identityasserter.function.UsernameFunctionProcessorTest.java
public void setUp(String username, Map<String, String> initParams) throws Exception { String descriptorUrl = getTestResource("rewrite.xml").toExternalForm(); Log.setLog(new NoOpLogger()); server = new ServletTester(); server.setContextPath("/"); server.getContext().addEventListener(new UrlRewriteServletContextListener()); server.getContext().setInitParameter(UrlRewriteServletContextListener.DESCRIPTOR_LOCATION_INIT_PARAM_NAME, descriptorUrl);/*from w w w. jav a2 s . co m*/ FilterHolder setupFilter = server.addFilter(SetupFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); setupFilter.setFilter(new SetupFilter(username)); FilterHolder rewriteFilter = server.addFilter(UrlRewriteServletFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); if (initParams != null) { for (Map.Entry<String, String> entry : initParams.entrySet()) { rewriteFilter.setInitParameter(entry.getKey(), entry.getValue()); } } rewriteFilter.setFilter(new UrlRewriteServletFilter()); interactions = new ArrayQueue<MockInteraction>(); ServletHolder servlet = server.addServlet(MockServlet.class, "/"); servlet.setServlet(new MockServlet("mock-servlet", interactions)); server.start(); interaction = new MockInteraction(); request = HttpTester.newRequest(); response = null; }
From source file:io.fabric8.apiman.Fabric8ManagerApiMicroService.java
@Override protected void addAuthFilter(ServletContextHandler apiManServer) { apiManServer.addFilter(BootstrapFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); apiManServer.addFilter(BearerTokenFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); apiManServer.addFilter(Kubernetes2ApimanFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); }
From source file:at.ac.univie.isc.asio.Web.java
@Bean public FilterRegistrationBean explorerPageRedirectFilter( @Value("${server.servletPath}") final String staticBasePath) { final ExplorerPageRedirectFilter filter = ExplorerPageRedirectFilter.withStaticPath(staticBasePath); final FilterRegistrationBean registration = new FilterRegistrationBean(filter); registration.addUrlPatterns("/*"); registration.setDispatcherTypes(DispatcherType.REQUEST); registration.setAsyncSupported(true); registration.setOrder(REDIRECT_FILTER_ORDER); registration.setName("explorer-redirect-filter"); return registration; }
From source file:io.springagora.store.AppInitializer.java
/** * Web Application./*from ww w . j a v a2 s . c o m*/ * * @param container * {@code ServletContext}. Representation of the context that is serving * the JEE application. Servlets, filters and listeners are registered * via this interface. */ private void initializeWebApplication(ServletContext container) { AnnotationConfigWebApplicationContext dispatcherContext = new AnnotationConfigWebApplicationContext(); dispatcherContext.register(WebConfig.class); DispatcherServlet webDispatcher = new DispatcherServlet(dispatcherContext); ServletRegistration.Dynamic servletReg = container.addServlet(dispatcherWebName, webDispatcher); servletReg.setLoadOnStartup(1); servletReg.addMapping(URL_PATTERN_WEB); HiddenHttpMethodFilter filter = new HiddenHttpMethodFilter(); FilterRegistration.Dynamic filterReg = container.addFilter("Hidden HTTP Method Filter", filter); filterReg.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST), true, dispatcherWebName); }
From source file:org.apache.hadoop.gateway.svcregfunc.impl.ServiceRegistryFunctionsTest.java
public void setUp(String username, Map<String, String> initParams) throws Exception { ServiceRegistry mockServiceRegistry = EasyMock.createNiceMock(ServiceRegistry.class); EasyMock.expect(mockServiceRegistry.lookupServiceURL("test-cluster", "NAMENODE")) .andReturn("test-nn-scheme://test-nn-host:411").anyTimes(); EasyMock.expect(mockServiceRegistry.lookupServiceURL("test-cluster", "JOBTRACKER")) .andReturn("test-jt-scheme://test-jt-host:511").anyTimes(); GatewayServices mockGatewayServices = EasyMock.createNiceMock(GatewayServices.class); EasyMock.expect(mockGatewayServices.getService(GatewayServices.SERVICE_REGISTRY_SERVICE)) .andReturn(mockServiceRegistry).anyTimes(); EasyMock.replay(mockServiceRegistry, mockGatewayServices); String descriptorUrl = getTestResource("rewrite.xml").toExternalForm(); Log.setLog(new NoOpLogger()); server = new ServletTester(); server.setContextPath("/"); server.getContext().addEventListener(new UrlRewriteServletContextListener()); server.getContext().setInitParameter(UrlRewriteServletContextListener.DESCRIPTOR_LOCATION_INIT_PARAM_NAME, descriptorUrl);//from w w w. j a v a 2 s .co m server.getContext().setAttribute(GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE, "test-cluster"); server.getContext().setAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE, mockGatewayServices); FilterHolder setupFilter = server.addFilter(SetupFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); setupFilter.setFilter(new SetupFilter(username)); FilterHolder rewriteFilter = server.addFilter(UrlRewriteServletFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); if (initParams != null) { for (Map.Entry<String, String> entry : initParams.entrySet()) { rewriteFilter.setInitParameter(entry.getKey(), entry.getValue()); } } rewriteFilter.setFilter(new UrlRewriteServletFilter()); interactions = new ArrayQueue<MockInteraction>(); ServletHolder servlet = server.addServlet(MockServlet.class, "/"); servlet.setServlet(new MockServlet("mock-servlet", interactions)); server.start(); interaction = new MockInteraction(); request = HttpTester.newRequest(); response = null; }
From source file:com.norconex.jefmon.server.JEFMonServer.java
private WebAppContext buildWebappContext() { WebAppContext webappContext = new WebAppContext(); webappContext.setResourceBase("/"); // Add Wicket filter WicketFilter filter = new WicketFilter(app); FilterHolder filterHolder = new FilterHolder(filter); filterHolder.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, JEFMON_MAPPING); webappContext.addFilter(filterHolder, JEFMON_MAPPING, EnumSet.of(DispatcherType.REQUEST)); // Add custom error message webappContext.setErrorHandler(new ErrorHandler() { protected void writeErrorPageBody(HttpServletRequest request, Writer writer, int code, String message, boolean showStacks) throws IOException { String uri = request.getRequestURI(); writeErrorPageMessage(request, writer, code, message, uri); if (showStacks) writeErrorPageStacks(request, writer); writer.write("<hr><i><small>" + "Norconex JEF Monitor</small></i><hr/>\n"); }//from w ww . j av a 2s.c om }); return webappContext; }
From source file:fi.helsinki.opintoni.config.WebConfigurer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { log.info("Web application configuration, using profiles: {}", Arrays.toString(env.getActiveProfiles())); EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC);//from w ww.j av a 2s . c o m if (env.acceptsProfiles(Constants.SPRING_PROFILE_DEVELOPMENT, Constants.SPRING_PROFILE_QA, Constants.SPRING_PROFILE_DEMO, Constants.SPRING_PROFILE_PRODUCTION)) { initMetrics(servletContext, dispatcherTypes); // Forces browser to send cookies with HTTPS connection only servletContext.getSessionCookieConfig().setSecure(true); } servletContext.getSessionCookieConfig().setName(Constants.SESSION_COOKIE_NAME); servletContext.getSessionCookieConfig().setDomain(appConfiguration.get("cookieDomain")); log.info("Web application fully configured"); }
From source file:com.zxy.commons.hystrix.web.HystrixInitializer.java
/** * {@inheritDoc}/*from w w w . jav a 2 s. com*/ */ public void onStartup(ServletContext container) throws ServletException { // WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(container); Properties properties = load(); String enabled = properties.getProperty(HystrixProperties.HYSTRIX_ENABLED); String streamEnabled = properties.getProperty(HystrixProperties.HYSTRIX_STREAM_ENABLED); if ((StringUtils.isBlank(enabled) || "true".equalsIgnoreCase(enabled)) && (StringUtils.isBlank(streamEnabled) || "true".equalsIgnoreCase(streamEnabled))) { // AnnotationConfigWebApplicationContext ctx = new // AnnotationConfigWebApplicationContext(); // ctx.register(AppConfig.class); // ctx.setServletContext(container); // ServletRegistration.Dynamic servlet = // container.addServlet("dispatcher", new DispatcherServlet(ctx)); // WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(container); // servlet.setLoadOnStartup(1); // servlet.addMapping("/"); FilterRegistration.Dynamic hystrixRequestContextServletFilter = container .addFilter("HystrixRequestContextServletFilter", new HystrixRequestContextServletFilter()); hystrixRequestContextServletFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); FilterRegistration.Dynamic hystrixRequestLogViaResponseHeaderServletFilter = container.addFilter( "HystrixRequestLogViaResponseHeaderServletFilter", new HystrixRequestLogViaResponseHeaderServletFilter()); hystrixRequestLogViaResponseHeaderServletFilter .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); ServletRegistration.Dynamic hystrixMetricsStreamServlet = container .addServlet("HystrixMetricsStreamServlet", new HystrixMetricsStreamServlet()); hystrixMetricsStreamServlet.addMapping("/hystrix.stream"); // ServletRegistration.Dynamic proxyStreamServlet = // container.addServlet("ProxyStreamServlet", new // ProxyStreamServlet()); // proxyStreamServlet.addMapping("/proxy.stream"); } }
From source file:org.ireland.jnetty.dispatch.filter.FilterMapping.java
/** * True if the dispatcher match specify dispatcherType . *///from w w w . j a v a 2 s . c om public boolean matchDispatcherType(DispatcherType dispatcherType) { Assert.notNull(dispatcherType); if (_dispatcherTypes == null) { return dispatcherType.equals(DispatcherType.REQUEST); } //_dispatcherTypes != null return _dispatcherTypes.contains(dispatcherType); }
From source file:org.hdiv.spring.boot.autoconfigure.HdivAutoConfiguration.java
@Bean public ServletContextInitializer validatorFilter() { ServletContextInitializer initializer = new ServletContextInitializer() { public void onStartup(ServletContext servletContext) throws ServletException { // Register HDIV InitListener and ValidatorFilter // InitListener servletContext.addListener(new InitListener()); // ValidatorFilter FilterRegistration.Dynamic registration = servletContext.addFilter("validatorFilter", new ValidatorFilter()); EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST); // isMatchAfter false to put it before existing filters registration.addMappingForUrlPatterns(dispatcherTypes, false, "/*"); }// w w w. java2 s. c o m }; return initializer; }