类 MBeanRegistrationSupport
- java.lang.Object
- org.springframework.jmx.support.MBeanRegistrationSupport
public class MBeanRegistrationSupport extends Object
Provides supporting infrastructure for registering MBeans with anMBeanServer
. The behavior when encountering an existing MBean at a givenObjectName
is fully configurable allowing for flexible registration settings.All registered MBeans are tracked and can be unregistered by calling the #
unregisterBeans()
method.Sub-classes can receive notifications when an MBean is registered or unregistered by overriding the
onRegister(ObjectName)
andonUnregister(ObjectName)
methods respectively.By default, the registration process will fail if attempting to register an MBean using a
ObjectName
that is already used.By setting the
registrationPolicy
property toRegistrationPolicy.IGNORE_EXISTING
the registration process will simply ignore existing MBeans leaving them registered. This is useful in settings where multiple applications want to share a common MBean in a sharedMBeanServer
.Setting
registrationPolicy
property toRegistrationPolicy.REPLACE_EXISTING
will cause existing MBeans to be replaced during registration if necessary. This is useful in situations where you can't guarantee the state of yourMBeanServer
.- 从以下版本开始:
- 2.0
- 作者:
- Rob Harrop, Juergen Hoeller, Phillip Webb
- 另请参阅:
setServer(javax.management.MBeanServer)
,setRegistrationPolicy(org.springframework.jmx.support.RegistrationPolicy)
,MBeanExporter
字段概要
字段 修饰符和类型 字段 说明 protected Log
logger
Log
instance for this class.static int
REGISTRATION_FAIL_ON_EXISTING
已过时。since Spring 3.2, in favor ofRegistrationPolicy.FAIL_ON_EXISTING
static int
REGISTRATION_IGNORE_EXISTING
已过时。since Spring 3.2, in favor ofRegistrationPolicy.IGNORE_EXISTING
static int
REGISTRATION_REPLACE_EXISTING
已过时。since Spring 3.2, in favor ofRegistrationPolicy.REPLACE_EXISTING
protected MBeanServer
server
TheMBeanServer
instance being used to register beans.
构造器概要
构造器 构造器 说明 MBeanRegistrationSupport()
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 protected void
doRegister(Object mbean, ObjectName objectName)
Actually register the MBean with the server.protected void
doUnregister(ObjectName objectName)
Actually unregister the specified MBean from the server.protected ObjectName[]
getRegisteredObjectNames()
Return theObjectNames
of all registered beans.MBeanServer
getServer()
Return theMBeanServer
that the beans will be registered with.protected void
onRegister(ObjectName objectName)
Called when an MBean is registered under the givenObjectName
.protected void
onRegister(ObjectName objectName, Object mbean)
Called when an MBean is registered under the givenObjectName
.protected void
onUnregister(ObjectName objectName)
Called when an MBean is unregistered under the givenObjectName
.void
setRegistrationBehavior(int registrationBehavior)
已过时。since Spring 3.2, in favor ofsetRegistrationPolicy(RegistrationPolicy)
void
setRegistrationBehaviorName(String registrationBehavior)
已过时。since Spring 3.2, in favor ofsetRegistrationPolicy(RegistrationPolicy)
void
setRegistrationPolicy(RegistrationPolicy registrationPolicy)
The policy to use when attempting to register an MBean under anObjectName
that already exists.void
setServer(MBeanServer server)
Specify theMBeanServer
instance with which all beans should be registered.protected void
unregisterBeans()
Unregisters all beans that have been registered by an instance of this class.
字段详细资料
REGISTRATION_FAIL_ON_EXISTING
@Deprecated public static final int REGISTRATION_FAIL_ON_EXISTING
已过时。since Spring 3.2, in favor ofRegistrationPolicy.FAIL_ON_EXISTING
Constant indicating that registration should fail when attempting to register an MBean under a name that already exists.This is the default registration behavior.
- 另请参阅:
- 常量字段值
REGISTRATION_IGNORE_EXISTING
@Deprecated public static final int REGISTRATION_IGNORE_EXISTING
已过时。since Spring 3.2, in favor ofRegistrationPolicy.IGNORE_EXISTING
Constant indicating that registration should ignore the affected MBean when attempting to register an MBean under a name that already exists.- 另请参阅:
- 常量字段值
REGISTRATION_REPLACE_EXISTING
@Deprecated public static final int REGISTRATION_REPLACE_EXISTING
已过时。since Spring 3.2, in favor ofRegistrationPolicy.REPLACE_EXISTING
Constant indicating that registration should replace the affected MBean when attempting to register an MBean under a name that already exists.- 另请参阅:
- 常量字段值
server
protected MBeanServer server
TheMBeanServer
instance being used to register beans.
构造器详细资料
MBeanRegistrationSupport
public MBeanRegistrationSupport()
方法详细资料
setServer
public void setServer(MBeanServer server)
Specify theMBeanServer
instance with which all beans should be registered. TheMBeanExporter
will attempt to locate an existingMBeanServer
if none is supplied.
getServer
public final MBeanServer getServer()
Return theMBeanServer
that the beans will be registered with.
setRegistrationBehaviorName
@Deprecated public void setRegistrationBehaviorName(String registrationBehavior)
已过时。since Spring 3.2, in favor ofsetRegistrationPolicy(RegistrationPolicy)
Set the registration behavior by the name of the corresponding constant, e.g. "REGISTRATION_IGNORE_EXISTING".
setRegistrationBehavior
@Deprecated public void setRegistrationBehavior(int registrationBehavior)
已过时。since Spring 3.2, in favor ofsetRegistrationPolicy(RegistrationPolicy)
Specify what action should be taken when attempting to register an MBean under anObjectName
that already exists.Default is REGISTRATION_FAIL_ON_EXISTING.
setRegistrationPolicy
public void setRegistrationPolicy(RegistrationPolicy registrationPolicy)
The policy to use when attempting to register an MBean under anObjectName
that already exists.- 参数:
registrationPolicy
- the policy to use- 从以下版本开始:
- 3.2
doRegister
protected void doRegister(Object mbean, ObjectName objectName) throws JMException
Actually register the MBean with the server. The behavior when encountering an existing MBean can be configured using thesetRegistrationBehavior(int)
andsetRegistrationBehaviorName(String)
methods.- 参数:
mbean
- the MBean instanceobjectName
- the suggested ObjectName for the MBean- 抛出:
JMException
- if the registration failed
unregisterBeans
protected void unregisterBeans()
Unregisters all beans that have been registered by an instance of this class.
doUnregister
protected void doUnregister(ObjectName objectName)
Actually unregister the specified MBean from the server.- 参数:
objectName
- the suggested ObjectName for the MBean
getRegisteredObjectNames
protected final ObjectName[] getRegisteredObjectNames()
Return theObjectNames
of all registered beans.
onRegister
protected void onRegister(ObjectName objectName, Object mbean)
Called when an MBean is registered under the givenObjectName
. Allows subclasses to perform additional processing when an MBean is registered.The default implementation delegates to
onRegister(ObjectName)
.- 参数:
objectName
- the actualObjectName
that the MBean was registered withmbean
- the registered MBean instance
onRegister
protected void onRegister(ObjectName objectName)
Called when an MBean is registered under the givenObjectName
. Allows subclasses to perform additional processing when an MBean is registered.The default implementation is empty. Can be overridden in subclasses.
- 参数:
objectName
- the actualObjectName
that the MBean was registered with
onUnregister
protected void onUnregister(ObjectName objectName)
Called when an MBean is unregistered under the givenObjectName
. Allows subclasses to perform additional processing when an MBean is unregistered.The default implementation is empty. Can be overridden in subclasses.
- 参数:
objectName
- theObjectName
that the MBean was registered with