List of usage examples for org.springframework.beans.factory.support DefaultListableBeanFactory copyConfigurationFrom
@Override public void copyConfigurationFrom(ConfigurableBeanFactory otherFactory)
From source file:org.eclipse.gemini.blueprint.compendium.internal.cm.ManagedServiceFactoryFactoryBean.java
private void createEmbeddedBeanFactory() { synchronized (monitor) { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(owningBeanFactory); if (owningBeanFactory instanceof ConfigurableBeanFactory) { bf.copyConfigurationFrom((ConfigurableBeanFactory) owningBeanFactory); }/* w w w.j a va 2 s. c o m*/ // just to be on the safe side bf.setBeanClassLoader(classLoader); // add autowiring processor bf.addBeanPostProcessor(new InitialInjectionProcessor()); beanFactory = bf; } }
From source file:org.springframework.aop.framework.autoproxy.target.AbstractBeanFactoryBasedTargetSourceCreator.java
/** * Build an internal BeanFactory for resolving target beans. * @param containingFactory the containing BeanFactory that originally defines the beans * @return an independent internal BeanFactory to hold copies of some target beans *//* w ww . j a va 2s. co m*/ protected DefaultListableBeanFactory buildInternalBeanFactory(ConfigurableBeanFactory containingFactory) { // Set parent so that references (up container hierarchies) are correctly resolved. DefaultListableBeanFactory internalBeanFactory = new DefaultListableBeanFactory(containingFactory); // Required so that all BeanPostProcessors, Scopes, etc become available. internalBeanFactory.copyConfigurationFrom(containingFactory); // Filter out BeanPostProcessors that are part of the AOP infrastructure, // since those are only meant to apply to beans defined in the original factory. for (Iterator<BeanPostProcessor> it = internalBeanFactory.getBeanPostProcessors().iterator(); it .hasNext();) { if (it.next() instanceof AopInfrastructureBean) { it.remove(); } } return internalBeanFactory; }
From source file:org.springframework.batch.core.configuration.support.ClassPathXmlApplicationContextFactory.java
/** * Extension point for special subclasses that want to do more complex * things with the bean factory prior to refresh. The default implementation * copies all configuration from the parent according to the * {@link #setCopyConfiguration(boolean) flag} set. * //from w w w . j a v a 2s. c o m * @param parent the parent bean factory for the new context (will never be * null) * @param beanFactory the new bean factory before bean definitions are * loaded * * @see ClassPathXmlApplicationContextFactory#setCopyConfiguration(boolean) * @see DefaultListableBeanFactory#copyConfigurationFrom(ConfigurableBeanFactory) */ protected void prepareBeanFactory(DefaultListableBeanFactory parent, DefaultListableBeanFactory beanFactory) { if (copyConfiguration && parent != null) { beanFactory.copyConfigurationFrom(parent); @SuppressWarnings("unchecked") List<BeanPostProcessor> beanPostProcessors = beanFactory.getBeanPostProcessors(); for (BeanPostProcessor beanPostProcessor : new ArrayList<BeanPostProcessor>(beanPostProcessors)) { for (Class<?> cls : beanPostProcessorExcludeClasses) { if (cls.isAssignableFrom(beanPostProcessor.getClass())) { logger.debug("Removing bean post processor: " + beanPostProcessor + " of type " + cls); beanPostProcessors.remove(beanPostProcessor); } } } } }
From source file:org.springframework.data.hadoop.admin.workflow.support.FileSystemApplicationContextFactory.java
/** * Extension point for special subclasses that want to do more complex * things with the bean factory prior to refresh. The default implementation * copies all configuration from the parent according to the * {@link #setCopyConfiguration(boolean) flag} set. * // ww w. ja v a 2 s . com * @param parent the parent bean factory for the new context (will never be * null) * @param beanFactory the new bean factory before bean definitions are * loaded * * @see ClassPathXmlApplicationContextFactory#setCopyConfiguration(boolean) * @see DefaultListableBeanFactory#copyConfigurationFrom(ConfigurableBeanFactory) */ protected void prepareBeanFactory(DefaultListableBeanFactory parent, DefaultListableBeanFactory beanFactory) { if (copyConfiguration && parent != null) { beanFactory.copyConfigurationFrom(parent); List<BeanPostProcessor> beanPostProcessors = beanFactory.getBeanPostProcessors(); for (BeanPostProcessor beanPostProcessor : new ArrayList<BeanPostProcessor>(beanPostProcessors)) { for (Class<?> cls : beanPostProcessorExcludeClasses) { if (cls.isAssignableFrom(beanPostProcessor.getClass())) { logger.debug("Removing bean post processor: " + beanPostProcessor + " of type " + cls); beanPostProcessors.remove(beanPostProcessor); } } } } }