- 所有父级接口:
DynamicMBean
,ModelMBeanNotificationBroadcaster
,NotificationBroadcaster
,PersistentMBean
- 所有已知的实现类:
RequiredModelMBean
public interface ModelMBean extends DynamicMBean , PersistentMBean , ModelMBeanNotificationBroadcaster
该接口必须由 ModelMBean 实现。每个 JMX 代理都必须附带此接口的实现。
希望易于管理的 Java 资源使用 MBeanServer 的 createMBean 方法实例化 ModelMBean。然后该资源为 ModelMBean 实例设置 ModelMBeanInfo(带有描述符)。通过 ModelMBeanInfo 为 ModelMBean 公开的属性和操作可从 MBean、连接器/适配器(如其他 MBean)访问。通过 ModelMBeanInfo 描述符,托管应用程序中的值和方法可以被定义并映射到 ModelMBean 的属性和操作。此map可以在开发期间以 XML 格式的文件或在运行时以编程方式动态定义。
在 MBeanServer 中实例化的每个 ModelMBean 都变得易于管理:它的属性和操作变得可以通过连接到该 MBeanServer 的连接器/适配器进行远程访问。 Java 对象不能在 MBeanServer 中注册,除非它是符合 JMX 的 MBean。通过实例化 ModelMBean,资源可以保证 MBean 有效。
必须在每个公共方法上抛出 MBeanException 和 RuntimeOperationsException。这允许包装来自分布式通信(RMI、EJB 等)的异常。除了在规范和 javadoc 中描述的场景外,这些异常不必由实现抛出。
- 自从:
- 1.5
-
方法总结
修饰符和类型方法描述void
setManagedResource
(Object mr, String mr_type) 设置要针对其执行此 ModelMBean 管理接口(MBeanInfo 和描述符)中的所有方法的对象的实例句柄。void
setModelMBeanInfo
(ModelMBeanInfo inModelMBeanInfo) 使用传入的 ModelMBeanInfo 初始化 ModelMBean 对象。在接口 javax.management.DynamicMBean 中声明的方法
getAttribute, getAttributes, getMBeanInfo, invoke, setAttribute, setAttributes
在接口 javax.management.modelmbean.ModelMBeanNotificationBroadcaster 中声明的方法
addAttributeChangeNotificationListener, removeAttributeChangeNotificationListener, sendAttributeChangeNotification, sendAttributeChangeNotification, sendNotification, sendNotification
在接口 javax.management.NotificationBroadcaster 中声明的方法
addNotificationListener, getNotificationInfo, removeNotificationListener
在接口 javax.management.PersistentMBean 中声明的方法
load, store
-
方法详情
-
setModelMBeanInfo
void setModelMBeanInfo(ModelMBeanInfo inModelMBeanInfo) throws MBeanException , RuntimeOperationsException 使用传入的 ModelMBeanInfo 初始化 ModelMBean 对象。只要 ModelMBean 未注册到 MBeanServer,此方法就可以在 ModelMBean 上设置自定义的 ModelMBeanInfo。
一旦 ModelMBean 的 ModelMBeanInfo(带有描述符)被定制并设置在 ModelMBean 上,就可以向 MBeanServer 注册 ModelMBean。如果 ModelMBean 当前已注册,此方法将抛出一个
RuntimeOperationsException
包装一个IllegalStateException
- 参数:
inModelMBeanInfo
- ModelMBean 使用的 ModelMBeanInfo 对象。- 抛出:
MBeanException
- 包装分布式通信异常。RuntimeOperationsException
-- 如果传入参数的 MBeanInfo 为 null,则包装
IllegalArgumentException
。 - 如果 ModelMBean 当前已在 MBeanServer 中注册,则包装一个
IllegalStateException
。
- 如果传入参数的 MBeanInfo 为 null,则包装
-
setManagedResource
void setManagedResource(Object mr, String mr_type) throws MBeanException , RuntimeOperationsException , InstanceNotFoundException , InvalidTargetObjectTypeException 设置要针对其执行此 ModelMBean 管理接口(MBeanInfo 和描述符)中的所有方法的对象的实例句柄。- 参数:
mr
- 作为托管资源的对象mr_type
- 托管资源的引用类型。可以是:ObjectReference、Handle、IOR、EJBHandle、RMIReference。如果 MBeanServer 无法处理传入的 mr_type,则会抛出 InvalidTargetTypeException。- 抛出:
MBeanException
- 对象的初始值设定项引发了异常。RuntimeOperationsException
- 包装 IllegalArgumentException:传入参数的托管资源类型为 null。InstanceNotFoundException
- 找不到托管资源对象InvalidTargetObjectTypeException
- 托管资源类型无法由 ModelMBean 或 JMX 代理处理。
-