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:
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?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()); }


Reply With Quote