|
27 | 27 | import org.springframework.asm.Type;
|
28 | 28 | import org.springframework.beans.factory.BeanFactory;
|
29 | 29 | import org.springframework.beans.factory.BeanFactoryAware;
|
30 |
| -import org.springframework.beans.factory.DisposableBean; |
31 | 30 | import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
32 | 31 | import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
33 | 32 | import org.springframework.beans.factory.support.SimpleInstantiationStrategy;
|
|
65 | 64 | */
|
66 | 65 | class ConfigurationClassEnhancer {
|
67 | 66 |
|
| 67 | + // The callbacks to use. Note that these callbacks must be stateless. |
68 | 68 | private static final Callback[] CALLBACKS = new Callback[] {
|
69 | 69 | new BeanMethodInterceptor(),
|
70 |
| - new DisposableBeanMethodInterceptor(), |
71 | 70 | new BeanFactoryAwareMethodInterceptor(),
|
72 | 71 | NoOp.INSTANCE
|
73 | 72 | };
|
@@ -139,15 +138,13 @@ private Class<?> createClass(Enhancer enhancer) {
|
139 | 138 | * Facilitates idempotent behavior for {@link ConfigurationClassEnhancer#enhance(Class)}
|
140 | 139 | * through checking to see if candidate classes are already assignable to it, e.g.
|
141 | 140 | * have already been enhanced.
|
142 |
| - * <p>Also extends {@link DisposableBean} and {@link BeanFactoryAware}, as all |
143 |
| - * enhanced {@code @Configuration} classes require access to the {@link BeanFactory} |
144 |
| - * that created them and must de-register static CGLIB callbacks on destruction, |
145 |
| - * which is handled by the (private) {@code DisposableBeanMethodInterceptor}. |
| 141 | + * <p>Also extends {@link BeanFactoryAware}, as all enhanced {@code @Configuration} |
| 142 | + * classes require access to the {@link BeanFactory} that created them. |
146 | 143 | * <p>Note that this interface is intended for framework-internal use only, however
|
147 | 144 | * must remain public in order to allow access to subclasses generated from other
|
148 | 145 | * packages (i.e. user code).
|
149 | 146 | */
|
150 |
| - public interface EnhancedConfiguration extends DisposableBean, BeanFactoryAware { |
| 147 | + public interface EnhancedConfiguration extends BeanFactoryAware { |
151 | 148 | }
|
152 | 149 |
|
153 | 150 |
|
@@ -403,32 +400,4 @@ public boolean isMatch(Method candidateMethod) {
|
403 | 400 | }
|
404 | 401 | }
|
405 | 402 |
|
406 |
| - |
407 |
| - /** |
408 |
| - * Intercepts the invocation of any {@link DisposableBean#destroy()} on @Configuration |
409 |
| - * class instances for the purpose of de-registering CGLIB callbacks. This helps avoid |
410 |
| - * garbage collection issues. See SPR-7901. |
411 |
| - * @see EnhancedConfiguration |
412 |
| - */ |
413 |
| - private static class DisposableBeanMethodInterceptor implements MethodInterceptor, ConditionalCallback { |
414 |
| - |
415 |
| - @Override |
416 |
| - public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable { |
417 |
| - Enhancer.registerStaticCallbacks(obj.getClass(), null); |
418 |
| - // Does the actual (non-CGLIB) superclass actually implement DisposableBean? |
419 |
| - // If so, call its dispose() method. If not, just exit. |
420 |
| - if (DisposableBean.class.isAssignableFrom(obj.getClass().getSuperclass())) { |
421 |
| - return proxy.invokeSuper(obj, args); |
422 |
| - } |
423 |
| - return null; |
424 |
| - } |
425 |
| - |
426 |
| - @Override |
427 |
| - public boolean isMatch(Method candidateMethod) { |
428 |
| - return candidateMethod.getName().equals("destroy") && |
429 |
| - candidateMethod.getParameterTypes().length == 0 && |
430 |
| - DisposableBean.class.isAssignableFrom(candidateMethod.getDeclaringClass()); |
431 |
| - } |
432 |
| - } |
433 |
| - |
434 | 403 | }
|
0 commit comments