Class ConfigurationClassPostProcessor
- All Implemented Interfaces:
org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor
,org.springframework.beans.factory.aot.BeanRegistrationAotProcessor
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanClassLoaderAware
,org.springframework.beans.factory.config.BeanFactoryPostProcessor
,org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
,ApplicationStartupAware
,EnvironmentAware
,ResourceLoaderAware
,org.springframework.core.Ordered
,org.springframework.core.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 Summary
FieldsModifier and TypeFieldDescriptionstatic final AnnotationBeanNameGenerator
ABeanNameGenerator
using fully qualified class names as default bean names.Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
enhanceConfigurationClasses
(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) Post-processes a BeanFactory in search of Configuration class BeanDefinitions; any candidates are then enhanced by aConfigurationClassEnhancer
.int
getOrder()
void
postProcessBeanDefinitionRegistry
(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) Derive further bean definitions from the configuration classes in the registry.void
postProcessBeanFactory
(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) Prepare the Configuration classes for servicing bean requests at runtime by replacing them with CGLIB-enhanced subclasses.org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution
processAheadOfTime
(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) org.springframework.beans.factory.aot.BeanRegistrationAotContribution
processAheadOfTime
(org.springframework.beans.factory.support.RegisteredBean registeredBean) void
processConfigBeanDefinitions
(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) Build and validate a configuration model based on the registry ofConfiguration
classes.void
setApplicationStartup
(org.springframework.core.metrics.ApplicationStartup applicationStartup) Set the ApplicationStartup that this object runs with.void
setBeanClassLoader
(ClassLoader beanClassLoader) void
setBeanNameGenerator
(org.springframework.beans.factory.support.BeanNameGenerator beanNameGenerator) Set theBeanNameGenerator
to be used when triggering component scanning fromConfiguration
classes and when registeringImport
'ed configuration classes.void
setEnvironment
(org.springframework.core.env.Environment environment) Set theEnvironment
that this component runs in.void
setMetadataReaderFactory
(org.springframework.core.type.classreading.MetadataReaderFactory metadataReaderFactory) Set theMetadataReaderFactory
to use.void
setProblemReporter
(org.springframework.beans.factory.parsing.ProblemReporter problemReporter) Set theProblemReporter
to use.void
setResourceLoader
(org.springframework.core.io.ResourceLoader resourceLoader) Set the ResourceLoader that this object runs in.void
setSourceExtractor
(org.springframework.beans.factory.parsing.SourceExtractor sourceExtractor) Set theSourceExtractor
to use for generated bean definitions that correspond toBean
factory methods.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.beans.factory.aot.BeanRegistrationAotProcessor
isBeanExcludedFromAotProcessing
-
Field Details
-
IMPORT_BEAN_NAME_GENERATOR
ABeanNameGenerator
using 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
-
ConfigurationClassPostProcessor
public ConfigurationClassPostProcessor()
-
-
Method Details
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
-
setSourceExtractor
public void setSourceExtractor(@Nullable org.springframework.beans.factory.parsing.SourceExtractor sourceExtractor) Set theSourceExtractor
to use for generated bean definitions that correspond toBean
factory methods. -
setProblemReporter
public void setProblemReporter(@Nullable org.springframework.beans.factory.parsing.ProblemReporter problemReporter) Set theProblemReporter
to use.Used to register any problems detected with
Configuration
orBean
declarations. For instance, an @Bean method marked asfinal
is illegal and would be reported as a problem. Defaults toFailFastProblemReporter
. -
setMetadataReaderFactory
public void setMetadataReaderFactory(org.springframework.core.type.classreading.MetadataReaderFactory metadataReaderFactory) Set theMetadataReaderFactory
to use.Default is a
CachingMetadataReaderFactory
for the specified bean class loader. -
setBeanNameGenerator
public void setBeanNameGenerator(org.springframework.beans.factory.support.BeanNameGenerator beanNameGenerator) Set theBeanNameGenerator
to be used when triggering component scanning fromConfiguration
classes and when registeringImport
'ed configuration classes. The default is a standardAnnotationBeanNameGenerator
for 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
Bean
methods.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. -
setEnvironment
public void setEnvironment(org.springframework.core.env.Environment environment) Description copied from interface:EnvironmentAware
Set theEnvironment
that this component runs in.- Specified by:
setEnvironment
in interfaceEnvironmentAware
-
setResourceLoader
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) Description copied from interface:ResourceLoaderAware
Set the ResourceLoader that this object runs in.This might be a ResourcePatternResolver, which can be checked through
instanceof ResourcePatternResolver
. See also theResourcePatternUtils.getResourcePatternResolver
method.Invoked after population of normal bean properties but before an init callback like InitializingBean's
afterPropertiesSet
or a custom init-method. Invoked before ApplicationContextAware'ssetApplicationContext
.- Specified by:
setResourceLoader
in interfaceResourceLoaderAware
- Parameters:
resourceLoader
- the ResourceLoader object to be used by this object- See Also:
-
ResourcePatternResolver
ResourcePatternUtils.getResourcePatternResolver(org.springframework.core.io.ResourceLoader)
-
setBeanClassLoader
- Specified by:
setBeanClassLoader
in interfaceorg.springframework.beans.factory.BeanClassLoaderAware
-
setApplicationStartup
public void setApplicationStartup(org.springframework.core.metrics.ApplicationStartup applicationStartup) Description copied from interface:ApplicationStartupAware
Set 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:
setApplicationStartup
in interfaceApplicationStartupAware
- Parameters:
applicationStartup
- application startup to be used by this object
-
postProcessBeanDefinitionRegistry
public void postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) Derive further bean definitions from the configuration classes in the registry.- Specified by:
postProcessBeanDefinitionRegistry
in interfaceorg.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
-
postProcessBeanFactory
public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) Prepare the Configuration classes for servicing bean requests at runtime by replacing them with CGLIB-enhanced subclasses.- Specified by:
postProcessBeanFactory
in interfaceorg.springframework.beans.factory.config.BeanFactoryPostProcessor
-
processAheadOfTime
@Nullable public org.springframework.beans.factory.aot.BeanRegistrationAotContribution processAheadOfTime(org.springframework.beans.factory.support.RegisteredBean registeredBean) - Specified by:
processAheadOfTime
in interfaceorg.springframework.beans.factory.aot.BeanRegistrationAotProcessor
-
processAheadOfTime
@Nullable public org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution processAheadOfTime(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) - Specified by:
processAheadOfTime
in interfaceorg.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor
-
processConfigBeanDefinitions
public void processConfigBeanDefinitions(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) Build and validate a configuration model based on the registry ofConfiguration
classes. -
enhanceConfigurationClasses
public void enhanceConfigurationClasses(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) Post-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
-