This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.management
class MBeanServerInvocationHandler

java.lang.Object extended by javax.management.MBeanServerInvocationHandler
All Implemented Interfaces:
InvocationHandler

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 reverse(List list);}
and given that the mapped type for {@code List} is {@code String[]}, a call to {@code proxy.reverse(someList)} will convert {@code someList} from a {@code List} to a {@code String[]}, call the MBean operation {@code reverse}, then convert the returned {@code String[]} into a {@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

          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
invoke(Object proxy, Method method, Object[] args)

          
 boolean

          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

MBeanServerInvocationHandler

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)}.

Parameters:
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.

MBeanServerInvocationHandler

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}.

Parameters:
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

getMBeanServerConnection

public MBeanServerConnection getMBeanServerConnection()

The MBean server connection through which the methods of a proxy using this handler are forwarded.

Returns:
the MBean server connection.

getObjectName

public ObjectName getObjectName()

The name of the MBean within the MBean server to which methods are forwarded.

Returns:
the object name.

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Parameters:
proxy
method
args
Throws:
Throwable

isMXBean

public boolean isMXBean()

If true, the proxy is for an MXBean, and appropriate mappings are applied to method parameters and return values.

Returns:
whether the proxy is for an MXBean.

newProxyInstance

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.

Parameters:
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}.
Returns:
the new proxy instance.


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.