提交 103c1aa8 编写于 作者: J Juergen Hoeller

exclude abstract lazy-init beans from MBean exposure as well (SPR-6784)

上级 a1e4f4f4
......@@ -44,7 +44,6 @@ import org.springframework.aop.target.LazyInitTargetSource;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanIsAbstractException;
import org.springframework.beans.factory.CannotLoadBeanClassException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
......@@ -873,7 +872,7 @@ public class MBeanExporter extends MBeanRegistrationSupport
beanNames.addAll(Arrays.asList(((ConfigurableBeanFactory) this.beanFactory).getSingletonNames()));
}
for (String beanName : beanNames) {
if (!isExcluded(beanName)) {
if (!isExcluded(beanName) && !isBeanDefinitionAbstract(this.beanFactory, beanName)) {
try {
Class beanClass = this.beanFactory.getType(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
}
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())))));
}
/**
* 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
......
......@@ -25,4 +25,6 @@
<bean id="toBeIgnored" class="javax.management.DynamicMBean" abstract="true"/>
<bean id="toBeIgnoredToo" class="javax.management.DynamicMBean" abstract="true" lazy-init="true"/>
</beans>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册