private static class ConfigurationClassEnhancer.BeanMethodInterceptor extends java.lang.Object implements ConfigurationClassEnhancer.ConditionalCallback
Bean
-annotated methods in order to ensure proper
handling of bean semantics such as scoping and AOP proxying.Bean
,
ConfigurationClassEnhancer
Modifier | Constructor and Description |
---|---|
private |
BeanMethodInterceptor() |
Modifier and Type | Method and Description |
---|---|
private java.lang.Object |
enhanceFactoryBean(java.lang.Object factoryBean,
ConfigurableBeanFactory beanFactory,
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(ConfigurableBeanFactory beanFactory,
java.lang.String beanName)
Check the BeanFactory to see whether the bean named beanName already
exists.
|
private ConfigurableBeanFactory |
getBeanFactory(java.lang.Object enhancedConfigInstance) |
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.
|
boolean |
isMatch(java.lang.reflect.Method candidateMethod) |
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(ConfigurableBeanFactory beanFactory, 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.Object factoryBean, ConfigurableBeanFactory beanFactory, java.lang.String beanName)
private ConfigurableBeanFactory getBeanFactory(java.lang.Object enhancedConfigInstance)
public boolean isMatch(java.lang.reflect.Method candidateMethod)
isMatch
in interface ConfigurationClassEnhancer.ConditionalCallback