public static <T> T newPlatformMXBeanProxy (MBeanServerConnection connection, String mxbeanName, Class<T> mxbeanInterface) throws IOException

Returns a proxy for a platform MXBean interface of a given MXBean name that forwards its method calls through the given MBeanServerConnection.

This method is equivalent to:

Proxy.newProxyInstance(mxbeanInterface.getClassLoader(), new Class[] { mxbeanInterface }, handler)
where handler is an InvocationHandler to which method invocations to the MXBean interface are dispatched. This handler converts an input parameter from an MXBean data type to its mapped open type before forwarding to the MBeanServer and converts a return value from an MXBean method call through the MBeanServer from an open type to the corresponding return type declared in the MXBean interface.

If the MXBean is a notification emitter (i.e., it implements NotificationEmitter), both the mxbeanInterface and NotificationEmitter will be implemented by this proxy.

Notes:

  1. Using an MXBean proxy is a convenience remote access to a platform MXBean of a running virtual machine. All method calls to the MXBean proxy are forwarded to an MBeanServerConnection where IOException may be thrown when the communication problem occurs with the connector server. An application remotely accesses the platform MXBeans using proxy should prepare to catch IOException as if accessing with the MBeanServerConnector interface.
  2. When a client application is designed to remotely access MXBeans for a running virtual machine whose version is different than the version on which the application is running, it should prepare to catch InvalidObjectException which is thrown when an MXBean proxy receives a name of an enum constant which is missing in the enum class loaded in the client application.
  3. MBeanServerInvocationHandler or its newProxyInstance method cannot be used to create a proxy for a platform MXBean. The proxy object created by MBeanServerInvocationHandler does not handle the properties of the platform MXBeans described in the class specification.

Parameters:
connection    the MBeanServerConnection to forward to.
mxbeanName    the name of a platform MXBean within connection to forward to. mxbeanName must be in the format of ObjectName.
mxbeanInterface    the MXBean interface to be implemented by the proxy.
<T>    an mxbeanInterface type parameter

Returns:  a proxy for a platform MXBean interface of a given MXBean name that forwards its method calls through the given MBeanServerConnection, or null if not exist.

Exceptions:
IllegalArgumentException    if
  • mxbeanName is not with a valid ObjectName format, or
  • the named MXBean in the connection is not a MXBean provided by the platform, or
  • the named MXBean is not registered in the MBeanServerConnection, or
  • the named MXBean is not an instance of the given mxbeanInterface
java.io.IOException    if a communication problem occurred when accessing the MBeanServerConnection.