use of org.springframework.web.context.support.ServletContextAwareProcessor in project spring-framework by spring-projects.
the class ServletContextAwareProcessorTests method servletContextAwareWithServletContextAndServletConfig.
@Test
public void servletContextAwareWithServletContextAndServletConfig() {
ServletContext servletContext = new MockServletContext();
ServletConfig servletConfig = new MockServletConfig(servletContext);
ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletContext, servletConfig);
ServletContextAwareBean bean = new ServletContextAwareBean();
assertThat(bean.getServletContext()).isNull();
processor.postProcessBeforeInitialization(bean, "testBean");
assertThat(bean.getServletContext()).as("ServletContext should have been set").isNotNull();
assertThat(bean.getServletContext()).isEqualTo(servletContext);
}
use of org.springframework.web.context.support.ServletContextAwareProcessor in project spring-framework by spring-projects.
the class ServletContextAwareProcessorTests method servletConfigAwareWithNullServletContextAndNonNullServletConfig.
@Test
public void servletConfigAwareWithNullServletContextAndNonNullServletConfig() {
ServletContext servletContext = new MockServletContext();
ServletConfig servletConfig = new MockServletConfig(servletContext);
ServletContextAwareProcessor processor = new ServletContextAwareProcessor(null, servletConfig);
ServletConfigAwareBean bean = new ServletConfigAwareBean();
assertThat(bean.getServletConfig()).isNull();
processor.postProcessBeforeInitialization(bean, "testBean");
assertThat(bean.getServletConfig()).as("ServletConfig should have been set").isNotNull();
assertThat(bean.getServletConfig()).isEqualTo(servletConfig);
}
use of org.springframework.web.context.support.ServletContextAwareProcessor in project grails-core by grails.
the class GrailsWebApplicationContext method postProcessBeanFactory.
/**
* Register ServletContextAwareProcessor.
* @see ServletContextAwareProcessor
*/
@Override
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
beanFactory.addBeanPostProcessor(new ServletContextAwareProcessor(servletContext));
beanFactory.ignoreDependencyInterface(ServletContextAware.class);
beanFactory.registerResolvableDependency(ServletContext.class, servletContext);
WebApplicationContextUtils.registerWebApplicationScopes(beanFactory);
}
use of org.springframework.web.context.support.ServletContextAwareProcessor in project cuba by cuba-platform.
the class CubaClassPathXmlApplicationContext method postProcessBeanFactory.
@Override
protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
if (this.servletContext != null) {
beanFactory.addBeanPostProcessor(new ServletContextAwareProcessor(this.servletContext));
beanFactory.ignoreDependencyInterface(ServletContextAware.class);
}
}
use of org.springframework.web.context.support.ServletContextAwareProcessor in project spring-framework by spring-projects.
the class ServletContextAwareProcessorTests method servletContextAwareWithServletConfig.
@Test
public void servletContextAwareWithServletConfig() {
ServletContext servletContext = new MockServletContext();
ServletConfig servletConfig = new MockServletConfig(servletContext);
ServletContextAwareProcessor processor = new ServletContextAwareProcessor(servletConfig);
ServletContextAwareBean bean = new ServletContextAwareBean();
assertThat(bean.getServletContext()).isNull();
processor.postProcessBeforeInitialization(bean, "testBean");
assertThat(bean.getServletContext()).as("ServletContext should have been set").isNotNull();
assertThat(bean.getServletContext()).isEqualTo(servletContext);
}
Aggregations