Skip to content

Commit 198911e

Browse files
committed
removed hard ScopedProxyUtils dependency in ConfigurationClassEnhancer
1 parent 776f049 commit 198911e

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.apache.commons.logging.Log;
3030
import org.apache.commons.logging.LogFactory;
3131

32-
import org.springframework.aop.scope.ScopedProxyUtils;
3332
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
3433
import org.springframework.core.annotation.AnnotationUtils;
3534
import org.springframework.util.Assert;
@@ -126,14 +125,11 @@ private Class<?> createClass(Enhancer enhancer) {
126125
/**
127126
* Intercepts the invocation of any {@link Bean}-annotated methods in order to ensure proper
128127
* handling of bean semantics such as scoping and AOP proxying.
129-
* @author Chris Beams
130128
* @see Bean
131129
* @see ConfigurationClassEnhancer
132130
*/
133131
private static class BeanMethodInterceptor implements MethodInterceptor {
134132

135-
private static final Log logger = LogFactory.getLog(BeanMethodInterceptor.class);
136-
137133
private final ConfigurableBeanFactory beanFactory;
138134

139135
public BeanMethodInterceptor(ConfigurableBeanFactory beanFactory) {
@@ -155,10 +151,9 @@ public Object intercept(Object obj, Method method, Object[] args, MethodProxy pr
155151
}
156152

157153
// determine whether this bean is a scoped-proxy
158-
// TODO: remove hard ScopedProxyUtils dependency
159154
Scope scope = AnnotationUtils.findAnnotation(method, Scope.class);
160155
if (scope != null && scope.proxyMode() != ScopedProxyMode.NO) {
161-
String scopedBeanName = ScopedProxyUtils.getTargetBeanName(beanName);
156+
String scopedBeanName = ScopedProxyCreator.getTargetBeanName(beanName);
162157
if (this.beanFactory.isCurrentlyInCreation(scopedBeanName)) {
163158
beanName = scopedBeanName;
164159
}
@@ -168,12 +163,7 @@ public Object intercept(Object obj, Method method, Object[] args, MethodProxy pr
168163
// container for already cached instances
169164
if (factoryContainsBean(beanName)) {
170165
// 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);
177167
}
178168

179169
// actually create and return the bean

org.springframework.context/src/main/java/org/springframework/context/annotation/ScopedProxyCreator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ public static BeanDefinitionHolder createScopedProxy(
3636
return ScopedProxyUtils.createScopedProxy(definitionHolder, registry, proxyTargetClass);
3737
}
3838

39+
public static String getTargetBeanName(String originalBeanName) {
40+
return ScopedProxyUtils.getTargetBeanName(originalBeanName);
41+
}
42+
3943
}

0 commit comments

Comments
 (0)