Example usage for org.springframework.beans.factory.support DefaultListableBeanFactory getBeanPostProcessors

List of usage examples for org.springframework.beans.factory.support DefaultListableBeanFactory getBeanPostProcessors

Introduction

In this page you can find the example usage for org.springframework.beans.factory.support DefaultListableBeanFactory getBeanPostProcessors.

Prototype

public List<BeanPostProcessor> getBeanPostProcessors() 

Source Link

Document

Return the list of BeanPostProcessors that will get applied to beans created with this factory.

Usage

From source file:com.codestd.spring.cxf.config.EndpointBeanProcessor.java

public static final void setBlocking(ApplicationContext ctx, EndpointImpl impl) {
    AutowireCapableBeanFactory fact = ctx.getAutowireCapableBeanFactory();
    if (fact instanceof DefaultListableBeanFactory) {
        DefaultListableBeanFactory dlbf = (DefaultListableBeanFactory) fact;
        for (BeanPostProcessor bpp : dlbf.getBeanPostProcessors()) {
            if (CommonAnnotationBeanPostProcessor.class.isInstance(bpp)) {
                impl.getServerFactory().setBlockPostConstruct(true);
                impl.getServerFactory().setBlockInjection(false);
                return;
            }// ww w  .  ja  v  a  2 s.  co m
            if (bpp instanceof Jsr250BeanPostProcessor) {
                impl.getServerFactory().setBlockInjection(true);
            }
        }
    }
}

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
 *//* www. jav a  2s . c o  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.
 * //  ww  w  .ja  va2s. 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.
 * /*www. ja  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);
        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);
                }
            }
        }
    }
}