类 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 和 Descriptors。通过 ModelMBeanInfo 为 ModelMBean 公开的属性和操作可从 MBean、连接器/适配器(如其他 MBean)访问。通过描述符,托管应用程序中的值和方法可以被定义并映射到 ModelMBean 的属性和操作。该map可以在开发期间在文件中定义,也可以在运行时以编程方式动态定义。

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

serialVersionUID这个类的是-1935722590756516193L

自从:
1.5
参见:
  • 构造方法详细信息

    • ModelMBeanInfoSupport

      public ModelMBeanInfoSupport(ModelMBeanInfo  mbi)
      构造一个 ModelMBeanInfoSupport,它是给定 ModelMBeanInfo 的副本。返回的对象是给定对象的浅表副本。描述符和包含的数组(ModelMBeanAttributeInfo[] 等)都没有被克隆。此方法主要用于通过 setDescriptor 修改返回实例的描述符,而不影响原始对象的描述符。
      参数:
      mbi - 从中初始化正在创建的 ModelMBeanInfo 的 ModelMBeanInfo 实例。
    • ModelMBeanInfoSupport

      public ModelMBeanInfoSupport(String  className, String  description, ModelMBeanAttributeInfo [] attributes, ModelMBeanConstructorInfo [] constructors, ModelMBeanOperationInfo [] operations, ModelMBeanNotificationInfo [] notifications)
      使用提供的信息创建 ModelMBeanInfoSupport,但描述符是默认值。默认描述符是:name=className, 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 对象数组
      mbeandescriptor - 用作包含 MBean 范围策略的 MBeanDescriptor 的描述符。如果描述符为空,将构造默认描述符。默认描述符是:name=className, descriptorType="mbean", displayName=className, persistPolicy="never", log="F", visibility="1"。如果描述符不包含所有这些字段,则将使用这些默认值添加缺失的字段。
      抛出:
      RuntimeOperationsException - 为参数中传递的无效描述符包装 IllegalArgumentException。 (有关有效 MBean 描述符的定义,请参阅 getMBeanDescriptor 。)
  • 方法详情

    • clone

      public Object  clone()
      返回此实例的浅克隆。描述符和包含的数组(ModelMBeanAttributeInfo[] 等)都没有被克隆。此方法主要用于通过 setDescriptor 修改克隆的描述符而不影响原始对象的描述符。
      指定者:
      clone 在接口 ModelMBeanInfo
      重写:
      clone 在类 MBeanInfo
      返回:
      此实例的浅克隆。
      参见:
    • getDescriptors

      public Descriptor [] getDescriptors(String  inDescriptorType) throws MBeanException , RuntimeOperationsException
      从接口 ModelMBeanInfo 复制的描述
      返回一个描述符数组,其中包含类型为 inDescriptorType 的 ModelMBeanInfo 的所有描述符。
      指定者:
      getDescriptors 在接口 ModelMBeanInfo
      参数:
      inDescriptorType - 必须为要返回的描述符设置的 descriptorType 字段的值。必须是“mbean”、“属性”、“操作”、“构造函数”或“通知”。如果它为 null 或空,则将返回所有类型。
      返回:
      如果在 DescriptorType 中键入,则包含 ModelMBean 的所有描述符的描述符数组。
      抛出:
      MBeanException - 包装分布式通信异常。
      RuntimeOperationsException - 当参数中的 descriptorType 不是以下之一时包装 IllegalArgumentException:“mbean”、“attribute”、“operation”、“constructor”、“notification”、empty 或 null。
      参见:
    • setDescriptors

      public void setDescriptors(Descriptor [] inDescriptors) throws MBeanException , RuntimeOperationsException
      从接口 ModelMBeanInfo 复制的描述
      添加或替换 ModelMBeanInfo 中的描述符。
      指定者:
      setDescriptors 在接口 ModelMBeanInfo
      参数:
      inDescriptors - 要在 ModelMBeanInfo 中设置的描述符。列表的空元素将被忽略。所有描述符都必须有名称和描述符类型字段。
      抛出:
      MBeanException - 包装分布式通信异常。
      RuntimeOperationsException - 包装空或无效描述符的 IllegalArgumentException。
      参见:
    • getDescriptor

      public Descriptor  getDescriptor(String  inDescriptorName) throws MBeanException , RuntimeOperationsException
      返回按名称请求的描述符。
      参数:
      inDescriptorName - 描述符的名称。
      返回:
      包含同名 ModelMBean 的描述符的描述符。如果未找到描述符,则返回 null。
      抛出:
      MBeanException - 包装分布式通信异常。
      RuntimeOperationsException - 包装空名称的 IllegalArgumentException。
      参见:
    • getDescriptor

      public Descriptor  getDescriptor(String  inDescriptorName, String  inDescriptorType) throws MBeanException , RuntimeOperationsException
      从接口 ModelMBeanInfo 复制的描述
      返回由名称和描述符类型请求的描述符。
      指定者:
      getDescriptor 在接口 ModelMBeanInfo
      参数:
      inDescriptorName - 描述符的名称。
      inDescriptorType - 被请求的描述符的类型。如果这是 null 或空,则搜索所有类型。有效类型为“mbean”、“属性”、“构造函数”、“操作”和“通知”。该值将等于返回的描述符中的“descriptorType”字段。
      返回:
      包含具有相同名称和 descriptorType 的 ModelMBean 的描述符的描述符。如果未找到描述符,则返回 null。
      抛出:
      MBeanException - 包装分布式通信异常。
      RuntimeOperationsException - 为 null 描述符名称或 null 或无效类型包装 IllegalArgumentException。类型必须是“mbean”、“属性”、“构造函数”、“操作”或“通知”。
      参见:
    • setDescriptor

      public void setDescriptor(Descriptor  inDescriptor, String  inDescriptorType) throws MBeanException , RuntimeOperationsException
      从接口 ModelMBeanInfo 复制的描述
      为 ModelMBean 在类型为 inDescriptorType 的信息数组中设置描述符。将调用相应ModelMBean*Info 的setDescriptor 方法来设置指定的描述符。
      指定者:
      setDescriptor 在接口 ModelMBeanInfo
      参数:
      inDescriptor - 要在 ModelMBean 中设置的描述符。它不能为空。所有描述符都必须有名称和描述符类型字段。
      inDescriptorType - 正在设置的描述符的类型。如果为空,则使用描述符中的 descriptorType 字段。如果指定,则必须在描述符的 descriptorType 字段中设置此值。必须是“mbean”、“属性”、“构造函数”、“操作”或“通知”。
      抛出:
      MBeanException - 包装分布式通信异常。
      RuntimeOperationsException - 如果在相应的 MBeanAttributeInfo 或 MBeanConstructorInfo 或 MBeanNotificationInfo 或 MBeanOperationInfo 中找不到描述符的名称字段,则为非法或空参数包装 IllegalArgumentException。
      参见:
    • getAttribute

      public ModelMBeanAttributeInfo  getAttribute(String  inName) throws MBeanException , RuntimeOperationsException
      从接口 ModelMBeanInfo 复制的描述
      返回按名称请求的 ModelMBeanAttributeInfo。
      指定者:
      getAttribute 在接口 ModelMBeanInfo
      参数:
      inName - 要获取的 ModelMBeanAttributeInfo 的名称。如果此名称不存在 ModelMBeanAttributeInfo,则返回 null。
      返回:
      命名属性的属性信息,如果没有则为 null。
      抛出:
      MBeanException - 包装分布式通信异常。
      RuntimeOperationsException - 包装空属性名称的 IllegalArgumentException。
    • getOperation

      public ModelMBeanOperationInfo  getOperation(String  inName) throws MBeanException , RuntimeOperationsException
      从接口 ModelMBeanInfo 复制的描述
      返回按名称请求的 ModelMBeanOperationInfo。
      指定者:
      getOperation 在接口 ModelMBeanInfo
      参数:
      inName - 要获取的 ModelMBeanOperationInfo 的名称。如果此名称不存在 ModelMBeanOperationInfo,则返回 null。
      返回:
      指定操作的操作信息,如果没有则为 null。
      抛出:
      MBeanException - 包装分布式通信异常。
      RuntimeOperationsException - 包装空操作名称的 IllegalArgumentException。
    • getConstructor

      public ModelMBeanConstructorInfo  getConstructor(String  inName) throws MBeanException , RuntimeOperationsException
      返回按名称请求的 ModelMBeanConstructorInfo。如果不存在此名称的 ModelMBeanConstructorInfo,则返回 null。
      参数:
      inName - 构造函数的名称。
      返回:
      命名构造方法的构造方法信息,如果没有则返回 null。
      抛出:
      MBeanException - 包装分布式通信异常。
      RuntimeOperationsException - 为空构造函数名称包装 IllegalArgumentException。
    • getNotification

      public ModelMBeanNotificationInfo  getNotification(String  inName) throws MBeanException , RuntimeOperationsException
      从接口 ModelMBeanInfo 复制的描述
      返回按名称请求的 ModelMBeanNotificationInfo。
      指定者:
      getNotification 在接口 ModelMBeanInfo
      参数:
      inName - 要获取的 ModelMBeanNotificationInfo 的名称。如果不存在此名称的 ModelMBeanNotificationInfo,则返回 null。
      返回:
      指定通知的信息,如果没有则为 null。
      抛出:
      MBeanException - 包装分布式通信异常。
      RuntimeOperationsException - 包装空通知名称的 IllegalArgumentException。
    • getDescriptor

      public Descriptor  getDescriptor()
      从类复制的描述:MBeanInfo
      获取此 MBeanInfo 的描述符。更改返回值不会影响原始描述符。
      指定者:
      getDescriptor 在接口 DescriptorRead
      重写:
      getDescriptor 在类 MBeanInfo
      返回:
      一个不可变的或原始副本的描述符。
      自从:
      1.6
    • getMBeanDescriptor

      public Descriptor  getMBeanDescriptor() throws MBeanException
      从接口 ModelMBeanInfo 复制的描述

      返回包含 MBean 范围策略的 ModelMBean 的描述符。该描述符包含有关 MBean 的元数据以及持久性和缓存的默认策略。

      描述符中的字段定义如下,但不限于以下内容。请注意,当此表中的 Type 为 Number 时,也可以使用作为 Long 的十进制表示形式的 String。

      ModelMBean 字段
      Name Type 意义
      name String MBean 名称。
      描述符类型 String 必须是“mbean”。
      显示名称 String 要在显示中使用的 MBean 的名称。
      坚持策略 String 其中之一:OnUpdate|OnTimer|NoMoreOftenThan|OnUnregister|Always|Never。请参阅 JMX 规范文档中的“MBean 描述符字段”部分。
      坚持位置 String 应保留 MBean 的完全限定目录名(如果适用)。
      持久文件 String MBean 应保存到的文件名。
      持续期 Number 持续周期的频率(以秒为单位),适用于 OnTime 和 NoMoreOftenThan PersistPolicy
      货币时间限制 Number 缓存值的有效时间:<0 从不,=0 始终,>0 秒。
      日志 String t:记录所有通知,f:不记录任何通知。
      日志文件 String 用于记录事件的完全限定文件名。
      能见度 Number 1-4 其中 1:总是可见 4:很少可见。
      export String 用于导出/公开此 MBean 的名称,以便其他 JMX 代理可以找到它。
      演示字符串 String XML 格式的字符串,允许显示与 MBean 关联的数据。

      默认的描述符是: name=className,descriptorType="mbean", displayName=className, persistPolicy="never",log="F",visibility="1" 如果描述符不包含所有这些字段,它们将被添加使用这些默认值。

      笔记:由于本规范以前版本的不一致,建议不要对 currencyTimeLimit 使用负值或零值。要指示缓存值永远无效,请省略 currencyTimeLimit 字段。要指示它始终有效,请为此字段使用一个非常大的数字。

      指定者:
      getMBeanDescriptor 在接口 ModelMBeanInfo
      返回:
      MBean 描述符。
      抛出:
      MBeanException - 包装分布式通信异常。
      参见:
    • setMBeanDescriptor

      public void setMBeanDescriptor(Descriptor  inMBeanDescriptor) throws MBeanException , RuntimeOperationsException
      从接口 ModelMBeanInfo 复制的描述
      设置 ModelMBean 的描述符。此描述符包含有关 MBean 的默认 MBean 范围元数据以及持久性和缓存的默认策略。这个操作完全替换了描述符,没有合并。如果要设置的描述符为空,则将创建默认描述符。默认的描述符是: name=className,descriptorType="mbean", displayName=className, persistPolicy="never",log="F",visibility="1" 如果描述符不包含所有这些字段,它们将被添加使用这些默认值。有关有效字段名称的描述,请参阅 getMBeanDescriptor 方法 javadoc。
      指定者:
      setMBeanDescriptor 在接口 ModelMBeanInfo
      参数:
      inMBeanDescriptor - 要设置的描述符。
      抛出:
      MBeanException - 包装分布式通信异常。
      RuntimeOperationsException - 包装无效描述符的 IllegalArgumentException。
      参见: