- 所有已知的实现类:
ModelMBeanInfoSupport
希望易于管理的 Java 资源使用 MBeanServer 的 createMBean 方法实例化 ModelMBean。该资源然后为 ModelMBean 实例设置 ModelMBeanInfo 和 Descriptors。通过 ModelMBean 的 ModelMBeanInfo 公开的属性、操作和通知构成了管理接口,并且可以像其他 MBean 一样从 MBean、连接器/适配器访问。通过描述符,托管应用程序中的值和方法可以被定义并映射到 ModelMBean 的属性和操作。该map可以在开发期间在文件中定义,也可以在运行时以编程方式动态定义。
在 MBeanServer 中实例化的每个 ModelMBean 都变得易于管理:它的属性、操作和通知变得可以通过连接到该 MBeanServer 的连接器/适配器进行远程访问。 Java 对象不能在 MBeanServer 中注册,除非它是符合 JMX 的 MBean。通过实例化 ModelMBean,资源可以保证 MBean 有效。必须在每个公共方法上抛出 MBeanException 和 RuntimeOperationsException。这允许包装来自分布式通信(RMI、EJB 等)的异常
- 自从:
- 1.5
-
方法总结
修饰符和类型方法描述clone()
创建并返回此对象的副本。getAttribute
(String inName) 返回按名称请求的 ModelMBeanAttributeInfo。返回为管理而公开的属性列表。返回此MBeanInfo
描述的 MBean 的 Java 类的名称。返回 MBean 的公共构造方法列表。返回 MBean 的人类可读描述。getDescriptor
(String inDescriptorName, String inDescriptorType) 返回由名称和描述符类型请求的描述符。getDescriptors
(String inDescriptorType) 返回一个描述符数组,其中包含类型为 inDescriptorType 的 ModelMBeanInfo 的所有描述符。返回包含 MBean 范围策略的 ModelMBean 的描述符。getNotification
(String inName) 返回按名称请求的 ModelMBeanNotificationInfo。返回 MBean 发出的通知列表。getOperation
(String inName) 返回按名称请求的 ModelMBeanOperationInfo。返回 MBean 的操作列表。void
setDescriptor
(Descriptor inDescriptor, String inDescriptorType) 为 ModelMBean 在类型为 inDescriptorType 的信息数组中设置描述符。void
setDescriptors
(Descriptor[] inDescriptors) 添加或替换 ModelMBeanInfo 中的描述符。void
setMBeanDescriptor
(Descriptor inDescriptor) 设置 ModelMBean 的描述符。
-
方法详情
-
getDescriptors
Descriptor [] getDescriptors(String inDescriptorType) throws MBeanException , RuntimeOperationsException 返回一个描述符数组,其中包含类型为 inDescriptorType 的 ModelMBeanInfo 的所有描述符。- 参数:
inDescriptorType
- 必须为要返回的描述符设置的 descriptorType 字段的值。必须是“mbean”、“属性”、“操作”、“构造函数”或“通知”。如果它为 null 或空,则将返回所有类型。- 返回:
- 如果在 DescriptorType 中键入,则包含 ModelMBean 的所有描述符的描述符数组。
- 抛出:
MBeanException
- 包装分布式通信异常。RuntimeOperationsException
- 当参数中的 descriptorType 不是以下之一时包装 IllegalArgumentException:“mbean”、“attribute”、“operation”、“constructor”、“notification”、empty 或 null。- 参见:
-
setDescriptors
添加或替换 ModelMBeanInfo 中的描述符。- 参数:
inDescriptors
- 要在 ModelMBeanInfo 中设置的描述符。列表的空元素将被忽略。所有描述符都必须有名称和描述符类型字段。- 抛出:
RuntimeOperationsException
- 包装空或无效描述符的 IllegalArgumentException。MBeanException
- 包装分布式通信异常。- 参见:
-
getDescriptor
Descriptor getDescriptor(String inDescriptorName, String inDescriptorType) throws MBeanException , RuntimeOperationsException 返回由名称和描述符类型请求的描述符。- 参数:
inDescriptorName
- 描述符的名称。inDescriptorType
- 被请求的描述符的类型。如果这是 null 或空,则搜索所有类型。有效类型为“mbean”、“属性”、“构造函数”、“操作”和“通知”。该值将等于返回的描述符中的“descriptorType”字段。- 返回:
- 包含具有相同名称和 descriptorType 的 ModelMBean 的描述符的描述符。如果未找到描述符,则返回 null。
- 抛出:
MBeanException
- 包装分布式通信异常。RuntimeOperationsException
- 为 null 描述符名称或 null 或无效类型包装 IllegalArgumentException。类型必须是“mbean”、“属性”、“构造函数”、“操作”或“通知”。- 参见:
-
setDescriptor
void setDescriptor(Descriptor inDescriptor, String inDescriptorType) throws MBeanException , RuntimeOperationsException 为 ModelMBean 在类型为 inDescriptorType 的信息数组中设置描述符。将调用相应ModelMBean*Info 的setDescriptor 方法来设置指定的描述符。- 参数:
inDescriptor
- 要在 ModelMBean 中设置的描述符。它不能为空。所有描述符都必须有名称和描述符类型字段。inDescriptorType
- 正在设置的描述符的类型。如果为空,则使用描述符中的 descriptorType 字段。如果指定,则必须在描述符的 descriptorType 字段中设置此值。必须是“mbean”、“属性”、“构造函数”、“操作”或“通知”。- 抛出:
RuntimeOperationsException
- 如果在相应的 MBeanAttributeInfo 或 MBeanConstructorInfo 或 MBeanNotificationInfo 或 MBeanOperationInfo 中找不到描述符的名称字段,则为非法或空参数包装 IllegalArgumentException。MBeanException
- 包装分布式通信异常。- 参见:
-
getMBeanDescriptor
返回包含 MBean 范围策略的 ModelMBean 的描述符。该描述符包含有关 MBean 的元数据以及持久性和缓存的默认策略。
描述符中的字段定义如下,但不限于以下内容。请注意,当此表中的 Type 为 Number 时,也可以使用作为 Long 的十进制表示形式的 String。
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
字段。要指示它始终有效,请为此字段使用一个非常大的数字。- 返回:
- MBean 描述符。
- 抛出:
MBeanException
- 包装分布式通信异常。RuntimeOperationsException
- 获取描述符时发生了RuntimeException
。- 参见:
-
setMBeanDescriptor
设置 ModelMBean 的描述符。此描述符包含有关 MBean 的默认 MBean 范围元数据以及持久性和缓存的默认策略。这个操作完全替换了描述符,没有合并。如果要设置的描述符为空,则将创建默认描述符。默认的描述符是: name=className,descriptorType="mbean", displayName=className, persistPolicy="never",log="F",visibility="1" 如果描述符不包含所有这些字段,它们将被添加使用这些默认值。有关有效字段名称的描述,请参阅getMBeanDescriptor
方法 javadoc。- 参数:
inDescriptor
- 要设置的描述符。- 抛出:
MBeanException
- 包装分布式通信异常。RuntimeOperationsException
- 包装无效描述符的 IllegalArgumentException。- 参见:
-
getAttribute
ModelMBeanAttributeInfo getAttribute(String inName) throws MBeanException , RuntimeOperationsException 返回按名称请求的 ModelMBeanAttributeInfo。- 参数:
inName
- 要获取的 ModelMBeanAttributeInfo 的名称。如果此名称不存在 ModelMBeanAttributeInfo,则返回 null。- 返回:
- 命名属性的属性信息,如果没有则为 null。
- 抛出:
MBeanException
- 包装分布式通信异常。RuntimeOperationsException
- 包装空属性名称的 IllegalArgumentException。
-
getOperation
ModelMBeanOperationInfo getOperation(String inName) throws MBeanException , RuntimeOperationsException 返回按名称请求的 ModelMBeanOperationInfo。- 参数:
inName
- 要获取的 ModelMBeanOperationInfo 的名称。如果此名称不存在 ModelMBeanOperationInfo,则返回 null。- 返回:
- 指定操作的操作信息,如果没有则为 null。
- 抛出:
MBeanException
- 包装分布式通信异常。RuntimeOperationsException
- 包装空操作名称的 IllegalArgumentException。
-
getNotification
ModelMBeanNotificationInfo getNotification(String inName) throws MBeanException , RuntimeOperationsException 返回按名称请求的 ModelMBeanNotificationInfo。- 参数:
inName
- 要获取的 ModelMBeanNotificationInfo 的名称。如果不存在此名称的 ModelMBeanNotificationInfo,则返回 null。- 返回:
- 指定通知的信息,如果没有则为 null。
- 抛出:
MBeanException
- 包装分布式通信异常。RuntimeOperationsException
- 包装空通知名称的 IllegalArgumentException。
-
clone
Object clone()创建并返回此对象的副本。- 返回:
- 此对象的副本
-
getAttributes
MBeanAttributeInfo [] getAttributes()返回为管理而公开的属性列表。每个属性都由一个MBeanAttributeInfo
对象描述。- 返回:
MBeanAttributeInfo
对象的数组。
-
getClassName
String getClassName()返回此MBeanInfo
描述的 MBean 的 Java 类的名称。- 返回:
- Java 类名。
-
getConstructors
MBeanConstructorInfo [] getConstructors()返回 MBean 的公共构造函数列表。每个构造函数都由一个MBeanConstructorInfo
对象描述。- 返回:
MBeanConstructorInfo
对象的数组。
-
getDescription
String getDescription()返回 MBean 的人类可读描述。- 返回:
- 说明。
-
getNotifications
MBeanNotificationInfo [] getNotifications()返回 MBean 发出的通知列表。每个通知都由一个MBeanNotificationInfo
对象描述。除了应用程序指定的任何通知之外,ModelMBean 还可以始终发送两个额外的通知:
- 一个具有描述符名称“GENERIC”和显示名称“jmx.modelmbean.generic”
- 第二个是标准属性更改通知,描述符名称为“ATTRIBUTE_CHANGE”,显示名称为“jmx.attribute.change”
- 返回:
MBeanNotificationInfo
对象的数组。
-
getOperations
MBeanOperationInfo [] getOperations()返回 MBean 的操作列表。每个操作都由一个MBeanOperationInfo
对象描述。- 返回:
MBeanOperationInfo
对象的数组。
-