List of usage examples for javax.servlet DispatcherType FORWARD
DispatcherType FORWARD
To view the source code for javax.servlet DispatcherType FORWARD.
Click Source Link
From source file:cn.org.once.cstack.initializer.ApplicationConfig.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(CloudUnitApplicationContext.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(rootContext)); dispatcher.setLoadOnStartup(1);// w w w . ja v a 2 s . c o m dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING); dispatcher.setAsyncSupported(true); FilterRegistration.Dynamic security = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy()); EnumSet<DispatcherType> securityDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC); security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/user/*"); security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/file/*"); security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/logs/*"); security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/messages/*"); security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/application/*"); security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/server/*"); security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/snapshot/*"); security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/module/*"); security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/admin/*"); security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/image/*"); security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/scripting/*"); security.addMappingForUrlPatterns(securityDispatcherTypes, false, "/gitlab/*"); security.setAsyncSupported(true); servletContext.addListener(new ContextLoaderListener(rootContext)); }
From source file:com.github.sshw.config.RootApplicationConfig.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(RootApplicationContext.class); ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", new DispatcherServlet(rootContext)); dispatcher.setLoadOnStartup(1);//from w w w.j a v a 2 s. co m dispatcher.setAsyncSupported(true); dispatcher.addMapping("/"); EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setEncoding("UTF-8"); characterEncodingFilter.setForceEncoding(true); FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter); characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*"); FilterRegistration.Dynamic security = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy()); security.addMappingForUrlPatterns(dispatcherTypes, true, "/*"); servletContext.addListener(new ContextLoaderListener(rootContext)); }
From source file:com.rakesh.rp3599.config.WebAppInitializer.java
public void onStartup(ServletContext container) throws ServletException { AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(AppContext.class); /** Dispatcher Servlet **/ ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(rootContext)); dispatcher.setLoadOnStartup(1);// w ww.j a va 2 s . com dispatcher.setAsyncSupported(true); dispatcher.addMapping("/"); /** Dispatcher Types Enum **/ EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setEncoding("UTF-8"); characterEncodingFilter.setForceEncoding(true); /** UTF-8 Filter **/ FilterRegistration.Dynamic characterEncoding = container.addFilter("characterEncoding", characterEncodingFilter); characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*"); /** Context Listener **/ container.addListener(new ContextLoaderListener(rootContext)); }
From source file:net.rgielen.actionframeworks.struts2.ApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); context.register(ApplicationConfig.class); servletContext.addListener(new ContextLoaderListener(context)); CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setEncoding("UTF-8"); characterEncodingFilter.setForceEncoding(true); EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter);/*from ww w . j av a2 s. c om*/ characterEncoding.addMappingForUrlPatterns(dispatcherTypes, false, "/*"); final FilterRegistration.Dynamic struts = servletContext.addFilter("struts", new StrutsPrepareAndExecuteFilter()); struts.addMappingForUrlPatterns(dispatcherTypes, false, "/*"); }
From source file:com.econcept.init.MainWebAppplicationInitializer.java
@Override public void onStartup(ServletContext pContainer) throws ServletException { // Create the 'root' Spring application context AnnotationConfigWebApplicationContext lRootContext = new AnnotationConfigWebApplicationContext(); lRootContext.scan("com.econcept.init"); // Manage the lifecycle of the root application context pContainer.addListener(new ContextLoaderListener(lRootContext)); // Register and map the dispatcher servlet ServletRegistration.Dynamic lDispatcher = pContainer.addServlet("CFXServlet", CXFServlet.class); lDispatcher.addMapping("/rest/*"); // Apply Spring OAuthSecurity to both forward and request dispatcher FilterRegistration.Dynamic lFilter = pContainer.addFilter("unicodeFilter", new UnicodeFilter()); lFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), true, "/*"); // Apply Spring OAuthSecurity to both forward and request dispatcher lFilter = pContainer.addFilter("securityFilter", new DelegatingFilterProxy("springSecurityFilterChain")); lFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD), true, "/*"); pContainer.addListener(AppHttpSessionListener.class); }
From source file:com.iflytek.edu.cloud.frame.web.RestServiceWebApplicationInitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { servletContext.setInitParameter("contextConfigLocation", "classpath*:META-INF/spring/*-context.xml"); servletContext.setInitParameter("contextInitializerClasses", ProfileApplicationContextInitializer.class.getName()); servletContext.addListener(new LogBackLoadConfigureListener()); servletContext.addListener(new ContextLoaderListener()); FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter()); EnumSet<DispatcherType> characterEncodingFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); characterEncodingFilter.setInitParameter("encoding", "UTF-8"); characterEncodingFilter.setInitParameter("forceEncoding", "true"); characterEncodingFilter.addMappingForUrlPatterns(characterEncodingFilterDispatcherTypes, true, "/*"); FilterRegistration.Dynamic openServiceFilter = servletContext.addFilter("openServiceFilter", new DelegatingFilterProxy()); EnumSet<DispatcherType> openServiceFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);/* w w w.j a va2 s . c o m*/ openServiceFilter.addMappingForUrlPatterns(openServiceFilterDispatcherTypes, true, "/api"); if (EnvUtil.jdbcEnabled()) { FilterRegistration.Dynamic serviceMetricsFilter = servletContext.addFilter("serviceMetricsFilter", new DelegatingFilterProxy()); EnumSet<DispatcherType> serviceMetricsFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); serviceMetricsFilter.addMappingForUrlPatterns(serviceMetricsFilterDispatcherTypes, true, "/api"); } FilterRegistration.Dynamic CORSFilter = servletContext.addFilter("CORSFilter", new DelegatingFilterProxy()); EnumSet<DispatcherType> CORSFilterDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); CORSFilter.addMappingForUrlPatterns(CORSFilterDispatcherTypes, true, "/api"); if (EnvUtil.oauthEnabled()) { FilterRegistration.Dynamic springSecurityFilterChain = servletContext .addFilter("springSecurityFilterChain", new DelegatingFilterProxyExt()); EnumSet<DispatcherType> springSecurityFilterChainDispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); springSecurityFilterChain.addMappingForUrlPatterns(springSecurityFilterChainDispatcherTypes, true, "/api"); } else { logger.info( "?oauth2???META-INF/res/profile.propertiesoauth2 profile"); } ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet("rest", new DispatcherServlet()); dispatcherServlet.setLoadOnStartup(1); dispatcherServlet.setInitParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName()); dispatcherServlet.setInitParameter("contextConfigLocation", "org.spring.rest"); dispatcherServlet.setMultipartConfig(getMultiPartConfig()); dispatcherServlet.addMapping("/api"); ServletRegistration.Dynamic printProjectVersionServlet = servletContext .addServlet("printProjectVersionServlet", new PrintProjectVersionServlet()); printProjectVersionServlet.setLoadOnStartup(Integer.MAX_VALUE); }
From source file:br.eti.danielcamargo.backend.common.config.WebAppInitializer.java
private void configureSpringSecurity(ServletContext servletContext, WebApplicationContext rootContext) { EnumSet<DispatcherType> dispacherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD); FilterRegistration.Dynamic springSecurity = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain", rootContext)); springSecurity.addMappingForUrlPatterns(dispacherTypes, true, "/*"); }
From source file:io.jmnarloch.spring.request.correlation.support.RequestCorrelationConfiguration.java
@Bean public FilterRegistrationBean requestCorrelationFilterBean(RequestCorrelationFilter correlationFilter) { final FilterRegistrationBean filterRegistration = new FilterRegistrationBean(); filterRegistration.setFilter(correlationFilter); filterRegistration.setMatchAfter(false); filterRegistration.setDispatcherTypes( EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC)); filterRegistration.setAsyncSupported(true); filterRegistration.setOrder(Ordered.HIGHEST_PRECEDENCE); return filterRegistration; }
From source file:de.interseroh.report.webapp.UiWebAppInitializer.java
private void addSecurityFilter(ServletContext servletContext) { servletContext.addFilter(SPRING_SECURITY_FILTER_NAME, DelegatingFilterProxy.class).addMappingForUrlPatterns( EnumSet.<DispatcherType>of(DispatcherType.REQUEST, DispatcherType.FORWARD), false, "/*"); }
From source file:io.undertow.servlet.test.dispatcher.DispatcherForwardTestCase.java
@BeforeClass public static void setup() throws ServletException { final PathHandler root = new PathHandler(); final ServletContainer container = ServletContainer.Factory.newInstance(); DeploymentInfo builder = new DeploymentInfo().setClassLoader(SimpleServletTestCase.class.getClassLoader()) .setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE) .setDeploymentName("servletContext.war") .setResourceManager(new TestResourceLoader(DispatcherForwardTestCase.class)) .addServlet(new ServletInfo("forward", MessageServlet.class) .addInitParam(MessageServlet.MESSAGE, "forwarded").addMapping("/forward")) .addServlet(new ServletInfo("dispatcher", ForwardServlet.class).addMapping("/dispatch")) .addServlet(new ServletInfo("pathTest", PathTestServlet.class).addMapping("/path")) .addFilter(new FilterInfo("notforwarded", MessageFilter.class).addInitParam(MessageFilter.MESSAGE, "Not forwarded")) .addFilter(new FilterInfo("inc", MessageFilter.class).addInitParam(MessageFilter.MESSAGE, "Path!")) .addFilter(new FilterInfo("nameFilter", MessageFilter.class).addInitParam(MessageFilter.MESSAGE, "Name!")) .addFilterUrlMapping("notforwarded", "/forward", DispatcherType.REQUEST) .addFilterUrlMapping("inc", "/forward", DispatcherType.FORWARD) .addFilterServletNameMapping("nameFilter", "forward", DispatcherType.FORWARD); DeploymentManager manager = container.addDeployment(builder); manager.deploy();//from w w w . j av a 2 s . c o m root.addPrefixPath(builder.getContextPath(), manager.start()); DefaultServer.setRootHandler( new AccessLogHandler(root, RECEIVER, "%r %U %R", AccessLogFileTestCase.class.getClassLoader())); }