MBeanServerInvocationHandler (Java SE 15 & JDK 15) (original) (raw)

All Implemented Interfaces:

[InvocationHandler](../../../java.base/java/lang/reflect/InvocationHandler.html "interface in java.lang.reflect")


public class MBeanServerInvocationHandler extends Object implements InvocationHandler

InvocationHandler that forwards methods in an MBean's management interface through the MBean server to the MBean.

Given an MBeanServerConnection, the ObjectName of an MBean within that MBean server, and a Java interfaceIntf that describes the management interface of the MBean using the patterns for a Standard MBean or an MXBean, this class can be used to construct a proxy for the MBean. The proxy implements the interface Intf such that all of its methods are forwarded through the MBean server to the MBean.

If the InvocationHandler is for an MXBean, then the parameters of a method are converted from the type declared in the MXBean interface into the corresponding mapped type, and the return value is converted from the mapped type into the declared type. For example, with the method
public List<String> reverse(List<String> list);
and given that the mapped type for List<String> is String[], a call to proxy.reverse(someList) will convertsomeList from a List<String> to a String[], call the MBean operation reverse, then convert the returnedString[] into a List<String>.

The method Object.toString(), Object.hashCode(), or Object.equals(Object), when invoked on a proxy using this invocation handler, is forwarded to the MBean server as a method on the proxied MBean only if it appears in one of the proxy's interfaces. For a proxy created with JMX.newMBeanProxy or JMX.newMXBeanProxy, this means that the method must appear in the Standard MBean or MXBean interface. Otherwise these methods have the following behavior:

Since:

1.5

Constructors

Constructor Description
MBeanServerInvocationHandler​(MBeanServerConnection connection,ObjectName objectName) Invocation handler that forwards methods through an MBean server to a Standard MBean.
MBeanServerInvocationHandler​(MBeanServerConnection connection,ObjectName objectName, boolean isMXBean) Invocation handler that can forward methods through an MBean server to a Standard MBean or MXBean.
Modifier and Type Method Description
MBeanServerConnection getMBeanServerConnection() The MBean server connection through which the methods of a proxy using this handler are forwarded.
ObjectName getObjectName() The name of the MBean within the MBean server to which methods are forwarded.
boolean isMXBean() If true, the proxy is for an MXBean, and appropriate mappings are applied to method parameters and return values.
static T newProxyInstance​(MBeanServerConnection connection,ObjectName objectName,Class interfaceClass, boolean notificationBroadcaster) Return a proxy that implements the given interface by forwarding its methods through the given MBean server to the named MBean.

Methods declared in class java.lang.Object

[clone](../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../java.base/java/lang/Object.html#notifyAll%28%29), [toString](../../../java.base/java/lang/Object.html#toString%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../java.base/java/lang/Object.html#wait%28long,int%29)