类 ConfigurationClassPostProcessor
- java.lang.Object
- org.springframework.context.annotation.ConfigurationClassPostProcessor
- 所有已实现的接口:
Aware
,BeanClassLoaderAware
,BeanFactoryPostProcessor
,BeanDefinitionRegistryPostProcessor
,EnvironmentAware
,ResourceLoaderAware
,Ordered
,PriorityOrdered
public class ConfigurationClassPostProcessor extends Object implements BeanDefinitionRegistryPostProcessor, PriorityOrdered, ResourceLoaderAware, BeanClassLoaderAware, EnvironmentAware
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 otherBeanFactoryPostProcessor
executes.- 从以下版本开始:
- 3.0
- 作者:
- Chris Beams, Juergen Hoeller, Phillip Webb
字段概要
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 ConfigurationClassPostProcessor()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
enhanceConfigurationClasses(ConfigurableListableBeanFactory beanFactory)
Post-processes a BeanFactory in search of Configuration class BeanDefinitions; any candidates are then enhanced by aConfigurationClassEnhancer
.int
getOrder()
Get the order value of this object.void
postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry)
Derive further bean definitions from the configuration classes in the registry.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 ofConfiguration
classes.void
setBeanClassLoader(ClassLoader beanClassLoader)
Callback that supplies the beanclass loader
to a bean instance.void
setBeanNameGenerator(BeanNameGenerator beanNameGenerator)
Set theBeanNameGenerator
to be used when triggering component scanning fromConfiguration
classes and when registeringImport
'ed configuration classes.void
setEnvironment(Environment environment)
Set theEnvironment
that this component runs in.void
setMetadataReaderFactory(MetadataReaderFactory metadataReaderFactory)
Set theMetadataReaderFactory
to use.void
setProblemReporter(ProblemReporter problemReporter)
Set theProblemReporter
to use.void
setResourceLoader(ResourceLoader resourceLoader)
Set the ResourceLoader that this object runs in.void
setSourceExtractor(SourceExtractor sourceExtractor)
Set theSourceExtractor
to use for generated bean definitions that correspond toBean
factory methods.
构造器详细资料
ConfigurationClassPostProcessor
public ConfigurationClassPostProcessor()
方法详细资料
getOrder
public int getOrder()
从接口复制的说明:Ordered
Get 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-startup
values).Same order values will result in arbitrary sort positions for the affected objects.
- 指定者:
getOrder
在接口中Ordered
- 返回:
- the order value
- 另请参阅:
Ordered.HIGHEST_PRECEDENCE
,Ordered.LOWEST_PRECEDENCE
setSourceExtractor
public void setSourceExtractor(SourceExtractor sourceExtractor)
Set theSourceExtractor
to use for generated bean definitions that correspond toBean
factory methods.
setProblemReporter
public void setProblemReporter(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(MetadataReaderFactory metadataReaderFactory)
Set theMetadataReaderFactory
to use.Default is a
CachingMetadataReaderFactory
for the specified bean class loader.
setBeanNameGenerator
public void setBeanNameGenerator(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 value set here.
setEnvironment
public void setEnvironment(Environment environment)
从接口复制的说明:EnvironmentAware
Set theEnvironment
that this component runs in.- 指定者:
setEnvironment
在接口中EnvironmentAware
setResourceLoader
public void setResourceLoader(ResourceLoader resourceLoader)
从接口复制的说明: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
.- 指定者:
setResourceLoader
在接口中ResourceLoaderAware
- 参数:
resourceLoader
- the ResourceLoader object to be used by this object- 另请参阅:
ResourcePatternResolver
,ResourcePatternUtils.getResourcePatternResolver(org.springframework.core.io.ResourceLoader)
setBeanClassLoader
public void setBeanClassLoader(ClassLoader beanClassLoader)
从接口复制的说明:BeanClassLoaderAware
Callback that supplies the beanclass 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.- 指定者:
setBeanClassLoader
在接口中BeanClassLoaderAware
- 参数:
beanClassLoader
- the owning class loader; may benull
in which case a defaultClassLoader
must be used, for example theClassLoader
obtained viaClassUtils.getDefaultClassLoader()
postProcessBeanDefinitionRegistry
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry)
Derive further bean definitions from the configuration classes in the registry.- 指定者:
postProcessBeanDefinitionRegistry
在接口中BeanDefinitionRegistryPostProcessor
- 参数:
registry
- the bean definition registry used by the application context
postProcessBeanFactory
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
Prepare the Configuration classes for servicing bean requests at runtime by replacing them with CGLIB-enhanced subclasses.- 指定者:
postProcessBeanFactory
在接口中BeanFactoryPostProcessor
- 参数:
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 ofConfiguration
classes.
enhanceConfigurationClasses
public void enhanceConfigurationClasses(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.- 另请参阅:
ConfigurationClassEnhancer