Make @Configuration classes thread-safe

Refactor ConfigurationClassEnhancer so that BeanFactory instances are
not held against CGLIB Callback objects. Enhanced @Configuration classes
now use the BeanFactoryAware interface in order to obtain a BeanFactory.

This change has the additional benefit that a static final field can
now be used to hold all Callback instances.

Issue: SPR-10307
This commit is contained in:
Phillip Webb
2013-03-06 16:56:26 -08:00
parent 8b904102ff
commit 30b21a987e
3 changed files with 147 additions and 98 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,8 +38,7 @@ public class ReflectionUtilsIntegrationTests {
@Test
public void getUniqueDeclaredMethods_withCovariantReturnType_andCglibRewrittenMethodNames() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
Class<?> cglibLeaf = new ConfigurationClassEnhancer(bf).enhance(Leaf.class);
Class<?> cglibLeaf = new ConfigurationClassEnhancer().enhance(Leaf.class);
int m1MethodCount = 0;
Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(cglibLeaf);
for (Method method : methods) {