Announcement Announcement Module
Collapse
No announcement yet.
Post processing with the ContextLoaderListener Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Post processing with the ContextLoaderListener

    So I wanted to add a post processor to my app context that depends upon some runtime info. I sublcassed ContextLoaderListener and have this in my contextInitialized method:
    Code:
    public void contextInitialized(ServletContextEvent event) {
    		super.contextInitialized(event);
    		XmlWebApplicationContext ctx = (XmlWebApplicationContext) WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
    		PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer(); 
    		String configName = "application-context";
    		Configuration appConfig = ConfigurationService.getConfiguration(configName);
    		Properties appProps = ConfigurationConverter.getProperties(appConfig); 
    		cfg.setProperties(appProps); 
    		cfg.postProcessBeanFactory(ctx.getBeanFactory());
    	}
    I'm thinking this doesn't work because of the refresh() call in ContextLoader.createWebApplicationContext(ServletC ontext, ApplicationContext) that preinstantiates singletons. Is it too late to run a postprocessor after refresh() has been called? Do I need to override ContextLoader to register my postprocessor before refresh() is called? Or is there some other thing I'm missing?
Working...
X