java.lang.Object | ||
↳ | org.springframework.jmx.support.MBeanRegistrationSupport | |
↳ | org.springframework.jmx.export.MBeanExporter |
Known Direct Subclasses |
JMX exporter that allows for exposing any Spring-managed bean to a JMX javax.management.MBeanServer, without the need to define any JMX-specific information in the bean classes.
If a bean implements one of the JMX management interfaces, MBeanExporter can simply register the MBean with the server through its autodetection process.
If a bean does not implement one of the JMX management interfaces, MBeanExporter
will create the management information using the supplied MBeanInfoAssembler
.
A list of MBeanExporterListeners
can be registered
via the 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.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | AUTODETECT_ALL | Autodetection mode indicating that all autodetection mechanisms should be used. | |||||||||
int | AUTODETECT_ASSEMBLER | Autodetection mode indicating that only the MBeanInfoAssembler should be able
to autodetect beans. |
|||||||||
int | AUTODETECT_MBEAN | Autodetection mode indicating that only valid MBeans should be autodetected. | |||||||||
int | AUTODETECT_NONE | Autodetection mode indicating that no autodetection should be used. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.jmx.support.MBeanRegistrationSupport
|
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.jmx.support.MBeanRegistrationSupport
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Start bean registration automatically when deployed in an
ApplicationContext . | |||||||||||
Unregisters all beans that this exported has exposed via JMX
when the enclosing
ApplicationContext is destroyed. | |||||||||||
Register the supplied resource with JMX.
| |||||||||||
Register the supplied resource with JMX.
| |||||||||||
Specify whether to allow eager initialization of candidate beans
when autodetecting MBeans in the Spring application context.
| |||||||||||
Set the implementation of the
MBeanInfoAssembler interface to use
for this exporter. | |||||||||||
Set whether to autodetect MBeans in the bean factory that this exporter
runs in.
| |||||||||||
Set the autodetection mode to use.
| |||||||||||
Set the autodetection mode to use by name.
| |||||||||||
Callback that supplies the bean
class loader to
a bean instance. | |||||||||||
Supply a
Map of beans to be registered with the JMX
MBeanServer . | |||||||||||
Indicates whether Spring should ensure that
ObjectNames
generated by the configured ObjectNamingStrategy for
runtime-registered MBeans (registerManagedResource(Object) ) should get
modified: to ensure uniqueness for every instance of a managed Class . | |||||||||||
Set the list of names for beans that should be excluded from autodetection.
| |||||||||||
Indicates whether or not the managed resource should be exposed on the
thread context ClassLoader before
allowing any invocations on the MBean to occur. | |||||||||||
Set the
MBeanExporterListener s that should be notified
of MBean registration and unregistration events. | |||||||||||
Set the implementation of the
ObjectNamingStrategy interface
to use for this exporter. | |||||||||||
Set the
NotificationListeners to register
with the javax.management.MBeanServer. | |||||||||||
Set the
NotificationListenerBeans
containing the
NotificationListeners
that will be registered with the MBeanServer. | |||||||||||
Remove the specified MBean from the underlying MBeanServer registry.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Build an adapted MBean for the given bean instance, if possible.
| |||||||||||
Creates an MBean that is configured with the appropriate management
interface for the supplied managed resource.
| |||||||||||
Create an instance of a class that implements
ModelMBean . | |||||||||||
Retrieve the
ObjectName for a bean. | |||||||||||
Return whether the specified bean definition should be considered as lazy-init.
| |||||||||||
Determine whether the given bean class qualifies as an MBean as-is.
| |||||||||||
Called when an MBean is registered.
| |||||||||||
Called when an MBean is unregistered.
| |||||||||||
Registers an individual bean with the
MBeanServer . | |||||||||||
Registers the defined beans with the MBeanServer.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.jmx.support.MBeanRegistrationSupport
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.BeanClassLoaderAware
| |||||||||||
From interface
org.springframework.beans.factory.BeanFactoryAware
| |||||||||||
From interface
org.springframework.beans.factory.DisposableBean
| |||||||||||
From interface
org.springframework.beans.factory.InitializingBean
| |||||||||||
From interface
org.springframework.jmx.export.MBeanExportOperations
|
Autodetection mode indicating that all autodetection mechanisms should be used.
Autodetection mode indicating that only the MBeanInfoAssembler
should be able
to autodetect beans.
Autodetection mode indicating that only valid MBeans should be autodetected.
Autodetection mode indicating that no autodetection should be used.
Start bean registration automatically when deployed in an
ApplicationContext
.
Unregisters all beans that this exported has exposed via JMX
when the enclosing ApplicationContext
is destroyed.
Register the supplied resource with JMX. If the resource is not a valid MBean already,
Spring will generate a management interface for it. The exact interface generated will
depend on the implementation and its configuration. This call also generates an
ObjectName
for the managed resource and returns this to the caller.
managedResource | the resource to expose via JMX |
---|
ObjectName
under which the resource was exposedMBeanExportException |
---|
Register the supplied resource with JMX. If the resource is not a valid MBean already, Spring will generate a management interface for it. The exact interface generated will depend on the implementation and its configuration.
managedResource | the resource to expose via JMX |
---|---|
objectName | the ObjectName under which to expose the resource |
MBeanExportException |
---|
Specify whether to allow eager initialization of candidate beans when autodetecting MBeans in the Spring application context.
Default is "false", respecting lazy-init flags on bean definitions. Switch this to "true" in order to search lazy-init beans as well, including FactoryBean-produced objects that haven't been initialized yet.
Set the implementation of the MBeanInfoAssembler
interface to use
for this exporter. Default is a SimpleReflectiveMBeanInfoAssembler
.
The passed-in assembler can optionally implement the
AutodetectCapableMBeanInfoAssembler
interface, which enables it
to participate in the exporter's MBean autodetection process.
Set whether to autodetect MBeans in the bean factory that this exporter
runs in. Will also ask an AutodetectCapableMBeanInfoAssembler
if available.
This feature is turned off by default. Explicitly specify
true
here to enable autodetection.
Set the autodetection mode to use.
IllegalArgumentException | if the supplied value is not
one of the AUTODETECT_ constants |
---|
Set the autodetection mode to use by name.
IllegalArgumentException | if the supplied value is not resolvable
to one of the AUTODETECT_ constants or is null |
---|
Callback that supplies the bean class loader
to
a bean instance.
Invoked after the population of normal bean properties but
before an initialization callback such as
InitializingBean's
afterPropertiesSet()
method or a custom init-method.
classLoader | the owning class loader; may be null in
which case a default ClassLoader must be used, for example
the ClassLoader obtained via
getDefaultClassLoader()
|
---|
Supply a Map
of beans to be registered with the JMX
MBeanServer
.
The String keys are the basis for the creation of JMX object names.
By default, a JMX ObjectName
will be created straight
from the given key. This can be customized through specifying a
custom NamingStrategy
.
Both bean instances and bean names are allowed as values. Bean instances are typically linked in through bean references. Bean names will be resolved as beans in the current factory, respecting lazy-init markers (that is, not triggering initialization of such beans).
beans | Map with JMX names as keys and bean instances or bean names as values |
---|
Indicates whether Spring should ensure that ObjectNames
generated by the configured ObjectNamingStrategy
for
runtime-registered MBeans (registerManagedResource(Object)
) should get
modified: to ensure uniqueness for every instance of a managed Class
.
The default value is true
.
Set the list of names for beans that should be excluded from autodetection.
Indicates whether or not the managed resource should be exposed on the
thread context ClassLoader
before
allowing any invocations on the MBean to occur.
The default value is true
, exposing a SpringModelMBean
which performs thread context ClassLoader management. Switch this flag off to
expose a standard JMX javax.management.modelmbean.RequiredModelMBean.
Set the MBeanExporterListener
s that should be notified
of MBean registration and unregistration events.
Set the implementation of the ObjectNamingStrategy
interface
to use for this exporter. Default is a KeyNamingStrategy
.
Set the NotificationListeners
to register
with the javax.management.MBeanServer.
The key of each entry in the Map
is a String
representation of the ObjectName
or the bean
name of the MBean the listener should be registered for. Specifying an
asterisk (*
) for a key will cause the listener to be
associated with all MBeans registered by this class at startup time.
The value of each entry is the
NotificationListener
to register. For more
advanced options such as registering
NotificationFilters
and
handback objects see setNotificationListeners(NotificationListenerBean[])
.
Set the NotificationListenerBeans
containing the
NotificationListeners
that will be registered with the MBeanServer.
Remove the specified MBean from the underlying MBeanServer registry.
objectName | the ObjectName of the resource to remove
|
---|
Build an adapted MBean for the given bean instance, if possible.
The default implementation builds a JMX 1.2 StandardMBean for the target's MBean/MXBean interface in case of an AOP proxy, delegating the interface's management operations to the proxy.
bean | the original bean instance |
---|
null
if not possible
JMException |
---|
Creates an MBean that is configured with the appropriate management interface for the supplied managed resource.
managedResource | the resource that is to be exported as an MBean |
---|---|
beanKey | the key associated with the managed bean |
MBeanExportException |
---|
createModelMBean()
Create an instance of a class that implements ModelMBean
.
This method is called to obtain a ModelMBean
instance to
use when registering a bean. This method is called once per bean during the
registration phase and must return a new instance of ModelMBean
ModelMBean
MBeanException | if creation of the ModelMBean failed |
---|
Retrieve the ObjectName
for a bean.
If the bean implements the SelfNaming
interface, then the
ObjectName
will be retrieved using SelfNaming.getObjectName()
.
Otherwise, the configured ObjectNamingStrategy
is used.
bean | the name of the bean in the BeanFactory |
---|---|
beanKey | the key associated with the bean in the beans map |
ObjectName
for the supplied beanMalformedObjectNameException | if the retrieved ObjectName is malformed
|
---|
Return whether the specified bean definition should be considered as lazy-init.
beanFactory | the bean factory that is supposed to contain the bean definition |
---|---|
beanName | the name of the bean to check |
Determine whether the given bean class qualifies as an MBean as-is.
The default implementation delegates to isMBean(Class>)
,
which checks for DynamicMBean
classes as well
as classes with corresponding "*MBean" interface (Standard MBeans)
or corresponding "*MXBean" interface (Java 6 MXBeans).
beanClass | the bean class to analyze |
---|
Called when an MBean is registered. Notifies all registered
MBeanExporterListeners
of the registration event.
Please note that if an MBeanExporterListener
throws a (runtime)
exception when notified, this will essentially interrupt the notification process
and any remaining listeners that have yet to be notified will not (obviously)
receive the mbeanRegistered(javax.management.ObjectName)
callback.
objectName | the ObjectName of the registered MBean
|
---|
Called when an MBean is unregistered. Notifies all registered
MBeanExporterListeners
of the unregistration event.
Please note that if an MBeanExporterListener
throws a (runtime)
exception when notified, this will essentially interrupt the notification process
and any remaining listeners that have yet to be notified will not (obviously)
receive the mbeanUnregistered(javax.management.ObjectName)
callback.
objectName | the ObjectName of the unregistered MBean
|
---|
Registers an individual bean with the MBeanServer
.
This method is responsible for deciding how a bean
should be exposed to the MBeanServer
. Specifically, if the
supplied mapValue
is the name of a bean that is configured
for lazy initialization, then a proxy to the resource is registered with
the MBeanServer
so that the the lazy load behavior is
honored. If the bean is already an MBean then it will be registered
directly with the MBeanServer
without any intervention. For
all other beans or bean names, the resource itself is registered with
the MBeanServer
directly.
mapValue | the value configured for this bean in the beans map;
may be either the String name of a bean, or the bean itself |
---|---|
beanKey | the key associated with this bean in the beans map |
ObjectName
under which the resource was registeredMBeanExportException | if the export failed |
---|
setBeans(Map)
Registers the defined beans with the MBeanServer.
Each bean is exposed to the MBeanServer
via a
ModelMBean
. The actual implemetation of the
ModelMBean
interface used depends on the implementation of
the ModelMBeanProvider
interface that is configured. By
default the RequiredModelMBean
class that is supplied with
all JMX implementations is used.
The management interface produced for each bean is dependent on the
MBeanInfoAssembler
implementation being used. The
ObjectName
given to each bean is dependent on the
implementation of the ObjectNamingStrategy
interface being used.