- java.lang.Object
-  
      - javax.management.JMX
 
-  
       
 public class JMX extends Object JMX API中的静态方法。 没有这个类的实例。- 从以下版本开始:
- 1.6
 
-  
        
       -  
             字段汇总字段 变量和类型 字段 描述 static StringDEFAULT_VALUE_FIELDdefaultValue字段的名称。static StringIMMUTABLE_INFO_FIELDimmutableInfo字段的名称。static StringINTERFACE_CLASS_NAME_FIELDinterfaceClassName字段的名称。static StringLEGAL_VALUES_FIELDlegalValues字段的名称。static StringMAX_VALUE_FIELDmaxValue字段的名称。static StringMIN_VALUE_FIELDminValue字段的名称。static StringMXBEAN_FIELDmxbean字段的名称。static StringOPEN_TYPE_FIELDopenType字段的名称。static StringORIGINAL_TYPE_FIELDoriginalType字段的名称。
 -  
             方法摘要所有方法 静态方法 具体的方法 变量和类型 方法 描述 static booleanisMXBeanInterface(类<?> interfaceClass)测试接口是否是MXBean接口。static <T> TnewMBeanProxy(MBeanServerConnection connection, ObjectName objectName, 类<T> interfaceClass)为本地或远程MBean Server中的标准MBean创建代理。static <T> TnewMBeanProxy(MBeanServerConnection connection, ObjectName objectName, 类<T> interfaceClass, boolean notificationEmitter)为本地或远程MBean Server中的标准MBean创建代理,该MBean也可能支持NotificationEmitter的方法。static <T> TnewMXBeanProxy(MBeanServerConnection connection, ObjectName objectName, 类<T> interfaceClass)为本地或远程MBean Server中的MXBean创建代理。static <T> TnewMXBeanProxy(MBeanServerConnection connection, ObjectName objectName, 类<T> interfaceClass, boolean notificationEmitter)为本地或远程MBean Server中的MXBean创建代理,该服务器也可能支持NotificationEmitter的方法。
 
-  
             
-  
        
       -  
             字段详细信息-  DEFAULT_VALUE_FIELDpublic static final String DEFAULT_VALUE_FIELD defaultValue字段的名称。- 另请参见:
- 常数字段值
 
 -  IMMUTABLE_INFO_FIELDpublic static final String IMMUTABLE_INFO_FIELD immutableInfo字段的名称。- 另请参见:
- 常数字段值
 
 -  INTERFACE_CLASS_NAME_FIELDpublic static final String INTERFACE_CLASS_NAME_FIELD interfaceClassName字段的名称。- 另请参见:
- 常数字段值
 
 -  LEGAL_VALUES_FIELDpublic static final String LEGAL_VALUES_FIELD legalValues字段的名称。- 另请参见:
- 常数字段值
 
 -  ORIGINAL_TYPE_FIELDpublic static final String ORIGINAL_TYPE_FIELD originalType字段的名称。- 另请参见:
- 常数字段值
 
 
-  
 -  
             方法详细信息-  newMBeanProxypublic static <T> T newMBeanProxy(MBeanServerConnection connection, ObjectName objectName, 类<T> interfaceClass) 为本地或远程MBean Server中的标准MBean创建代理。 如果您的MBean Server mbs包含具有ObjectNamename的MBean,并且如果MBean的管理接口由Java接口MyMBean描述,则可以为此MBean构造代理,如下所示:MyMBean proxy = JMX.newMBeanProxy(mbs, name, MyMBean.class);例如,假设 MyMBean看起来像这样:public interface MyMBean { public String getSomeAttribute(); public void setSomeAttribute(String value); public void someOperation(String param1, int param2); }然后你可以执行: -  proxy.getSomeAttribute(),这将致电mbs.getAttribute(name, "SomeAttribute")。
-  proxy.setSomeAttribute("whatever"),这将致电mbs.setAttribute(name, new Attribute("SomeAttribute", "whatever"))。
-  proxy.someOperation("param1", 2)将转换为致电mbs.invoke(name, "someOperation", <etc>)。
 此方法返回的对象是 Proxy,其InvocationHandler是MBeanServerInvocationHandler。此方法相当于 newMBeanProxy(connection, objectName, interfaceClass, false)。- 参数类型
-  
              T- 允许编译器知道,例如,如果interfaceClass参数为MyMBean.class,则返回类型为MyMBean。
- 参数
-  
              connection- 要转发到的MBean服务器。
-  
              objectName- 要转发到的connection内的MBean的名称。
-  
              interfaceClass- MBean导出的管理接口,也将由返回的代理实现。
- 结果
- 新的代理实例。
- 异常
-  
              IllegalArgumentException- 如果interfaceClass不是 compliant MBean interface
 
-  
 -  newMBeanProxypublic static <T> T newMBeanProxy(MBeanServerConnection connection, ObjectName objectName, 类<T> interfaceClass, boolean notificationEmitter) 为本地或远程MBean Server中的标准MBean创建代理,该服务器也可能支持 NotificationEmitter的方法。此方法的行为与 newMBeanProxy(MBeanServerConnection, ObjectName, Class)相同,但另外,如果notificationEmitter是true,则假定MBean为NotificationBroadcaster或NotificationEmitter,返回的代理将实现NotificationEmitter以及interfaceClass。 在代理上调用NotificationBroadcaster.addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)将导致调用MBeanServerConnection.addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object),同样对NotificationBroadcaster和NotificationEmitter的其他方法调用 。- 参数类型
-  
              T- 允许编译器知道,例如,如果interfaceClass参数为MyMBean.class,则返回类型为MyMBean。
- 参数
-  
              connection- 要转发到的MBean服务器。
-  
              objectName- 要转发到的connection内的MBean的名称。
-  
              interfaceClass- MBean导出的管理接口,也将由返回的代理实现。
-  
              notificationEmitter-使返回的代理实现NotificationEmitter经由其方法转发connection。
- 结果
- 新的代理实例。
- 异常
-  
              IllegalArgumentException- 如果interfaceClass不是 compliant MBean interface
 
 -  newMXBeanProxypublic static <T> T newMXBeanProxy(MBeanServerConnection connection, ObjectName objectName, 类<T> interfaceClass) 为本地或远程MBean Server中的MXBean创建代理。如果您的MBean Server mbs包含带有50190578353的name的MXBean,并且如果Java接口MyMXBean描述了MXBean的管理接口,则可以为MXBean构造代理,如下所示:MyMXBean proxy = JMX.newMXBeanProxy(mbs, name, MyMXBean.class);例如,假设 MyMXBean看起来像这样:public interface MyMXBean { public String getSimpleAttribute(); public void setSimpleAttribute(String value); publicMemoryUsagegetMappedAttribute(); public void setMappedAttribute(MemoryUsage memoryUsage); public MemoryUsage someOperation(String param1, MemoryUsage param2); }然后: - proxy.getSimpleAttribute()将致电- mbs.- getAttribute- (name, "SimpleAttribute")。
- proxy.setSimpleAttribute("whatever")将致电- mbs.- setAttribute- (name, new Attribute("SimpleAttribute", "whatever"))。- 因为 - String是一个简单类型 ,在- SimpleType的意义上,它不会在MXBean的上下文中更改。 对于属性- SimpleAttribute,MXBean代理的行为与标准MBean代理(请参阅- newMBeanProxy)- SimpleAttribute。
- proxy.getMappedAttribute()将致电- mbs.getAttribute("MappedAttribute")。 MXBean映射规则意味着属性- MappedAttribute的实际类型将为- CompositeData,这就是- mbs.getAttribute调用将返回的内容。 然后,代理将使用MXBean映射规则将- CompositeData转换回预期类型- MemoryUsage。
- 同样, - proxy.setMappedAttribute(memoryUsage)将转换- MemoryUsage参数为- CompositeData之前调用- mbs.setAttribute。
- proxy.someOperation("whatever", memoryUsage)将- MemoryUsage参数转换为- CompositeData并调用- mbs.invoke。- mbs.invoke返回的值也将是- CompositeData,代理将使用MXBean映射规则将其转换为预期类型- MemoryUsage。
 此方法返回的对象是 Proxy,其InvocationHandler是MBeanServerInvocationHandler。此方法相当于 newMXBeanProxy(connection, objectName, interfaceClass, false)。- 参数类型
-  
              T- 允许编译器知道,例如,如果interfaceClass参数为MyMXBean.class,则返回类型为MyMXBean。
- 参数
-  
              connection- 要转发到的MBean服务器。
-  
              objectName- 要转发到的connection内的MBean的名称。
-  
              interfaceClass- MXBean接口,也将由返回的代理实现。
- 结果
- 新的代理实例。
- 异常
-  
              IllegalArgumentException- 如果interfaceClass不是compliant MXBean interface
 
 -  newMXBeanProxypublic static <T> T newMXBeanProxy(MBeanServerConnection connection, ObjectName objectName, 类<T> interfaceClass, boolean notificationEmitter) 为本地或远程MBean Server中的MXBean创建代理,该服务器也可能支持 NotificationEmitter的方法。此方法与 newMXBeanProxy(MBeanServerConnection, ObjectName, Class)的行为相同,但另外,如果notificationEmitter是true,则假定MXBean为NotificationBroadcaster或NotificationEmitter,返回的代理将实现NotificationEmitter以及interfaceClass。 在代理上调用NotificationBroadcaster.addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)将导致调用MBeanServerConnection.addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object),同样对NotificationBroadcaster和NotificationEmitter的其他方法调用 。- 参数类型
-  
              T- 允许编译器知道,如果interfaceClass参数为MyMXBean.class,则返回类型为MyMXBean。
- 参数
-  
              connection- 要转发到的MBean服务器。
-  
              objectName- 要转发到的connection内的MBean的名称。
-  
              interfaceClass- MXBean接口,也将由返回的代理实现。
-  
              notificationEmitter-使返回的代理实现NotificationEmitter经由其方法转发connection。
- 结果
- 新的代理实例。
- 异常
-  
              IllegalArgumentException- 如果interfaceClass不是compliant MXBean interface
 
 -  isMXBeanInterfacepublic static boolean isMXBeanInterface(类<?> interfaceClass) 测试接口是否是MXBean接口。 接口是MXBean接口,如果它是公共的,注释为 @MXBean或@MXBean(true)或者如果它没有@MXBean注释,并且其名称以“MXBean”结尾。- 参数
-  
              interfaceClass- 候选界面。
- 结果
-  
              如果interfaceClass是compliant MXBean interface,则为true
- 异常
-  
              NullPointerException- 如果interfaceClass为空。
 
 
-  
 
-