- 已知的所有子接口:
-
MBeanServer,MBeanServerForwarder
MBeanServer接口扩展了这个接口。
- 自:
- 1.5
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) 向已注册的MBean添加监听器。voidaddNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) 向已注册的MBean添加监听器。createMBean(String className, ObjectName name) 在MBean服务器中实例化并注册一个MBean。createMBean(String className, ObjectName name, Object[] params, String[] signature) 在MBean服务器中实例化并注册一个MBean。createMBean(String className, ObjectName name, ObjectName loaderName) 在MBean服务器中实例化并注册一个MBean。createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) 在MBean服务器中实例化并注册一个MBean。getAttribute(ObjectName name, String attribute) 获取命名MBean的特定属性的值。getAttributes(ObjectName name, String[] attributes) 检索命名MBean的多个属性的值。返回用于命名MBean的默认域。String[]返回当前任何MBean已注册的域的列表。返回MBean服务器中已注册的MBean数量。getMBeanInfo(ObjectName name) 此方法发现MBean为管理公开的属性和操作。getObjectInstance(ObjectName name) 获取已在MBean服务器中注册的给定MBean的ObjectInstance。invoke(ObjectName name, String operationName, Object[] params, String[] signature) 在MBean上调用操作。booleanisInstanceOf(ObjectName name, String className) 如果指定的MBean是指定类的实例,则返回true,否则返回false。booleanisRegistered(ObjectName name) 检查通过其对象名称标识的MBean是否已在MBean服务器中注册。queryMBeans(ObjectName name, QueryExp query) 获取MBean服务器控制的MBean。queryNames(ObjectName name, QueryExp query) 获取MBean服务器控制的MBean的名称。voidremoveNotificationListener(ObjectName name, NotificationListener listener) 从已注册的MBean中删除监听器。voidremoveNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) 从已注册的MBean中删除监听器。voidremoveNotificationListener(ObjectName name, ObjectName listener) 从已注册的MBean中删除监听器。voidremoveNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) 从已注册的MBean中删除监听器。voidsetAttribute(ObjectName name, Attribute attribute) 设置命名MBean的特定属性的值。setAttributes(ObjectName name, AttributeList attributes) 设置命名MBean的多个属性的值。voidunregisterMBean(ObjectName name) 从MBean服务器中注销一个MBean。
-
Method Details
-
createMBean
ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, IOException 在MBean服务器中实例化并注册一个MBean。MBean服务器将使用其
默认加载器存储库来加载MBean的类。与MBean关联一个对象名称。如果给定的对象名称为null,则MBean必须通过实现MBeanRegistration接口并从preRegister方法返回名称来提供自己的名称。此方法等效于
createMBean(className, name, (Object[]) null, (String[]) null)。- 参数:
-
className- 要实例化的MBean的类名。 -
name- MBean的对象名称。可能为null。 - 返回:
-
一个
ObjectInstance,包含新实例化的MBean的ObjectName和Java类名。如果包含的ObjectName为n,则包含的Java类名为。getMBeanInfo(n).getClassName() - 抛出:
-
ReflectionException- 包装了在尝试调用MBean构造函数时发生的java.lang.ClassNotFoundException或java.lang.Exception。 -
InstanceAlreadyExistsException- MBean已经在MBean服务器的控制下。 -
MBeanRegistrationException- MBean的preRegister(MBeanRegistration接口)方法抛出异常。MBean将不会被注册。 -
RuntimeMBeanException- 如果MBean的构造函数或其preRegister或postRegister方法抛出RuntimeException。如果MBean的postRegister(MBeanRegistration接口)方法抛出RuntimeException,createMBean方法将抛出RuntimeMBeanException,尽管MBean的创建和注册成功。在这种情况下,实际上将注册MBean,即使createMBean方法抛出异常。请注意,RuntimeMBeanException也可以由preRegister抛出,在这种情况下,MBean将不会被注册。 -
RuntimeErrorException- 如果MBean的postRegister(MBeanRegistration接口)方法抛出Error,createMBean方法将抛出RuntimeErrorException,尽管MBean的创建和注册成功。在这种情况下,实际上将注册MBean,即使createMBean方法抛出异常。请注意,RuntimeErrorException也可以由preRegister抛出,在这种情况下,MBean将不会被注册。 -
MBeanException- MBean的构造函数抛出异常 -
NotCompliantMBeanException- 此类不是符合JMX标准的MBean -
RuntimeOperationsException- 包装了java.lang.IllegalArgumentException:传递的参数中的className为null,传递的参数中的ObjectName包含模式或未为MBean指定ObjectName。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
createMBean
ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException 在MBean服务器中实例化并注册一个MBean。要使用的类加载器由其对象名称标识。与MBean关联一个对象名称。如果加载器的对象名称为null,则将使用加载MBean服务器的ClassLoader。如果MBean的对象名称为null,则MBean必须通过实现
MBeanRegistration接口并从preRegister方法返回名称来提供自己的名称。此方法等效于
createMBean(className, name, loaderName, (Object[]) null, (String[]) null)。- 参数:
-
className- 要实例化的MBean的类名。 -
name- MBean的对象名称。可以为null。 -
loaderName- 要使用的类加载器的对象名称。 - 返回:
-
一个
ObjectInstance,包含新实例化的MBean的ObjectName和Java类名。如果包含的ObjectName是n,则包含的Java类名是。getMBeanInfo(n).getClassName() - 抛出:
-
ReflectionException- 封装了尝试调用MBean构造函数时发生的java.lang.ClassNotFoundException或java.lang.Exception。 -
InstanceAlreadyExistsException- MBean已经在MBean服务器的控制下。 -
MBeanRegistrationException- MBean的preRegister(MBeanRegistration接口)方法抛出异常。MBean将不会被注册。 -
RuntimeMBeanException- 如果MBean的构造函数或其preRegister或postRegister方法抛出RuntimeException。如果MBean的postRegister(MBeanRegistration接口)方法抛出RuntimeException,createMBean方法将抛出RuntimeMBeanException,尽管MBean的创建和注册成功。在这种情况下,即使createMBean方法抛出异常,MBean实际上也将被注册。请注意,RuntimeMBeanException也可以由preRegister抛出,在这种情况下,MBean将不会被注册。 -
RuntimeErrorException- 如果MBean的postRegister(MBeanRegistration接口)方法抛出Error,createMBean方法将抛出RuntimeErrorException,尽管MBean的创建和注册成功。在这种情况下,即使createMBean方法抛出异常,MBean实际上也将被注册。请注意,RuntimeErrorException也可以由preRegister抛出,在这种情况下,MBean将不会被注册。 -
MBeanException- MBean的构造函数抛出异常 -
NotCompliantMBeanException- 此类不是符合JMX标准的MBean -
InstanceNotFoundException- 指定的类加载器未在MBean服务器中注册。 -
RuntimeOperationsException- 封装了一个java.lang.IllegalArgumentException:传入参数中的className为null,传入参数中的ObjectName包含模式,或未为MBean指定ObjectName。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
createMBean
ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, IOException 在MBean服务器中实例化并注册一个MBean。MBean服务器将使用其默认加载器存储库来加载MBean的类。与MBean关联一个对象名称。如果给定的对象名称为null,则MBean必须通过实现MBeanRegistration接口并从preRegister方法返回名称来提供自己的名称。- 参数:
-
className- 要实例化的MBean的类名。 -
name- MBean的对象名称。可以为null。 -
params- 包含要调用的构造函数的参数的数组。 -
signature- 包含要调用的构造函数的签名的数组。 - 返回:
-
一个
ObjectInstance,包含新实例化的MBean的ObjectName和Java类名。如果包含的ObjectName是n,则包含的Java类名是。getMBeanInfo(n).getClassName() - 抛出:
-
ReflectionException- 封装了尝试调用MBean构造函数时发生的java.lang.ClassNotFoundException或java.lang.Exception。 -
InstanceAlreadyExistsException- MBean已经在MBean服务器的控制下。 -
MBeanRegistrationException- MBean的preRegister(MBeanRegistration接口)方法抛出异常。MBean将不会被注册。 -
RuntimeMBeanException- 如果MBean的构造函数或其preRegister或postRegister方法抛出RuntimeException。如果MBean的postRegister(MBeanRegistration接口)方法抛出RuntimeException,createMBean方法将抛出RuntimeMBeanException,尽管MBean的创建和注册成功。在这种情况下,即使createMBean方法抛出异常,MBean实际上也将被注册。请注意,RuntimeMBeanException也可以由preRegister抛出,在这种情况下,MBean将不会被注册。 -
RuntimeErrorException- 如果MBean的postRegister(MBeanRegistration接口)方法抛出Error,createMBean方法将抛出RuntimeErrorException,尽管MBean的创建和注册成功。在这种情况下,即使createMBean方法抛出异常,MBean实际上也将被注册。请注意,RuntimeErrorException也可以由preRegister抛出,在这种情况下,MBean将不会被注册。 -
MBeanException- MBean的构造函数抛出异常 -
NotCompliantMBeanException- 此类不是符合JMX标准的MBean -
RuntimeOperationsException- 封装了一个java.lang.IllegalArgumentException:传入参数中的className为null,传入参数中的ObjectName包含模式,或未为MBean指定ObjectName。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
createMBean
ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException 在MBean服务器中实例化并注册一个MBean。要使用的类加载器由其对象名称标识。与MBean关联一个对象名称。如果未指定加载器的对象名称,则将使用加载MBean服务器的类加载器。如果给定的MBean对象名称为null,则MBean必须通过实现
MBeanRegistration接口并从preRegister方法返回名称来提供自己的名称。- 参数:
-
className- 要实例化的MBean的类名。 -
name- MBean的对象名称。可以为null。 -
loaderName- 要使用的类加载器的对象名称。 -
params- 包含要调用的构造函数的参数的数组。 -
signature- 包含要调用的构造函数的签名的数组。 - 返回:
-
一个
ObjectInstance,包含新实例化的MBean的ObjectName和Java类名。如果包含的ObjectName是n,则包含的Java类名是。getMBeanInfo(n).getClassName() - 抛出:
-
ReflectionException- 封装了尝试调用MBean构造函数时发生的java.lang.ClassNotFoundException或java.lang.Exception。 -
InstanceAlreadyExistsException- MBean已经受MBean服务器控制。 -
MBeanRegistrationException- MBean的preRegister(MBeanRegistration接口)方法抛出异常。MBean将不会被注册。 -
RuntimeMBeanException- MBean的构造函数或其preRegister或postRegister方法抛出RuntimeException。如果MBean的postRegister(MBeanRegistration接口)方法抛出RuntimeException,createMBean方法将抛出RuntimeMBeanException,尽管MBean的创建和注册成功。在这种情况下,实际上将注册MBean,即使createMBean方法抛出异常。请注意,RuntimeMBeanException也可以由preRegister抛出,在这种情况下,MBean将不会被注册。 -
RuntimeErrorException- 如果MBean的postRegister方法(MBeanRegistration接口)抛出Error,createMBean方法将抛出RuntimeErrorException,尽管MBean的创建和注册成功。在这种情况下,实际上将注册MBean,即使createMBean方法抛出异常。请注意,RuntimeErrorException也可以由preRegister抛出,在这种情况下,MBean将不会被注册。 -
MBeanException- MBean的构造函数抛出异常 -
NotCompliantMBeanException- 此类不是符合JMX标准的MBean -
InstanceNotFoundException- 指定的类加载器未在MBean服务器中注册。 -
RuntimeOperationsException- 封装了java.lang.IllegalArgumentException:传递的参数className为null,传递的ObjectName包含模式或未为MBean指定ObjectName。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
unregisterMBean
void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException, IOException 从MBean服务器中注销一个MBean。MBean由其对象名称标识。一旦调用了该方法,MBean将不再可以通过其对象名称访问。- 参数:
-
name- 要注销的MBean的对象名称。 - 抛出:
-
InstanceNotFoundException- 指定的MBean未在MBean服务器中注册。 -
MBeanRegistrationException- MBean的preDeregister(MBeanRegistration接口)方法抛出异常。 -
RuntimeMBeanException- 如果MBean的postDeregister(MBeanRegistration接口)方法抛出RuntimeException,unregisterMBean方法将抛出RuntimeMBeanException,尽管MBean注销成功。在这种情况下,实际上将注销MBean,即使unregisterMBean方法抛出异常。请注意,RuntimeMBeanException也可以由preDeregister抛出,在这种情况下,MBean将保持注册状态。 -
RuntimeErrorException- 如果MBean的postDeregister(MBeanRegistration接口)方法抛出Error,unregisterMBean方法将抛出RuntimeErrorException,尽管MBean注销成功。在这种情况下,实际上将注销MBean,即使unregisterMBean方法抛出异常。请注意,RuntimeMBeanException也可以由preDeregister抛出,在这种情况下,MBean将保持注册状态。 -
RuntimeOperationsException- 封装了java.lang.IllegalArgumentException:参数中的对象名称为null或您尝试注销的MBean是MBeanServerDelegateMBean。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
getObjectInstance
获取已在MBean服务器中注册的给定MBean的ObjectInstance。- 参数:
-
name- MBean的对象名称。 - 返回:
-
与由name指定的MBean关联的
ObjectInstance。包含的ObjectName是name,包含的类名是。getMBeanInfo(name).getClassName() - 抛出:
-
InstanceNotFoundException- 指定的MBean未在MBean服务器中注册。 -
IOException- 与MBean服务器通信时发生通信问题。
-
queryMBeans
获取MBean服务器控制的MBeans。此方法允许获取以下任何内容:所有MBeans,通过ObjectName的模式匹配和/或查询表达式指定的一组MBeans,特定的MBean。当对象名称为null或未指定域和键属性时,将选择所有对象(如果指定了查询,则将进行过滤)。它返回所选MBeans的ObjectInstance对象集(包含ObjectName和Java类名)。- 参数:
-
name- 标识要检索的MBeans的对象名称模式。如果为null或未指定域和键属性,则将检索所有已注册的MBeans。 -
query- 用于选择MBeans的查询表达式。如果为null,则不会应用查询表达式以选择MBeans。 - 返回:
-
包含所选MBeans的
ObjectInstance对象的集合。如果没有MBean满足查询条件,则返回空列表。 - 抛出:
-
IOException- 与MBean服务器通信时发生通信问题。
-
queryNames
获取MBean服务器控制的MBeans的名称。此方法允许获取以下任何内容:所有MBeans的名称,通过ObjectName的模式匹配和/或查询表达式指定的一组MBeans的名称,特定MBean的名称(相当于测试MBean是否已注册)。当对象名称为null或未指定域和键属性时,将选择所有对象(如果指定了查询,则将进行过滤)。它返回所选MBeans的ObjectName集。- 参数:
-
name- 标识要检索的MBean名称的对象名称模式。如果为null或未指定域和键属性,则将检索所有已注册MBeans的名称。 -
query- 用于选择MBeans的查询表达式。如果为null,则不会应用查询表达式以选择MBeans。 - 返回:
-
包含所选MBeans的
ObjectName的集合。如果没有MBean满足查询条件,则返回空列表。 - 抛出:
-
IOException- 与MBean服务器通信时发生通信问题。
-
isRegistered
检查由其对象名称标识的MBean是否已在MBean服务器中注册。- 参数:
-
name- 要检查的MBean的对象名称。 - 返回:
- 如果MBean已在MBean服务器中注册,则返回true,否则返回false。
- 抛出:
-
RuntimeOperationsException- 封装了java.lang.IllegalArgumentException:参数中的对象名称为null。 -
IOException- 与MBean服务器通信时发生通信问题。
-
getMBeanCount
返回MBean服务器中注册的MBean数量。- 返回:
- 注册的MBean数量。
- 抛出:
-
IOException- 与MBean服务器通信时发生通信问题。
-
getAttribute
Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException, IOException 获取命名MBean的特定属性的值。MBean由其对象名称标识。- 参数:
-
name- 要检索属性的MBean的对象名称。 -
attribute- 指定要检索的属性的名称的字符串。 - 返回:
- 检索到的属性的值。
- 抛出:
-
AttributeNotFoundException- 指定的属性在MBean中不可访问。 -
MBeanException- 包装MBean的getter抛出的异常。 -
InstanceNotFoundException- 指定的MBean未在MBean服务器中注册。 -
ReflectionException- 包装尝试调用setter时抛出的java.lang.Exception。 -
RuntimeOperationsException- 包装java.lang.IllegalArgumentException:参数中的对象名称为null或参数中的属性为null。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
getAttributes
AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException, IOException 检索命名MBean的多个属性的值。MBean由其对象名称标识。
如果由于某种原因无法检索一个或多个属性,则它们将从返回的
AttributeList中省略。调用者应检查列表是否与attributes数组的大小相同。要发现阻止检索给定属性的问题,调用getAttribute以获取该属性。以下是调用此方法并检查是否成功检索所有请求属性的示例:
String[] attrNames = ...; AttributeList list = mbeanServerConnection.getAttributes(objectName, attrNames); if (list.size() == attrNames.length) System.out.println("成功检索所有属性"); else {List<String>missing = newArrayList<String>(Arrays.asList(attrNames)); for (Attribute a : list.asList()) missing.remove(a.getName()); System.out.println("未检索到: " + missing); }- 参数:
-
name- 要从中检索属性的MBean的对象名称。 -
attributes- 要检索的属性列表。 - 返回:
- 检索到的属性列表。
- 抛出:
-
InstanceNotFoundException- 指定的MBean未在MBean服务器中注册。 -
ReflectionException- 尝试调用Dynamic MBean的getAttributes方法时发生异常。 -
RuntimeOperationsException- 包装java.lang.IllegalArgumentException:参数中的对象名称为null或参数中的属性为null。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
setAttribute
void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException, IOException 设置命名MBean的特定属性的值。MBean由其对象名称标识。
- 参数:
-
name- 要设置属性的MBean的名称。 -
attribute- 要设置的属性的标识以及要设置的值。 - 抛出:
-
InstanceNotFoundException- 指定的MBean未在MBean服务器中注册。 -
AttributeNotFoundException- 指定的属性在MBean中不可访问。 -
InvalidAttributeValueException- 为属性指定的值无效。 -
MBeanException- 包装MBean的setter抛出的异常。 -
ReflectionException- 包装尝试调用setter时抛出的java.lang.Exception。 -
RuntimeOperationsException- 包装java.lang.IllegalArgumentException:参数中的对象名称为null或参数中的属性为null。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
setAttributes
AttributeList setAttributes(ObjectName name, AttributeList attributes) throws InstanceNotFoundException, ReflectionException, IOException 设置命名MBean的多个属性的值。MBean由其对象名称标识。
如果由于某种原因无法设置一个或多个属性,则它们将从返回的
AttributeList中省略。调用者应检查输入的AttributeList与输出的列表是否大小相同。要发现阻止设置给定属性的问题,通常可以调用setAttribute来获取该属性,尽管不能保证一定有效(例如,两个属性的值可能被拒绝,因为它们与彼此不一致。仅允许设置其中一个)。以下是调用此方法并检查是否成功设置所有请求属性的示例:
AttributeList inputAttrs = ...; AttributeList outputAttrs = mbeanServerConnection.setAttributes(objectName, inputAttrs); if (inputAttrs.size() == outputAttrs.size()) System.out.println("成功设置所有属性"); else {List<String>missing = newArrayList<String>(); for (Attribute a : inputAttrs.asList()) missing.add(a.getName()); for (Attribute a : outputAttrs.asList()) missing.remove(a.getName()); System.out.println("未设置: " + missing); }- 参数:
-
name- 要在其中设置属性的MBean的对象名称。 -
attributes- 属性列表:要设置的属性的标识以及要设置的值。 - 返回:
- 设置的属性列表及其新值。
- 抛出:
-
InstanceNotFoundException- 指定的MBean未在MBean服务器中注册。 -
ReflectionException- 尝试调用Dynamic MBean的getAttributes方法时发生异常。 -
RuntimeOperationsException- 包装java.lang.IllegalArgumentException:参数中的对象名称为null或参数中的属性为null。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
invoke
Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException, IOException 在MBean上执行操作。
由于需要一个
signature来区分可能重载的操作,因此最好通过MBean代理来调用操作。例如,假设您有一个类似于以下内容的标准MBean接口:public interface FooMBean { public int countMatches(String[] patterns, boolean ignoreCase); }可以如下调用
countMatches操作:String[] myPatterns = ...; int count = (Integer) mbeanServerConnection.invoke( objectName, "countMatches", new Object[] {myPatterns, true}, new String[] {String[].class.getName(), boolean.class.getName()});或者,可以通过代理进行调用:
String[] myPatterns = ...; FooMBean fooProxy = JMX.newMBeanProxy( mbeanServerConnection, objectName, FooMBean.class); int count = fooProxy.countMatches(myPatterns, true);- 参数:
-
name- 要调用方法的MBean对象名称。 -
operationName- 要调用的操作的名称。 -
params- 包含在调用操作时要设置的参数的数组。 -
signature- 包含操作的签名的数组,格式为由Class.getName()返回的格式的类名数组。类对象将使用与调用操作的MBean加载时相同的类加载器加载。 - 返回:
- 操作返回的对象,表示在指定的MBean上调用操作的结果。
- 抛出:
-
InstanceNotFoundException- 指定的MBean未在MBean服务器中注册。 -
MBeanException- 包装了MBean调用方法抛出的异常。 -
ReflectionException- 包装了在尝试调用方法时抛出的java.lang.Exception。 -
IOException- 与MBean服务器通信时发生通信问题。
-
getDefaultDomain
返回用于命名MBean的默认域。如果用户未指定域,则默认域名称将用作MBeans的ObjectName中的域部分。- 返回:
- 默认域。
- 抛出:
-
IOException- 与MBean服务器通信时发生通信问题。
-
getDomains
返回当前注册任何MBean的域列表。仅当至少有一个MBean注册了其
getDomain()等于该字符串时,返回的数组中才有一个字符串。返回的数组中字符串的顺序未定义。- 返回:
- 域列表。
- 抛出:
-
IOException- 与MBean服务器通信时发生通信问题。
-
addNotificationListener
void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, IOException 向已注册的MBean添加监听器。由MBean发出的通知将转发给监听器。
- 参数:
-
name- 应向其添加监听器的MBean的名称。 -
listener- 将处理已注册MBean发出的通知的监听器对象。 -
filter- 过滤器对象。如果filter为null,则在处理通知之前不会执行任何过滤。 -
handback- 发出通知时要发送给监听器的上下文。 - 抛出:
-
InstanceNotFoundException- 提供的MBean名称与已注册的任何MBean都不匹配。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
addNotificationListener
void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, IOException 向已注册的MBean添加监听器。
MBean发出的通知将由MBeanServer转发给监听器。如果通知的源是对MBean对象的引用,则MBean服务器将其替换为该MBean的ObjectName。否则,源保持不变。
接收通知的监听器对象是在调用此方法时使用给定名称注册的对象。即使稍后取消注册,它仍将继续接收通知。
- 参数:
-
name- 应向其添加监听器的MBean的名称。 -
listener- 将处理已注册MBean发出的通知的监听器对象的对象名称。 -
filter- 过滤器对象。如果filter为null,则在处理通知之前不会执行任何过滤。 -
handback- 发出通知时要发送给监听器的上下文。 - 抛出:
-
InstanceNotFoundException- 通知监听器的MBean名称或通知广播器的MBean名称与已注册的任何MBean都不匹配。 -
RuntimeOperationsException- 包装了一个IllegalArgumentException。由listener命名的MBean存在,但未实现NotificationListener接口。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
removeNotificationListener
void removeNotificationListener(ObjectName name, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException 从已注册的MBean中移除监听器。
如果监听器注册了多次,可能使用不同的过滤器或回调函数,此方法将删除所有这些注册。
- 参数:
-
name- 应从其移除监听器的MBean的名称。 -
listener- 要移除的监听器的对象名称。 - 抛出:
-
InstanceNotFoundException- 提供的MBean名称与已注册的任何MBean都不匹配。 -
ListenerNotFoundException- 该监听器未在MBean中注册。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
removeNotificationListener
void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException 从已注册的MBean中移除监听器。
MBean必须具有与给定的
listener、filter和handback参数完全匹配的监听器。如果存在多个这样的监听器,则仅删除一个。如果
filter和handback参数为null,则只有在要移除的监听器中它们为null时才能为null。- 参数:
-
name- 应从其移除监听器的MBean的名称。 -
listener- 要移除的监听器的对象名称。 -
filter- 添加监听器时指定的过滤器。 -
handback- 添加监听器时指定的上下文。 - 抛出:
-
InstanceNotFoundException- 提供的MBean名称与已注册的任何MBean都不匹配。 -
ListenerNotFoundException- 该监听器未在MBean中注册,或者未使用给定的过滤器和上下文注册。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
removeNotificationListener
void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException 从已注册的MBean中移除监听器。
如果监听器注册了多次,可能使用不同的过滤器或回调函数,此方法将删除所有这些注册。
- 参数:
-
name- 应从其移除监听器的MBean的名称。 -
listener- 要移除的监听器。 - 抛出:
-
InstanceNotFoundException- 提供的MBean名称与已注册的任何MBean都不匹配。 -
ListenerNotFoundException- 该监听器未在MBean中注册。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
removeNotificationListener
void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException 从注册的MBean中移除监听器。
MBean必须具有与给定的
listener、filter和handback参数完全匹配的监听器。如果存在多个这样的监听器,则只会移除一个。如果
filter和handback参数为null,则只有在要移除的监听器中它们也为null时才能为null。- 参数:
-
name- 应从中移除监听器的MBean的名称。 -
listener- 要移除的监听器。 -
filter- 添加监听器时指定的过滤器。 -
handback- 添加监听器时指定的回传对象。 - 抛出:
-
InstanceNotFoundException- 提供的MBean名称与注册的任何MBean都不匹配。 -
ListenerNotFoundException- 该监听器未在MBean中注册,或者未使用给定的过滤器和回传对象注册。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-
getMBeanInfo
MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException 该方法发现MBean为管理公开的属性和操作。- 参数:
-
name- 要分析的MBean的名称 - 返回:
-
一个
MBeanInfo实例,允许检索此MBean的所有属性和操作。 - 抛出:
-
IntrospectionException- 在内省期间发生异常。 -
InstanceNotFoundException- 未找到指定的MBean。 -
ReflectionException- 尝试调用动态MBean的getMBeanInfo时发生异常。 -
IOException- 与MBean服务器通信时发生通信问题。
-
isInstanceOf
boolean isInstanceOf(ObjectName name, String className) throws InstanceNotFoundException, IOException 如果指定的MBean是指定类的实例,则返回true,否则返回false。
如果
name未命名MBean,则此方法会抛出InstanceNotFoundException异常。否则,让
X为name命名的MBean,
L为X的ClassLoader,
N为X的MBeanInfo中的类名。如果N等于
className,则结果为true。否则,如果L成功加载
className并且X是此类的实例,则结果为true。否则,如果L成功加载N和
className,并且第二个类可从第一个类分配,则结果为true。否则,结果为false。
- 参数:
-
name- MBean的ObjectName。 -
className- 类的名称。 - 返回:
- 如果根据上述规则指定的MBean是指定类的实例,则返回true,否则返回false。
- 抛出:
-
InstanceNotFoundException- 指定的MBean未在MBean服务器中注册。 -
IOException- 与MBean服务器通信时发生通信问题。 - 参见:
-