@Override protected void doHandle(Map<String, Object> attributes, BeanDefinition beanDefinition, BeanDefinitionRegistry registry) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ServletListenerRegistrationBean.class); builder.addPropertyValue("listener", beanDefinition); registry.registerBeanDefinition(beanDefinition.getBeanClassName(), builder.getBeanDefinition()); }
@Bean public ServletListenerRegistrationBean<CatListener> catListener() { ServletListenerRegistrationBean<CatListener> bean = new ServletListenerRegistrationBean<CatListener>( new CatListener()); bean.setName("cat-listener"); return bean; }
@Override protected void doHandle(Map<String, Object> attributes, BeanDefinition beanDefinition, BeanDefinitionRegistry registry) { BeanDefinitionBuilder builder = BeanDefinitionBuilder .rootBeanDefinition(ServletListenerRegistrationBean.class); builder.addPropertyValue("listener", beanDefinition); registry.registerBeanDefinition(beanDefinition.getBeanClassName(), builder.getBeanDefinition()); }
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(); }
@Bean public ServletListenerRegistrationBean shiroServletListenerRegistrationBean() { ServletListenerRegistrationBean registrationBean = new ServletListenerRegistrationBean(); EnvironmentLoaderListener environmentLoaderListener = new EnvironmentLoaderListener(); registrationBean.setListener(environmentLoaderListener); registrationBean.setOrder(0); return registrationBean; }
@Bean public ServletListenerRegistrationBean redisAppSettingListner() { ServletListenerRegistrationBean redisAppSettingListener = new ServletListenerRegistrationBean(); redisAppSettingListener.setListener(listener("org.jasig.cas.client.credis.CRedisAppSettingListner")); return redisAppSettingListener; }
@Bean public ServletListenerRegistrationBean<ConfigureListener> jsfConfigureListener() { return new ServletListenerRegistrationBean<ConfigureListener>( new ConfigureListener()); }
@Bean ServletListenerRegistrationBean<HttpSessionListener> httpSessionCreatedListener() { ServletListenerRegistrationBean<HttpSessionListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); listenerRegistrationBean.setListener(new HttpSessionCreatedListener()); return listenerRegistrationBean; }
@Bean public ServletListenerRegistrationBean<HttpSessionListener> sessionCreatedListener() { ServletListenerRegistrationBean<HttpSessionListener> listenerRegistrationBean = new ServletListenerRegistrationBean<>(); listenerRegistrationBean.setListener(new HttpSessionCreatedListener()); return listenerRegistrationBean; }
@Bean public ServletListenerRegistrationBean<ServletContextListener> registration() { return new ServletListenerRegistrationBean<ServletContextListener>( mock(ServletContextListener.class)); }
@Bean public static ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() { return new ServletListenerRegistrationBean<HttpSessionEventPublisher>(new HttpSessionEventPublisher()); }
private void createAndRegisterWebListenerBean(DefaultListableBeanFactory beanFactory, BeanDefinition bd, Class<?> beanClass, WebListener webListener) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ServletListenerRegistrationBean.class); builder.addPropertyValue("listener", bd); String beanName = StringUtils.uncapitalize(beanClass.getSimpleName()); beanFactory.registerBeanDefinition(beanName, builder.getBeanDefinition()); }
@Bean public ServletListenerRegistrationBean<HttpSessionEventPublisher> httpSessionEventPublisher() { return new ServletListenerRegistrationBean<HttpSessionEventPublisher>(new HttpSessionEventPublisher()); }