Top Description Fields Constructors Methods
javax.management

public Class JMX

extends Object
Class Inheritance
Imports
com.sun.jmx.mbeanserver.Introspector, java.lang.reflect.InvocationHandler, .Modifier, .Proxy, sun.reflect.misc.ReflectUtil

Static methods from the JMX API. There are no instances of this class.
Since
1.6

Field Summary

Modifier and TypeField and Description
public static final String
DEFAULT_VALUE_FIELD

The name of the defaultValue field.

public static final String
IMMUTABLE_INFO_FIELD

The name of the immutableInfo field.

public static final String
public static final String
MAX_VALUE_FIELD

The name of the maxValue field.

public static final String
MIN_VALUE_FIELD

The name of the minValue field.

public static final String
MXBEAN_FIELD

The name of the mxbean field.

public static final String
OPEN_TYPE_FIELD

The name of the openType field.

public static final String
ORIGINAL_TYPE_FIELD

The name of the originalType field.

pack-priv static final JMX

Constructor Summary

AccessConstructor and Description
private
JMX()

Method Summary

Modifier and TypeMethod and Description
private static <T> T

Returns:

Returns an M(X)Bean proxy generated for the provided interface class
createProxy
(MBeanServerConnection connection, ObjectName
M(X)Bean object name
objectName
,
Class<T>
M(X)Bean interface class
interfaceClass
,
boolean
Is a notification emitter?
notificationEmitter
,
boolean
Is an MXBean?
isMXBean
)

Centralised M(X)Bean proxy creation code

public static boolean

Returns:

true if interfaceClass is a compliant MXBean interface
isMXBeanInterface
(Class<?>
The candidate interface.
interfaceClass
)

Test whether an interface is an MXBean interface.

public static <
allows the compiler to know that if the interfaceClass parameter is MyMBean.class, for example, then the return type is MyMBean.
T
>
T

Returns:

the new proxy instance.
newMBeanProxy
(MBeanServerConnection
the MBean server to forward to.
connection
,
ObjectName
the name of the MBean within connection to forward to.
objectName
,
Class<T>
the management interface that the MBean exports, which will also be implemented by the returned proxy.
interfaceClass
)

Make a proxy for a Standard MBean in a local or remote MBean Server.

public static <
allows the compiler to know that if the interfaceClass parameter is MyMBean.class, for example, then the return type is MyMBean.
T
>
T

Returns:

the new proxy instance.
newMBeanProxy
(MBeanServerConnection
the MBean server to forward to.
connection
,
ObjectName
the name of the MBean within connection to forward to.
objectName
,
Class<T>
the management interface that the MBean exports, which will also be implemented by the returned proxy.
interfaceClass
,
boolean
make the returned proxy implement NotificationEmitter by forwarding its methods via connection.
notificationEmitter
)

Make a proxy for a Standard MBean in a local or remote MBean Server that may also support the methods of NotificationEmitter.

public static <
allows the compiler to know that if the interfaceClass parameter is MyMXBean.class, for example, then the return type is MyMXBean.
T
>
T

Returns:

the new proxy instance.
newMXBeanProxy
(MBeanServerConnection
the MBean server to forward to.
connection
,
ObjectName
the name of the MBean within connection to forward to.
objectName
,
Class<T>
the MXBean interface, which will also be implemented by the returned proxy.
interfaceClass
)

Make a proxy for an MXBean in a local or remote MBean Server.

public static <
allows the compiler to know that if the interfaceClass parameter is MyMXBean.class, for example, then the return type is MyMXBean.
T
>
T

Returns:

the new proxy instance.
newMXBeanProxy
(MBeanServerConnection
the MBean server to forward to.
connection
,
ObjectName
the name of the MBean within connection to forward to.
objectName
,
Class<T>
the MXBean interface, which will also be implemented by the returned proxy.
interfaceClass
,
boolean
make the returned proxy implement NotificationEmitter by forwarding its methods via connection.
notificationEmitter
)

Make a proxy for an MXBean in a local or remote MBean Server that may also support the methods of NotificationEmitter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_VALUE_FIELDback to summary
public static final String DEFAULT_VALUE_FIELD

The name of the defaultValue field.

IMMUTABLE_INFO_FIELDback to summary
public static final String IMMUTABLE_INFO_FIELD

The name of the immutableInfo field.

INTERFACE_CLASS_NAME_FIELDback to summary
public static final String INTERFACE_CLASS_NAME_FIELD

The name of the interfaceClassName field.

MAX_VALUE_FIELDback to summary
public static final String MAX_VALUE_FIELD

The name of the maxValue field.

MIN_VALUE_FIELDback to summary
public static final String MIN_VALUE_FIELD

The name of the minValue field.

MXBEAN_FIELDback to summary
public static final String MXBEAN_FIELD

The name of the mxbean field.

OPEN_TYPE_FIELDback to summary
public static final String OPEN_TYPE_FIELD

The name of the openType field.

ORIGINAL_TYPE_FIELDback to summary
public static final String ORIGINAL_TYPE_FIELD

The name of the originalType field.

proofback to summary
pack-priv static final JMX proof

Constructor Detail

JMXback to summary
private JMX()

Method Detail

createProxyback to summary
private static <T> T createProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass, boolean notificationEmitter, boolean isMXBean)

Centralised M(X)Bean proxy creation code

Parameters
connection:MBeanServerConnection

MBeanServerConnection to use

objectName:ObjectName

M(X)Bean object name

interfaceClass:Class<T>

M(X)Bean interface class

notificationEmitter:boolean

Is a notification emitter?

isMXBean:boolean

Is an MXBean?

Returns:T

Returns an M(X)Bean proxy generated for the provided interface class

isMXBeanInterfaceback to summary
public static boolean isMXBeanInterface(Class<?> interfaceClass)

Test whether an interface is an MXBean interface. An interface is an MXBean interface if it is public, annotated @MXBean or @MXBean(true) or if it does not have an @MXBean annotation and its name ends with "MXBean".

Parameters
interfaceClass:Class<?>

The candidate interface.

Returns:boolean

true if interfaceClass is a compliant MXBean interface

Exceptions
NullPointerException:
if interfaceClass is null.
newMBeanProxyback to summary
public static <T> T newMBeanProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass)

Make a proxy for a Standard MBean in a local or remote MBean Server.

If you have an MBean Server mbs containing an MBean with ObjectName name, and if the MBean's management interface is described by the Java interface MyMBean, you can construct a proxy for the MBean like this:

MyMBean proxy = JMX.newMBeanProxy(mbs, name, MyMBean.class);

Suppose, for example, MyMBean looks like this:

public interface MyMBean {
    public String getSomeAttribute();
    public void setSomeAttribute(String value);
    public void someOperation(String param1, int param2);
}

Then you can execute:

  • proxy.getSomeAttribute() which will result in a call to mbs.getAttribute(name, "SomeAttribute").
  • proxy.setSomeAttribute("whatever") which will result in a call to mbs.setAttribute(name, new Attribute("SomeAttribute", "whatever")).
  • proxy.someOperation("param1", 2) which will be translated into a call to mbs.invoke(name, "someOperation", <etc>).

The object returned by this method is a Proxy whose InvocationHandler is an MBeanServerInvocationHandler.

This method is equivalent to newMBeanProxy(connection, objectName, interfaceClass, false).

Parameters
<T>
allows the compiler to know that if the interfaceClass parameter is MyMBean.class, for example, then the return type is MyMBean.
connection:MBeanServerConnection

the MBean server to forward to.

objectName:ObjectName

the name of the MBean within connection to forward to.

interfaceClass:Class<T>

the management interface that the MBean exports, which will also be implemented by the returned proxy.

Returns:T

the new proxy instance.

Exceptions
IllegalArgumentException:
if interfaceClass is not a compliant MBean interface
newMBeanProxyback to summary
public static <T> T newMBeanProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass, boolean notificationEmitter)

Make a proxy for a Standard MBean in a local or remote MBean Server that may also support the methods of NotificationEmitter.

This method behaves the same as newMBeanProxy(MBeanServerConnection, ObjectName, Class), but additionally, if notificationEmitter is true, then the MBean is assumed to be a NotificationBroadcaster or NotificationEmitter and the returned proxy will implement NotificationEmitter as well as interfaceClass. A call to NotificationBroadcaster#addNotificationListener on the proxy will result in a call to MBeanServerConnection#addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object), and likewise for the other methods of NotificationBroadcaster and NotificationEmitter.

Parameters
<T>
allows the compiler to know that if the interfaceClass parameter is MyMBean.class, for example, then the return type is MyMBean.
connection:MBeanServerConnection

the MBean server to forward to.

objectName:ObjectName

the name of the MBean within connection to forward to.

interfaceClass:Class<T>

the management interface that the MBean exports, which will also be implemented by the returned proxy.

notificationEmitter:boolean

make the returned proxy implement NotificationEmitter by forwarding its methods via connection.

Returns:T

the new proxy instance.

Exceptions
IllegalArgumentException:
if interfaceClass is not a compliant MBean interface
newMXBeanProxyback to summary
public static <T> T newMXBeanProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass)

Make a proxy for an MXBean in a local or remote MBean Server.

If you have an MBean Server mbs containing an MXBean with ObjectName name, and if the MXBean's management interface is described by the Java interface MyMXBean, you can construct a proxy for the MXBean like this:

MyMXBean proxy = JMX.newMXBeanProxy(mbs, name, MyMXBean.class);

Suppose, for example, MyMXBean looks like this:

public interface MyMXBean {
    public String getSimpleAttribute();
    public void setSimpleAttribute(String value);
    public java.lang.management.MemoryUsage getMappedAttribute();
    public void setMappedAttribute(MemoryUsage memoryUsage);
    public MemoryUsage someOperation(String param1, MemoryUsage param2);
}

Then:

  • proxy.getSimpleAttribute() will result in a call to mbs.getAttribute(name, "SimpleAttribute").

  • proxy.setSimpleAttribute("whatever") will result in a call to mbs.setAttribute(name, new Attribute("SimpleAttribute", "whatever")).

    Because String is a simple type, in the sense of javax.management.openmbean.SimpleType, it is not changed in the context of an MXBean. The MXBean proxy behaves the same as a Standard MBean proxy (see newMBeanProxy) for the attribute SimpleAttribute.

  • proxy.getMappedAttribute() will result in a call to mbs.getAttribute("MappedAttribute"). The MXBean mapping rules mean that the actual type of the attribute MappedAttribute will be CompositeData and that is what the mbs.getAttribute call will return. The proxy will then convert the CompositeData back into the expected type MemoryUsage using the MXBean mapping rules.

  • Similarly, proxy.setMappedAttribute(memoryUsage) will convert the MemoryUsage argument into a CompositeData before calling mbs.setAttribute.

  • proxy.someOperation("whatever", memoryUsage) will convert the MemoryUsage argument into a CompositeData and call mbs.invoke. The value returned by mbs.invoke will be also be a CompositeData, and the proxy will convert this into the expected type MemoryUsage using the MXBean mapping rules.

The object returned by this method is a Proxy whose InvocationHandler is an MBeanServerInvocationHandler.

This method is equivalent to newMXBeanProxy(connection, objectName, interfaceClass, false).

Parameters
<T>
allows the compiler to know that if the interfaceClass parameter is MyMXBean.class, for example, then the return type is MyMXBean.
connection:MBeanServerConnection

the MBean server to forward to.

objectName:ObjectName

the name of the MBean within connection to forward to.

interfaceClass:Class<T>

the MXBean interface, which will also be implemented by the returned proxy.

Returns:T

the new proxy instance.

Exceptions
IllegalArgumentException:
if interfaceClass is not a compliant MXBean interface
newMXBeanProxyback to summary
public static <T> T newMXBeanProxy(MBeanServerConnection connection, ObjectName objectName, Class<T> interfaceClass, boolean notificationEmitter)

Make a proxy for an MXBean in a local or remote MBean Server that may also support the methods of NotificationEmitter.

This method behaves the same as newMXBeanProxy(MBeanServerConnection, ObjectName, Class), but additionally, if notificationEmitter is true, then the MXBean is assumed to be a NotificationBroadcaster or NotificationEmitter and the returned proxy will implement NotificationEmitter as well as interfaceClass. A call to NotificationBroadcaster#addNotificationListener on the proxy will result in a call to MBeanServerConnection#addNotificationListener(ObjectName, NotificationListener, NotificationFilter, Object), and likewise for the other methods of NotificationBroadcaster and NotificationEmitter.

Parameters
<T>
allows the compiler to know that if the interfaceClass parameter is MyMXBean.class, for example, then the return type is MyMXBean.
connection:MBeanServerConnection

the MBean server to forward to.

objectName:ObjectName

the name of the MBean within connection to forward to.

interfaceClass:Class<T>

the MXBean interface, which will also be implemented by the returned proxy.

notificationEmitter:boolean

make the returned proxy implement NotificationEmitter by forwarding its methods via connection.

Returns:T

the new proxy instance.

Exceptions
IllegalArgumentException:
if interfaceClass is not a compliant MXBean interface