Browse Source

added "unregisterManagedResource" method to MBeanExporter/MBeanExportOperations (SPR-5517)

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@886 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Juergen Hoeller 17 years ago
parent
commit
c759465a5e
  1. 8
      org.springframework.context/src/main/java/org/springframework/jmx/export/MBeanExportOperations.java
  2. 29
      org.springframework.context/src/main/java/org/springframework/jmx/export/MBeanExporter.java

8
org.springframework.context/src/main/java/org/springframework/jmx/export/MBeanExportOperations.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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);
}

29
org.springframework.context/src/main/java/org/springframework/jmx/export/MBeanExporter.java

@ -66,23 +66,19 @@ import org.springframework.util.CollectionUtils; @@ -66,23 +66,19 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
/**
* JMX exporter that allows for exposing any <i>Spring-managed bean</i>
* to a JMX <code>MBeanServer</code>, without the need to define any
* JMX exporter that allows for exposing any <i>Spring-managed bean</i> to a
* JMX {@link javax.management.MBeanServer}, without the need to define any
* JMX-specific information in the bean classes.
*
* <p>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.
* <p>If a bean implements one of the JMX management interfaces, MBeanExporter can
* simply register the MBean with the server through its autodetection process.
*
* <p>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.
* <p>If a bean does not implement one of the JMX management interfaces, MBeanExporter
* will create the management information using the supplied {@link MBeanInfoAssembler}.
*
* <p>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.
* <p>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.
*
* <p>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 @@ -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 @@ -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

Loading…
Cancel
Save