@Override public void onStartup(ServletContext servletContext) throws ServletException { servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain")) .addMappingForUrlPatterns(null, false, "/api/*"); // 静态资源映射 servletContext.getServletRegistration("default").addMapping("/static/*", "*.html", "*.ico"); servletContext.addListener(HttpSessionEventPublisher.class); super.onStartup(servletContext); }
/** * Implemented a listener - HttpSessionEventPublisher. */ @Bean public HttpSessionEventPublisher httpSessionEventPublisher() { return new HttpSessionEventPublisher(); }
@Bean public HttpSessionEventPublisher httpSessionEventPublisher() { return new HttpSessionEventPublisher(); }
@SuppressWarnings("unchecked") @Bean public static ServletListenerRegistrationBean httpSessionEventPublisher() { return new ServletListenerRegistrationBean(new HttpSessionEventPublisher()); }
@Override protected void afterSessionRepositoryFilter(ServletContext servletContext) { servletContext.addListener(new HttpSessionEventPublisher()); }
@Override public void onStartup(ServletContext sc) throws ServletException { log.debug("web starting up..."); // Create the 'root' Spring application context AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.register(SpringConfiguration.class); ctx.refresh(); // Register the Spring Context in the ServletContext sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx); // Request Listener sc.addListener(new RequestContextListener()); // Manages the lifecycle sc.addListener(new ContextCleanupListener()); sc.addListener(new HttpSessionEventPublisher()); log.info("web initialized."); }
@Bean public static ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() { return new ServletListenerRegistrationBean<HttpSessionEventPublisher>(new HttpSessionEventPublisher()); }
/** * A Molgenis common web application initializer */ protected void onStartup(ServletContext servletContext, Class<?> appConfig, int maxFileSize) { // Create the 'root' Spring application context AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext(); rootContext.register(appConfig); // Manage the lifecycle of the root application context servletContext.addListener(new ContextLoaderListener(rootContext)); // Register and map the dispatcher servlet DispatcherServlet dispatcherServlet = new DispatcherServlet(rootContext); dispatcherServlet.setDispatchOptionsRequest(true); // instead of throwing a 404 when a handler is not found allow for custom handling dispatcherServlet.setThrowExceptionIfNoHandlerFound(true); ServletRegistration.Dynamic dispatcherServletRegistration = servletContext.addServlet("dispatcher", dispatcherServlet); if (dispatcherServletRegistration == null) { LOG.warn("ServletContext already contains a complete ServletRegistration for servlet 'dispatcher'"); } else { final long maxSize = (long) maxFileSize * MB; dispatcherServletRegistration.addMapping("/"); dispatcherServletRegistration.setMultipartConfig( new MultipartConfigElement(null, maxSize, maxSize, FILE_SIZE_THRESHOLD)); } // add filters Dynamic browserDetectionFiler = servletContext.addFilter("browserDetectionFilter", BrowserDetectionFilter.class); browserDetectionFiler.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "*"); Dynamic etagFilter = servletContext.addFilter("etagFilter", ShallowEtagHeaderFilter.class); etagFilter.addMappingForServletNames(EnumSet.of(DispatcherType.REQUEST), true, "dispatcher"); Dynamic corsFilter = servletContext.addFilter("corsFilter", CorsFilter.class); corsFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/api/*"); corsFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/fdp/*"); // enable use of request scoped beans in FrontController servletContext.addListener(new RequestContextListener()); servletContext.addListener(HttpSessionEventPublisher.class); }
@Bean public HttpSessionEventPublisher httpSessionEventPublisher(){ return new HttpSessionEventPublisher(); }
/** * Security Web Application Initializer * * Filtering for multi part file upload. * Adding listener to collect session events. * * @author Ant Kaynak - Github/Exercon * */ @Override protected void beforeSpringSecurityFilterChain(ServletContext servletContext) { insertFilters(servletContext, new MultipartFilter()); servletContext.addListener(HttpSessionEventPublisher.class); }
/** * Security Web Application Initializer * Adding listener to collect session events. * * @author Ant Kaynak - Github/Exercon * */ @Override protected void beforeSpringSecurityFilterChain(ServletContext servletContext) { servletContext.addListener(HttpSessionEventPublisher.class); }
@Bean public ServletListenerRegistrationBean httpSessionEventPublisher() { return new ServletListenerRegistrationBean(new HttpSessionEventPublisher()); }
@Bean public HttpSessionEventPublisher registerHttpSessionEventPublisher(){ return new HttpSessionEventPublisher(); }
@Bean public ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() { return new ServletListenerRegistrationBean<HttpSessionEventPublisher>(new HttpSessionEventPublisher()); }
/** * Listener to redirect to login page after session timeout. Close the * vaadin session, because it's is not possible to redirect in * atmospehere. * * @return the servlet listener. */ @Bean public ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() { return new ServletListenerRegistrationBean<>(new HttpSessionEventPublisher()); }