| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public class MBeanServerInvocationHandler extends Object implements InvocationHandler
{@link InvocationHandler} that forwards methods in an MBean's management interface through the MBean server to the MBean.
Given an {@link MBeanServerConnection}, the {@link ObjectName}
of an MBean within that MBean server, and a Java interface
Intf
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 {@code 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
{@code public List
and given that the mapped type for {@code List
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 {@link JMX#newMBeanProxy(MBeanServerConnection, ObjectName, Class) JMX.newMBeanProxy} or {@link JMX#newMXBeanProxy(MBeanServerConnection, ObjectName, Class) JMX.newMXBeanProxy}, this means that the method must appear in the Standard MBean or MXBean interface. Otherwise these methods have the following behavior:
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
MBeanServerConnection |
The MBean server connection through which the methods of a proxy using this handler are forwarded. |
ObjectName |
The name of the MBean within the MBean server to which methods are forwarded. |
Object |
|
boolean |
isMXBean() If true, the proxy is for an MXBean, and appropriate mappings are applied to method parameters and return values. |
static Object |
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 inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MBeanServerInvocationHandler(MBeanServerConnection connection, ObjectName objectName)
Invocation handler that forwards methods through an MBean server to a Standard MBean. This constructor may be called instead of relying on {@link JMX#newMBeanProxy(MBeanServerConnection, ObjectName, Class) JMX.newMBeanProxy}, for instance if you need to supply a different {@link ClassLoader} to {@link Proxy#newProxyInstance Proxy.newProxyInstance}.
This constructor is not appropriate for an MXBean. Use {@link #MBeanServerInvocationHandler(MBeanServerConnection, ObjectName, boolean)} for that. This constructor is equivalent to {@code new MBeanServerInvocationHandler(connection, objectName, false)}.
connection
- the MBean server connection through which all
methods of a proxy using this handler will be forwarded.objectName
- the name of the MBean within the MBean server
to which methods will be forwarded.public MBeanServerInvocationHandler(MBeanServerConnection connection, ObjectName objectName, boolean isMXBean)
Invocation handler that can forward methods through an MBean server to a Standard MBean or MXBean. This constructor may be called instead of relying on {@link JMX#newMXBeanProxy(MBeanServerConnection, ObjectName, Class) JMX.newMXBeanProxy}, for instance if you need to supply a different {@link ClassLoader} to {@link Proxy#newProxyInstance Proxy.newProxyInstance}.
connection
- the MBean server connection through which all
methods of a proxy using this handler will be forwarded.objectName
- the name of the MBean within the MBean server
to which methods will be forwarded.isMXBean
- if true, the proxy is for an {@link MXBean}, and
appropriate mappings will be applied to method parameters and return
values.Method Detail |
---|
public MBeanServerConnection getMBeanServerConnection()
The MBean server connection through which the methods of a proxy using this handler are forwarded.
public ObjectName getObjectName()
The name of the MBean within the MBean server to which methods are forwarded.
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
proxy
method
args
Throwable
public boolean isMXBean()
If true, the proxy is for an MXBean, and appropriate mappings are applied to method parameters and return values.
public static Object 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. As of 1.6, the methods {@link JMX#newMBeanProxy(MBeanServerConnection, ObjectName, Class)} and {@link JMX#newMBeanProxy(MBeanServerConnection, ObjectName, Class, boolean)} are preferred to this method.
This method is equivalent to {@link Proxy#newProxyInstance
Proxy.newProxyInstance}(interfaceClass.getClassLoader(),
interfaces, handler)
. Here handler
is the
result of {@link #MBeanServerInvocationHandler new
MBeanServerInvocationHandler(connection, objectName)}, and
interfaces
is an array that has one element if
notificationBroadcaster
is false and two if it is
true. The first element of interfaces
is
interfaceClass
and the second, if present, is
NotificationEmitter.class
.
connection
- the MBean server to forward to.objectName
- the name of the MBean within
connection
to forward to.interfaceClass
- the management interface that the MBean
exports, which will also be implemented by the returned proxy.notificationBroadcaster
- make the returned proxy
implement {@link NotificationEmitter} by forwarding its methods
via connection
. A call to {@link
NotificationBroadcaster#addNotificationListener} on the proxy will
result in a call to {@link
MBeanServerConnection#addNotificationListener(ObjectName,
NotificationListener, NotificationFilter, Object)}, and likewise
for the other methods of {@link NotificationBroadcaster} and {@link
NotificationEmitter}.
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |