private static class ConfigurationClassEnhancer.BeanMethodInterceptor
extends java.lang.Object
Bean
-annotated methods in order to ensure proper
handling of bean semantics such as scoping and AOP proxying.Bean
,
ConfigurationClassEnhancer
Modifier and Type | Field and Description |
---|---|
private ConfigurableBeanFactory |
beanFactory |
private static CallbackFilter |
CALLBACK_FILTER |
private static java.lang.Class<?>[] |
CALLBACK_TYPES |
Constructor and Description |
---|
ConfigurationClassEnhancer.BeanMethodInterceptor(ConfigurableBeanFactory beanFactory) |
Modifier and Type | Method and Description |
---|---|
private java.lang.Object |
enhanceFactoryBean(java.lang.Class<?> fbClass,
java.lang.String beanName)
Create a subclass proxy that intercepts calls to getObject(), delegating to the current BeanFactory
instead of creating a new instance.
|
private boolean |
factoryContainsBean(java.lang.String beanName)
Check the BeanFactory to see whether the bean named beanName already
exists.
|
java.lang.Object |
intercept(java.lang.Object enhancedConfigInstance,
java.lang.reflect.Method beanMethod,
java.lang.Object[] beanMethodArgs,
MethodProxy cglibMethodProxy)
Enhance a
@Bean method to check the supplied BeanFactory for the
existence of this bean object. |
private boolean |
isCurrentlyInvokedFactoryMethod(java.lang.reflect.Method method)
Check whether the given method corresponds to the container's currently invoked
factory method.
|
private static final java.lang.Class<?>[] CALLBACK_TYPES
private static final CallbackFilter CALLBACK_FILTER
private final ConfigurableBeanFactory beanFactory
public ConfigurationClassEnhancer.BeanMethodInterceptor(ConfigurableBeanFactory beanFactory)
public java.lang.Object intercept(java.lang.Object enhancedConfigInstance, java.lang.reflect.Method beanMethod, java.lang.Object[] beanMethodArgs, MethodProxy cglibMethodProxy) throws java.lang.Throwable
@Bean
method to check the supplied BeanFactory for the
existence of this bean object.java.lang.Throwable
- as a catch-all for any exception that may be thrown when invoking the
super implementation of the proxied method i.e., the actual @Bean
methodprivate boolean factoryContainsBean(java.lang.String beanName)
Said another way, this check repurposes
ConfigurableBeanFactory.isCurrentlyInCreation(String)
to determine whether
the container is calling this method or the user is calling this method.
beanName
- name of bean to check forprivate boolean isCurrentlyInvokedFactoryMethod(java.lang.reflect.Method method)
private java.lang.Object enhanceFactoryBean(java.lang.Class<?> fbClass, java.lang.String beanName) throws java.lang.InstantiationException, java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.IllegalAccessException