29
29
import org .apache .commons .logging .Log ;
30
30
import org .apache .commons .logging .LogFactory ;
31
31
32
- import org .springframework .aop .scope .ScopedProxyUtils ;
33
32
import org .springframework .beans .factory .config .ConfigurableBeanFactory ;
34
33
import org .springframework .core .annotation .AnnotationUtils ;
35
34
import org .springframework .util .Assert ;
@@ -126,14 +125,11 @@ private Class<?> createClass(Enhancer enhancer) {
126
125
/**
127
126
* Intercepts the invocation of any {@link Bean}-annotated methods in order to ensure proper
128
127
* handling of bean semantics such as scoping and AOP proxying.
129
- * @author Chris Beams
130
128
* @see Bean
131
129
* @see ConfigurationClassEnhancer
132
130
*/
133
131
private static class BeanMethodInterceptor implements MethodInterceptor {
134
132
135
- private static final Log logger = LogFactory .getLog (BeanMethodInterceptor .class );
136
-
137
133
private final ConfigurableBeanFactory beanFactory ;
138
134
139
135
public BeanMethodInterceptor (ConfigurableBeanFactory beanFactory ) {
@@ -155,10 +151,9 @@ public Object intercept(Object obj, Method method, Object[] args, MethodProxy pr
155
151
}
156
152
157
153
// determine whether this bean is a scoped-proxy
158
- // TODO: remove hard ScopedProxyUtils dependency
159
154
Scope scope = AnnotationUtils .findAnnotation (method , Scope .class );
160
155
if (scope != null && scope .proxyMode () != ScopedProxyMode .NO ) {
161
- String scopedBeanName = ScopedProxyUtils .getTargetBeanName (beanName );
156
+ String scopedBeanName = ScopedProxyCreator .getTargetBeanName (beanName );
162
157
if (this .beanFactory .isCurrentlyInCreation (scopedBeanName )) {
163
158
beanName = scopedBeanName ;
164
159
}
@@ -168,12 +163,7 @@ public Object intercept(Object obj, Method method, Object[] args, MethodProxy pr
168
163
// container for already cached instances
169
164
if (factoryContainsBean (beanName )) {
170
165
// we have an already existing cached instance of this bean -> retrieve it
171
- Object cachedBean = this .beanFactory .getBean (beanName );
172
- if (logger .isDebugEnabled ()) {
173
- logger .debug (String .format ("Returning cached object [%s] for @Bean method %s.%s" ,
174
- cachedBean , method .getDeclaringClass ().getSimpleName (), beanName ));
175
- }
176
- return cachedBean ;
166
+ return this .beanFactory .getBean (beanName );
177
167
}
178
168
179
169
// actually create and return the bean
0 commit comments