List of usage examples for org.springframework.context ConfigurableApplicationContext addBeanFactoryPostProcessor
void addBeanFactoryPostProcessor(BeanFactoryPostProcessor postProcessor);
From source file:org.os890.ds.addon.spring.impl.unidirectional.CdiAwareApplicationContextInitializer.java
@Override public void initialize(ConfigurableApplicationContext applicationContext) { applicationContext.addBeanFactoryPostProcessor(EmptySpringContainerManager.getBeanFactoryPostProcessor()); }
From source file:org.os890.ds.addon.spring.impl.bidirectional.CdiAwareApplicationContextInitializer.java
@Override public void initialize(ConfigurableApplicationContext applicationContext) { applicationContext.addBeanFactoryPostProcessor(SpringBridgeExtension.getBeanFactoryPostProcessor()); }
From source file:io.jmnarloch.spring.cloud.discovery.DiscoveryClientPropertySourceConfigurer.java
/** * Registers bean post processors.//from w w w. j a v a 2 s.c o m * * @param applicationContext the application context */ protected void registerPostProcessors(ConfigurableApplicationContext applicationContext) { applicationContext.addBeanFactoryPostProcessor(new DiscoveryPropertySourceInitializer(applicationContext)); }
From source file:guru.qas.martini.jmeter.config.DefaultApplicationContextBuilder.java
protected void setEnvironment(ConfigurableApplicationContext context, Properties properties) { PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); configurer.setProperties(properties); configurer.setLocalOverride(true);// w w w. ja v a 2 s . co m configurer.setSearchSystemEnvironment(true); configurer.setSystemPropertiesMode(SYSTEM_PROPERTIES_MODE_FALLBACK); context.addBeanFactoryPostProcessor(configurer); }
From source file:org.cloudfoundry.reconfiguration.spring.CloudAutoReconfigurationApplicationContextInitializer.java
private void addBeanFactoryPostProcessor(ConfigurableApplicationContext applicationContext, BeanFactoryPostProcessor beanFactoryPostProcessor) { if (hasBeanFactoryPostProcessor(applicationContext, beanFactoryPostProcessor)) { this.logger.fine(String.format("'%s' already in list of BeanFactoryPostProcessors", beanFactoryPostProcessor.getClass())); } else {//from w ww. ja v a 2 s .com this.logger.fine(String.format("Adding '%s' to the list of BeanFactoryPostProcessors", beanFactoryPostProcessor.getClass())); applicationContext.addBeanFactoryPostProcessor(beanFactoryPostProcessor); } }
From source file:com.github.persapiens.jsfboot.annotations.JsfCdiToSpringApplicationContextInitializer.java
/** * Add scope metadata resolver, bean name generator and bean factory post * processor to enable jsf cdi annotations in spring. *///from w ww. j av a 2 s. co m @Override public void initialize(ConfigurableApplicationContext c) { if (c instanceof AnnotationConfigEmbeddedWebApplicationContext) { AnnotationConfigEmbeddedWebApplicationContext cc = (AnnotationConfigEmbeddedWebApplicationContext) c; cc.setScopeMetadataResolver(new JsfCdiToSpringScopeMetadataResolver()); cc.setBeanNameGenerator(new JsfCdiToSpringBeanNameGenerator()); } else if (c instanceof AnnotationConfigWebApplicationContext) { AnnotationConfigWebApplicationContext cc = (AnnotationConfigWebApplicationContext) c; cc.setScopeMetadataResolver(new JsfCdiToSpringScopeMetadataResolver()); cc.setBeanNameGenerator(new JsfCdiToSpringBeanNameGenerator()); } else if (c instanceof AnnotationConfigApplicationContext) { AnnotationConfigApplicationContext cc = (AnnotationConfigApplicationContext) c; cc.setScopeMetadataResolver(new JsfCdiToSpringScopeMetadataResolver()); cc.setBeanNameGenerator(new JsfCdiToSpringBeanNameGenerator()); } c.addBeanFactoryPostProcessor(new JsfCdiToSpringBeanFactoryPostProcessor()); }
From source file:com.ms.commons.test.BaseTestCase.java
/** * Service???//from www . ja v a 2 s . co m * * @throws InstantiationException * @throws IllegalAccessException */ protected void initMoke() throws InstantiationException, IllegalAccessException { // Mock once on startup if (isMockOn()) { if (log.isDebugEnabled()) { log.debug("================>initMock!"); } ConfigurableApplicationContext context = (ConfigurableApplicationContext) CommonServiceLocator .getApplicationContext(); context.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() { public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { beanFactory.addBeanPostProcessor(new MockBeanPostProcessor()); } }); context.refresh(); } }
From source file:de.micromata.genome.gwiki.model.config.GWikiAbstractSpringContextBootstrapConfigLoader.java
@Override public GWikiDAOContext loadConfig(ServletConfig config) { if (config != null && StringUtils.isBlank(fileName) == true) { fileName = config// w w w .ja v a 2 s . co m .getInitParameter("de.micromata.genome.gwiki.model.config.GWikiBootstrapConfigLoader.fileName"); supportsJndi = StringUtils.equals(config.getInitParameter("de.micromata.genome.gwiki.supportsJndi"), "true"); } ConfigurableApplicationContext actx = createApplicationContext(config, getApplicationContextName()); actx.addBeanFactoryPostProcessor(new GWikiDAOContextPropertyPlaceholderConfigurer(config, supportsJndi)); actx.refresh(); beanFactory = actx; GWikiDAOContext daoContext = (GWikiDAOContext) actx.getBean("GWikiBootstrapConfig"); daoContext.setBeanFactory(beanFactory); return daoContext; }
From source file:ome.client.utests.Preferences3Test.java
public void xxxtestPreferencesAreUpdated() { log.info("CONTEXT"); ConfigurableApplicationContext applicationContext = OmeroContext.getClientContext(); // A)/*from ww w. j a v a 2 s . c om*/ // PropertyPlaceholderConfigurer ppc =(PropertyPlaceholderConfigurer) // applicationContext.getBean("placeholderConfig"); // ppc.setProperties( props ); // 1 // ppc.postProcessBeanFactory( applicationContext.getBeanFactory() ); // 2 // applicationContext.refresh(); // applicationContext.getBeanFactory(). // 3 // ConfigurableListableBeanFactory bf = // applicationContext.getBeanFactory(); // ppc.postProcessBeanFactory( bf ); // while (bf.getParentBeanFactory() != null) // { // bf = (ConfigurableListableBeanFactory) bf.getParentBeanFactory(); // ppc.postProcessBeanFactory( bf ); // } // 4 // B) log.info("OWN BFPP"); BeanFactoryPostProcessor bfpp = new BeanFactoryPostProcessor() { public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { PropertyPlaceholderConfigurer ppc = (PropertyPlaceholderConfigurer) beanFactory .getBean("placeholderConfig"); ppc.setProperties(props); } }; log.info("ADDING BFPP"); applicationContext.addBeanFactoryPostProcessor(bfpp); log.info("GETTING PRINCIPAL"); Principal principal = (Principal) applicationContext.getBean("principal"); assertTrue(principal.getName(), "bar".equals(principal.getName())); }
From source file:org.sakaiproject.component.cover.TestComponentManagerContainer.java
/** * create a component manager based on a list of component.xml * @param configPaths a ';' seperated list of xml bean config files * @throws IOException// w w w . j av a 2s . c o m */ public TestComponentManagerContainer(String configPaths, Properties props) throws IOException { // we assume that all the jars are in the same classloader, so this will // not check for // incorrect bindings and will not fully replicate the tomcat // experience, but is an easier environment // to work within for kernel testing. // For a more complex structure we could use the kernel poms in the repo // to generate the dep list. if (ComponentManager.m_componentManager != null) { log.info("Closing existing Component Manager "); /* try { ComponentManager.m_componentManager.close(); } catch ( Throwable t ) { log.warn("Close Failed with message, safe to ignore "+t.getMessage()); } */ log.info("Closing Complete "); ComponentManager.m_componentManager = null; } log.info("Starting Component Manager with [" + configPaths + "]"); ComponentManager.setLateRefresh(true); componentManager = (SpringCompMgr) ComponentManager.getInstance(); ConfigurableApplicationContext ac = componentManager.getApplicationContext(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); // Supply any additional configuration. if (props != null) { PropertyOverrideConfigurer beanFactoryPostProcessor = new PropertyOverrideConfigurer(); beanFactoryPostProcessor.setBeanNameSeparator("@"); beanFactoryPostProcessor.setProperties(props); ac.addBeanFactoryPostProcessor(beanFactoryPostProcessor); } // we could take the kernel bootstrap from from the classpath in future // rather than from // the filesystem List<Resource> config = new ArrayList<Resource>(); String[] configPath = configPaths.split(";"); for (String p : configPath) { File xml = new File(p); config.add(new FileSystemResource(xml.getCanonicalPath())); } loadComponent(ac, config, classLoader); ac.refresh(); // SAK-20908 - band-aid for TLM sync issues causing tests to fail // This sleep shouldn't be needed but it seems these tests are starting before ThreadLocalManager has finished its startup. try { Thread.sleep(500); // 1/2 second log.debug("Finished starting the component manager"); } catch (InterruptedException e) { log.error("Component manager startup interrupted..."); } }