Java 类org.springframework.boot.web.servlet.ServletListenerRegistrationBean 实例源码

项目:springboot-shiro-cas-mybatis    文件:ShiroCasConfiguration.java   
/**
     * 注册单点登出listener
     * @return
     */
    @Bean
    public ServletListenerRegistrationBean singleSignOutHttpSessionListener(){
        ServletListenerRegistrationBean bean = new ServletListenerRegistrationBean();
        bean.setListener(new SingleSignOutHttpSessionListener());
//        bean.setName(""); //默认为bean name
        bean.setEnabled(true);
        //bean.setOrder(Ordered.HIGHEST_PRECEDENCE); //设置优先级
        return bean;
    }
项目:springboot-shiro-cas-mybatis    文件:ShiroConfiguration.java   
/**
 * 注册单点登出的listener
 * 
 * @return
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@Bean
public ServletListenerRegistrationBean<?> singleSignOutHttpSessionListener() {
    ServletListenerRegistrationBean bean = new ServletListenerRegistrationBean();
    bean.setListener(new SingleSignOutHttpSessionListener());
    bean.setEnabled(true);
    return bean;
}
项目:cas-5.1.0    文件:CasWebAppConfiguration.java   
@Bean
public ServletListenerRegistrationBean log4jServletContextListener() {
    final ServletListenerRegistrationBean bean = new ServletListenerRegistrationBean();
    bean.setEnabled(true);
    bean.setName("log4jServletContextListener");
    bean.setListener(new Log4jServletContextListener());
    return bean;
}
项目:springBoot-demo    文件:SpringBootDemoApplication.java   
@Bean
public ServletListenerRegistrationBean myListener(){
    ServletListenerRegistrationBean servletListenerRegistrationBean = new ServletListenerRegistrationBean();
    servletListenerRegistrationBean.setListener(new MyListener());
    servletListenerRegistrationBean.setName("myListener");
    return  servletListenerRegistrationBean;
}
项目:TARA-Server    文件:CasWebAppConfiguration.java   
@Bean
public ServletListenerRegistrationBean log4jServletContextListener() {
    ServletListenerRegistrationBean bean = new ServletListenerRegistrationBean();
    bean.setEnabled(true);
    bean.setName("log4jServletContextListener");
    bean.setListener(new Log4jServletContextListener());
    return bean;
}
项目:Spring-Security-Third-Edition    文件:CasConfig.java   
/**
 *  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;
}
项目:Spring-Security-Third-Edition    文件:CasConfig.java   
/**
 *  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;
}
项目:Spring-Security-Third-Edition    文件:CasConfig.java   
/**
 *  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;
}
项目:Spring-Security-Third-Edition    文件:CasConfig.java   
/**
 *  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;
}
项目:Spring-Security-Third-Edition    文件:CasConfig.java   
/**
 *  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;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EmbeddedServletContainerServletContextListenerTests.java   
private void registeredServletContextListenerBeanIsCalled(Class<?> configuration) {
    AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext(
            ServletListenerRegistrationBeanConfiguration.class, configuration);
    ServletContextListener servletContextListener = (ServletContextListener) context
            .getBean("registration", ServletListenerRegistrationBean.class)
            .getListener();
    verify(servletContextListener).contextInitialized(any(ServletContextEvent.class));
    context.close();
}
项目:spring-boot-concourse    文件:EmbeddedServletContainerServletContextListenerTests.java   
private void registeredServletContextListenerBeanIsCalled(Class<?> configuration) {
    AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext(
            ServletListenerRegistrationBeanConfiguration.class, configuration);
    ServletContextListener servletContextListener = (ServletContextListener) context
            .getBean("registration", ServletListenerRegistrationBean.class)
            .getListener();
    verify(servletContextListener).contextInitialized(any(ServletContextEvent.class));
    context.close();
}
项目:BizHttpRequestTest    文件:DevHelperAutoConfiguration.java   
@Bean
public ServletListenerRegistrationBean<BootstrapperContextListener> bootstrapperContextListener() {
    String listenerName = "bootstrapperContextListener";

    ServletListenerRegistrationBean<BootstrapperContextListener> registrationBean = new ServletListenerRegistrationBean<BootstrapperContextListener>();

    BootstrapperContextListener listener = new BootstrapperContextListener();
    registrationBean.setListener(listener);
    registrationBean.setName(listenerName);

    return registrationBean;
}
项目:javamelody    文件:JavaMelodyAutoConfiguration.java   
/**
 * Registers the JavaMelody {@link SessionListener}.
 * @param servletContext ServletContext
 * @return ServletListenerRegistrationBean
 */
@Bean
public ServletListenerRegistrationBean<EventListener> monitoringSessionListener(
        ServletContext servletContext) {
    final ServletListenerRegistrationBean<EventListener> servletListenerRegistrationBean = new ServletListenerRegistrationBean<EventListener>(
            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;
}
项目:timesheet-upload    文件:ApplicationSessionConfiguration.java   
@Bean
public ServletListenerRegistrationBean<HttpSessionListener> sessionListener() {
    return new ServletListenerRegistrationBean<HttpSessionListener>(new SessionListener());
}
项目:amanda    文件:SecurityConfiguration.java   
@SuppressWarnings("unchecked")
@Bean
public static ServletListenerRegistrationBean httpSessionEventPublisher() {
    return new ServletListenerRegistrationBean(new HttpSessionEventPublisher());
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EmbeddedServletContainerServletContextListenerTests.java   
@Bean
public ServletListenerRegistrationBean<ServletContextListener> registration() {
    return new ServletListenerRegistrationBean<ServletContextListener>(
            mock(ServletContextListener.class));
}
项目:spring-boot-keycloak-server-example    文件:EmbeddedKeycloakConfig.java   
@Bean
ServletListenerRegistrationBean<KeycloakSessionDestroyListener> keycloakSessionDestroyListener() {
  return new ServletListenerRegistrationBean<>(new KeycloakSessionDestroyListener());
}
项目:checksumDatabase    文件:Application.java   
@Bean
public ServletListenerRegistrationBean<JsfApplicationObjectConfigureListener> jsfConfigureListener() {
    return new ServletListenerRegistrationBean<>(
            new JsfApplicationObjectConfigureListener());
}
项目:spring-boot-concourse    文件:EmbeddedServletContainerServletContextListenerTests.java   
@Bean
public ServletListenerRegistrationBean<ServletContextListener> registration() {
    return new ServletListenerRegistrationBean<ServletContextListener>(
            mock(ServletContextListener.class));
}
项目:releasetrain    文件:PrimeBootAdapterConfiguration.java   
@Bean
public ServletListenerRegistrationBean<ConfigureListener> jsfConfigureListener() {
    return new ServletListenerRegistrationBean<ConfigureListener>(new ConfigureListener());
}
项目:javamelody    文件:TestJavaMelodyAutoConfiguration.java   
/**
 * 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 filterRegistrationBean = (FilterRegistrationBean) 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 = (MonitoringFilter) filterRegistrationBean
            .getFilter();
    assertThat(monitoringFilter.getApplicationType()).isEqualTo("Spring Boot");

    // It should create 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 if (springAdvisor.getPointcut() instanceof AnnotationMatchingPointcut) {
            stereotypeAdvisorsCount++;
            // Maybe use synthetic @Service, @Controller and @RestController classes to check if point cuts match.
        }
    }
    assertThat(monitoredWithAdvisorFound).isTrue();
    assertThat(stereotypeAdvisorsCount).isEqualTo(3);

    // It should create a bean post-processor for rest templates.
    final SpringRestTemplateBeanPostProcessor restTemplatePostProcessor = context
            .getBean(SpringRestTemplateBeanPostProcessor.class);
    assertThat(restTemplatePostProcessor).isNotNull();
}
项目:midpoint    文件:MidPointSpringApplication.java   
@Bean
public ServletListenerRegistrationBean requestContextListener() {
    return new ServletListenerRegistrationBean(new RequestContextListener());
}
项目:vaadin4spring    文件:AtmosphereAutoConfiguration.java   
@Bean
ServletListenerRegistrationBean<SessionSupport> atmosphereSessionSupport() {
    return new ServletListenerRegistrationBean<SessionSupport>(new SessionSupport());
}
项目:midpoint    文件:MidPointSpringApplication.java   
@Bean
public ServletListenerRegistrationBean requestContextListener() {
    return new ServletListenerRegistrationBean(new RequestContextListener());
}
项目:data-migration    文件:WebSecurityConfiguration.java   
@Bean
public ServletListenerRegistrationBean httpSessionEventPublisher() {
    return new ServletListenerRegistrationBean(new HttpSessionEventPublisher());
}
项目:hawkbit    文件:SecurityManagedConfiguration.java   
/**
 * 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());
}