JavaTM 2 Platform
Standard Ed. 6

javax.management.modelmbean
类 ModelMBeanInfoSupport

java.lang.Object
  继承者 javax.management.MBeanInfo
      继承者 javax.management.modelmbean.ModelMBeanInfoSupport
所有已实现的接口:
Serializable, Cloneable, DescriptorRead, ModelMBeanInfo

public class ModelMBeanInfoSupport
extends MBeanInfo
implements ModelMBeanInfo

此类表示 ModelMBean 的元数据。描述符已被添加到元数据对象上。

Java 资源使用 MBeanServer 的 createMBean 方法来实例化 ModelMBean,以便具有可管理性。然后该资源设置 ModelMBean 实例的 ModelMBeanInfo 和 Descriptor。通过 ModelMBean 的 ModelMBeanInfo 公开的属性和操作像其他 MBean 一样可以从 MBean、连接器/适配器进行访问。通过使用 Descriptor,可以定义托管应用程序中的值和方法,并且可以将它们映射到 ModelMBean 的属性和操作。此映射可以在文件的开发过程中定义,也可以以编程方式在运行时动态定义。

MBeanServer 中实例化的每个 ModelMBean 都是可管理的:通过连接到该 MBeanServer 的连接器/适配器,可以远程访问其属性和操作。如果 Java 对象不是兼容 JMX 的 MBean,那么它不能在 MBeanServer 中进行注册。通过实例化 ModelMBean,资源得到保证,因此 MBean 是有效的。每个公共方法必须抛出 MBeanException 和 RuntimeOperationsException。这允许包装来自分布式通信(RMI、EJB 等)的异常。

此类的 serialVersionUID-1935722590756516193L

从以下版本开始:
1.5
另请参见:
序列化表格

构造方法摘要
ModelMBeanInfoSupport(ModelMBeanInfo mbi)
          构造作为给定 ModelMBeanInfoSupport 副本的 ModelMBeanInfoSupport。
ModelMBeanInfoSupport(String className, String description, ModelMBeanAttributeInfo[] attributes, ModelMBeanConstructorInfo[] constructors, ModelMBeanOperationInfo[] operations, ModelMBeanNotificationInfo[] notifications)
          创建带有所提供的信息、但描述符为默认描述符的 ModelMBeanInfoSupport。
ModelMBeanInfoSupport(String className, String description, ModelMBeanAttributeInfo[] attributes, ModelMBeanConstructorInfo[] constructors, ModelMBeanOperationInfo[] operations, ModelMBeanNotificationInfo[] notifications, Descriptor mbeandescriptor)
          创建带有所提供的信息和参数中给出的描述符的 ModelMBeanInfoSupport。
 
方法摘要
 Object clone()
          返回此实例的浅表复制。
 ModelMBeanAttributeInfo getAttribute(String inName)
          返回通过名称请求的 ModelMBeanAttributeInfo。
 ModelMBeanConstructorInfo getConstructor(String inName)
          返回通过名称请求的 ModelMBeanConstructorInfo。
 Descriptor getDescriptor()
          获取此 MBean 的描述符。
 Descriptor getDescriptor(String inDescriptorName)
          返回通过名称请求的 Descriptor。
 Descriptor getDescriptor(String inDescriptorName, String inDescriptorType)
          返回通过 name 和 descriptorType 请求的 Descriptor。
 Descriptor[] getDescriptors(String inDescriptorType)
          返回由 inDescriptorType 类型的 ModelMBeanInfo 的所有 Descriptor 组成的 Descriptor 数组。
 Descriptor getMBeanDescriptor()
          返回包含 MBean 级策略的 ModelMBean 的描述符。
 ModelMBeanNotificationInfo getNotification(String inName)
          返回通过名称请求的 ModelMBeanNotificationInfo。
 ModelMBeanOperationInfo getOperation(String inName)
          返回通过名称请求的 ModelMBeanOperationInfo。
 void setDescriptor(Descriptor inDescriptor, String inDescriptorType)
          设置 inDescriptorType 类型的 ModelMBean 的 info 数组中的描述符。
 void setDescriptors(Descriptor[] inDescriptors)
          添加或替换 ModelMBeanInfo 中的描述符。
 void setMBeanDescriptor(Descriptor inMBeanDescriptor)
          设置 ModelMBean 的描述符。
 
从类 javax.management.MBeanInfo 继承的方法
equals, getAttributes, getClassName, getConstructors, getDescription, getNotifications, getOperations, hashCode, toString
 
从类 java.lang.Object 继承的方法
finalize, getClass, notify, notifyAll, wait, wait, wait
 
从接口 javax.management.modelmbean.ModelMBeanInfo 继承的方法
getAttributes, getClassName, getConstructors, getDescription, getNotifications, getOperations
 

构造方法详细信息

ModelMBeanInfoSupport

public ModelMBeanInfoSupport(ModelMBeanInfo mbi)
构造作为给定 ModelMBeanInfoSupport 副本的 ModelMBeanInfoSupport。返回对象是给定对象的浅表复制。Descriptor 或所包含的数组(@code ModelMBeanAttributeInfo[]} 等)都不会被复制。此方法的主要作用是通过 setDescriptor 修改返回实例的 Descriptor,而不影响原对象的 Descriptor。

参数:
mbi - ModelMBeanInfo 实例,正在创建的 ModelMBeanInfo 从该实例进行实例化。

ModelMBeanInfoSupport

public ModelMBeanInfoSupport(String className,
                             String description,
                             ModelMBeanAttributeInfo[] attributes,
                             ModelMBeanConstructorInfo[] constructors,
                             ModelMBeanOperationInfo[] operations,
                             ModelMBeanNotificationInfo[] notifications)
创建带有所提供的信息、但描述符为默认描述符的 ModelMBeanInfoSupport。默认描述符为:name=mbeanName、descriptorType=mbean、displayName=ClassName、persistPolicy=never、log=F 和 visibility=1。

参数:
className - MBean 的类名称
description - ModelMBean 的可读描述
attributes - 带有描述符的 ModelMBeanAttributeInfo 对象数组
constructors - 带有描述符的 ModelMBeanConstructorInfo 对象数组
operations - 带有描述符的 ModelMBeanOperationInfo 对象数组
notifications - 带有描述符的 ModelMBeanNotificationInfo 对象数组

ModelMBeanInfoSupport

public ModelMBeanInfoSupport(String className,
                             String description,
                             ModelMBeanAttributeInfo[] attributes,
                             ModelMBeanConstructorInfo[] constructors,
                             ModelMBeanOperationInfo[] operations,
                             ModelMBeanNotificationInfo[] notifications,
                             Descriptor mbeandescriptor)
创建带有所提供的信息和参数中给出的描述符的 ModelMBeanInfoSupport。

参数:
className - MBean 的类名称
description - ModelMBean 的可读描述
attributes - 带有描述符的 ModelMBeanAttributeInfo 对象数组
constructors - 带有描述符的 ModelMBeanConstructorInfo 对象数组
operations - 带有描述符的 ModelMBeanOperationInfo 对象数组
notifications - 带有描述符的 ModelMBeanNotificationInfo 对象数组如果描述符为 null,则将构造默认描述符。默认描述符为:name=className、descriptorType=mbean、displayName=className、persistPolicy=never、log=F 和 visibility=1。如果描述符不包含所有这些字段,则将用默认值添加它们。
抛出:
RuntimeOperationsException - 包装了针对传入参数中的无效描述符的 IllegalArgumentException。(有关有效 MBean 描述符的定义,请参见 getMBeanDescriptor)。
方法详细信息

clone

public Object clone()
返回此实例的浅表复制。Descriptor 或所包含的数组(@code ModelMBeanAttributeInfo[]} 等)都不会被复制。此方法的主要作用是通过 setDescriptor 修改副本的 Descriptor,而不影响原对象的 Descriptor。

指定者:
接口 ModelMBeanInfo 中的 clone
覆盖:
MBeanInfo 中的 clone
返回:
此实例的浅表复制。
另请参见:
Cloneable

getDescriptors

public Descriptor[] getDescriptors(String inDescriptorType)
                            throws MBeanException,
                                   RuntimeOperationsException
从接口 ModelMBeanInfo 复制的描述
返回由 inDescriptorType 类型的 ModelMBeanInfo 的所有 Descriptor 组成的 Descriptor 数组。

指定者:
接口 ModelMBeanInfo 中的 getDescriptors
参数:
inDescriptorType - 必须为要返回的描述符设置的 descriptorType 字段值。必须为 "mbean"、"attribute"、"operation"、"constructor" 或 "notification"。如果它为 null 或空,则将返回所有类型。
返回:
包含 inDescriptorType 类型的 ModelMBean 的所有描述符的 Descriptor 数组。
抛出:
MBeanException - 包装一个分布式通信异常。
RuntimeOperationsException - 当参数中的 descriptorType 不是以下值之一时,包装一个 IllegalArgumentException:"mbean"、"attribute"、"operation"、"constructor"、"notification"、空、 null。
另请参见:
ModelMBeanInfo.setDescriptors(javax.management.Descriptor[])

setDescriptors

public void setDescriptors(Descriptor[] inDescriptors)
                    throws MBeanException,
                           RuntimeOperationsException
从接口 ModelMBeanInfo 复制的描述
添加或替换 ModelMBeanInfo 中的描述符。

指定者:
接口 ModelMBeanInfo 中的 setDescriptors
参数:
inDescriptors - ModelMBeanInfo 中要设置的描述符。忽略列表中的 null 元素。所有描述符必须具有 name 和 descriptorType 字段。
抛出:
MBeanException - 包装一个分布式通信异常。
RuntimeOperationsException - 包装 null 或无效描述符的 IllegalArgumentException。
另请参见:
ModelMBeanInfo.getDescriptors(java.lang.String)

getDescriptor

public Descriptor getDescriptor(String inDescriptorName)
                         throws MBeanException,
                                RuntimeOperationsException
返回通过名称请求的 Descriptor。

参数:
inDescriptorName - 描述符名称。
返回:
包含具有相同名称的 ModelMBean 描述符的 Descriptor。如果未找到该描述符,则返回 null。
抛出:
MBeanException - 包装了一个分布式通信异常。
RuntimeOperationsException - 包装了针对 null 名称的 IllegalArgumentException。
另请参见:
setDescriptor(javax.management.Descriptor, java.lang.String)

getDescriptor

public Descriptor getDescriptor(String inDescriptorName,
                                String inDescriptorType)
                         throws MBeanException,
                                RuntimeOperationsException
从接口 ModelMBeanInfo 复制的描述
返回通过 name 和 descriptorType 请求的 Descriptor。

指定者:
接口 ModelMBeanInfo 中的 getDescriptor
参数:
inDescriptorName - 描述符的名称。
inDescriptorType - 要请求的描述符的类型。如果它为 null 或空,就搜索所有类型。有效的类型有 'mbean'、'attribute'、'constructor'、'operation'、'notification'。此值将等于所返回的描述符中的 'descriptorType' 字段。
返回:
包含具有相同 name 和 descriptorType 的 ModelMBean 描述符的 Descriptor。如果未找到描述符,则返回 null。
抛出:
MBeanException - 包装一个分布式通信异常。
RuntimeOperationsException - 包装描述符的名称为 null 的 IllegalArgumentException,或者 null 或无效类型的 IllegalArgumentException。类型必须为 "mbean"、"attribute"、"constructor"、"operation" 或 "notification"。
另请参见:
ModelMBeanInfo.setDescriptor(javax.management.Descriptor, java.lang.String)

setDescriptor

public void setDescriptor(Descriptor inDescriptor,
                          String inDescriptorType)
                   throws MBeanException,
                          RuntimeOperationsException
从接口 ModelMBeanInfo 复制的描述
设置 inDescriptorType 类型的 ModelMBean 的 info 数组中的描述符。将调用对应 ModelMBean*Info 的 setDescriptor 方法来设置指定的描述符。

指定者:
接口 ModelMBeanInfo 中的 setDescriptor
参数:
inDescriptor - ModelMBean 中要设置的描述符。它必须不为 null。所有描述符必须有 name 和 descriptorType 字段。
inDescriptorType - 要设置的描述符类型。如果它为 null,则使用描述符中的 descriptorType 字段。如果此值是指定的,则必须在描述符的 descriptorType 字段中设置它。必须为 "mbean"、"attribute"、"constructor"、"operation" 或 "notification"。
抛出:
MBeanException - 包装一个分布式通信异常。
RuntimeOperationsException - 包装非法或 null 参数的 IllegalArgumentException,或者如果在对应的 MBeanAttributeInfo、MBeanConstructorInfo、MBeanNotificationInfo 或 MBeanOperationInfo 中找不到描述符的 name 字段。
另请参见:
ModelMBeanInfo.getDescriptor(java.lang.String, java.lang.String)

getAttribute

public ModelMBeanAttributeInfo getAttribute(String inName)
                                     throws MBeanException,
                                            RuntimeOperationsException
从接口 ModelMBeanInfo 复制的描述
返回通过名称请求的 ModelMBeanAttributeInfo。

指定者:
接口 ModelMBeanInfo 中的 getAttribute
参数:
inName - 要获取的 ModelMBeanAttributeInfo 名称。如果不存在此名称的 ModelMBeanAttributeInfo,则返回 null。
返回:
指定属性的属性信息,如果没有,则返回 null。
抛出:
MBeanException - 包装一个分布式通信异常。
RuntimeOperationsException - 包装 null 属性名称的 IllegalArgumentException。

getOperation

public ModelMBeanOperationInfo getOperation(String inName)
                                     throws MBeanException,
                                            RuntimeOperationsException
从接口 ModelMBeanInfo 复制的描述
返回通过名称请求的 ModelMBeanOperationInfo。

指定者:
接口 ModelMBeanInfo 中的 getOperation
参数:
inName - 要获取的 ModelMBeanOperationInfo 名称。如果不存在此名称的 ModelMBeanOperationInfo,则返回 null。
返回:
指定操作的操作信息,如果没有,则返回 null。
抛出:
MBeanException - 包装一个分布式通信异常。
RuntimeOperationsException - 包装 null 操作名称的 IllegalArgumentException。

getConstructor

public ModelMBeanConstructorInfo getConstructor(String inName)
                                         throws MBeanException,
                                                RuntimeOperationsException
返回通过名称请求的 ModelMBeanConstructorInfo。如果不存在具有此名称的 ModelMBeanConstructorInfo,则返回 null。

参数:
inName - 构造方法名称。
返回:
指定构造方法的构造方法信息,如果没有这类信息,则返回 null。
抛出:
MBeanException - 包装了一个分布式通信异常。
RuntimeOperationsException - 包装了针对 null 构造方法名称的 IllegalArgumentException。

getNotification

public ModelMBeanNotificationInfo getNotification(String inName)
                                           throws MBeanException,
                                                  RuntimeOperationsException
从接口 ModelMBeanInfo 复制的描述
返回通过名称请求的 ModelMBeanNotificationInfo。

指定者:
接口 ModelMBeanInfo 中的 getNotification
参数:
inName - 要获取的 ModelMBeanNotificationInfo 名称。如果不存在此名称的 ModelMBeanNotificationInfo,则返回 null。
返回:
指定通知的信息,如果没有,则返回 null。
抛出:
MBeanException - 包装一个分布式通信异常。
RuntimeOperationsException - 包装 null 通知名称的 IllegalArgumentException。

getDescriptor

public Descriptor getDescriptor()
从类 MBeanInfo 复制的描述
获取此 MBean 的描述符。更改返回值对原描述符没有影响。

指定者:
接口 DescriptorRead 中的 getDescriptor
覆盖:
MBeanInfo 中的 getDescriptor
返回:
一个描述符,可能是不可变的,也可能是原描述符的副本。
从以下版本开始:
1.6

getMBeanDescriptor

public Descriptor getMBeanDescriptor()
                              throws MBeanException
从接口 ModelMBeanInfo 复制的描述
返回包含 MBean 级策略的 ModelMBean 的描述符。此描述符包含关于 MBean 和默认持久性及缓存策略的元数据。

描述符中的字段定义如下,但不限于此:

 name           : MBean 名称  
 descriptorType : 必须为 "mbean"   
 displayName    : 要在显示中使用的属性名称
 persistPolicy  : OnUpdate|OnTimer|NoMoreOftenThan|OnUnregister|Always|Never  
 persistLocation : 应在其中保持 MBean 的完全限定目录名(如果适当)。
 persistFile    : 应在其中保持 MBean 的文件名称。
 persistPeriod  : 秒数 -  OnTime 和 NoMoreOftenThan PersistPolicy 的保持周期的频率
 currencyTimeLimit : 值保持有效的时间,<0 为无效,=0 为总是有效,>0 为有效的秒数
 log            : 其中 t:记录所有通知;f:不记录通知
 logfile        : 要记录事件的完全限定文件名
 visibility     : 1-4,其中 1:总是可见;4:几乎不可见
 export         : 要用于导出/公开此 MBean 的名称,以便其他 JMX Agent 可以找到它
                     
 presentationString : 允许数据与 MBean 关联的 xml 格式的字符串。 
 

默认描述符为:name=mbeanName、descriptorType=mbean、displayName=this.getClassName()、persistPolicy=never、log=F、export=F、visibility=1 如果描述符不包含所有这些字段,则将以这些默认值添加它们。

注:由于与此规范的以前版本不一致,因此对于 currencyTimeLimit,推荐不使用负值或零。要指示某个缓存的值永远无效,请忽略 currencyTimeLimit 字段。要指示它总是有效,请为此字段使用一个非常大的值。

指定者:
接口 ModelMBeanInfo 中的 getMBeanDescriptor
返回:
MBean 描述符。
抛出:
MBeanException - 包装一个分布式通信异常。
另请参见:
ModelMBeanInfo.setMBeanDescriptor(javax.management.Descriptor)

setMBeanDescriptor

public void setMBeanDescriptor(Descriptor inMBeanDescriptor)
                        throws MBeanException,
                               RuntimeOperationsException
从接口 ModelMBeanInfo 复制的描述
设置 ModelMBean 的描述符。此描述符包含默认的、关于 MBean 和默认持久性及缓存策略的 MBean 级元数据。此操作执行描述符的完全替换,不执行合并。如果要设置的描述符为 null,则将创建默认描述符。默认描述符为:name=mbeanName、descriptorType=mbean、displayName=this.getClassName()、 persistPolicy=never、log=F、export=F、visibility=1 如果描述符不包含所有这些字段,则将以这些默认值添加它们。 有关有效字段名称的描述,请参阅 getMBeanDescriptor 方法的 javadoc。

指定者:
接口 ModelMBeanInfo 中的 setMBeanDescriptor
参数:
inMBeanDescriptor - 要设置的描述符。
抛出:
MBeanException - 包装一个分布式通信异常。
RuntimeOperationsException - 包装无效描述符的 IllegalArgumentException。
另请参见:
ModelMBeanInfo.getMBeanDescriptor()

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only