Handle scoped proxy properly in MBeanExporter

Previously, if a bean has a scoped proxy and is annotated to be exposed
to the JMX domain, both the scoped proxy and the target instance were
exposed in the JMX domain, resulting in a duplicate entries. Worse, if
such bean defines an explicit name, the application wouldn't start
because of a name conflict.

This commit deals explicitely with scoped proxy and make sure to only
expose the relevant bean.

Issue: SPR-12529
This commit is contained in:
Stephane Nicoll
2014-12-16 10:45:25 +01:00
parent 809ee0d350
commit cae217de94
3 changed files with 48 additions and 2 deletions

View File

@@ -97,4 +97,12 @@ public abstract class ScopedProxyUtils {
return TARGET_NAME_PREFIX + originalBeanName;
}
/**
* Specify if the {@code beanName} is the name of a bean that references the target
* bean within a scoped proxy.
*/
public static boolean isScopedTarget(String beanName) {
return beanName.startsWith(TARGET_NAME_PREFIX);
}
}