org.springframework.boot.web.servlet.ServletListenerRegistrationBean Java Examples

The following examples show how to use org.springframework.boot.web.servlet.ServletListenerRegistrationBean. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CasCustomConfig.java    From CAS with Apache License 2.0 5 votes vote down vote up
@Bean
public ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> singleSignOutHttpSessionListener() {
    ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> listener = new ServletListenerRegistrationBean<SingleSignOutHttpSessionListener>();
    listener.setEnabled(casEnabled);
    listener.setListener(new SingleSignOutHttpSessionListener());
    listener.setOrder(1);
    return listener;
}
 
Example #2
Source File: CasConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 *  For single point logout
 */
@Bean
public ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> singleSignOutHttpSessionListener() {
    ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> listener = new ServletListenerRegistrationBean<>();
    listener.setEnabled(true);
    listener.setListener(new SingleSignOutHttpSessionListener());
    listener.setOrder(1);
    return listener;
}
 
Example #3
Source File: CasConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 *  For single point logout
 */
@Bean
public ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> singleSignOutHttpSessionListener() {
    ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> listener = new ServletListenerRegistrationBean<>();
    listener.setEnabled(true);
    listener.setListener(new SingleSignOutHttpSessionListener());
    listener.setOrder(1);
    return listener;
}
 
Example #4
Source File: CasConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 *  For single point logout
 */
@Bean
public ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> singleSignOutHttpSessionListener() {
    ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> listener = new ServletListenerRegistrationBean<>();
    listener.setEnabled(true);
    listener.setListener(new SingleSignOutHttpSessionListener());
    listener.setOrder(1);
    return listener;
}
 
Example #5
Source File: CasConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 *  For single point logout
 */
@Bean
public ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> singleSignOutHttpSessionListener() {
    ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> listener = new ServletListenerRegistrationBean<>();
    listener.setEnabled(true);
    listener.setListener(new SingleSignOutHttpSessionListener());
    listener.setOrder(1);
    return listener;
}
 
Example #6
Source File: CasConfig.java    From Spring-Security-Third-Edition with MIT License 5 votes vote down vote up
/**
 *  For single point logout
 */
@Bean
public ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> singleSignOutHttpSessionListener() {
    ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> listener = new ServletListenerRegistrationBean<>();
    listener.setEnabled(true);
    listener.setListener(new SingleSignOutHttpSessionListener());
    listener.setOrder(1);
    return listener;
}
 
Example #7
Source File: ShiroConfiguration.java    From springboot-shiro-cas-mybatis with MIT License 5 votes vote down vote up
/**
 * 注册单点登出的listener
 * 
 * @return
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@Bean
public ServletListenerRegistrationBean<?> singleSignOutHttpSessionListener() {
	ServletListenerRegistrationBean bean = new ServletListenerRegistrationBean();
	bean.setListener(new SingleSignOutHttpSessionListener());
	bean.setEnabled(true);
	return bean;
}
 
Example #8
Source File: AuthConfiguration.java    From apollo with Apache License 2.0 5 votes vote down vote up
@Bean
public ServletListenerRegistrationBean redisAppSettingListner() {
  ServletListenerRegistrationBean redisAppSettingListener = new ServletListenerRegistrationBean();
  redisAppSettingListener
      .setListener(listener("org.jasig.cas.client.credis.CRedisAppSettingListner"));
  return redisAppSettingListener;
}
 
Example #9
Source File: CasCustomConfig.java    From CAS with Apache License 2.0 5 votes vote down vote up
@Bean
public ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> singleSignOutHttpSessionListener() {
    ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> listener = new ServletListenerRegistrationBean<SingleSignOutHttpSessionListener>();
    listener.setEnabled(casEnabled);
    listener.setListener(new SingleSignOutHttpSessionListener());
    listener.setOrder(1);
    return listener;
}
 
Example #10
Source File: CasCustomConfig.java    From CAS with Apache License 2.0 5 votes vote down vote up
@Bean
public ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> singleSignOutHttpSessionListener() {
    ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> listener = new ServletListenerRegistrationBean<SingleSignOutHttpSessionListener>();
    listener.setEnabled(casEnabled);
    listener.setListener(new SingleSignOutHttpSessionListener());
    listener.setOrder(1);
    return listener;
}
 
Example #11
Source File: ShiroCasWebFilterConfiguration.java    From shiro-cas-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@Bean
public ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> singleSignOutHttpSessionListener() {
	ServletListenerRegistrationBean<SingleSignOutHttpSessionListener> registration = new ServletListenerRegistrationBean<SingleSignOutHttpSessionListener>(
			new SingleSignOutHttpSessionListener());
	registration.setOrder(1);
	return registration;
}
 
Example #12
Source File: CasConfiguration.java    From taoshop with Apache License 2.0 5 votes vote down vote up
/**
 * 单点登出监听器
 * @return
 */
@Bean
public ServletListenerRegistrationBean servletListenerRegistrationBean() {
    ServletListenerRegistrationBean registrationBean = new ServletListenerRegistrationBean();
    registrationBean.setListener(new SingleSignOutHttpSessionListener());
    registrationBean.setEnabled(true);
    return registrationBean;
}
 
Example #13
Source File: WebMvcConfig.java    From SpringBoot2.0 with Apache License 2.0 5 votes vote down vote up
@Bean
public ServletListenerRegistrationBean<MyListener1> registrationBean() {
    ServletListenerRegistrationBean<MyListener1> servletListenerRegistrationBean
            = new ServletListenerRegistrationBean<>();
    servletListenerRegistrationBean.setListener(new MyListener1());
    return servletListenerRegistrationBean;
}
 
Example #14
Source File: JavaMelodyAutoConfiguration.java    From javamelody with Apache License 2.0 5 votes vote down vote up
/**
 * Registers the JavaMelody {@link SessionListener}.
 * @param servletContext ServletContext
 * @return ServletListenerRegistrationBean
 */
@Bean
public ServletListenerRegistrationBean<EventListener> monitoringSessionListener(
		ServletContext servletContext) {
	final ServletListenerRegistrationBean<EventListener> servletListenerRegistrationBean = new ServletListenerRegistrationBean<>(
			new SessionListener());
	if (servletContext.getFilterRegistration("javamelody") != null) {
		// if webapp deployed as war in a container with MonitoringFilter and SessionListener already added by web-fragment.xml,
		// do not add again
		servletListenerRegistrationBean.setEnabled(false);
	}
	return servletListenerRegistrationBean;
}
 
Example #15
Source File: SpringBootConfiguration.java    From bugsnag-java with MIT License 5 votes vote down vote up
/**
 * The {@link com.bugsnag.servlet.BugsnagServletContainerInitializer} does not work for Spring Boot, need to
 * register the {@link BugsnagServletRequestListener} using a Spring Boot
 * {@link ServletListenerRegistrationBean} instead. This adds session tracking and
 * automatic servlet request metadata collection.
 */
@Bean
@Conditional(SpringWebMvcLoadedCondition.class)
ServletListenerRegistrationBean<ServletRequestListener> listenerRegistrationBean() {
    ServletListenerRegistrationBean<ServletRequestListener> srb =
            new ServletListenerRegistrationBean<ServletRequestListener>();
    srb.setListener(new BugsnagServletRequestListener());
    return srb;
}
 
Example #16
Source File: WebConfig.java    From Guns with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * ConfigListener注册
 */
@Bean
public ServletListenerRegistrationBean<ConfigListener> configListenerRegistration() {
    return new ServletListenerRegistrationBean<>(new ConfigListener());
}
 
Example #17
Source File: WebHasorConfiguration.java    From hasor with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnClass(name = "net.hasor.web.startup.RuntimeListener")
public ServletListenerRegistrationBean<?> hasorRuntimeListener() {
    Objects.requireNonNull(this.appContext, "AppContext is not inject.");
    return new ServletListenerRegistrationBean<>(new RuntimeListener(this.appContext));
}
 
Example #18
Source File: LayuiAdminStartUp.java    From layui-admin with MIT License 4 votes vote down vote up
@Bean
public ServletListenerRegistrationBean IntrospectorCleanupListener(){
    ServletListenerRegistrationBean servletListenerRegistrationBean = new ServletListenerRegistrationBean();
    servletListenerRegistrationBean.setListener(new org.springframework.web.util.IntrospectorCleanupListener());
    return servletListenerRegistrationBean;
}
 
Example #19
Source File: TestJavaMelodyAutoConfiguration.java    From javamelody with Apache License 2.0 4 votes vote down vote up
/**
 * test.
 */
@SuppressWarnings("unchecked")
@Test
public void testJavaMelodyAutoConfigurationIsCreated() {
	// It should create a session listener.
	final ServletListenerRegistrationBean<EventListener> sessionListenerRegistrationBean = context
			.getBean(ServletListenerRegistrationBean.class);
	assertThat(sessionListenerRegistrationBean).isNotNull();

	// It should create a registration bean named "javamelody-registration".
	final Object registrationBean = context
			.getBean(JavaMelodyAutoConfiguration.REGISTRATION_BEAN_NAME);
	assertThat(registrationBean).isNotNull();
	assertThat(registrationBean).isInstanceOf(FilterRegistrationBean.class);

	// It should create a filter registration bean with the appropriately configured monitoring filter.
	final FilterRegistrationBean<MonitoringFilter> filterRegistrationBean = (FilterRegistrationBean<MonitoringFilter>) registrationBean;
	assertThat(filterRegistrationBean.getFilter()).isNotNull();
	assertThat(filterRegistrationBean.getFilter()).isInstanceOf(MonitoringFilter.class);
	assertThat(filterRegistrationBean.getInitParameters()).containsEntry("log", "true");
	assertThat(filterRegistrationBean.getInitParameters()).containsEntry("monitoring-path",
			"/test/path");
	assertThat(filterRegistrationBean.getUrlPatterns()).containsExactly("/*");

	// It should create the monitoring filter with the application type "Spring Boot".
	final MonitoringFilter monitoringFilter = filterRegistrationBean.getFilter();
	assertThat(monitoringFilter.getApplicationType()).isEqualTo("Spring Boot");

	// It should not create anymore an auto-proxy creator.
	//		final DefaultAdvisorAutoProxyCreator autoProxyCreator = context
	//				.getBean(DefaultAdvisorAutoProxyCreator.class);
	//		assertThat(autoProxyCreator).isNotNull();

	// It should create a bean post-processor for data sources.
	final SpringDataSourceBeanPostProcessor dataSourcePostProcessor = context
			.getBean(SpringDataSourceBeanPostProcessor.class);
	assertThat(dataSourcePostProcessor).isNotNull();
	// Cannot test excluded data sources since there is no public accessor for that.

	// It should create interceptors to monitor Spring services and controllers.
	final Map<String, MonitoringSpringAdvisor> springAdvisors = context
			.getBeansOfType(MonitoringSpringAdvisor.class);
	boolean monitoredWithAdvisorFound = false;
	int stereotypeAdvisorsCount = 0;
	for (final MonitoringSpringAdvisor springAdvisor : springAdvisors.values()) {
		if (springAdvisor.getPointcut() instanceof MonitoredWithAnnotationPointcut) {
			monitoredWithAdvisorFound = true;
		} else {
			stereotypeAdvisorsCount++;
			// Maybe use synthetic @Service, @Controller and @RestController classes to check if point cuts match.
		}
	}
	assertThat(monitoredWithAdvisorFound).isTrue();
	assertThat(stereotypeAdvisorsCount).isEqualTo(5);

	// It should create a bean post-processor for rest templates.
	final SpringRestTemplateBeanPostProcessor restTemplatePostProcessor = context
			.getBean(SpringRestTemplateBeanPostProcessor.class);
	assertThat(restTemplatePostProcessor).isNotNull();
}
 
Example #20
Source File: WebSecurityConfig.java    From fredbet with Creative Commons Attribution Share Alike 4.0 International 4 votes vote down vote up
@Bean
public ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() {
    return new ServletListenerRegistrationBean<>(new HttpSessionEventPublisher());
}
 
Example #21
Source File: RESTCXFContext.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Bean
public ServletListenerRegistrationBean<ServletRequestListener> listenerRegistrationBean() {
    ServletListenerRegistrationBean<ServletRequestListener> bean = new ServletListenerRegistrationBean<>();
    bean.setListener(new ThreadLocalCleanupListener());
    return bean;
}
 
Example #22
Source File: ShutdownHookConfiguration.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
ServletListenerRegistrationBean<ServletContextListener> servletListener() {
    ServletListenerRegistrationBean<ServletContextListener> srb = new ServletListenerRegistrationBean<>();
    srb.setListener(new ExampleServletContextListener());
    return srb;
}
 
Example #23
Source File: WebConfig.java    From sanshanblog with Apache License 2.0 4 votes vote down vote up
/**
  * 主要负责处理由 JavaBeans Introspector的使用而引起的缓冲泄露
  * @return
  */
@Bean
public ServletListenerRegistrationBean<IntrospectorCleanupListener> introspectorCleanupListener() {
     return  new ServletListenerRegistrationBean<>(new IntrospectorCleanupListener());
}
 
Example #24
Source File: WebConfig.java    From sanshanblog with Apache License 2.0 4 votes vote down vote up
/**
  * 允许请求到外部的Listener
  * @return
  */
@Bean
public ServletListenerRegistrationBean<RequestContextListener> requestContextListener(){
    return new ServletListenerRegistrationBean<RequestContextListener>(new RequestContextListener());
}
 
Example #25
Source File: SpringWebConfig.java    From we-cmdb with Apache License 2.0 4 votes vote down vote up
@Bean
public ServletListenerRegistrationBean<ServletRequestListener> registerRequestListener() {
    ServletListenerRegistrationBean<ServletRequestListener> servletListenerRegistrationBean = new ServletListenerRegistrationBean<>();
    servletListenerRegistrationBean.setListener(new RequestContextListener());
    return servletListenerRegistrationBean;
}
 
Example #26
Source File: WebConfig.java    From Guns with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * RequestContextListener注册
 */
@Bean
public ServletListenerRegistrationBean<RequestContextListener> requestContextListenerRegistration() {
    return new ServletListenerRegistrationBean<>(new RequestContextListener());
}
 
Example #27
Source File: WebApplicationConfig.java    From springbootexamples with Apache License 2.0 4 votes vote down vote up
@Bean
public ServletListenerRegistrationBean<ApplicationListener>  userServlet(){
	return new ServletListenerRegistrationBean<ApplicationListener> (new ApplicationListener());
}
 
Example #28
Source File: SpringmvcConfiguration.java    From ml-blog with MIT License 4 votes vote down vote up
@Bean
public ServletListenerRegistrationBean<GlobalListener> servletListenerRegistrationBean() {
    return new ServletListenerRegistrationBean<>(globalListener);
}
 
Example #29
Source File: WebConfig.java    From WebStack-Guns with MIT License 4 votes vote down vote up
/**
 * ConfigListener注册
 */
@Bean
public ServletListenerRegistrationBean<ConfigListener> configListenerRegistration() {
    return new ServletListenerRegistrationBean<>(new ConfigListener());
}
 
Example #30
Source File: WebConfig.java    From WebStack-Guns with MIT License 4 votes vote down vote up
/**
 * RequestContextListener注册
 */
@Bean
public ServletListenerRegistrationBean<RequestContextListener> requestContextListenerRegistration() {
    return new ServletListenerRegistrationBean<>(new RequestContextListener());
}