public interface MBeanServer extends MBeanServerConnection
这是代理方面的MBean操作界面。 它包含创建,注册和删除MBean所需的方法以及注册的MBean的访问方法。 这是JMX基础架构的核心组件。
用户代码通常不会实现此接口。 相反,使用MBeanServerFactory类中的一种方法获取实现此接口的对象。
添加到MBean服务器中的每个MBean变得可管理:通过连接到该MBean服务器的连接器/适配器,其属性和操作可以远程访问。 除非是符合JMX的MBean,否则无法在MBean服务器中注册Java对象。
当MBean服务器中注册或未注册MBean时,会发出MBeanServerNotification通知。 要注册的对象为收听到你MBeanServerNotifications的应该调用MBean服务器方法addNotificationListener与ObjectName在ObjectName的的MBeanServerDelegate 。 这个ObjectName是:
JMImplementation:type=MBeanServerDelegate 。
从MBeanServerFactory类的createMBeanServer或newMBeanServer方法获取的对象对其方法应用安全检查,如下所示。
首先,如果没有安全管理员( System.getSecurityManager()为null),那么这个接口的实现是免费的,不进行任何检查。
假设有一个安全管理员,或者执行选择进行检查,检查如下所述。 在下文中,除非另有说明, className是目标MBean的MBeanInfo.getClassName()返回的字符串。
如果安全检查失败,该方法将抛出SecurityException 。
对于可以抛出InstanceNotFoundException的方法, 无论权限如何 ,都会抛出不存在的MBean异常。 这是因为一个不存在的MBean没有className 。
对于invoke方法,呼叫者的权限必须意味着MBeanPermission(className, operationName, name, "invoke") 。
对于getAttribute方法,呼叫者的权限必须意味着MBeanPermission(className, attribute, name, "getAttribute") 。
对于getAttributes方法,呼叫者的权限必须意味着MBeanPermission(className, null, name, "getAttribute") 。 此外,对于每个属性在AttributeList ,如果调用者的权限并不意味着MBeanPermission(className, a, name, "getAttribute") ,则MBean服务器的行为与该属性未在所提供的列表。
对于setAttribute方法,呼叫者的权限必须意味着MBeanPermission(className, attrName, name, "setAttribute") ,其中attrName是attribute.getName() 。
对于setAttributes方法,呼叫者的权限必须意味着MBeanPermission(className, null, name, "setAttribute") 。 此外,对于每个属性在AttributeList ,如果调用者的权限并不意味着MBeanPermission(className, a, name, "setAttribute") ,则MBean服务器的行为与该属性未在所提供的列表。
对于addNotificationListener方法,呼叫者的权限必须意味着MBeanPermission(className, null, name, "addNotificationListener") 。
对于removeNotificationListener方法,呼叫者的权限必须意味着MBeanPermission(className, null, name, "removeNotificationListener") 。
对于getMBeanInfo方法,呼叫者的权限必须意味着MBeanPermission(className, null, name, "getMBeanInfo") 。
对于getObjectInstance方法,呼叫者的权限必须意味着MBeanPermission(className, null, name, "getObjectInstance") 。
对于isInstanceOf方法,呼叫者的权限必须意味着MBeanPermission(className, null, name, "isInstanceOf") 。
对于queryMBeans方法,呼叫者的权限必须意味着MBeanPermission(null, null, null, "queryMBeans") 。 此外,对于每个MBean n表示匹配name ,如果调用者的权限并不意味着MBeanPermission(className, null, n, "queryMBeans") ,该MBean服务器的行为与该MBean不存在。
某些查询元素在MBean服务器上执行操作。 如果调用者没有给定MBean所需的权限,该MBean将不会包含在查询的结果中。 受此影响的标准查询元素是Query.attr(String) , Query.attr(String,String)和Query.classattr() 。
对于queryNames方法,该检查是相同queryMBeans除了"queryNames"被用来代替"queryMBeans"在MBeanPermission对象。 请注意,一个"queryMBeans"权限意味着相应的"queryNames"权限。
对于getDomains方法,呼叫者的权限必须暗示MBeanPermission(null, null, null, "getDomains") 。 此外,对于返回的数组中的每个域d ,如果调用者的权限不意味着MBeanPermission(null, null, new ObjectName("d:x=x"), "getDomains") ,则该域将从数组中删除。 这里, x=x是任何key =值对,需要满足ObjectName的构造函数,但没有其他相关。
对于getClassLoader方法,呼叫者的权限必须暗示MBeanPermission(className, null, loaderName, "getClassLoader") 。
对于getClassLoaderFor方法,呼叫者的权限必须意味着MBeanPermission(className, null, mbeanName, "getClassLoaderFor") 。
对于getClassLoaderRepository方法,呼叫者的权限必须意味着MBeanPermission(null, null, null, "getClassLoaderRepository") 。
对于已弃用的deserialize方法,所需的权限与替换它们的方法相同。
对于instantiate方法,调用者的权限必须意味着MBeanPermission(className, null, null, "instantiate") ,其中className是要实例化的类的名称。
对于registerMBean方法,呼叫者的权限必须意味着MBeanPermission(className, null, name, "registerMBean") 。
如果MBeanPermission检查成功,MBean的类通过检查其ProtectionDomain意味着MBeanTrustPermission("register")来验证 。
最后,如果name参数为空,则使用ObjectName返回的ObjectName进行另一个MBeanPermission检查。
对于createMBean方法,调用者的权限必须意味着等效的instantiate所需的instantiate后跟registerMBean 。
对于unregisterMBean方法,呼叫者的权限必须暗示MBeanPermission(className, null, name, "unregisterMBean") 。
| Modifier and Type | Method and Description |
|---|---|
void |
addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
将一个监听器添加到注册的MBean。
|
void |
addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback)
将一个监听器添加到注册的MBean。
|
ObjectInstance |
createMBean(String className, ObjectName name)
在MBean服务器中实例化并注册一个MBean。
|
ObjectInstance |
createMBean(String className, ObjectName name, Object[] params, String[] signature)
在MBean服务器中实例化并注册一个MBean。
|
ObjectInstance |
createMBean(String className, ObjectName name, ObjectName loaderName)
在MBean服务器中实例化并注册一个MBean。
|
ObjectInstance |
createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature)
在MBean服务器中实例化并注册一个MBean。
|
ObjectInputStream |
deserialize(ObjectName name, byte[] data)
已弃用
使用
getClassLoaderFor获取适当的反序列化类加载器。
|
ObjectInputStream |
deserialize(String className, byte[] data)
已弃用
使用
getClassLoaderRepository()获取类加载器存储库并将其用于反序列化。
|
ObjectInputStream |
deserialize(String className, ObjectName loaderName, byte[] data)
已弃用
使用
getClassLoader获取反序列化的类加载器。
|
Object |
getAttribute(ObjectName name, String attribute)
获取命名MBean的特定属性的值。
|
AttributeList |
getAttributes(ObjectName name, String[] attributes)
检索命名MBean的几个属性的值。
|
ClassLoader |
getClassLoader(ObjectName loaderName)
返回名为 ClassLoader 。
|
ClassLoader |
getClassLoaderFor(ObjectName mbeanName)
返回用于加载名为MBean的类的 ClassLoader 。
|
ClassLoaderRepository |
getClassLoaderRepository()
返回此MBeanServer的ClassLoaderRepository。
|
String |
getDefaultDomain()
返回用于命名MBean的默认域。
|
String[] |
getDomains()
返回任何MBean当前注册的域列表。
|
Integer |
getMBeanCount()
返回在MBean服务器中注册的MBeans数。
|
MBeanInfo |
getMBeanInfo(ObjectName name)
此方法可以发现MBean公开管理的属性和操作。
|
ObjectInstance |
getObjectInstance(ObjectName name)
获取在MBean服务器上
ObjectInstance的给定MBean的ObjectInstance。
|
Object |
instantiate(String className)
使用在MBean服务器的 Class Loader Repository中注册的所有类加载器的列表来实例化对象。
|
Object |
instantiate(String className, Object[] params, String[] signature)
使用在MBean服务器 Class Loader Repository中注册的所有类加载器的列表来实例化对象。
|
Object |
instantiate(String className, ObjectName loaderName)
实例化使用由它的指定的类加载器对象
ObjectName 。
|
Object |
instantiate(String className, ObjectName loaderName, Object[] params, String[] signature)
实例化一个对象。
|
Object |
invoke(ObjectName name, String operationName, Object[] params, String[] signature)
调用MBean上的操作。
|
boolean |
isInstanceOf(ObjectName name, String className)
如果指定的MBean是指定类的实例,则返回true,否则返回false。
|
boolean |
isRegistered(ObjectName name)
检查由其对象名称标识的MBean是否已经向MBean服务器注册。
|
Set<ObjectInstance> |
queryMBeans(ObjectName name, QueryExp query)
获取由MBean服务器控制的MBean。
|
Set<ObjectName> |
queryNames(ObjectName name, QueryExp query)
获取由MBean服务器控制的MBean的名称。
|
ObjectInstance |
registerMBean(Object object, ObjectName name)
使用MBean服务器将一个预先存在的对象注册为MBean。
|
void |
removeNotificationListener(ObjectName name, NotificationListener listener)
从注册的MBean中删除一个监听器。
|
void |
removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
从注册的MBean中删除一个监听器。
|
void |
removeNotificationListener(ObjectName name, ObjectName listener)
从注册的MBean中删除一个监听器。
|
void |
removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback)
从注册的MBean中删除一个监听器。
|
void |
setAttribute(ObjectName name, Attribute attribute)
设置命名MBean的特定属性的值。
|
AttributeList |
setAttributes(ObjectName name, AttributeList attributes)
设置一个命名MBean的几个属性的值。
|
void |
unregisterMBean(ObjectName name)
从MBean服务器取消注册MBean。
|
ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException
在MBean服务器中实例化并注册一个MBean。 MBean服务器将使用其Default Loader Repository加载MBean的类。 对象名称与MBean相关联。 如果给定的对象名称为空,则MBean必须通过实现MBeanRegistration接口并从preRegister方法返回名称来提供自己的名称。
此方法相当于createMBean(className, name, (Object[]) null, (String[]) null) 。
如果此方法成功创建一个MBean,将按照above所述发送通知 。
createMBean在界面
MBeanServerConnection
className - 要实例化的MBean的类名。
name - MBean的对象名称。
可能为null。
ObjectInstance ,其中包含ObjectName和新实例化的MBean的Java类名。
如果包含的ObjectName是n ,则包含的Java类名称为getMBeanInfo(n).getClassName() 。
RuntimeOperationsException -包装一个
java.lang.IllegalArgumentException :通过className传入参数是空值,则
ObjectName传入的参数包含一个图案或没有
ObjectName被为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将不会被注册。
ReflectionException - 包裹一个
java.lang.ClassNotFoundException或
java.lang.Exception在尝试调用MBean的构造函数时发生。
InstanceAlreadyExistsException - MBean已经在MBean服务器的控制之下。
MBeanRegistrationException - MBean的preRegister ( MBeanRegistration接口)方法抛出异常。
MBean将不会被注册。
MBeanException - MBean的构造函数已抛出异常
NotCompliantMBeanException - 此类不是符合JMX的MBean
MBeanRegistration
ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
在MBean服务器中实例化并注册一个MBean。 要使用的类加载器由其对象名称标识。 对象名称与MBean相关联。 如果加载器的对象名称为空,则将使用加载MBean服务器的ClassLoader。 如果给出的MBean对象名称为空,则MBean必须通过实现MBeanRegistration接口并从preRegister方法返回名称来提供自己的名称。
此方法相当于createMBean(className, name, loaderName, (Object[]) null, (String[]) null) 。
如果此方法成功创建MBean,将按照above所述发送通知 。
createMBean在界面
MBeanServerConnection
className - 要实例化的MBean的类名。
name - MBean的对象名称。
可能为null。
loaderName - 要使用的类加载器的对象名称。
ObjectInstance ,包含ObjectName和新实例化的MBean的Java类名。
如果包含的ObjectName是n ,则包含的Java类名称为getMBeanInfo(n).getClassName() 。
RuntimeOperationsException -包装一个
java.lang.IllegalArgumentException :通过className传入参数是空值,则
ObjectName传入的参数包含一个图案或没有
ObjectName被为MBean指定。
RuntimeMBeanException - 如果MBean的构造函数或其preRegister或postRegister方法抛出一个RuntimeException 。
如果postRegister ( MBeanRegistration的MBean的接口)方法抛出RuntimeException ,所述createMBean方法将抛出RuntimeMBeanException ,虽然该MBean创建和注册成功了。
在这种情况下,即使createMBean方法抛出异常,MBean也会实际注册。
请注意, RuntimeMBeanException也可以由preRegister抛出,在这种情况下,MBean将不会被注册。
RuntimeErrorException -如果postRegister ( MBeanRegistration的MBean的接口)方法抛出Error ,所述createMBean方法将抛出RuntimeErrorException ,虽然该MBean创建和注册成功了。
在这种情况下,即使createMBean方法抛出异常,MBean也会实际注册。
请注意, RuntimeErrorException也可以由preRegister抛出,在这种情况下MBean将不会被注册。
ReflectionException - 包裹一个
java.lang.ClassNotFoundException或
java.lang.Exception在尝试调用MBean的构造函数时发生。
InstanceAlreadyExistsException - MBean已经在MBean服务器的控制之下了。
MBeanRegistrationException - MBean的preRegister ( MBeanRegistration接口)方法已经抛出异常。
MBean将不会被注册。
MBeanException - MBean的构造函数已抛出异常
NotCompliantMBeanException - 此类不是符合JMX的MBean
InstanceNotFoundException - 指定的类加载器未在MBean服务器中注册。
MBeanRegistration
ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException
Default Loader Repository加载MBean的类。
对象名称与MBean相关联。
如果给定的对象名称为空,则MBean必须通过实现MBeanRegistration接口并从preRegister方法返回名称来提供自己的名称。
如果此方法成功创建MBean,将按照above的说明发送通知 。
createMBean在界面
MBeanServerConnection
className - 要实例化的MBean的类名。
name - MBean的对象名称。
可能为null。
params - 包含要调用的构造函数的参数的数组。
signature - 包含要调用的构造函数的签名的数组。
ObjectInstance ,包含ObjectName和新实例化的MBean的Java类名。
如果包含的ObjectName是n ,则包含的Java类名称为getMBeanInfo(n).getClassName() 。
RuntimeOperationsException -包装一个
java.lang.IllegalArgumentException :通过className传入参数是空值,则
ObjectName传入的参数包含一个图案或没有
ObjectName被为MBean指定。
RuntimeMBeanException - 如果MBean的构造函数或其preRegister或postRegister方法抛出一个RuntimeException 。
如果postRegister ( MBeanRegistration的MBean的接口)方法抛出RuntimeException ,所述createMBean方法将抛出RuntimeMBeanException ,虽然该MBean创建和注册成功了。
在这种情况下,即使createMBean方法抛出异常,MBean也将实际注册。
请注意, RuntimeMBeanException也可以被preRegister抛出,在这种情况下MBean将不会被注册。
RuntimeErrorException -如果postRegister ( MBeanRegistration的MBean的接口)方法抛出Error ,所述createMBean方法将抛出RuntimeErrorException ,虽然该MBean创建和注册成功了。
在这种情况下,即使createMBean方法抛出异常,MBean也将实际注册。
请注意, RuntimeErrorException也可以由preRegister抛出,在这种情况下,MBean将不会被注册。
ReflectionException -包装了
java.lang.ClassNotFoundException或
java.lang.Exception试图调用MBean的构造方法时所发生的。
InstanceAlreadyExistsException - MBean已经在MBean服务器的控制之下了。
MBeanRegistrationException - MBean的preRegister ( MBeanRegistration接口)方法已抛出异常。
MBean将不会被注册。
MBeanException - MBean的构造函数已抛出异常
NotCompliantMBeanException - 此类不是符合JMX的MBean
MBeanRegistration
ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
在MBean服务器中实例化并注册一个MBean。 要使用的类加载器由其对象名称标识。 对象名称与MBean相关联。 如果未指定加载程序的对象名称,则将使用加载MBean服务器的ClassLoader。 如果给出的MBean对象名称为空,则MBean必须通过实现MBeanRegistration接口并从preRegister方法返回名称来提供自己的名称。
createMBean在界面
MBeanServerConnection
className - 要实例化的MBean的类名。
name - MBean的对象名称。
可能为null。
loaderName - 要使用的类加载器的对象名称。
params - 包含要调用的构造函数的参数的数组。
signature - 包含要调用的构造函数的签名的数组。
ObjectInstance ,其中包含ObjectName和新实例化的MBean的Java类名。
如果包含的ObjectName是n ,则包含的Java类名称为getMBeanInfo(n).getClassName() 。
RuntimeOperationsException -包装一个
java.lang.IllegalArgumentException :通过className传入参数是空值,则
ObjectName传入的参数包含一个图案或没有
ObjectName被为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将不会被注册。
ReflectionException -包装了
java.lang.ClassNotFoundException或
java.lang.Exception试图调用MBean的构造方法时所发生的。
InstanceAlreadyExistsException - MBean已经在MBean服务器的控制之下了。
MBeanRegistrationException - MBean的preRegister ( MBeanRegistration接口)方法已抛出异常。
MBean将不会被注册。
MBeanException - MBean的构造函数抛出异常
NotCompliantMBeanException - 此类不是符合JMX的MBean
InstanceNotFoundException - 指定的类加载器未在MBean服务器中注册。
MBeanRegistration
ObjectInstance registerMBean(Object object, ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException
使用MBean服务器将一个预先存在的对象注册为MBean。 如果给定的对象名称为空,则MBean必须通过实现MBeanRegistration接口并从preRegister方法返回名称来提供自己的名称。
如果此方法成功注册了MBean,将按照above的说明发送通知 。
object - 要注册为MBean的MBean。
name - MBean的对象名称。
可能为null。
ObjectInstance ,包含ObjectName和新注册的MBean的Java类名。
如果包含的ObjectName是n ,则包含的Java类名称为getMBeanInfo(n).getClassName() 。
InstanceAlreadyExistsException - MBean已经在MBean服务器的控制之下。
MBeanRegistrationException - MBean的preRegister ( MBeanRegistration接口)方法抛出异常。
MBean将不会被注册。
RuntimeMBeanException -如果postRegister ( MBeanRegistration的MBean的接口)方法抛出RuntimeException ,所述registerMBean方法将抛出RuntimeMBeanException ,虽然该MBean注册成功了。
在这种情况下,即使registerMBean方法抛出异常,MBean也将实际注册。
请注意, RuntimeMBeanException也可以由preRegister抛出,在这种情况下MBean将不会被注册。
RuntimeErrorException - 如果MBean的postRegister ( MBeanRegistration接口)方法抛出Error ,则registerMBean方法将抛出RuntimeErrorException ,尽管MBean注册成功。
在这种情况下,即使registerMBean方法抛出异常,MBean也会实际注册。
请注意, RuntimeErrorException也可以抛出preRegister ,在这种情况下MBean将不会被注册。
NotCompliantMBeanException - 此对象不是符合JMX的MBean
RuntimeOperationsException - 包裹一个
java.lang.IllegalArgumentException :传入参数的对象为null或没有指定对象名称。
MBeanRegistration
void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException
unregisterMBean在界面
MBeanServerConnection
name - 要注销的MBean的对象名称。
RuntimeOperationsException - 包裹一个java.lang.IllegalArgumentException :参数中的对象名称为空,或者您尝试注销时的MBean是MBeanServerDelegate MBean。
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将保持注册。
InstanceNotFoundException - 指定的MBean未在MBean服务器中注册。
MBeanRegistrationException - MBean的preDeregister((
MBeanRegistration接口)方法已经抛出异常。
MBeanRegistration
ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException
MBeanServerConnection复制
ObjectInstance与MBean服务器注册的给定MBean。
getObjectInstance在界面
MBeanServerConnection
name - MBean的对象名称。
ObjectInstance与name指定的与MBean关联。
包含的ObjectName是name ,包含的类名是getMBeanInfo(name).getClassName() 。
InstanceNotFoundException - 指定的MBean未在MBean服务器中注册。
Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query)
ObjectName和/或Query表达式上的模式匹配指定的一组MBean,一个特定的MBean。
当对象名称为空或没有指定域和键属性时,将选择所有对象(如果指定了查询,则过滤它们)。
它返回所选MBean的ObjectInstance对象(包含ObjectName和Java类名)的集合。
queryMBeans在界面
MBeanServerConnection
name - 标识要检索的MBean的对象名称模式。
如果指定了null或没有域和密钥属性,则将检索注册的所有MBean。
query - 要应用于选择MBean的查询表达式。
如果null,则不会应用查询表达式来选择MBean。
ObjectInstance对象。
如果没有MBean满足查询,则返回一个空列表。
RuntimeOperationsException
Set<ObjectName> queryNames(ObjectName name, QueryExp query)
ObjectName和/或Query表达式上的模式匹配指定的一组MBean的名称,特定的MBean名称(相当于测试MBean是否为注册)。
当对象名称为空或没有指定域和键属性时,将选择所有对象(如果指定了查询,则将其过滤)。
它返回所选MBean的一组ObjectNames。
queryNames在界面
MBeanServerConnection
name - 标识要检索的MBean名称的对象名称模式。
如果指定了null或没有域和键属性,将检索所有注册的MBean的名称。
query - 要应用于选择MBean的查询表达式。
如果null,则不会应用查询表达式来选择MBean。
RuntimeOperationsException
boolean isRegistered(ObjectName name)
MBeanServerConnection复制
isRegistered中的
MBeanServerConnection
name - 要检查的MBean的对象名称。
RuntimeOperationsException - 包裹一个
java.lang.IllegalArgumentException :参数中的对象名称为null。
Integer getMBeanCount()
getMBeanCount在界面
MBeanServerConnection
Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException
MBeanServerConnection复制
getAttribute在界面
MBeanServerConnection
name -
name属性的MBean的对象名称。
attribute - 指定要检索的属性名称的字符串。
RuntimeOperationsException - 包装
java.lang.IllegalArgumentException :参数中的对象名称为null或参数中的属性为空。
MBeanException - 包装MBean的getter抛出的异常。
AttributeNotFoundException - 指定的属性在MBean中无法访问。
InstanceNotFoundException - 指定的MBean未在MBean服务器中注册。
ReflectionException - 在尝试调用设置器时抛出一个
java.lang.Exception 。
MBeanServerConnection.setAttribute(javax.management.ObjectName, javax.management.Attribute)
AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException
MBeanServerConnection复制
检索命名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 = new ArrayList<String>(
Arrays.asList(attrNames));
for (Attribute a : list.asList())
missing.remove(a.getName());
System.out.println("Did not retrieve: " + missing);
}
getAttributes在界面
MBeanServerConnection
name -
name属性的MBean的对象名称。
attributes - 要检索的属性列表。
RuntimeOperationsException - 包装
java.lang.IllegalArgumentException :参数中的对象名称为空,或参数中的属性为空。
InstanceNotFoundException - 指定的MBean未在MBean服务器中注册。
ReflectionException - 尝试调用动态MBean的getAttributes方法时发生异常。
MBeanServerConnection.setAttributes(javax.management.ObjectName, javax.management.AttributeList)
void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
MBeanServerConnection复制
setAttribute在界面
MBeanServerConnection
name - 要在其中设置属性的MBean的名称。
attribute - 要设置的属性的标识和要设置的值。
RuntimeOperationsException - 包裹一个
java.lang.IllegalArgumentException :参数中的对象名称为null或参数中的属性为null。
InstanceNotFoundException - 指定的MBean未在MBean服务器中注册。
AttributeNotFoundException - 指定的属性在MBean中无法访问。
InvalidAttributeValueException -
InvalidAttributeValueException的值无效。
MBeanException - 包装由MBean的设置器抛出的异常。
ReflectionException - 在尝试调用setter时,引发
java.lang.Exception 。
MBeanServerConnection.getAttribute(javax.management.ObjectName, java.lang.String)
AttributeList setAttributes(ObjectName name, AttributeList attributes) throws InstanceNotFoundException, ReflectionException
MBeanServerConnection复制
设置一个命名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 = new ArrayList<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);
}
setAttributes在界面
MBeanServerConnection
name - 要在其中设置属性的MBean的对象名称。
attributes - 属性列表:要设置的属性的标识以及要设置的属性值。
RuntimeOperationsException - 包裹一个
java.lang.IllegalArgumentException :参数中的对象名称为null或参数中的属性为空。
InstanceNotFoundException - 指定的MBean未在MBean服务器中注册。
ReflectionException - 尝试调用动态MBean的getAttributes方法时发生异常。
MBeanServerConnection.getAttributes(javax.management.ObjectName, java.lang.String[])
Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException
MBeanServerConnection复制
调用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);
invoke在界面
MBeanServerConnection
name - 要调用该方法的MBean的对象名称。
operationName - 要调用的操作的名称。
params - 包含调用操作时要设置的参数的数组
signature - 包含操作签名的数组,以Class.getName()返回的格式的类名数组。
将使用与用于加载调用操作的MBean相同的类加载器来加载类对象。
InstanceNotFoundException - 指定的MBean未在MBean服务器中注册。
MBeanException - 包装MBean调用方法抛出的异常。
ReflectionException - 在尝试调用该方法时抛出一个
java.lang.Exception 。
String getDefaultDomain()
MBeanServerConnection复制
getDefaultDomain在界面
MBeanServerConnection
String[] getDomains()
MBeanServerConnection复制
返回任何MBean当前注册的域列表。 当且仅当至少有一个MBean注册了一个ObjectName,其中getDomain()等于该字符串时,字符串在返回的数组中。 未定义返回的数组中的字符串顺序。
getDomains在界面
MBeanServerConnection
void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException
将一个监听器添加到注册的MBean。 MBean发出的通知将被转发给收听者。
如果通知源是对MBean对象的引用,则MBean服务器将用该MBean的ObjectName替换它。 否则源不变。addNotificationListener在界面
MBeanServerConnection
name - 应在其上添加侦听器的MBean的名称。
listener - 将处理由注册的MBean发出的通知的侦听器对象。
filter - 过滤器对象。
如果过滤器为空,则在处理通知之前不会执行过滤。
handback - 发出通知时发送到侦听器的上下文。
InstanceNotFoundException - 提供的MBean名称与任何注册的MBean不匹配。
MBeanServerConnection.removeNotificationListener(ObjectName, NotificationListener) ,
MBeanServerConnection.removeNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object)
void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException
将一个监听器添加到注册的MBean。
MBean发出的通知将由MBeanServer转发给侦听器。 如果通知源是对MBean对象的引用,则MBean服务器将用该MBean的ObjectName替换它。 否则源不变。
接收通知的侦听器对象是在调用此方法时用给定名称注册的对象。 即使随后未注册,它将继续收到通知。
addNotificationListener在界面
MBeanServerConnection
name - 要添加侦听器的MBean的名称。
listener - 将处理由注册的MBean发出的通知的侦听器的对象名称。
filter - 过滤器对象。
如果过滤器为空,则在处理通知之前不会执行过滤。
handback - 发出通知时发送到侦听器的上下文。
RuntimeOperationsException - 包裹一个IllegalArgumentException 。
由listener命名的MBean存在但不实现NotificationListener接口。
InstanceNotFoundException - 通知侦听器或通知广播者的MBean名称与任何已注册的MBean不匹配。
MBeanServerConnection.removeNotificationListener(ObjectName, ObjectName) ,
MBeanServerConnection.removeNotificationListener(ObjectName, ObjectName, NotificationFilter, Object)
void removeNotificationListener(ObjectName name, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException
MBeanServerConnection复制
如果监听器注册不止一次,也许使用不同的过滤器或回调函数,此方法将删除所有这些注册。
removeNotificationListener在界面
MBeanServerConnection
name - 应删除侦听器的MBean的名称。
listener - 要删除的侦听器的对象名称。
InstanceNotFoundException - 提供的MBean名称与任何已注册的MBean不匹配。
ListenerNotFoundException - 监听器未在MBean中注册。
MBeanServerConnection.addNotificationListener(ObjectName, ObjectName, NotificationFilter, Object)
void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException
MBeanServerConnection复制
从注册的MBean中删除一个监听器。
该MBean必须有一个与给定匹配的侦听listener , filter和handback参数。 如果有多个这样的听众,只有一个被删除。
filter和handback参数可以为null,当且仅当它们在要删除的侦听器中为空时。
removeNotificationListener在界面
MBeanServerConnection
name - 应删除侦听器的MBean的名称。
listener - 要删除的侦听器的对象名称。
filter - 添加侦听器时指定的过滤器。
handback - 添加侦听器时指定的回调。
InstanceNotFoundException - 提供的MBean名称与任何注册的MBean不匹配。
ListenerNotFoundException - 监听器未在MBean中注册,或者未注册给定过滤器和回传。
MBeanServerConnection.addNotificationListener(ObjectName, ObjectName, NotificationFilter, Object)
void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException
MBeanServerConnection复制
从注册的MBean中删除一个监听器。
如果监听器注册不止一次,也许使用不同的过滤器或回调函数,此方法将删除所有这些注册。
removeNotificationListener在接口
MBeanServerConnection
name - 要删除侦听器的MBean的名称。
listener - 要删除的侦听器。
InstanceNotFoundException - 提供的MBean名称与任何注册的MBean不匹配。
ListenerNotFoundException - 监听器未在MBean中注册。
MBeanServerConnection.addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object)
void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException
MBeanServerConnection复制
从注册的MBean中删除一个监听器。
该MBean必须有一个与给定匹配的侦听listener , filter和handback参数。 如果有多个这样的听众,只有一个被删除。
filter和handback参数可以为null,当且仅当它们在要删除的侦听器中为空时。
removeNotificationListener在界面
MBeanServerConnection
name - 应删除侦听器的MBean的名称。
listener - 要删除的侦听器。
filter - 添加侦听器时指定的过滤器。
handback - 添加侦听器时指定的回传。
InstanceNotFoundException - 提供的MBean名称与任何已注册的MBean不匹配。
ListenerNotFoundException - 监听器未在MBean中注册,或者未注册给定过滤器和回传。
MBeanServerConnection.addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object)
MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, IntrospectionException, ReflectionException
MBeanServerConnection复制
getMBeanInfo在界面
MBeanServerConnection
name - 要分析的MBean的名称
MBeanInfo一个实例允许检索此MBean的所有属性和操作。
InstanceNotFoundException - 未找到
InstanceNotFoundException的MBean。
IntrospectionException - 内省时发生异常。
ReflectionException - 尝试调用动态MBean的getMBeanInfo时发生异常。
boolean isInstanceOf(ObjectName name, String className) throws InstanceNotFoundException
MBeanServerConnection复制
如果指定的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。
否则,结果是假的。
isInstanceOf在界面
MBeanServerConnection
name - MBean的
ObjectName 。
className - 类的名称。
InstanceNotFoundException - 指定的MBean未在MBean服务器中注册。
Class.isInstance(java.lang.Object)
Object instantiate(String className) throws ReflectionException, MBeanException
使用在MBean服务器的Class Loader Repository中注册的所有类加载器的列表来实例化对象。 对象的类应该有一个公共构造函数。 此方法返回对新创建的对象的引用。 新创建的对象未在MBean服务器中注册。
此方法相当于instantiate(className, (Object[]) null, (String[]) null) 。
className - 要实例化的对象的类名。
ReflectionException -包装了
java.lang.ClassNotFoundException或
java.lang.Exception试图调用该对象的构造方法时发生。
MBeanException - 对象的构造函数抛出异常
RuntimeOperationsException - 包裹一个
java.lang.IllegalArgumentException :传入参数的className为null。
Object instantiate(String className, ObjectName loaderName) throws ReflectionException, MBeanException, InstanceNotFoundException
实例化使用由它的指定的类加载器对象ObjectName 。 如果加载程序名称为空,则将使用加载MBean Server的ClassLoader。 对象的类应该有一个公共构造函数。 此方法返回对新创建的对象的引用。 新创建的对象未在MBean服务器中注册。
此方法相当于instantiate(className, loaderName, (Object[]) null, (String[]) null) 。
className - 要实例化的MBean的类名。
loaderName - 要使用的类加载器的对象名称。
ReflectionException -包装了
java.lang.ClassNotFoundException或
java.lang.Exception试图调用该对象的构造方法时发生。
MBeanException - 对象的构造函数抛出异常。
InstanceNotFoundException - 指定的类加载器未在MBeanServer中注册。
RuntimeOperationsException - 包裹一个
java.lang.IllegalArgumentException :传入参数的className为null。
Object instantiate(String className, Object[] params, String[] signature) throws ReflectionException, MBeanException
使用在MBean服务器Class Loader Repository中注册的所有类加载器的列表来实例化对象。 对象的类应该有一个公共构造函数。 该调用返回对新创建的对象的引用。 新创建的对象未在MBean服务器中注册。
className - 要实例化的对象的类名。
params - 包含要调用的构造函数的参数的数组。
signature - 包含要调用的构造函数的签名的数组。
ReflectionException -包装了
java.lang.ClassNotFoundException或
java.lang.Exception试图调用该对象的构造方法时发生。
MBeanException - 对象的构造函数抛出异常
RuntimeOperationsException - 包裹一个
java.lang.IllegalArgumentException :参数中传递的className为null。
Object instantiate(String className, ObjectName loaderName, Object[] params, String[] signature) throws ReflectionException, MBeanException, InstanceNotFoundException
实例化一个对象。 要使用的类加载器由其对象名称标识。 如果加载器的对象名称为空,则将使用加载MBean服务器的ClassLoader。 对象的类应该有一个公共构造函数。 该调用返回对新创建的对象的引用。 新创建的对象未在MBean服务器中注册。
className - 要实例化的对象的类名。
params - 包含要调用的构造函数的参数的数组。
signature - 包含要调用的构造函数的签名的数组。
loaderName - 要使用的类加载器的对象名。
ReflectionException -包装了
java.lang.ClassNotFoundException或
java.lang.Exception试图调用该对象的构造方法时发生。
MBeanException - 对象的构造函数抛出异常
InstanceNotFoundException - 指定的类加载器未在MBean服务器中注册。
RuntimeOperationsException - 包裹一个
java.lang.IllegalArgumentException :传入参数的className为null。
@Deprecated ObjectInputStream deserialize(ObjectName name, byte[] data) throws InstanceNotFoundException, OperationsException
getClassLoaderFor获取适当的反序列化类加载器。
在MBean的类加载器的上下文中取消序列化字节数组。
name - 将类加载器用于解除序列化的MBean的名称。
data - 要去除的字节数组。
InstanceNotFoundException -
InstanceNotFoundException的MBean。
OperationsException - 任何常见的输入/输出相关异常。
@Deprecated ObjectInputStream deserialize(String className, byte[] data) throws OperationsException, ReflectionException
getClassLoaderRepository()获取类加载器存储库并将其用于反序列化。
在给定的MBean类加载器的上下文中取消序列化字节数组。 通过Class Loader Repository加载类className可以找到类加载器。 结果类的类加载器是使用的。
className - 类加载器应用于解除序列化的类的名称。
data - 要解除去的字节数组。
OperationsException - 任何常见的输入/输出相关异常。
ReflectionException - 类加载程序库无法加载指定的类
@Deprecated ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data) throws InstanceNotFoundException, OperationsException, ReflectionException
getClassLoader获取反序列化的类加载器。
在给定的MBean类加载器的上下文中取消序列化字节数组。 类加载器是加载名为“className”的类的加载器。 指定用于加载指定类的类加载器的名称。 如果为空,则将使用MBean Server的类加载器。
className - 类加载器应用于解除序列化的类的名称。
data - 要解除去的字节数组。
loaderName - 用于加载指定类的类加载器的名称。
如果为空,则将使用MBean Server的类加载器。
InstanceNotFoundException - 找不到指定的类加载器MBean。
OperationsException - 任何常见的输入/输出相关异常。
ReflectionException - 指定的类不能由指定的类加载器加载。
ClassLoader getClassLoaderFor(ObjectName mbeanName) throws InstanceNotFoundException
返回用于加载名为MBean的类的ClassLoader 。
mbeanName - MBean的ObjectName。
.loadClass(s)相同升 .loadClass(s)任何字符串s。 InstanceNotFoundException - 如果没有找到命名的MBean。
ClassLoader getClassLoader(ObjectName loaderName) throws InstanceNotFoundException
返回名为ClassLoader 。
loaderName - ClassLoader的ObjectName。
可能为null,在这种情况下,返回MBean服务器自己的ClassLoader。
.loadClass(s)相同升 .loadClass(s)任何字符串s。 InstanceNotFoundException - 如果未找到命名的ClassLoader。
ClassLoaderRepository getClassLoaderRepository()
返回此MBeanServer的ClassLoaderRepository。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.