exclude abstract lazy-init beans from MBean exposure as well (SPR-6784)
This commit is contained in:
parent
a1e4f4f406
commit
103c1aa82f
|
|
@ -44,7 +44,6 @@ import org.springframework.aop.target.LazyInitTargetSource;
|
||||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
import org.springframework.beans.factory.BeanFactoryAware;
|
import org.springframework.beans.factory.BeanFactoryAware;
|
||||||
import org.springframework.beans.factory.BeanIsAbstractException;
|
|
||||||
import org.springframework.beans.factory.CannotLoadBeanClassException;
|
import org.springframework.beans.factory.CannotLoadBeanClassException;
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
@ -873,7 +872,7 @@ public class MBeanExporter extends MBeanRegistrationSupport
|
||||||
beanNames.addAll(Arrays.asList(((ConfigurableBeanFactory) this.beanFactory).getSingletonNames()));
|
beanNames.addAll(Arrays.asList(((ConfigurableBeanFactory) this.beanFactory).getSingletonNames()));
|
||||||
}
|
}
|
||||||
for (String beanName : beanNames) {
|
for (String beanName : beanNames) {
|
||||||
if (!isExcluded(beanName)) {
|
if (!isExcluded(beanName) && !isBeanDefinitionAbstract(this.beanFactory, beanName)) {
|
||||||
try {
|
try {
|
||||||
Class beanClass = this.beanFactory.getType(beanName);
|
Class beanClass = this.beanFactory.getType(beanName);
|
||||||
if (beanClass != null && callback.include(beanClass, beanName)) {
|
if (beanClass != null && callback.include(beanClass, beanName)) {
|
||||||
|
|
@ -900,9 +899,6 @@ public class MBeanExporter extends MBeanRegistrationSupport
|
||||||
}
|
}
|
||||||
// otherwise ignore beans where the class is not resolvable
|
// otherwise ignore beans where the class is not resolvable
|
||||||
}
|
}
|
||||||
catch (BeanIsAbstractException ex) {
|
|
||||||
// ignore - can't expose an abstract bean
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -917,6 +913,14 @@ public class MBeanExporter extends MBeanRegistrationSupport
|
||||||
this.excludedBeans.contains(beanName.substring(BeanFactory.FACTORY_BEAN_PREFIX.length())))));
|
this.excludedBeans.contains(beanName.substring(BeanFactory.FACTORY_BEAN_PREFIX.length())))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return whether the specified bean definition should be considered as abstract.
|
||||||
|
*/
|
||||||
|
private boolean isBeanDefinitionAbstract(ListableBeanFactory beanFactory, String beanName) {
|
||||||
|
return (beanFactory instanceof ConfigurableListableBeanFactory && beanFactory.containsBeanDefinition(beanName) &&
|
||||||
|
((ConfigurableListableBeanFactory) beanFactory).getBeanDefinition(beanName).isAbstract());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// Notification and listener management
|
// Notification and listener management
|
||||||
|
|
|
||||||
|
|
@ -25,4 +25,6 @@
|
||||||
|
|
||||||
<bean id="toBeIgnored" class="javax.management.DynamicMBean" abstract="true"/>
|
<bean id="toBeIgnored" class="javax.management.DynamicMBean" abstract="true"/>
|
||||||
|
|
||||||
|
<bean id="toBeIgnoredToo" class="javax.management.DynamicMBean" abstract="true" lazy-init="true"/>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue