|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jmx.export.MBeanExporter
public class MBeanExporter
A bean that allows for any Spring-managed bean to be exposed to a JMX
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 the bean does not implement one of the JMX management interfaces then
MBeanExporter
will create the management information using the
supplied MBeanInfoAssembler
implementation.
A list of MBeanExporterListener
s can be registered via the
listeners
property, allowing application code to be notified
of MBean registration and unregistration events.
setBeans(java.util.Map)
,
setAutodetect(boolean)
,
setAssembler(org.springframework.jmx.export.assembler.MBeanInfoAssembler)
,
setListeners(org.springframework.jmx.export.MBeanExporterListener[])
,
MBeanInfoAssembler
,
MBeanExporterListener
Field Summary | |
---|---|
protected org.apache.commons.logging.Log |
logger
Log instance for this class. |
static int |
REGISTRATION_FAIL_ON_EXISTING
Constant indicating that registration should fail when attempting to register an MBean under a name that already exists. |
static int |
REGISTRATION_IGNORE_EXISTING
Constant indicating that registration should ignore the affected MBean when attempting to register an MBean under a name that already exists. |
static int |
REGISTRATION_REPLACE_EXISTING
Constant indicating that registration should replace the affected MBean when attempting to register an MBean under a name that already exists. |
Constructor Summary | |
---|---|
MBeanExporter()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
Start bean registration automatically when deployed in an ApplicationContext . |
protected ModelMBean |
createModelMBean()
Create an instance of a class that implements ModelMBean . |
void |
destroy()
Unregisters all beans that this exported has exposed via JMX when the enclosing ApplicationContext is destroyed. |
protected void |
doRegister(Object mbean,
ObjectName objectName)
Actually registers the MBean with the server. |
protected boolean |
isBeanDefinitionLazyInit(ListableBeanFactory beanFactory,
String beanName)
Return whether the specified bean definition should be considered as lazy-init. |
protected void |
registerBeans()
Registers the defined beans with the MBeanServer . |
void |
setAssembler(MBeanInfoAssembler assembler)
Set the implementation of the MBeanInfoAssembler interface to use
for this exporter. |
void |
setAutodetect(boolean autodetect)
Set whether to autodetect MBeans in the bean factory that this exporter runs in. |
void |
setBeanFactory(BeanFactory beanFactory)
This callback is only required for resolution of bean names in the "beans" Map and for autodetection of MBeans (in the latter case,
a ListableBeanFactory is required). |
void |
setBeans(Map beans)
Supply a Map of beans to be registered with the JMX
MBeanServer . |
void |
setExcludedBeans(String[] excludedBeans)
Set the list of names for beans that should be excluded from autodetection. |
void |
setListeners(MBeanExporterListener[] listeners)
Set the MBeanExporterListener s that should be notified
of MBean registration and unregistration events. |
void |
setNamingStrategy(ObjectNamingStrategy namingStrategy)
Set the implementation of the ObjectNamingStrategy interface
to use for this exporter. |
void |
setRegistrationBehavior(int registrationBehavior)
Specify what action should be taken when attempting to register an MBean under an ObjectName that already exists. |
void |
setRegistrationBehaviorName(String registrationBehavior)
Set the registration behavior by the name of the corresponding constant, e.g. |
void |
setServer(MBeanServer server)
Specify the instance MBeanServer with which all beans should
be registered. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int REGISTRATION_FAIL_ON_EXISTING
This is the default registration behavior.
public static final int REGISTRATION_IGNORE_EXISTING
public static final int REGISTRATION_REPLACE_EXISTING
protected final org.apache.commons.logging.Log logger
Log
instance for this class.
Constructor Detail |
---|
public MBeanExporter()
Method Detail |
---|
public void setServer(MBeanServer server)
MBeanServer
with which all beans should
be registered. The MBeanExporter
will attempt to locate an
existing MBeanServer
if none is supplied.
public void setBeans(Map beans)
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 bean instances or bean names as valuessetNamingStrategy(org.springframework.jmx.export.naming.ObjectNamingStrategy)
,
KeyNamingStrategy
,
ObjectName.ObjectName(String)
public void setAutodetect(boolean autodetect)
AutodetectCapableMBeanInfoAssembler
if available.
This feature is turned off by default. Explicitly specify "true" here to enable autodetection.
setAssembler(org.springframework.jmx.export.assembler.MBeanInfoAssembler)
,
AutodetectCapableMBeanInfoAssembler
,
JmxUtils.isMBean(java.lang.Class)
public void setExcludedBeans(String[] excludedBeans)
public void setAssembler(MBeanInfoAssembler assembler)
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 particiapte in the exporter's MBean autodetection process.
SimpleReflectiveMBeanInfoAssembler
,
AutodetectCapableMBeanInfoAssembler
,
MetadataMBeanInfoAssembler
,
setAutodetect(boolean)
public void setNamingStrategy(ObjectNamingStrategy namingStrategy)
ObjectNamingStrategy
interface
to use for this exporter. Default is a KeyNamingStrategy
.
KeyNamingStrategy
,
MetadataNamingStrategy
public void setListeners(MBeanExporterListener[] listeners)
MBeanExporterListener
s that should be notified
of MBean registration and unregistration events.
MBeanExporterListener
public void setRegistrationBehaviorName(String registrationBehavior)
setRegistrationBehavior(int)
,
REGISTRATION_FAIL_ON_EXISTING
,
REGISTRATION_IGNORE_EXISTING
,
REGISTRATION_REPLACE_EXISTING
public void setRegistrationBehavior(int registrationBehavior)
ObjectName
that already exists.
Default is REGISTRATION_FAIL_ON_EXISTING.
setRegistrationBehaviorName(String)
,
REGISTRATION_FAIL_ON_EXISTING
,
REGISTRATION_IGNORE_EXISTING
,
REGISTRATION_REPLACE_EXISTING
public void setBeanFactory(BeanFactory beanFactory)
Map
and for autodetection of MBeans (in the latter case,
a ListableBeanFactory
is required).
setBeanFactory
in interface BeanFactoryAware
beanFactory
- owning BeanFactory (may not be null
).
The bean can immediately call methods on the factory.setBeans(java.util.Map)
,
setAutodetect(boolean)
,
ListableBeanFactory
public void afterPropertiesSet() throws JMException
ApplicationContext
.
afterPropertiesSet
in interface InitializingBean
JMException
registerBeans()
protected void registerBeans() throws JMException
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.
JMException
protected void doRegister(Object mbean, ObjectName objectName) throws JMException
setRegistrationBehavior(int)
and setRegistrationBehaviorName(String)
methods.
JMException
protected boolean isBeanDefinitionLazyInit(ListableBeanFactory beanFactory, String beanName)
beanFactory
- the bean factory that is supposed to contain the bean definitionbeanName
- the name of the bean to checkConfigurableListableBeanFactory.getBeanDefinition(java.lang.String)
,
BeanDefinition.isLazyInit()
protected ModelMBean createModelMBean() throws MBeanException
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 failedpublic void destroy()
ApplicationContext
is destroyed.
destroy
in interface DisposableBean
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |