下面列出了org.springframework.boot.context.embedded.ServletListenerRegistrationBean#org.springframework.security.web.session.HttpSessionEventPublisher 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void onStartup(ServletContext aServletContext) throws ServletException
{
// 2) Make username accessible to logging framework
FilterRegistration loggingFilter = aServletContext.addFilter("logging",
LoggingFilter.class);
loggingFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*");
// 5) Make sure we have one JPA session/transaction per request. Closes session at the
// end, without this, changed data may not be automatically saved to the DB.
FilterRegistration openSessionInViewFilter = aServletContext.addFilter("opensessioninview",
OpenEntityManagerInViewFilter.class);
openSessionInViewFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false,
"/*");
aServletContext.addListener(HttpSessionEventPublisher.class);
}
@Override
public void onStartup(ServletContext aServletContext) throws ServletException
{
// 2) Make username accessible to logging framework
FilterRegistration loggingFilter = aServletContext.addFilter("logging",
LoggingFilter.class);
loggingFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*");
// 5) Make sure we have one JPA session/transaction per request. Closes session at the
// end, without this, changed data may not be automatically saved to the DB.
FilterRegistration openSessionInViewFilter = aServletContext.addFilter("opensessioninview",
OpenEntityManagerInViewFilter.class);
openSessionInViewFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false,
"/*");
aServletContext.addListener(HttpSessionEventPublisher.class);
}
@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);
}
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
@Bean
@ConditionalOnMissingBean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
@Bean
public ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() {
return new ServletListenerRegistrationBean<HttpSessionEventPublisher>(new HttpSessionEventPublisher());
}
@Bean
public ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() {
return new ServletListenerRegistrationBean<>(new HttpSessionEventPublisher());
}
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
@Bean
public static ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() {
return new ServletListenerRegistrationBean<HttpSessionEventPublisher>(new HttpSessionEventPublisher());
}
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return 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.registerShutdownHook();
rootContext.setAllowBeanDefinitionOverriding(false);
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));
dispatcherServletRegistration.setAsyncSupported(true);
}
// Add filters
Dynamic browserDetectionFiler =
servletContext.addFilter("browserDetectionFilter", BrowserDetectionFilter.class);
browserDetectionFiler.setAsyncSupported(true);
browserDetectionFiler.addMappingForUrlPatterns(
EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC), false, "*");
Dynamic etagFilter = servletContext.addFilter("etagFilter", ShallowEtagHeaderFilter.class);
etagFilter.setAsyncSupported(true);
etagFilter.addMappingForServletNames(
EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC), true, "dispatcher");
// enable use of request scoped beans in FrontController
servletContext.addListener(new RequestContextListener());
servletContext.addListener(HttpSessionEventPublisher.class);
}
@Bean
public HttpSessionEventPublisher httpSessionEventPublisher() {
return new HttpSessionEventPublisher();
}
/**
* Listener to redirect to login page after session timeout. Close the
* vaadin session, because it's is not possible to redirect in
* atmosphere.
*
* @return the servlet listener.
*/
@Bean
public ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() {
return new ServletListenerRegistrationBean<>(new HttpSessionEventPublisher());
}