added "unregisterManagedResource" method to MBeanExporter/MBeanExportOperations (SPR-5517)
This commit is contained in:
parent
5885c703f2
commit
aa8bd6313b
|
|
@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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;
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,23 +66,19 @@ import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JMX exporter that allows for exposing any <i>Spring-managed bean</i>
|
* JMX exporter that allows for exposing any <i>Spring-managed bean</i> to a
|
||||||
* to a JMX <code>MBeanServer</code>, without the need to define any
|
* JMX {@link javax.management.MBeanServer}, without the need to define any
|
||||||
* JMX-specific information in the bean classes.
|
* JMX-specific information in the bean classes.
|
||||||
*
|
*
|
||||||
* <p>If the bean implements one of the JMX management interfaces,
|
* <p>If a bean implements one of the JMX management interfaces, MBeanExporter can
|
||||||
* then MBeanExporter can simply register the MBean with the server
|
* simply register the MBean with the server through its autodetection process.
|
||||||
* automatically, through its autodetection process.
|
|
||||||
*
|
*
|
||||||
* <p>If the bean does not implement one of the JMX management interfaces,
|
* <p>If a bean does not implement one of the JMX management interfaces, MBeanExporter
|
||||||
* then MBeanExporter will create the management information using the
|
* will create the management information using the supplied {@link MBeanInfoAssembler}.
|
||||||
* supplied {@link MBeanInfoAssembler} implementation.
|
|
||||||
*
|
*
|
||||||
* <p>A list of {@link MBeanExporterListener MBeanExporterListeners}
|
* <p>A list of {@link MBeanExporterListener MBeanExporterListeners} can be registered
|
||||||
* can be registered via the
|
* via the {@link #setListeners(MBeanExporterListener[]) listeners} property, allowing
|
||||||
* {@link #setListeners(MBeanExporterListener[]) listeners} property,
|
* application code to be notified of MBean registration and unregistration events.
|
||||||
* 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.
|
* <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.
|
* 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 {
|
public ObjectName registerManagedResource(Object managedResource) throws MBeanExportException {
|
||||||
Assert.notNull(managedResource, "Managed resource must not be null");
|
Assert.notNull(managedResource, "Managed resource must not be null");
|
||||||
ObjectName objectName = null;
|
ObjectName objectName;
|
||||||
try {
|
try {
|
||||||
objectName = getObjectName(managedResource, null);
|
objectName = getObjectName(managedResource, null);
|
||||||
if (this.ensureUniqueRuntimeObjectNames) {
|
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
|
// Exporter implementation
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue