List of usage examples for org.springframework.context.support AbstractRefreshableApplicationContext addBeanFactoryPostProcessor
@Override public void addBeanFactoryPostProcessor(BeanFactoryPostProcessor postProcessor)
From source file:cross.applicationContext.DefaultApplicationContextFactory.java
/** * Creates a new application context from the current list of * <code>applicationContextPaths</code>, interpreted as class path * resources, and the current <code>configuration</code>. * * @return the application context//from w ww . j a v a 2 s. c o m * @throws BeansException if any beans are not configured correctly */ public ApplicationContext createClassPathApplicationContext() throws BeansException { AbstractRefreshableApplicationContext context = null; try { final ConfiguringBeanPostProcessor cbp = new ConfiguringBeanPostProcessor(); cbp.setConfiguration(configuration); context = new ClassPathXmlApplicationContext( applicationContextPaths.toArray(new String[applicationContextPaths.size()]), context); context.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() { @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory clbf) throws BeansException { clbf.addBeanPostProcessor(cbp); } }); context.refresh(); } catch (BeansException e2) { throw e2; } return context; }
From source file:cross.applicationContext.DefaultApplicationContextFactory.java
/** * Creates a new application context from the current list of * <code>applicationContextPaths</code>, interpreted as file system * resources, and the current//from w w w .ja v a 2s. c om * <code>configuration</code>. * * @return the application context * @throws BeansException if any beans are not configured correctly */ public ApplicationContext createApplicationContext() throws BeansException { AbstractRefreshableApplicationContext context = null; try { final ConfiguringBeanPostProcessor cbp = new ConfiguringBeanPostProcessor(); cbp.setConfiguration(configuration); context = new FileSystemXmlApplicationContext( applicationContextPaths.toArray(new String[applicationContextPaths.size()]), context); context.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() { @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory clbf) throws BeansException { clbf.addBeanPostProcessor(cbp); } }); context.refresh(); } catch (BeansException e2) { throw e2; } return context; }