List of usage examples for javax.servlet ServletContext addFilter
public FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass);
From source file:com.tcloud.bee.key.server.jetty.config.WebAppInitializer.java
private void configureEncodingFilter(ServletContext servletContext) { CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter(); encodingFilter.setEncoding("UTF-8"); encodingFilter.setForceEncoding(false); FilterRegistration.Dynamic encodingFilterDinamic = servletContext.addFilter("charEncodingFilter", encodingFilter);/*from www.j a v a2 s.c o m*/ encodingFilterDinamic.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); }
From source file:org.obiba.mica.config.WebConfiguration.java
private void initAllowedMethods(ServletContext servletContext) { log.debug("Registering Allowed Methods Filter"); FilterRegistration.Dynamic filterRegistration = servletContext.addFilter("noTrace", new NoTraceFilter()); filterRegistration.addMappingForUrlPatterns(EnumSet.of(REQUEST, FORWARD, ASYNC, INCLUDE, ERROR), true, "/*"); filterRegistration.setAsyncSupported(true); }
From source file:org.lightadmin.core.config.LightAdminWebApplicationInitializer.java
private void registerTilesDecorationFilter(final ServletContext servletContext) { final String urlMapping = urlMapping(lightAdminBaseUrl(servletContext)); servletContext.addFilter("lightAdminTilesContainerEnrichmentFilter", TilesContainerEnrichmentFilter.class) .addMappingForUrlPatterns(null, false, urlMapping); }
From source file:org.lightadmin.core.config.LightAdminWebApplicationInitializer.java
private void registerHiddenHttpMethodFilter(final ServletContext servletContext) { final String urlMapping = urlMapping(lightAdminBaseUrl(servletContext)); servletContext.addFilter("lightAdminHiddenHttpMethodFilter", HiddenHttpMethodFilter.class) .addMappingForUrlPatterns(null, false, urlMapping); }
From source file:org.lightadmin.core.config.LightAdminWebApplicationInitializer.java
private void registerSpringSecurityFilter(final ServletContext servletContext) { final String urlMapping = urlMapping(lightAdminBaseUrl(servletContext)); servletContext.addFilter("lightAdminSpringSecurityFilterChain", springSecurityFilterChain()) .addMappingForUrlPatterns(null, false, urlMapping); }
From source file:org.lightadmin.core.config.LightAdminWebApplicationInitializer.java
private void registerCharsetFilter(final ServletContext servletContext) { final String urlMapping = urlMapping(lightAdminBaseUrl(servletContext)); servletContext.addFilter("lightAdminCharsetFilter", characterEncodingFilter()) .addMappingForServletNames(null, false, urlMapping); }
From source file:com.azirar.requester.ws.config.WebAppInitializer.java
public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext dispatcherServlet = new AnnotationConfigWebApplicationContext(); dispatcherServlet.register(AppConf.class); dispatcherServlet.setServletContext(servletContext); // //Added filter dynamically javax.servlet.FilterRegistration.Dynamic corsFilter = servletContext.addFilter("corsFilter", CorsFilter.class); corsFilter.addMappingForUrlPatterns(null, true, "/*"); Dynamic dynamic = servletContext.addServlet("dispatcher", new DispatcherServlet(dispatcherServlet)); dynamic.addMapping("/"); dynamic.setLoadOnStartup(1);/*from w w w . ja v a2s. c om*/ }
From source file:com.haulmont.cuba.web.sys.singleapp.SingleAppWebContextLoader.java
protected void registerCubaHttpFilter(ServletContext servletContext) { CubaHttpFilter cubaHttpFilter = new CubaHttpFilter(); FilterRegistration.Dynamic cubaHttpFilterReg = servletContext.addFilter("CubaHttpFilter", cubaHttpFilter); cubaHttpFilterReg.setAsyncSupported(true); cubaHttpFilterReg.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*"); }
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, "/*"); }//from ww w . j a va 2 s. co m }; return initializer; }
From source file:org.obiba.mica.config.WebConfiguration.java
/** * Initializes the GZip filter./* w w w . ja v a 2s.c om*/ */ private void initGzipFilter(ServletContext servletContext, EnumSet<DispatcherType> disps) { log.debug("Registering GZip Filter"); FilterRegistration.Dynamic filterRegistration = servletContext.addFilter("gzipFilter", new GzipFilter()); if (filterRegistration == null) { filterRegistration = (FilterRegistration.Dynamic) servletContext.getFilterRegistration("gzipFilter"); } filterRegistration.addMappingForUrlPatterns(disps, true, "*.css"); filterRegistration.addMappingForUrlPatterns(disps, true, "*.json"); filterRegistration.addMappingForUrlPatterns(disps, true, "*.html"); filterRegistration.addMappingForUrlPatterns(disps, true, "*.js"); filterRegistration.addMappingForUrlPatterns(disps, true, "/jvm/*"); filterRegistration.addMappingForUrlPatterns(disps, true, WS_ROOT + "/*"); filterRegistration.setAsyncSupported(true); }