java.lang.Objectjavax.management.MBeanInfo
javax.management.modelmbean.ModelMBeanInfoSupport
public class ModelMBeanInfoSupport
     此类表示 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。 
| 构造方法摘要 | |
|---|---|
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 |  
    
| 构造方法详细信息 | 
|---|
public ModelMBeanInfoSupport(ModelMBeanInfo mbi)
setDescriptor 修改返回实例的 Descriptor,而不影响原对象的 Descriptor。 
    
mbi - ModelMBeanInfo 实例,正在创建的 ModelMBeanInfo 从该实例进行实例化。
     public ModelMBeanInfoSupport(String className, String description, ModelMBeanAttributeInfo[] attributes, ModelMBeanConstructorInfo[] constructors, ModelMBeanOperationInfo[] operations, ModelMBeanNotificationInfo[] notifications)
className - MBean 的类名称
     description - ModelMBean 的可读描述
     attributes - 带有描述符的 ModelMBeanAttributeInfo 对象数组
     constructors - 带有描述符的 ModelMBeanConstructorInfo 对象数组
     operations - 带有描述符的 ModelMBeanOperationInfo 对象数组
     notifications - 带有描述符的 ModelMBeanNotificationInfo 对象数组
     public ModelMBeanInfoSupport(String className, String description, ModelMBeanAttributeInfo[] attributes, ModelMBeanConstructorInfo[] constructors, ModelMBeanOperationInfo[] operations, ModelMBeanNotificationInfo[] notifications, Descriptor mbeandescriptor)
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)。
     | 方法详细信息 | 
|---|
public Object clone()
setDescriptor 修改副本的 Descriptor,而不影响原对象的 Descriptor。 
    
ModelMBeanInfo 中的 
      clone
     MBeanInfo 中的 
      clone
     Cloneable
     public Descriptor[] getDescriptors(String inDescriptorType) throws MBeanException, RuntimeOperationsException
ModelMBeanInfo 复制的描述
   
ModelMBeanInfo 中的 
      getDescriptors
     inDescriptorType - 必须为要返回的描述符设置的 descriptorType 字段值。必须为 "mbean"、"attribute"、"operation"、"constructor" 或 "notification"。如果它为 null 或空,则将返回所有类型。 
     MBeanException - 包装一个分布式通信异常。 
     RuntimeOperationsException - 当参数中的 descriptorType 不是以下值之一时,包装一个 IllegalArgumentException:"mbean"、"attribute"、"operation"、"constructor"、"notification"、空、 null。
     ModelMBeanInfo.setDescriptors(javax.management.Descriptor[])
     public void setDescriptors(Descriptor[] inDescriptors) throws MBeanException, RuntimeOperationsException
ModelMBeanInfo 复制的描述
   
ModelMBeanInfo 中的 
      setDescriptors
     inDescriptors - ModelMBeanInfo 中要设置的描述符。忽略列表中的 null 元素。所有描述符必须具有 name 和 descriptorType 字段。 
     MBeanException - 包装一个分布式通信异常。 
     RuntimeOperationsException - 包装 null 或无效描述符的 IllegalArgumentException。
     ModelMBeanInfo.getDescriptors(java.lang.String)
     public Descriptor getDescriptor(String inDescriptorName) throws MBeanException, RuntimeOperationsException
inDescriptorName - 描述符名称。 
     MBeanException - 包装了一个分布式通信异常。 
     RuntimeOperationsException - 包装了针对 null 名称的 IllegalArgumentException。
     setDescriptor(javax.management.Descriptor, java.lang.String)
     public Descriptor getDescriptor(String inDescriptorName, String inDescriptorType) throws MBeanException, RuntimeOperationsException
ModelMBeanInfo 复制的描述
   
ModelMBeanInfo 中的 
      getDescriptor
     inDescriptorName - 描述符的名称。
     inDescriptorType - 要请求的描述符的类型。如果它为 null 或空,就搜索所有类型。有效的类型有 'mbean'、'attribute'、'constructor'、'operation'、'notification'。此值将等于所返回的描述符中的 'descriptorType' 字段。 
     MBeanException - 包装一个分布式通信异常。 
     RuntimeOperationsException - 包装描述符的名称为 null 的 IllegalArgumentException,或者 null 或无效类型的 IllegalArgumentException。类型必须为 "mbean"、"attribute"、"constructor"、"operation" 或 "notification"。
     ModelMBeanInfo.setDescriptor(javax.management.Descriptor, java.lang.String)
     public void setDescriptor(Descriptor inDescriptor, String inDescriptorType) throws MBeanException, RuntimeOperationsException
ModelMBeanInfo 复制的描述
   
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)
     public ModelMBeanAttributeInfo getAttribute(String inName) throws MBeanException, RuntimeOperationsException
ModelMBeanInfo 复制的描述
   
ModelMBeanInfo 中的 
      getAttribute
     inName - 要获取的 ModelMBeanAttributeInfo 名称。如果不存在此名称的 ModelMBeanAttributeInfo,则返回 null。 
     MBeanException - 包装一个分布式通信异常。 
     RuntimeOperationsException - 包装 null 属性名称的 IllegalArgumentException。
     public ModelMBeanOperationInfo getOperation(String inName) throws MBeanException, RuntimeOperationsException
ModelMBeanInfo 复制的描述
   
ModelMBeanInfo 中的 
      getOperation
     inName - 要获取的 ModelMBeanOperationInfo 名称。如果不存在此名称的 ModelMBeanOperationInfo,则返回 null。 
     MBeanException - 包装一个分布式通信异常。 
     RuntimeOperationsException - 包装 null 操作名称的 IllegalArgumentException。
     public ModelMBeanConstructorInfo getConstructor(String inName) throws MBeanException, RuntimeOperationsException
inName - 构造方法名称。 
     MBeanException - 包装了一个分布式通信异常。 
     RuntimeOperationsException - 包装了针对 null 构造方法名称的 IllegalArgumentException。
     public ModelMBeanNotificationInfo getNotification(String inName) throws MBeanException, RuntimeOperationsException
ModelMBeanInfo 复制的描述
   
ModelMBeanInfo 中的 
      getNotification
     inName - 要获取的 ModelMBeanNotificationInfo 名称。如果不存在此名称的 ModelMBeanNotificationInfo,则返回 null。 
     MBeanException - 包装一个分布式通信异常。 
     RuntimeOperationsException - 包装 null 通知名称的 IllegalArgumentException。
     public Descriptor getDescriptor()
MBeanInfo 复制的描述
   
DescriptorRead 中的 
      getDescriptor
     MBeanInfo 中的 
      getDescriptor
     public Descriptor getMBeanDescriptor() throws MBeanException
ModelMBeanInfo 复制的描述
   描述符中的字段定义如下,但不限于此:
 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
     MBeanException - 包装一个分布式通信异常。
     ModelMBeanInfo.setMBeanDescriptor(javax.management.Descriptor)
     public void setMBeanDescriptor(Descriptor inMBeanDescriptor) throws MBeanException, RuntimeOperationsException
ModelMBeanInfo 复制的描述
   getMBeanDescriptor 方法的 javadoc。 
    
ModelMBeanInfo 中的 
      setMBeanDescriptor
     inMBeanDescriptor - 要设置的描述符。 
     MBeanException - 包装一个分布式通信异常。 
     RuntimeOperationsException - 包装无效描述符的 IllegalArgumentException。
     ModelMBeanInfo.getMBeanDescriptor()