Class ConfigurationClassPostProcessor
- All Implemented Interfaces:
- BeanFactoryInitializationAotProcessor,- Aware,- BeanClassLoaderAware,- BeanFactoryPostProcessor,- BeanDefinitionRegistryPostProcessor,- ApplicationStartupAware,- EnvironmentAware,- ResourceLoaderAware,- Ordered,- PriorityOrdered
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 priority-ordered as it is important that any
 @Bean methods declared in @Configuration classes have
 their corresponding bean definitions registered before any other
 BeanFactoryPostProcessor executes.
- Since:
- 3.0
- Author:
- Chris Beams, Juergen Hoeller, Phillip Webb, Sam Brannen
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final AnnotationBeanNameGeneratorABeanNameGeneratorusing fully qualified class names as default bean names.Fields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidPost-processes a BeanFactory in search of Configuration class BeanDefinitions; any candidates are then enhanced by aConfigurationClassEnhancer.intgetOrder()Get the order value of this object.voidDerive further bean definitions from the configuration classes in the registry.voidpostProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) Prepare the Configuration classes for servicing bean requests at runtime by replacing them with CGLIB-enhanced subclasses.processAheadOfTime(ConfigurableListableBeanFactory beanFactory) Process the givenConfigurableListableBeanFactoryinstance ahead-of-time and return a contribution ornull.voidBuild and validate a configuration model based on the registry ofConfigurationclasses.voidsetApplicationStartup(ApplicationStartup applicationStartup) Set the ApplicationStartup that this object runs with.voidsetBeanClassLoader(ClassLoader beanClassLoader) Callback that supplies the beanclass loaderto a bean instance.voidsetBeanNameGenerator(BeanNameGenerator beanNameGenerator) Set theBeanNameGeneratorto be used when triggering component scanning fromConfigurationclasses and when registeringImport'ed configuration classes.voidsetEnvironment(Environment environment) Set theEnvironmentthat this component runs in.voidsetMetadataReaderFactory(MetadataReaderFactory metadataReaderFactory) Set theMetadataReaderFactoryto use.voidsetProblemReporter(ProblemReporter problemReporter) Set theProblemReporterto use.voidsetResourceLoader(ResourceLoader resourceLoader) Set the ResourceLoader that this object runs in.voidsetSourceExtractor(SourceExtractor sourceExtractor) Set theSourceExtractorto use for generated bean definitions that correspond toBeanfactory methods.
- 
Field Details- 
IMPORT_BEAN_NAME_GENERATORABeanNameGeneratorusing fully qualified class names as default bean names.This default for configuration-level import purposes may be overridden through setBeanNameGenerator(org.springframework.beans.factory.support.BeanNameGenerator). Note that the default for component scanning purposes is a plainAnnotationBeanNameGenerator.INSTANCE, unless overridden throughsetBeanNameGenerator(org.springframework.beans.factory.support.BeanNameGenerator)with a unified user-level bean name generator.- Since:
- 5.2
- See Also:
 
 
- 
- 
Constructor Details- 
ConfigurationClassPostProcessorpublic ConfigurationClassPostProcessor()
 
- 
- 
Method Details- 
getOrderpublic int getOrder()Description copied from interface:OrderedGet the order value of this object.Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet load-on-startupvalues).Same order values will result in arbitrary sort positions for the affected objects. 
- 
setSourceExtractorSet theSourceExtractorto use for generated bean definitions that correspond toBeanfactory methods.
- 
setProblemReporterSet theProblemReporterto use.Used to register any problems detected with ConfigurationorBeandeclarations. For instance, an @Bean method marked asfinalis illegal and would be reported as a problem. Defaults toFailFastProblemReporter.
- 
setMetadataReaderFactorySet theMetadataReaderFactoryto use.Default is a CachingMetadataReaderFactoryfor the specified bean class loader.
- 
setBeanNameGeneratorSet theBeanNameGeneratorto be used when triggering component scanning fromConfigurationclasses and when registeringImport'ed configuration classes. The default is a standardAnnotationBeanNameGeneratorfor scanned components (compatible with the default inClassPathBeanDefinitionScanner) and a variant thereof for imported configuration classes (using unique fully-qualified class names instead of standard component overriding).Note that this strategy does not apply to Beanmethods.This setter is typically only appropriate when configuring the post-processor as a standalone bean definition in XML, e.g. not using the dedicated AnnotationConfig*application contexts or the<context:annotation-config>element. Any bean name generator specified against the application context will take precedence over any set here.
- 
setEnvironmentDescription copied from interface:EnvironmentAwareSet theEnvironmentthat this component runs in.- Specified by:
- setEnvironmentin interface- EnvironmentAware
 
- 
setResourceLoaderDescription copied from interface:ResourceLoaderAwareSet the ResourceLoader that this object runs in.This might be a ResourcePatternResolver, which can be checked through instanceof ResourcePatternResolver. See also theResourcePatternUtils.getResourcePatternResolvermethod.Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSetor a custom init-method. Invoked before ApplicationContextAware'ssetApplicationContext.- Specified by:
- setResourceLoaderin interface- ResourceLoaderAware
- Parameters:
- resourceLoader- the ResourceLoader object to be used by this object
- See Also:
 
- 
setBeanClassLoaderDescription copied from interface:BeanClassLoaderAwareCallback that supplies the beanclass loaderto a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean'sInitializingBean.afterPropertiesSet()method or a custom init-method.- Specified by:
- setBeanClassLoaderin interface- BeanClassLoaderAware
- Parameters:
- beanClassLoader- the owning class loader
 
- 
setApplicationStartupDescription copied from interface:ApplicationStartupAwareSet the ApplicationStartup that this object runs with.Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked before ApplicationContextAware's setApplicationContext. - Specified by:
- setApplicationStartupin interface- ApplicationStartupAware
- Parameters:
- applicationStartup- application startup to be used by this object
 
- 
postProcessBeanDefinitionRegistryDerive further bean definitions from the configuration classes in the registry.- Specified by:
- postProcessBeanDefinitionRegistryin interface- BeanDefinitionRegistryPostProcessor
- Parameters:
- registry- the bean definition registry used by the application context
 
- 
postProcessBeanFactoryPrepare the Configuration classes for servicing bean requests at runtime by replacing them with CGLIB-enhanced subclasses.- Specified by:
- postProcessBeanFactoryin interface- BeanFactoryPostProcessor
- Parameters:
- beanFactory- the bean factory used by the application context
 
- 
processAheadOfTimepublic BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) Description copied from interface:BeanFactoryInitializationAotProcessorProcess the givenConfigurableListableBeanFactoryinstance ahead-of-time and return a contribution ornull.Processors are free to use any techniques they like to analyze the given instance. Most typically use reflection to find fields or methods to use in the contribution. Contributions typically generate source code or resource files that can be used when the AOT optimized application runs. If the given instance isn't relevant to the processor, it should return a nullcontribution.- Specified by:
- processAheadOfTimein interface- BeanFactoryInitializationAotProcessor
- Parameters:
- beanFactory- the bean factory to process
- Returns:
- a BeanFactoryInitializationAotContributionornull
 
- 
processConfigBeanDefinitionsBuild and validate a configuration model based on the registry ofConfigurationclasses.
- 
enhanceConfigurationClassesPost-processes a BeanFactory in search of Configuration class BeanDefinitions; any candidates are then enhanced by aConfigurationClassEnhancer. Candidate status is determined by BeanDefinition attribute metadata.- See Also:
- 
- ConfigurationClassEnhancer
 
 
 
-