diff --git a/org.springframework.context/src/main/java/org/springframework/jmx/export/MBeanExportOperations.java b/org.springframework.context/src/main/java/org/springframework/jmx/export/MBeanExportOperations.java
index f99fa5f657b..8eab53dbac8 100644
--- a/org.springframework.context/src/main/java/org/springframework/jmx/export/MBeanExportOperations.java
+++ b/org.springframework.context/src/main/java/org/springframework/jmx/export/MBeanExportOperations.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2005 the original author or authors.
+ * Copyright 2002-2009 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.
@@ -54,4 +54,10 @@ public interface MBeanExportOperations {
*/
void registerManagedResource(Object managedResource, ObjectName objectName) throws MBeanExportException;
+ /**
+ * Remove the specified MBean from the underlying MBeanServer registry.
+ * @param objectName the {@link ObjectName} of the resource to remove
+ */
+ void unregisterManagedResource(ObjectName objectName);
+
}
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 06406b61919..b137668f48f 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
@@ -66,23 +66,19 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
/**
- * JMX exporter that allows for exposing any Spring-managed bean
- * to a JMX MBeanServer, without the need to define any
+ * JMX exporter that allows for exposing any Spring-managed bean to a
+ * JMX {@link javax.management.MBeanServer}, without the need to define any
* JMX-specific information in the bean classes.
*
- *
If the bean implements one of the JMX management interfaces, - * then MBeanExporter can simply register the MBean with the server - * automatically, through its autodetection process. + *
If a bean implements one of the JMX management interfaces, MBeanExporter can + * simply register the MBean with the server through its autodetection process. * - *
If the bean does not implement one of the JMX management interfaces, - * then MBeanExporter will create the management information using the - * supplied {@link MBeanInfoAssembler} implementation. + *
If a bean does not implement one of the JMX management interfaces, MBeanExporter + * will create the management information using the supplied {@link MBeanInfoAssembler}. * - *
A list of {@link MBeanExporterListener MBeanExporterListeners} - * can be registered via the - * {@link #setListeners(MBeanExporterListener[]) listeners} property, - * allowing application code to be notified of MBean registration and - * unregistration events. + *
A list of {@link MBeanExporterListener MBeanExporterListeners} can be registered + * via the {@link #setListeners(MBeanExporterListener[]) listeners} property, allowing + * application code to be notified of MBean registration and unregistration events. * *
This exporter is compatible with JMX 1.2 on Java 5 and above. * As of Spring 2.5, it also autodetects and exports Java 6 MXBeans. @@ -442,7 +438,7 @@ public class MBeanExporter extends MBeanRegistrationSupport public ObjectName registerManagedResource(Object managedResource) throws MBeanExportException { Assert.notNull(managedResource, "Managed resource must not be null"); - ObjectName objectName = null; + ObjectName objectName; try { objectName = getObjectName(managedResource, null); if (this.ensureUniqueRuntimeObjectNames) { @@ -475,6 +471,11 @@ public class MBeanExporter extends MBeanRegistrationSupport } } + public void unregisterManagedResource(ObjectName objectName) { + Assert.notNull(objectName, "ObjectName must not be null"); + doUnregister(objectName); + } + //--------------------------------------------------------------------- // Exporter implementation