/** * Register request/session scopes, a {@link PortletContextAwareProcessor}, etc. */ @Override protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { beanFactory.addBeanPostProcessor(new ServletContextAwareProcessor(this.servletContext)); beanFactory.addBeanPostProcessor(new PortletContextAwareProcessor(this.portletContext, this.portletConfig)); beanFactory.ignoreDependencyInterface(PortletContextAware.class); beanFactory.ignoreDependencyInterface(PortletConfigAware.class); PortletApplicationContextUtils.registerPortletApplicationScopes(beanFactory, this.portletContext); PortletApplicationContextUtils.registerEnvironmentBeans( beanFactory, this.servletContext, this.portletContext, this.portletConfig); }
/** * Register request/session scopes, a {@link PortletContextAwareProcessor}, etc. */ @Override protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { beanFactory.addBeanPostProcessor(new ServletContextAwareProcessor(this.servletContext)); beanFactory.addBeanPostProcessor(new PortletContextAwareProcessor(this.portletContext, this.portletConfig)); beanFactory.ignoreDependencyInterface(ServletContextAware.class); beanFactory.ignoreDependencyInterface(PortletContextAware.class); beanFactory.ignoreDependencyInterface(PortletConfigAware.class); PortletApplicationContextUtils.registerPortletApplicationScopes(beanFactory, this.portletContext); PortletApplicationContextUtils.registerEnvironmentBeans( beanFactory, this.servletContext, this.portletContext, this.portletConfig); }
@Test public void servletContextAwareWithServletContext() { ServletContext servletContext = new MockServletContext(); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext); ServletContextAwareBean bean = new ServletContextAwareBean(); assertNull(bean.getServletContext()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletContext should have been set", bean.getServletContext()); assertEquals(servletContext, bean.getServletContext()); }
@Test public void servletContextAwareWithServletConfig() { ServletContext servletContext = new MockServletContext(); ServletConfig servletConfig = new MockServletConfig(servletContext); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletConfig); ServletContextAwareBean bean = new ServletContextAwareBean(); assertNull(bean.getServletContext()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletContext should have been set", bean.getServletContext()); assertEquals(servletContext, bean.getServletContext()); }
@Test public void servletContextAwareWithServletContextAndServletConfig() { ServletContext servletContext = new MockServletContext(); ServletConfig servletConfig = new MockServletConfig(servletContext); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext, servletConfig); ServletContextAwareBean bean = new ServletContextAwareBean(); assertNull(bean.getServletContext()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletContext should have been set", bean.getServletContext()); assertEquals(servletContext, bean.getServletContext()); }
@Test public void servletContextAwareWithNullServletContextAndNonNullServletConfig() { ServletContext servletContext = new MockServletContext(); ServletConfig servletConfig = new MockServletConfig(servletContext); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(null, servletConfig); ServletContextAwareBean bean = new ServletContextAwareBean(); assertNull(bean.getServletContext()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletContext should have been set", bean.getServletContext()); assertEquals(servletContext, bean.getServletContext()); }
@Test public void servletContextAwareWithNonNullServletContextAndNullServletConfig() { ServletContext servletContext = new MockServletContext(); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext, null); ServletContextAwareBean bean = new ServletContextAwareBean(); assertNull(bean.getServletContext()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletContext should have been set", bean.getServletContext()); assertEquals(servletContext, bean.getServletContext()); }
@Test public void servletContextAwareWithNullServletContext() { ServletContext servletContext = null; ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext); ServletContextAwareBean bean = new ServletContextAwareBean(); assertNull(bean.getServletContext()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNull(bean.getServletContext()); }
@Test public void servletConfigAwareWithServletContextOnly() { ServletContext servletContext = new MockServletContext(); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext); ServletConfigAwareBean bean = new ServletConfigAwareBean(); assertNull(bean.getServletConfig()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNull(bean.getServletConfig()); }
@Test public void servletConfigAwareWithServletConfig() { ServletContext servletContext = new MockServletContext(); ServletConfig servletConfig = new MockServletConfig(servletContext); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletConfig); ServletConfigAwareBean bean = new ServletConfigAwareBean(); assertNull(bean.getServletConfig()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletConfig should have been set", bean.getServletConfig()); assertEquals(servletConfig, bean.getServletConfig()); }
@Test public void servletConfigAwareWithServletContextAndServletConfig() { ServletContext servletContext = new MockServletContext(); ServletConfig servletConfig = new MockServletConfig(servletContext); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext, servletConfig); ServletConfigAwareBean bean = new ServletConfigAwareBean(); assertNull(bean.getServletConfig()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletConfig should have been set", bean.getServletConfig()); assertEquals(servletConfig, bean.getServletConfig()); }
@Test public void servletConfigAwareWithNullServletContextAndNonNullServletConfig() { ServletContext servletContext = new MockServletContext(); ServletConfig servletConfig = new MockServletConfig(servletContext); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(null, servletConfig); ServletConfigAwareBean bean = new ServletConfigAwareBean(); assertNull(bean.getServletConfig()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletConfig should have been set", bean.getServletConfig()); assertEquals(servletConfig, bean.getServletConfig()); }
@Test public void servletConfigAwareWithNonNullServletContextAndNullServletConfig() { ServletContext servletContext = new MockServletContext(); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext, null); ServletConfigAwareBean bean = new ServletConfigAwareBean(); assertNull(bean.getServletConfig()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNull(bean.getServletConfig()); }
@Test public void servletConfigAwareWithNullServletContext() { ServletContext servletContext = null; ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext); ServletConfigAwareBean bean = new ServletConfigAwareBean(); assertNull(bean.getServletConfig()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNull(bean.getServletConfig()); }
public void testServletContextAwareWithServletContext() { ServletContext servletContext = new MockServletContext(); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext); ServletContextAwareBean bean = new ServletContextAwareBean(); assertNull(bean.getServletContext()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletContext should have been set", bean.getServletContext()); assertEquals(servletContext, bean.getServletContext()); }
public void testServletContextAwareWithServletConfig() { ServletContext servletContext = new MockServletContext(); ServletConfig servletConfig = new MockServletConfig(servletContext); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletConfig); ServletContextAwareBean bean = new ServletContextAwareBean(); assertNull(bean.getServletContext()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletContext should have been set", bean.getServletContext()); assertEquals(servletContext, bean.getServletContext()); }
public void testServletContextAwareWithServletContextAndServletConfig() { ServletContext servletContext = new MockServletContext(); ServletConfig servletConfig = new MockServletConfig(servletContext); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext, servletConfig); ServletContextAwareBean bean = new ServletContextAwareBean(); assertNull(bean.getServletContext()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletContext should have been set", bean.getServletContext()); assertEquals(servletContext, bean.getServletContext()); }
public void testServletContextAwareWithNullServletContextAndNonNullServletConfig() { ServletContext servletContext = new MockServletContext(); ServletConfig servletConfig = new MockServletConfig(servletContext); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(null, servletConfig); ServletContextAwareBean bean = new ServletContextAwareBean(); assertNull(bean.getServletContext()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletContext should have been set", bean.getServletContext()); assertEquals(servletContext, bean.getServletContext()); }
public void testServletContextAwareWithNonNullServletContextAndNullServletConfig() { ServletContext servletContext = new MockServletContext(); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext, null); ServletContextAwareBean bean = new ServletContextAwareBean(); assertNull(bean.getServletContext()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletContext should have been set", bean.getServletContext()); assertEquals(servletContext, bean.getServletContext()); }
public void testServletContextAwareWithNullServletContext() { ServletContext servletContext = null; ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext); ServletContextAwareBean bean = new ServletContextAwareBean(); assertNull(bean.getServletContext()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNull(bean.getServletContext()); }
public void testServletConfigAwareWithServletContextOnly() { ServletContext servletContext = new MockServletContext(); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext); ServletConfigAwareBean bean = new ServletConfigAwareBean(); assertNull(bean.getServletConfig()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNull(bean.getServletConfig()); }
public void testServletConfigAwareWithServletConfig() { ServletContext servletContext = new MockServletContext(); ServletConfig servletConfig = new MockServletConfig(servletContext); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletConfig); ServletConfigAwareBean bean = new ServletConfigAwareBean(); assertNull(bean.getServletConfig()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletConfig should have been set", bean.getServletConfig()); assertEquals(servletConfig, bean.getServletConfig()); }
public void testServletConfigAwareWithServletContextAndServletConfig() { ServletContext servletContext = new MockServletContext(); ServletConfig servletConfig = new MockServletConfig(servletContext); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext, servletConfig); ServletConfigAwareBean bean = new ServletConfigAwareBean(); assertNull(bean.getServletConfig()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletConfig should have been set", bean.getServletConfig()); assertEquals(servletConfig, bean.getServletConfig()); }
public void testServletConfigAwareWithNullServletContextAndNonNullServletConfig() { ServletContext servletContext = new MockServletContext(); ServletConfig servletConfig = new MockServletConfig(servletContext); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(null, servletConfig); ServletConfigAwareBean bean = new ServletConfigAwareBean(); assertNull(bean.getServletConfig()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNotNull("ServletConfig should have been set", bean.getServletConfig()); assertEquals(servletConfig, bean.getServletConfig()); }
public void testServletConfigAwareWithNonNullServletContextAndNullServletConfig() { ServletContext servletContext = new MockServletContext(); ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext, null); ServletConfigAwareBean bean = new ServletConfigAwareBean(); assertNull(bean.getServletConfig()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNull(bean.getServletConfig()); }
public void testServletConfigAwareWithNullServletContext() { ServletContext servletContext = null; ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext); ServletConfigAwareBean bean = new ServletConfigAwareBean(); assertNull(bean.getServletConfig()); processor.postProcessBeforeInitialization(bean, "testBean"); assertNull(bean.getServletConfig()); }
/** * {@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)); }