-
- All Known Subinterfaces:
-
MBeanServer,MBeanServerForwarder
public interface MBeanServerConnection此接口表示与MBean服务器通信的方式,无论是本地还是远程。 代表本地MBean服务器的MBeanServer接口扩展了此接口。- 从以下版本开始:
- 1.5
-
-
方法摘要
所有方法 接口方法 抽象方法 Modifier and Type 方法 描述 voidaddNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)将一个监听器添加到注册的MBean。voidaddNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback)将一个监听器添加到注册的MBean。ObjectInstancecreateMBean(String className, ObjectName name)在MBean服务器中实例化并注册一个MBean。ObjectInstancecreateMBean(String className, ObjectName name, Object[] params, String[] signature)在MBean服务器中实例化并注册一个MBean。ObjectInstancecreateMBean(String className, ObjectName name, ObjectName loaderName)在MBean服务器中实例化并注册一个MBean。ObjectInstancecreateMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature)在MBean服务器中实例化并注册一个MBean。ObjectgetAttribute(ObjectName name, String attribute)获取命名MBean的特定属性的值。AttributeListgetAttributes(ObjectName name, String[] attributes)检索命名MBean的几个属性的值。StringgetDefaultDomain()返回用于命名MBean的默认域。String[]getDomains()返回任何MBean当前注册的域列表。IntegergetMBeanCount()返回在MBean服务器中注册的MBeans数。MBeanInfogetMBeanInfo(ObjectName name)此方法可以发现MBean公开管理的属性和操作。ObjectInstancegetObjectInstance(ObjectName name)获取为MBean服务器注册的给定MBean的ObjectInstance。Objectinvoke(ObjectName name, String operationName, Object[] params, String[] signature)调用MBean上的操作。booleanisInstanceOf(ObjectName name, String className)如果指定的MBean是指定类的实例,则返回true,否则返回false。booleanisRegistered(ObjectName name)检查由其对象名称标识的MBean是否已经向MBean服务器注册。Set<ObjectInstance>queryMBeans(ObjectName name, QueryExp query)获取由MBean服务器控制的MBean。Set<ObjectName>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的特定属性的值。AttributeListsetAttributes(ObjectName name, AttributeList attributes)设置一个命名MBean的几个属性的值。voidunregisterMBean(ObjectName name)从MBean服务器取消注册MBean。
-
-
-
方法详细信息
-
createMBean
ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, IOException
在MBean服务器中实例化并注册一个MBean。 MBean服务器将使用其
Default Loader Repository加载MBean的类。 对象名称与MBean相关联。 如果给定的对象名称为空,则MBean必须通过实现MBeanRegistration接口并从preRegister方法返回名称来提供自己的名称。此方法相当于
createMBean(className, name, (Object[]) null, (String[]) null)。- 参数
-
className- 要实例化的MBean的类名。 -
name- MBean的对象名称。 可能为null。 - 结果
-
一个
ObjectInstance,其中包含ObjectName和新实例化的MBean的Java类名。 如果包含的ObjectName是n,则包含的Java类名称为。getMBeanInfo(n).getClassName() - 异常
-
ReflectionException- 包装一个java.lang.ClassNotFoundException或java.lang.Exception,当尝试调用MBean的构造函数时。 -
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-如果postRegister(MBeanRegistration的MBean的接口)方法抛出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服务器通信时发生通信问题。 - 另请参见:
-
MBeanRegistration
-
createMBean
ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException
在MBean服务器中实例化并注册一个MBean。 要使用的类加载器由其对象名称标识。 对象名称与MBean相关联。 如果加载器的对象名为null,则将使用加载MBean服务器的ClassLoader。 如果给出的MBean的对象名称为空,则MBean必须通过实现
MBeanRegistration接口并从preRegister方法返回名称来提供自己的名称。此方法相当于
createMBean(className, name, loaderName, (Object[]) null, (String[]) null)。- 参数
-
className- 要实例化的MBean的类名。 -
name- MBean的对象名称。 可能为null。 -
loaderName- 要使用的类加载器的对象名称。 - 结果
-
一个
ObjectInstance,包含ObjectName和新实例化的MBean的Java类名。 如果包含的ObjectName是n,则包含的Java类名称为。getMBeanInfo(n).getClassName() - 异常
-
ReflectionException- 包装一个java.lang.ClassNotFoundException或java.lang.Exception,当尝试调用MBean的构造函数时发生。 -
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服务器通信时发生通信问题。 - 另请参见:
-
MBeanRegistration
-
createMBean
ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, IOException
在MBean服务器中实例化并注册一个MBean。 MBean服务器将使用其Default Loader Repository加载MBean的类。 对象名称与MBean相关联。 如果给定的对象名称为空,则MBean必须通过实现MBeanRegistration接口并从preRegister方法返回名称来提供自己的名称。- 参数
-
className- 要实例化的MBean的类名。 -
name- MBean的对象名称。 可能为null。 -
params- 包含要调用的构造函数的参数的数组。 -
signature- 包含要调用的构造函数的签名的数组。 - 结果
-
一个
ObjectInstance,包含ObjectName和新实例化的MBean的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服务器通信时发生通信问题。 - 另请参见:
-
MBeanRegistration
-
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服务器的ClassLoader。 如果给出的MBean对象名称为空,则MBean必须通过实现
MBeanRegistration接口并从preRegister方法返回名称来提供自己的名称。- 参数
-
className- 要实例化的MBean的类名。 -
name- MBean的对象名称。 可能为null。 -
params- 包含要调用的构造函数的参数的数组。 -
signature- 包含要调用的构造函数的签名的数组。 -
loaderName- 要使用的类加载器的对象名称。 - 结果
-
一个
ObjectInstance,包含ObjectName和新实例化的MBean的Java类名。 如果包含的ObjectName是n,则包含的Java类名称为。getMBeanInfo(n).getClassName() - 异常
-
ReflectionException- 包装一个java.lang.ClassNotFoundException或java.lang.Exception,当尝试调用MBean的构造函数时发生。 -
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服务器通信时发生通信问题。 - 另请参见:
-
MBeanRegistration
-
unregisterMBean
void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException, IOException
从MBean服务器取消注册MBean。 MBean由其对象名称标识。 一旦方法被调用,MBean可能不再被其对象名称访问。- 参数
-
name- 要注销的MBean的对象名称。 - 异常
-
InstanceNotFoundException- 指定的MBean未在MBean服务器中注册。 -
MBeanRegistrationException- MBean的preDeregister((MBeanRegistration接口)方法已经抛出异常。 -
RuntimeMBeanException-如果postDeregister(MBeanRegistration的MBean的接口)方法抛出一个RuntimeException,该unregisterMBean方法将抛出RuntimeMBeanException,虽然该MBean注销成功。 在这种情况下,即使unregisterMBean方法抛出异常,MBean实际上也将被注销。 请注意,RuntimeMBeanException也可以抛出preDeregister,在这种情况下,MBean将保持注册。 -
RuntimeErrorException-如果postDeregister(MBeanRegistration的MBean的接口)方法抛出Error,所述unregisterMBean方法将抛出RuntimeErrorException,虽然该MBean注销成功。 在这种情况下,即使unregisterMBean方法抛出异常,MBean实际上也是未注册的。 请注意,RuntimeMBeanException也可以抛出preDeregister,在这种情况下,MBean将保持注册。 -
RuntimeOperationsException- 包裹一个java.lang.IllegalArgumentException:参数中的对象名称为null或尝试注销时的MBean是MBeanServerDelegateMBean。 -
IOException- 与MBean服务器通信时发生通信问题。 - 另请参见:
-
MBeanRegistration
-
getObjectInstance
ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException, IOException
获取为MBean服务器注册的给定MBean的ObjectInstance。- 参数
-
name- MBean的对象名称。 - 结果
-
与名称指定的MBean相关联的
ObjectInstance。 包含的ObjectName是name,包含的类名是。getMBeanInfo(name).getClassName() - 异常
-
InstanceNotFoundException- 指定的MBean未在MBean服务器中注册。 -
IOException- 与MBean服务器通信时发生通信问题。
-
queryMBeans
Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) throws IOException
获取由MBean服务器控制的MBean。 此方法允许获取以下任何内容:所有MBean,由ObjectName和/或Query表达式上的模式匹配指定的一组MBean,特定的MBean。 当对象名称为空或没有指定域和键属性时,将选择所有对象(如果指定了查询,则过滤它们)。 它返回所选MBean的一组ObjectInstance对象(包含ObjectName和Java类名)。- 参数
-
name- 标识要检索的MBean的对象名称模式。 如果指定了null或没有域和密钥属性,则将检索注册的所有MBean。 -
query- 要应用于选择MBean的查询表达式。 如果null,则不会应用查询表达式来选择MBean。 - 结果
-
一组包含所选MBean的
ObjectInstance对象。 如果没有MBean满足查询,则返回一个空列表。 - 异常
-
IOException- 与MBean服务器通信时发生通信问题。
-
queryNames
Set<ObjectName> queryNames(ObjectName name, QueryExp query) throws IOException
获取由MBean服务器控制的MBean的名称。 该方法可以获得以下任何一种:所有MBean的名称,由ObjectName和/或Query表达式通过模式匹配指定的一组MBean的名称,特定的MBean名称(相当于测试MBean是否为注册)。 当对象名称为空或没有指定域和键属性时,将选择所有对象(如果指定了查询,则将其过滤)。 它返回所选MBean的一组ObjectNames。- 参数
-
name- 标识要检索的MBean名称的对象名称模式。 如果指定了null或没有域和键属性,将检索所有注册的MBean的名称。 -
query- 要应用于选择MBean的查询表达式。 如果null,则不会应用查询表达式来选择MBean。 - 结果
- 包含所选MBean的ObjectName的集合。 如果没有MBean满足查询,则返回一个空列表。
- 异常
-
IOException- 与MBean服务器通信时发生通信问题。
-
isRegistered
boolean isRegistered(ObjectName name) throws IOException
检查由其对象名称标识的MBean是否已经向MBean服务器注册。- 参数
-
name- 要检查的MBean的对象名称。 - 结果
- 如果MBean已经在MBean服务器中注册,则为true,否则为false。
- 异常
-
RuntimeOperationsException- 包裹一个java.lang.IllegalArgumentException:参数中的对象名称为空。 -
IOException- 与MBean服务器通信时发生通信问题。
-
getMBeanCount
Integer getMBeanCount() throws IOException
返回在MBean服务器中注册的MBeans数。- 结果
- 注册的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- 在尝试调用设置器时抛出一个java.lang.Exception。 -
RuntimeOperationsException- 包裹一个java.lang.IllegalArgumentException:参数中的对象名称为null或参数中的属性为null。 -
IOException- 与MBean服务器通信时发生通信问题。 - 另请参见:
-
setAttribute(javax.management.ObjectName, javax.management.Attribute)
-
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("All attributes were retrieved successfully"); else {List<String>missing = newArrayList<String>(Arrays.asList(attrNames)); for (Attribute a : list.asList()) missing.remove(a.getName()); System.out.println("Did not retrieve: " + missing); }- 参数
-
name- 从中检索属性的MBean的对象名称。 -
attributes- 要检索的属性的列表。 - 结果
- 检索属性的列表。
- 异常
-
InstanceNotFoundException- 指定的MBean未在MBean服务器中注册。 -
ReflectionException- 尝试调用动态MBean的getAttributes方法时发生异常。 -
RuntimeOperationsException- 包装java.lang.IllegalArgumentException:参数中的对象名称为空,或参数中的属性为空。 -
IOException- 与MBean服务器通信时发生通信问题。 - 另请参见:
-
setAttributes(javax.management.ObjectName, javax.management.AttributeList)
-
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的设置器抛出的异常。 -
ReflectionException- 在尝试调用设置器时抛出一个java.lang.Exception。 -
RuntimeOperationsException- 包裹一个java.lang.IllegalArgumentException:参数中的对象名称为null或参数中的属性为null。 -
IOException- 与MBean服务器通信时发生通信问题。 - 另请参见:
-
getAttribute(javax.management.ObjectName, java.lang.String)
-
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("All attributes were set successfully"); 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("Did not set: " + missing); }- 参数
-
name- 要在其中设置属性的MBean的对象名称。 -
attributes- 属性列表:要设置的属性的标识以及要设置的属性值。 - 结果
- 已设置的属性列表及其新值。
- 异常
-
InstanceNotFoundException- 指定的MBean未在MBean服务器中注册。 -
ReflectionException- 尝试调用动态MBean的getAttributes方法时发生异常。 -
RuntimeOperationsException- 包裹一个java.lang.IllegalArgumentException:参数中的对象名称为null或参数中的属性为空。 -
IOException- 与MBean服务器通信时发生通信问题。 - 另请参见:
-
getAttributes(javax.management.ObjectName, java.lang.String[])
-
invoke
Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException, IOException
调用MBean上的操作。
由于需要一个
signature来区分可能的重载操作,所以在可能的情况下通过MBean proxy调用操作要简单得多。 例如,假设你有一个这样的标准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
String getDefaultDomain() throws IOException
返回用于命名MBean的默认域。 如果用户没有指定域,默认域名将用作MBeans的ObjectName中的域部分。- 结果
- 默认域。
- 异常
-
IOException- 与MBean服务器通信时发生通信问题。
-
getDomains
String[] getDomains() throws IOException
返回任何MBean当前注册的域列表。 当且仅当至少有一个注册了一个ObjectName的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- 过滤器对象。 如果过滤器为空,则在处理通知之前不会执行过滤。 -
handback- 发出通知时发送到侦听器的上下文。 - 异常
-
InstanceNotFoundException- 提供的MBean名称与任何注册的MBean不匹配。 -
IOException- 与MBean服务器通信时发生通信问题。 - 另请参见:
-
removeNotificationListener(ObjectName, NotificationListener),removeNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object)
-
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- 过滤器对象。 如果过滤器为空,则在处理通知之前不会执行过滤。 -
handback- 发出通知时发送到侦听器的上下文。 - 异常
-
InstanceNotFoundException- 通知侦听器或通知广播者的MBean名称与任何注册的MBean不匹配。 -
RuntimeOperationsException- 包装IllegalArgumentException。 由listener命名的MBean存在但不实现NotificationListener接口。 -
IOException- 与MBean服务器通信时发生通信问题。 - 另请参见:
-
removeNotificationListener(ObjectName, ObjectName),removeNotificationListener(ObjectName, ObjectName, NotificationFilter, Object)
-
removeNotificationListener
void removeNotificationListener(ObjectName name, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException
从注册的MBean中删除一个监听器。如果监听器注册不止一次,也许使用不同的过滤器或回调函数,此方法将删除所有这些注册。
- 参数
-
name- 应删除侦听器的MBean的名称。 -
listener- 要删除的侦听器的对象名称。 - 异常
-
InstanceNotFoundException- 提供的MBean名称与任何已注册的MBean不匹配。 -
ListenerNotFoundException- 监听器未在MBean中注册。 -
IOException- 与MBean服务器通信时发生通信问题。 - 另请参见:
-
addNotificationListener(ObjectName, ObjectName, NotificationFilter, Object)
-
removeNotificationListener
void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException
从注册的MBean中删除一个监听器。
该MBean必须有一个与给定匹配的侦听
listener,filter,并handback参数。 如果有多个这样的听众,只有一个被删除。当且仅当它们在要删除的侦听器中为空时,
filter和handback参数可能为空。- 参数
-
name- 应删除侦听器的MBean的名称。 -
listener- 要删除的侦听器的对象名称。 -
filter- 添加侦听器时指定的过滤器。 -
handback- 添加侦听器时指定的handback。 - 异常
-
InstanceNotFoundException- 提供的MBean名称与任何已注册的MBean不匹配。 -
ListenerNotFoundException- 监听器未在MBean中注册,或者未注册给定过滤器和回传。 -
IOException- 与MBean服务器通信时发生通信问题。 - 另请参见:
-
addNotificationListener(ObjectName, ObjectName, NotificationFilter, Object)
-
removeNotificationListener
void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException
从注册的MBean中删除一个监听器。
如果监听器注册不止一次,也许使用不同的过滤器或回调函数,此方法将删除所有这些注册。
- 参数
-
name- 应删除侦听器的MBean的名称。 -
listener- 要删除的侦听器。 - 异常
-
InstanceNotFoundException- 提供的MBean名称与任何注册的MBean不匹配。 -
ListenerNotFoundException- 监听器未在MBean中注册。 -
IOException- 与MBean服务器通信时发生通信问题。 - 另请参见:
-
addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object)
-
removeNotificationListener
void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException
从注册的MBean中删除一个监听器。
该MBean必须有一个与给定匹配的侦听
listener,filter,并handback参数。 如果有多个这样的听众,只有一个被删除。当且仅当在要删除的侦听器中为空时,
filter和handback参数可能为null。- 参数
-
name- 应删除侦听器的MBean的名称。 -
listener- 要删除的侦听器。 -
filter- 添加侦听器时指定的过滤器。 -
handback- 添加侦听器时指定的handback。 - 异常
-
InstanceNotFoundException- 提供的MBean名称与任何已注册的MBean不匹配。 -
ListenerNotFoundException- 侦听器未在MBean中注册,或者未注册给定的过滤器和回传。 -
IOException- 与MBean服务器通信时发生通信问题。 - 另请参见:
-
addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object)
-
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,则结果为真。否则,如果L成功加载
className并且X是此类的实例,则结果为true。否则,如果L成功加载N和
className,并且第二个类可以从第一个类可分配,则结果为true。否则,结果是假的。
- 参数
-
name- MBean的ObjectName。 -
className- 类的名称。 - 结果
- 如果指定的MBean是根据上述规则的指定类的实例,则为true,否则为false。
- 异常
-
InstanceNotFoundException- 指定的MBean未在MBean服务器中注册。 -
IOException- 与MBean服务器通信时发生通信问题。 - 另请参见:
-
Class.isInstance(java.lang.Object)
-
-