class ConfigurationClassEnhancer
extends java.lang.Object
Configuration
classes by generating a CGLIB subclass which
interacts with the Spring container to respect bean scoping semantics for
@Bean
methods. Each such @Bean
method will be overridden in
the generated subclass, only delegating to the actual @Bean
method
implementation if the container actually requests the construction of a new
instance. Otherwise, a call to such an @Bean
method serves as a
reference back to the container, obtaining the corresponding bean by name.enhance(java.lang.Class<?>)
,
ConfigurationClassPostProcessor
Modifier and Type | Class and Description |
---|---|
private static class |
ConfigurationClassEnhancer.BeanFactoryAwareGeneratorStrategy
Custom extension of CGLIB's DefaultGeneratorStrategy, introducing a
BeanFactory field. |
private static class |
ConfigurationClassEnhancer.BeanFactoryAwareMethodInterceptor
Intercepts the invocation of any
BeanFactoryAware.setBeanFactory(BeanFactory) on
@Configuration class instances for the purpose of recording the BeanFactory . |
private static class |
ConfigurationClassEnhancer.BeanMethodInterceptor
Intercepts the invocation of any
Bean -annotated methods in order to ensure proper
handling of bean semantics such as scoping and AOP proxying. |
private static interface |
ConfigurationClassEnhancer.ConditionalCallback
Conditional
Callback . |
private static class |
ConfigurationClassEnhancer.ConditionalCallbackFilter
A
CallbackFilter that works by interrogating Callback s in the order
that they are defined via ConfigurationClassEnhancer.ConditionalCallback . |
private static class |
ConfigurationClassEnhancer.DisposableBeanMethodInterceptor
Intercepts the invocation of any
DisposableBean.destroy() on @Configuration
class instances for the purpose of de-registering CGLIB callbacks. |
static interface |
ConfigurationClassEnhancer.EnhancedConfiguration
Marker interface to be implemented by all @Configuration CGLIB subclasses.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
BEAN_FACTORY_FIELD |
private static ConfigurationClassEnhancer.ConditionalCallbackFilter |
CALLBACK_FILTER |
private static Callback[] |
CALLBACKS |
private static DefaultGeneratorStrategy |
GENERATOR_STRATEGY |
private static Log |
logger |
Constructor and Description |
---|
ConfigurationClassEnhancer() |
Modifier and Type | Method and Description |
---|---|
private java.lang.Class<?> |
createClass(Enhancer enhancer)
Uses enhancer to generate a subclass of superclass,
ensuring that callbacks are registered for the new subclass.
|
java.lang.Class<?> |
enhance(java.lang.Class<?> configClass)
Loads the specified class and generates a CGLIB subclass of it equipped with
container-aware callbacks capable of respecting scoping and other bean semantics.
|
private Enhancer |
newEnhancer(java.lang.Class<?> superclass)
Creates a new CGLIB
Enhancer instance. |
private static final Callback[] CALLBACKS
private static final ConfigurationClassEnhancer.ConditionalCallbackFilter CALLBACK_FILTER
private static final DefaultGeneratorStrategy GENERATOR_STRATEGY
private static final java.lang.String BEAN_FACTORY_FIELD
private static final Log logger
public java.lang.Class<?> enhance(java.lang.Class<?> configClass)
private Enhancer newEnhancer(java.lang.Class<?> superclass)
Enhancer
instance.private java.lang.Class<?> createClass(Enhancer enhancer)