org.springframework.context.annotation
Class ConfigurationClassPostProcessor

java.lang.Object
  extended by org.springframework.context.annotation.ConfigurationClassPostProcessor
All Implemented Interfaces:
BeanClassLoaderAware, BeanFactoryPostProcessor

public class ConfigurationClassPostProcessor
extends Object
implements BeanFactoryPostProcessor, BeanClassLoaderAware

BeanFactoryPostProcessor used for bootstrapping processing of @Configuration classes.

Registered by default when using <context:annotation-config/> or <context:component-scan/>. Otherwise, may be declared manually as with any other BeanFactoryPostProcessor.

This post processor is Ordered.HIGHEST_PRECEDENCE as it is important that any Bean methods declared in Configuration classes have their respective bean definitions registered before any other BeanFactoryPostProcessor executes.

Since:
3.0
Author:
Chris Beams, Juergen Hoeller

Constructor Summary
ConfigurationClassPostProcessor()
           
 
Method Summary
protected  boolean checkConfigurationClassCandidate(BeanDefinition beanDef)
          Check whether the given bean definition is a candidate for a configuration class, and mark it accordingly.
 void enhanceConfigurationClasses(ConfigurableListableBeanFactory beanFactory)
          Post-processes a BeanFactory in search of Configuration class BeanDefinitions; any candidates are then enhanced by a ConfigurationClassEnhancer.
 int getOrder()
           
 void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
          Prepare the Configuration classes for servicing bean requests at runtime by replacing them with CGLIB-enhanced subclasses.
 void processConfigBeanDefinitions(BeanDefinitionRegistry registry)
          Build and validate a configuration model based on the registry of Configuration classes.
 void setBeanClassLoader(ClassLoader beanClassLoader)
          Callback that supplies the bean class loader to a bean instance.
 void setMetadataReaderFactory(MetadataReaderFactory metadataReaderFactory)
          Set the MetadataReaderFactory to use.
 void setProblemReporter(ProblemReporter problemReporter)
          Set the ProblemReporter to use.
 void setSourceExtractor(SourceExtractor sourceExtractor)
          Set the SourceExtractor to use for generated bean definitions that correspond to Bean factory methods.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationClassPostProcessor

public ConfigurationClassPostProcessor()
Method Detail

setSourceExtractor

public void setSourceExtractor(SourceExtractor sourceExtractor)
Set the SourceExtractor to use for generated bean definitions that correspond to Bean factory methods.


setProblemReporter

public void setProblemReporter(ProblemReporter problemReporter)
Set the ProblemReporter to use.

Used to register any problems detected with Configuration or Bean declarations. For instance, an @Bean method marked as final is illegal and would be reported as a problem. Defaults to FailFastProblemReporter.


setMetadataReaderFactory

public void setMetadataReaderFactory(MetadataReaderFactory metadataReaderFactory)
Set the MetadataReaderFactory to use.

Default is a CachingMetadataReaderFactory for the specified bean class loader.


setBeanClassLoader

public void setBeanClassLoader(ClassLoader beanClassLoader)
Description copied from interface: BeanClassLoaderAware
Callback that supplies the bean class loader to a bean instance.

Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean's InitializingBean.afterPropertiesSet() method or a custom init-method.

Specified by:
setBeanClassLoader in interface BeanClassLoaderAware
Parameters:
beanClassLoader - the owning class loader; may be null in which case a default ClassLoader must be used, for example the ClassLoader obtained via ClassUtils.getDefaultClassLoader()

getOrder

public int getOrder()

postProcessBeanFactory

public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
Prepare the Configuration classes for servicing bean requests at runtime by replacing them with CGLIB-enhanced subclasses.

Specified by:
postProcessBeanFactory in interface BeanFactoryPostProcessor
Parameters:
beanFactory - the bean factory used by the application context

processConfigBeanDefinitions

public void processConfigBeanDefinitions(BeanDefinitionRegistry registry)
Build and validate a configuration model based on the registry of Configuration classes.


checkConfigurationClassCandidate

protected boolean checkConfigurationClassCandidate(BeanDefinition beanDef)
Check whether the given bean definition is a candidate for a configuration class, and mark it accordingly.

Parameters:
beanDef - the bean definition to check
Returns:
whether the candidate qualifies as (any kind of) configuration class

enhanceConfigurationClasses

public void enhanceConfigurationClasses(ConfigurableListableBeanFactory beanFactory)
Post-processes a BeanFactory in search of Configuration class BeanDefinitions; any candidates are then enhanced by a ConfigurationClassEnhancer. Candidate status is determined by BeanDefinition attribute metadata.

See Also:
ConfigurationClassEnhancer