/** * Register request/session scopes, a {@link ServletContextAwareProcessor}, etc. */ @Override protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { beanFactory.addBeanPostProcessor(new ServletContextAwareProcessor(this.servletContext, this.servletConfig)); beanFactory.ignoreDependencyInterface(ServletContextAware.class); beanFactory.ignoreDependencyInterface(ServletConfigAware.class); WebApplicationContextUtils.registerWebApplicationScopes(beanFactory, this.servletContext); WebApplicationContextUtils.registerEnvironmentBeans(beanFactory, this.servletContext, this.servletConfig); }
@Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (getServletContext() != null && bean instanceof ServletContextAware) { ((ServletContextAware) bean).setServletContext(getServletContext()); } if (getServletConfig() != null && bean instanceof ServletConfigAware) { ((ServletConfigAware) bean).setServletConfig(getServletConfig()); } return bean; }
@Override protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { SdcctServletConfig servletConfig = new SdcctServletConfig(); this.setServletConfig(servletConfig); beanFactory.registerSingleton(AbstractRefreshableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME, servletConfig); beanFactory.ignoreDependencyInterface(ServletConfigAware.class); super.postProcessBeanFactory(beanFactory); }
@Override protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { CrigttServletConfig servletConfig = new CrigttServletConfig(); this.setServletConfig(servletConfig); beanFactory.registerSingleton(AbstractRefreshableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME, servletConfig); beanFactory.ignoreDependencyInterface(ServletConfigAware.class); super.postProcessBeanFactory(beanFactory); }
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (this.servletContext != null && bean instanceof ServletContextAware) { ((ServletContextAware) bean).setServletContext(this.servletContext); } if (this.servletConfig != null && bean instanceof ServletConfigAware) { ((ServletConfigAware) bean).setServletConfig(this.servletConfig); } return bean; }
/** * {@inheritDoc} * * Registers request/session scopes, a {@link ServletContextAwareProcessor}, * etc. */ protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { super.postProcessBeanFactory(beanFactory); beanFactory.addBeanPostProcessor(new ServletContextAwareProcessor(this.servletContext, this.servletConfig)); beanFactory.ignoreDependencyInterface(ServletContextAware.class); beanFactory.ignoreDependencyInterface(ServletConfigAware.class); beanFactory.registerResolvableDependency(ServletContext.class, this.servletContext); beanFactory.registerResolvableDependency(ServletConfig.class, this.servletConfig); WebApplicationContextUtils.registerWebApplicationScopes(beanFactory); }
public void testPostProcessBeanFactoryConfigurableListableBeanFactory() { ConfigurableListableBeanFactory mock = new DefaultListableBeanFactory() { public void ignoreDependencyInterface(Class ifc) { ignored.add(ifc); } public void addBeanPostProcessor(BeanPostProcessor beanPostProcessor) { super.addBeanPostProcessor(beanPostProcessor); bpp.add(beanPostProcessor.getClass()); } public void registerResolvableDependency(Class dependencyType, Object autowiredValue) { super.registerResolvableDependency(dependencyType, autowiredValue); resolved.add(dependencyType); } }; context.postProcessBeanFactory(mock); assertTrue(ignored.contains(ServletConfigAware.class)); assertTrue(ignored.contains(ServletContextAware.class)); assertTrue(resolved.contains(ServletContext.class)); assertTrue(resolved.contains(ServletConfig.class)); assertTrue(bpp.contains(ServletContextAwareProcessor.class)); }