Java 类org.springframework.web.context.support.ServletContextAwareProcessor 实例源码

项目:spring4-understanding    文件:StaticPortletApplicationContext.java   
/**
 * 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);
}
项目:spring4-understanding    文件:AbstractRefreshablePortletApplicationContext.java   
/**
 * 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);
}
项目:spring4-understanding    文件:ServletContextAwareProcessorTests.java   
@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());
}
项目:spring4-understanding    文件:ServletContextAwareProcessorTests.java   
@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());
}
项目:spring4-understanding    文件:ServletContextAwareProcessorTests.java   
@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());
}
项目:spring4-understanding    文件:ServletContextAwareProcessorTests.java   
@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());
}
项目:spring4-understanding    文件:ServletContextAwareProcessorTests.java   
@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());
}
项目:spring4-understanding    文件:ServletContextAwareProcessorTests.java   
@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());
}
项目:spring4-understanding    文件:ServletContextAwareProcessorTests.java   
@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());
}
项目:spring4-understanding    文件:ServletContextAwareProcessorTests.java   
@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());
}
项目:spring4-understanding    文件:ServletContextAwareProcessorTests.java   
@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());
}
项目:spring4-understanding    文件:ServletContextAwareProcessorTests.java   
@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());
}
项目:spring4-understanding    文件:ServletContextAwareProcessorTests.java   
@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());
}
项目:spring4-understanding    文件:ServletContextAwareProcessorTests.java   
@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());
}
项目:class-guard    文件:StaticPortletApplicationContext.java   
/**
 * 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);
}
项目:class-guard    文件:AbstractRefreshablePortletApplicationContext.java   
/**
 * 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);
}
项目:class-guard    文件:ServletContextAwareProcessorTests.java   
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());
}
项目:class-guard    文件:ServletContextAwareProcessorTests.java   
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());
}
项目:class-guard    文件:ServletContextAwareProcessorTests.java   
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());
}
项目:class-guard    文件:ServletContextAwareProcessorTests.java   
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());
}
项目:class-guard    文件:ServletContextAwareProcessorTests.java   
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());
}
项目:class-guard    文件:ServletContextAwareProcessorTests.java   
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());
}
项目:class-guard    文件:ServletContextAwareProcessorTests.java   
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());
}
项目:class-guard    文件:ServletContextAwareProcessorTests.java   
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());
}
项目:class-guard    文件:ServletContextAwareProcessorTests.java   
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());
}
项目:class-guard    文件:ServletContextAwareProcessorTests.java   
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());
}
项目:class-guard    文件:ServletContextAwareProcessorTests.java   
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());
}
项目:class-guard    文件:ServletContextAwareProcessorTests.java   
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());
}
项目:spring-osgi    文件:OsgiBundleXmlWebApplicationContext.java   
/**
 * {@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);
}
项目:spring-osgi    文件:OsgiBundleXmlWebApplicationContextTest.java   
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));
    }