From a983d181aaf3d6979e1336f76f6b60a82feb2c11 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 1 Feb 2010 17:56:03 +0000 Subject: [PATCH] fixed MBeanExporter regression: do not try to expose abstract beans (SPR-6784) git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2896 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../beans/factory/BeanIsAbstractException.java | 13 +++++++------ .../springframework/jmx/export/MBeanExporter.java | 6 +++++- .../springframework/jmx/export/autodetectMBeans.xml | 2 ++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/BeanIsAbstractException.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/BeanIsAbstractException.java index 413f2c7349d..26a5e8f3f3c 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/BeanIsAbstractException.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/BeanIsAbstractException.java @@ -1,12 +1,12 @@ /* - * Copyright 2002-2005 the original author or authors. - * + * Copyright 2002-2010 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. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,8 +17,9 @@ package org.springframework.beans.factory; /** - * Exception thrown when a bean instance has been requested for a bean - * which has been defined as abstract + * Exception thrown when a bean instance has been requested for + * a bean definition which has been marked as abstract. + * * @author Juergen Hoeller * @since 1.1 * @see org.springframework.beans.factory.support.AbstractBeanDefinition#setAbstract diff --git a/org.springframework.context/src/main/java/org/springframework/jmx/export/MBeanExporter.java b/org.springframework.context/src/main/java/org/springframework/jmx/export/MBeanExporter.java index 333ae5fb736..ccd1973f9a1 100644 --- a/org.springframework.context/src/main/java/org/springframework/jmx/export/MBeanExporter.java +++ b/org.springframework.context/src/main/java/org/springframework/jmx/export/MBeanExporter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 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. @@ -44,6 +44,7 @@ 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; @@ -899,6 +900,9 @@ public class MBeanExporter extends MBeanRegistrationSupport } // otherwise ignore beans where the class is not resolvable } + catch (BeanIsAbstractException ex) { + // ignore - can't expose an abstract bean + } } } } diff --git a/org.springframework.context/src/test/java/org/springframework/jmx/export/autodetectMBeans.xml b/org.springframework.context/src/test/java/org/springframework/jmx/export/autodetectMBeans.xml index c45205909b9..83d7ae46ad1 100644 --- a/org.springframework.context/src/test/java/org/springframework/jmx/export/autodetectMBeans.xml +++ b/org.springframework.context/src/test/java/org/springframework/jmx/export/autodetectMBeans.xml @@ -23,4 +23,6 @@ + +