org.springframework.web.context.support.ServletContextAwareProcessor Java Examples

The following examples show how to use org.springframework.web.context.support.ServletContextAwareProcessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServletContextAwareProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #2
Source File: ServletContextAwareProcessorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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());
}
 
Example #3
Source File: ServletContextAwareProcessorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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());
}
 
Example #4
Source File: ServletContextAwareProcessorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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());
}
 
Example #5
Source File: ServletContextAwareProcessorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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());
}
 
Example #6
Source File: StaticPortletApplicationContext.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #7
Source File: AbstractRefreshablePortletApplicationContext.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #8
Source File: ServletContextAwareProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #9
Source File: ServletContextAwareProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #10
Source File: ServletContextAwareProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #11
Source File: ServletContextAwareProcessorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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());
}
 
Example #12
Source File: ServletContextAwareProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #13
Source File: ServletContextAwareProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #14
Source File: ServletContextAwareProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #15
Source File: ServletContextAwareProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #16
Source File: ServletContextAwareProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #17
Source File: ServletContextAwareProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #18
Source File: ServletContextAwareProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #19
Source File: ServletContextAwareProcessorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #20
Source File: CubaClassPathXmlApplicationContext.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
    if (this.servletContext != null) {
        beanFactory.addBeanPostProcessor(new ServletContextAwareProcessor(this.servletContext));
        beanFactory.ignoreDependencyInterface(ServletContextAware.class);
    }
}
 
Example #21
Source File: ServletContextAwareProcessorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example #22
Source File: ServletContextAwareProcessorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example #23
Source File: ServletContextAwareProcessorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example #24
Source File: ServletContextAwareProcessorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example #25
Source File: ServletContextAwareProcessorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example #26
Source File: ServletContextAwareProcessorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example #27
Source File: ServletContextAwareProcessorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example #28
Source File: ServletContextAwareProcessorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example #29
Source File: ServletContextAwareProcessorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example #30
Source File: ServletContextAwareProcessorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}