public class StandardMBean extends Object implements DynamicMBean, MBeanRegistration
MBean的管理界面是通过一个java界面反射测定。
这类在标准MBean管理使用接口的概念带来了更大的灵活性。该模式为标准MBean在JMX规范描述简单的使用意味着一个MBean及其管理接口的实现类之间有固定的关系(即,如果实现类的东西,管理界面必须thingmbean)。这个类可以使指定的管理接口与java接口的便利,而不需要有任何命名关系和接口类的实现。
通过dynamicmbean从MBean,这个类可以选择任何接口实现通过MBean的管理界面,提供符合JMX模式(即属性的getter和setter等..)。
该类还提供了挂钩,使人们有可能为MBeanInfo提供自定义的描述和名字的dynamicmbean接口返回。
使用这个类,MBean可以与任何实现类的名字实现与管理接口定义了(如电流标准MBean)通过任何接口intF、一种一般方法:
StandardMBean(impl,interface):MBeanServer MBS;…实现实现=新计划(…);standardmbean MBean =新standardmbean(实现,Intf.class,假);住房抵押贷款证券化。registermbean(MBean,对象);
公共课实施延伸standardmbean实现INTF {公共impl() {超(Intf.class,假);}/ /实施方法INTF}[…]MBeanServer MBS;的…实现实现=新impl();住房抵押贷款证券化。registermbean(实现、对象);在任何情况下,该类必须实现的接口实现INTF。
基于命名关系实现接口的类之间的标准MBean当然仍可用。
这个类也可以被用来构建mxbeans。使用完全相同的标准MBean除了在以上的例子中,该false参数的构造函数或super(...)调用而不是true。
| Modifier | Constructor and Description |
|---|---|
protected |
StandardMBean(类<?> mbeanInterface)
从
这使dynamicmbean,使用指定的
mbeaninterface类。
|
protected |
StandardMBean(类<?> mbeanInterface, boolean isMXBean)
从
这使dynamicmbean,使用指定的
mbeaninterface类,并选择是否产生的MBean的MXBean。
|
|
StandardMBean(T implementation, 类<T> mbeanInterface)
从对象
实施使dynamicmbean,使用指定的
mbeaninterface类。
|
|
StandardMBean(T implementation, 类<T> mbeanInterface, boolean isMXBean)
从对象
实施使dynamicmbean,使用指定的
mbeaninterface类,并选择是否产生MBean是MXBean。
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
cacheMBeanInfo(MBeanInfo info)
定制钩子:缓存mbeaninfo建立该对象。
|
Object |
getAttribute(String attribute)
得到的动态MBean的特定属性的值。
|
AttributeList |
getAttributes(String[] attributes)
得到的动态MBean的几个属性的值。
|
protected MBeanInfo |
getCachedMBeanInfo()
定制钩子:返回mbeaninfo缓存该对象。
|
protected String |
getClassName(MBeanInfo info)
定制钩子:得到类名,将用于mbeaninfo这个MBean返回。
|
protected MBeanConstructorInfo[] |
getConstructors(MBeanConstructorInfo[] ctors, Object impl)
定制钩子:得到mbeanconstructorinfo [ ],将用于mbeaninfo这个MBean返回。
|
protected String |
getDescription(MBeanAttributeInfo info)
定制钩子:获得描述,将用于mbeanattributeinfo这个MBean返回。
|
protected String |
getDescription(MBeanConstructorInfo info)
定制钩子:获得描述,将用于mbeanconstructorinfo这个MBean返回。
|
protected String |
getDescription(MBeanConstructorInfo ctor, MBeanParameterInfo param, int sequence)
定制钩子:获得描述,将用于对mbeanconstructorinfo的
序列 mbeanparameterinfo这个MBean返回。
|
protected String |
getDescription(MBeanFeatureInfo info)
定制钩子:获得描述,将用于mbeanfeatureinfo这个MBean返回。
|
protected String |
getDescription(MBeanInfo info)
定制钩子:获得描述,将用于mbeaninfo这个MBean返回。
|
protected String |
getDescription(MBeanOperationInfo info)
定制钩子:获得描述,将用于mbeanoperationinfo这个MBean返回。
|
protected String |
getDescription(MBeanOperationInfo op, MBeanParameterInfo param, int sequence)
定制钩子:获得描述,将用于对mbeanoperationinfo的
序列 mbeanparameterinfo这个MBean返回。
|
protected int |
getImpact(MBeanOperationInfo info)
定制钩子:获得操作,将用于mbeanoperationinfo的
影响旗的MBean返回。
|
Object |
getImplementation()
得到这个标准MBean实现(或MXBean)。
|
类<?> |
getImplementationClass()
获得本标准MBean实现类(或MXBean)。
|
MBeanInfo |
getMBeanInfo()
得到
MBeanInfo这个MBean。
|
类<?> |
getMBeanInterface()
得到这个标准MBean管理界面(或MXBean)。
|
protected String |
getParameterName(MBeanConstructorInfo ctor, MBeanParameterInfo param, int sequence)
定制钩子:获取名称,将用于对mbeanconstructorinfo的
序列 mbeanparameterinfo这个MBean返回。
|
protected String |
getParameterName(MBeanOperationInfo op, MBeanParameterInfo param, int sequence)
定制钩子:获取名称,将用于对mbeanoperationinfo的
序列 mbeanparameterinfo这个MBean返回。
|
Object |
invoke(String actionName, Object[] params, String[] signature)
让一个动作被调用的动态MBean。
|
void |
postDeregister()
允许MBean执行任何操作在MBean服务器被注册后需要。
|
void |
postRegister(Boolean registrationDone)
允许MBean执行任何操作在MBean服务器或注册后不需要注册后。
|
void |
preDeregister()
允许MBean执行任何需要的操作之前被注册的MBean服务器。
|
ObjectName |
preRegister(MBeanServer server, ObjectName name)
允许MBean执行任何操作之前,它需要在MBean服务器注册。
|
void |
setAttribute(Attribute attribute)
整套动态MBean的特定属性的值。
|
AttributeList |
setAttributes(AttributeList attributes)
设置动态MBean的几个属性的值。
|
void |
setImplementation(Object implementation)
替换在这个对象中包的实现对象。
|
public StandardMBean(T implementation,
类<T> mbeanInterface)
throws NotCompliantMBeanException
从对象实施使dynamicmbean,使用指定的mbeaninterface类。
T -允许编译器检查
implementation确实实现了
mbeanInterface类。编译器只能在
mbeanInterface是一类文字如
MyMBean.class检查。
implementation -这个MBean实现。
mbeanInterface -管理界面通过MBean实现出口。如果
null,那么这个对象将使用标准的JMX设计模式来确定与实施相关的管理界面。
IllegalArgumentException -如果给定的
实施是空的。
NotCompliantMBeanException -如果
mbeaninterface不遵循JMX管理接口的设计模式,或者给
实施没有实现指定的接口。
protected StandardMBean(类<?> mbeanInterface) throws NotCompliantMBeanException
从这使dynamicmbean,使用指定的mbeaninterface类。
电话this(this,mbeanInterface)。此构造函数保留给子类。
mbeanInterface -管理界面的MBean的出口。
NotCompliantMBeanException -如果
mbeaninterface不遵循JMX管理接口的设计模式,或者如果
这没有实现指定的接口。
public StandardMBean(T implementation,
类<T> mbeanInterface,
boolean isMXBean)
从对象实施使dynamicmbean,使用指定的mbeaninterface类,并选择是否产生MBean是MXBean。此构造函数可以用来做标准MBean或mxbeans。与构造函数StandardMBean(Object, Class),它不把notcompliantmbeanexception。
T -允许编译器检查
implementation确实实现了
mbeanInterface类。编译器只能在
mbeanInterface是一类文字如
MyMBean.class检查。
implementation -这个MBean实现。
mbeanInterface -管理界面通过MBean实现出口。如果
null,那么这个对象将使用标准的JMX设计模式来确定与实施相关的管理界面。
isMXBean -如果真的
mbeanInterface参数名称的MXBean接口和所得的MBean的MXBean。
IllegalArgumentException -如果给定的
实施是无效的,或者如果
mbeaninterface不遵循JMX管理接口的设计模式,或者给
实施没有实现指定的接口。
protected StandardMBean(类<?> mbeanInterface, boolean isMXBean)
从这使dynamicmbean,使用指定的mbeaninterface类,并选择是否产生的MBean的MXBean。此构造函数可以用来做标准MBean或mxbeans。与构造函数StandardMBean(Object, Class),它不把notcompliantmbeanexception。
调用此构造函数this(this, mbeanInterface, isMXBean)保留到子类。
mbeanInterface -管理界面的MBean的出口。
isMXBean -如果真的
mbeanInterface参数名称的MXBean接口和所得的MBean的MXBean。
IllegalArgumentException -如果
mbeaninterface不遵循JMX管理接口的设计模式,或者如果
这没有实现指定的接口。
public void setImplementation(Object implementation) throws NotCompliantMBeanException
替换在这个对象中包的实现对象。
implementation -本标准MBean新的实现(或MXBean)。的
implementation对象必须实现标准MBean(或MXBean)接口,提供了在这
StandardMBean。
IllegalArgumentException -如果给定的
实施是空的。
NotCompliantMBeanException -如果给定的
实施不执行标准MBean(或MXBean)接口,提供施工。
getImplementation()
public Object getImplementation()
setImplementation(java.lang.Object)
public final 类<?> getMBeanInterface()
public 类<?> getImplementationClass()
public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException
DynamicMBean
getAttribute 接口
DynamicMBean
attribute -属性的名称进行检索
AttributeNotFoundException
MBeanException -包装
java.lang.Exception通过MBean的吸气剂扔。
ReflectionException -包装
java.lang.Exception扔在试图调用getter。
DynamicMBean.setAttribute(javax.management.Attribute)
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
DynamicMBean
setAttribute 接口
DynamicMBean
attribute -属性要设置的识别和可设置的值。
AttributeNotFoundException
InvalidAttributeValueException
MBeanException -包装
java.lang.Exception通过MBean的setter抛出。
ReflectionException -包装
java.lang.Exception扔在试图调用MBean的二传手。
DynamicMBean.getAttribute(java.lang.String)
public AttributeList getAttributes(String[] attributes)
DynamicMBean
getAttributes 接口
DynamicMBean
attributes -目录的属性进行检索。
DynamicMBean.setAttributes(javax.management.AttributeList)
public AttributeList setAttributes(AttributeList attributes)
DynamicMBean
setAttributes 接口
DynamicMBean
attributes -目录属性:属性的识别是集和它们的值被设置为。
DynamicMBean.getAttributes(java.lang.String[])
public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, ReflectionException
DynamicMBean
invoke 接口
DynamicMBean
actionName -名字的动作被调用。
params -一个数组包含的参数需要设置,当调用动作。
signature -一个数组包含行动的签名。类的对象将通过同一个类加载器加载的一个用于装载MBean的动作被调用。
MBeanException -包装
java.lang.Exception通过MBean的方法被调用。
ReflectionException -包装
java.lang.Exception扔在试图调用的方法
public MBeanInfo getMBeanInfo()
MBeanInfo。
该方法实现了DynamicMBean.getMBeanInfo()。
该方法首先调用getCachedMBeanInfo()为了检索缓存的mbeaninfo这MBean,如果任何。如果mbeaninfo返回getCachedMBeanInfo()不为空,则returned.
否则,此方法建立的这个MBean默认mbeaninfo,使用这个MBean指定的管理界面。
在MBeanInfo,这个方法调用,使得子类来提供自定义的描述,定制钩子的参数名称,等等。
最后,它要求cacheMBeanInfo()为了缓存新mbeaninfo。
getMBeanInfo 接口
DynamicMBean
protected String getClassName(MBeanInfo info)
info.getClassName()。
info衍生的默认mbeaninfo反射。
protected String getDescription(MBeanInfo info)
info.getDescription()。
info衍生的默认mbeaninfo反射。
protected String getDescription(MBeanFeatureInfo info)
定制钩子:获得描述,将用于mbeanfeatureinfo这个MBean返回。
子类可以重新定义此方法,以提供他们的自定义描述。默认的实现返回info.getDescription()。
这种方法被称为getDescription(MBeanAttributeInfo),getDescription(MBeanOperationInfo),getDescription(MBeanConstructorInfo)。
info衍生的默认mbeanfeatureinfo反射。
protected String getDescription(MBeanAttributeInfo info)
子类可以重新定义此方法,以提供他们的自定义描述。默认的实现返回getDescription((MBeanFeatureInfo) info)。
info衍生的默认mbeanattributeinfo反射。
protected String getDescription(MBeanConstructorInfo info)
getDescription((MBeanFeatureInfo) info)。
info衍生的默认mbeanconstructorinfo反射。
protected String getDescription(MBeanConstructorInfo ctor, MBeanParameterInfo param, int sequence)
param.getDescription()。
ctor衍生的默认mbeanconstructorinfo反射。
param衍生的默认mbeanparameterinfo反射。
sequence的序列数的参数是(“0”为第一个参数,“1”的第二参数,等等)。
protected String getParameterName(MBeanConstructorInfo ctor, MBeanParameterInfo param, int sequence)
param.getName()。
ctor衍生的默认mbeanconstructorinfo反射。
param衍生的默认mbeanparameterinfo反射。
sequence的序列数的参数是(“0”为第一个参数,“1”的第二参数,等等)。
protected String getDescription(MBeanOperationInfo info)
getDescription((MBeanFeatureInfo) info)。
info衍生的默认mbeanoperationinfo反射。
protected int getImpact(MBeanOperationInfo info)
info.getImpact()。
info衍生的默认mbeanoperationinfo反射。
protected String getParameterName(MBeanOperationInfo op, MBeanParameterInfo param, int sequence)
param.getName()。
op衍生的默认mbeanoperationinfo反射。
param衍生的默认mbeanparameterinfo反射。
sequence的序列数的参数是(“0”为第一个参数,“1”的第二参数,等等)。
protected String getDescription(MBeanOperationInfo op, MBeanParameterInfo param, int sequence)
param.getDescription()。
op衍生的默认mbeanoperationinfo反射。
param衍生的默认mbeanparameterinfo反射。
sequence的序列数的参数是(“0”为第一个参数,“1”的第二参数,等等)。
protected MBeanConstructorInfo[] getConstructors(MBeanConstructorInfo[] ctors, Object impl)
null如果包执行不
这。的确,如果包实现这不是对象本身,它不可能通过调用构造函数通过实施
MBeanServer.createMBean(...)包裹实施重建。
ctors -默认mbeanconstructorinfo [ ]由反射。
impl -包装的实施。如果
null通过包装实现被忽视,
因素返回。
protected MBeanInfo getCachedMBeanInfo()
子类可以重新定义此方法,以实现自己的缓存策略。默认实现门店每一MBeanInfo对象实例。
cacheMBeanInfo(MBeanInfo)
protected void cacheMBeanInfo(MBeanInfo info)
子类可以重新定义此方法,以实现自己的缓存策略。在这种情况下的默认实现门店info。子类可以定义其他的政策,如不节约info(所以它是重建的每一次getMBeanInfo()叫做)或共享一个独特的MBeanInfo对象时,几StandardMBean实例MBeanInfo值相等。
info -缓存新
MBeanInfo。任何先前缓存的值都被丢弃。这个参数可能是空的,在这种情况下,没有新的缓存值。
public ObjectName preRegister(MBeanServer server, ObjectName name) throws 异常
允许MBean执行任何操作之前,它需要在MBean服务器注册。如果未指定的MBean的名字,MBean可以登记为其提供一个名称。如果有异常抛出,MBean将不会在MBean服务器注册。
此方法的默认实现返回name参数。它没有别的标准MBean。对于mxbeans,它记录了MBeanServer和ObjectName参数可以用来翻译跨MXBean参考。
这是一个类,重写该方法调用重写的方法通过super.preRegister(...)良好实践。如果这个对象是一个MXBean是由其他mxbeans属性或操作的参考这是必要的。
preRegister 接口
MBeanRegistration
server的MBean服务器中,MBean将注册。
name - MBean对象名称。如果Name参数中的一个
MBeanServer接口
createMBean或
registerMBean方法是零这个名字是空的。在这种情况下,该方法必须返回一个非空的新的MBean对象。
name参数不为空,它通常但不返回值。
IllegalArgumentException MXBean和
name是空的。
InstanceAlreadyExistsException MXBean和已经在另一个名字注册的(在这个MBean服务器或另一个)。
异常没有其他检查异常的方法但
异常声明,子类可以重写该方法,把自己的异常抛出。
public void postRegister(Boolean registrationDone)
允许MBean执行任何操作在MBean服务器或注册后不需要注册后。
此方法的默认实现是什么标准MBean。对于mxbeans,它让做的preRegister任何工作如果注册失败。
这是一个类,重写该方法调用重写的方法通过super.postRegister(...)良好实践。如果这个对象是一个MXBean是由其他mxbeans属性或操作的参考这是必要的。
postRegister 接口
MBeanRegistration
registrationDone -指示是否MBean已在MBean服务器注册成功。价值错误意味着注册阶段已经失败。
public void preDeregister()
throws 异常
允许MBean执行任何需要的操作之前被注册的MBean服务器。
这种方法的默认实现不做任何事。
这是一个类,重写该方法调用重写的方法通过super.preDeregister(...)良好实践。
preDeregister 接口
MBeanRegistration
异常不检查异常被抛出的方法但
异常声明,子类可以重写此方法,并把自己的异常。
public void postDeregister()
允许MBean执行任何操作在MBean服务器被注册后需要。
此方法的默认实现是什么标准MBean。对于mxbeans,它排除了任何信息被preRegister方法记录。
这是一个类,重写该方法调用重写的方法通过super.postRegister(...)良好实践。如果这个对象是一个MXBean是由其他mxbeans属性或操作的参考这是必要的。
postDeregister 接口
MBeanRegistration
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.