javax.management
public class JMX extends Object
Since: 1.6
Field Summary | |
---|---|
static String | DEFAULT_VALUE_FIELD
The name of the defaultValue field. |
static String | IMMUTABLE_INFO_FIELD
The name of the immutableInfo field. |
static String | INTERFACE_CLASS_NAME_FIELD
The name of the interfaceClassName field. |
static String | LEGAL_VALUES_FIELD
The name of the legalValues field. |
static String | MAX_VALUE_FIELD
The name of the maxValue field. |
static String | MIN_VALUE_FIELD
The name of the minValue field. |
static String | MXBEAN_FIELD
The name of the mxbean field. |
static String | OPEN_TYPE_FIELD
The name of the openType field. |
static String | ORIGINAL_TYPE_FIELD
The name of the originalType field. |
Method Summary | |
---|---|
static boolean | isMXBeanInterface(Class<?> iface) Returns true if the given class represents an {@link MXBean} interface. |
static <T> T | newMBeanProxy(MBeanServerConnection conn, ObjectName name, Class<T> iface) Returns a proxy for a standard management bean, using the specified connection to access the named implementation. |
static <T> T | newMBeanProxy(MBeanServerConnection conn, ObjectName name, Class<T> iface, boolean bcast)
Returns a proxy for a standard management bean, using
the specified connection to access the named implementation,
as with {@link #newMBeanProxy(MBeanServerConnection, ObjectName,
Class)}. |
static <T> T | newMXBeanProxy(MBeanServerConnection conn, ObjectName name, Class<T> iface) Returns a proxy for a {@link MXBean}, using the specified connection to access the named implementation. |
static <T> T | newMXBeanProxy(MBeanServerConnection conn, ObjectName name, Class<T> iface, boolean bcast)
Returns a proxy for a {@link MXBean}, using
the specified connection to access the named implementation,
as with {@link #newMXBeanProxy(MBeanServerConnection, ObjectName,
Class)}. |
Returns true if the given class represents an {@link MXBean} interface. An interface is an {@link MXBean interface} if:
Parameters: iface the interface class that is to be checked for {@link MXBean} status.
Returns: true if the interface represents an {@link MXBean}.
Throws: NullPointerException if {@code iface} is {@code null}.
Returns a proxy for a standard management bean, using the specified connection to access the named implementation. To create a proxy for the bean, {@code SomethingMBean}, a call to {@code JMX.newMBeanProxy(server, name, SomethingMBean.class)} is made, where {@code server} is a local or remote management server, and {@code name} is the registered {@link ObjectName} of the implementation of {@code SomethingMBean} to use.
The proxy redirects calls to the methods of the interface, {@link SomethingMBean}, to the appropriate methods of the management server. If {@link SomethingMBean} is specified as follows:
public interface SomethingMBean { String getName(); void setName(String name); void doStuff(); }
The proxy created above will provide these three methods using an instance of {@link MBeanServerInvocationHandler}. The two methods, {@code getName} and {@code setName} define an attribute, {@code Name}, so a call to {@code getName()} will return the value of {@code server.getAttribute(name, "Name")}, while {@code setName(newName)} will result in a call to {@code server.setAttribute(name, new Attribute("Name", newName))}. Finally, {@code doStuff()}, as an operation, will cause the proxy to call {@link MBeanServer#invoke(ObjectName, String, Object[], String[])} as {@code server.invoke(name, "doStuff", null, null)}.
Calling this method is equivalent to calling {@link #newMBeanProxy(MBeanServerConnection, ObjectName, Class, boolean)}.
Parameters: conn the server connection over which to forward calls to the bean. name the registered name of the bean to use to implement the given interface. iface the interface to provide a proxy for.
Returns: a proxy implementing the specified interface using calls to the methods of the bean registered with the supplied server using the given name.
See Also: JMX
Parameters: conn the server connection over which to forward calls to the bean. name the registered name of the bean to use to implement the given interface. iface the interface to provide a proxy for. bcast true if the proxy should implement {@link NotificationEmitter}.
Returns: a proxy implementing the specified interface using calls to the methods of the bean registered with the supplied server using the given name.
See Also: JMX
Returns a proxy for a {@link MXBean}, using the specified connection to access the named implementation. To create a proxy for the bean, {@code SomethingMXBean}, a call to {@code JMX.newMXBeanProxy(server, name, SomethingMXBean.class)} is made, where {@code server} is a local or remote management server, and {@code name} is the registered {@link ObjectName} of the implementation of {@code SomethingMBean} to use.
The proxy redirects calls to the methods of the interface, {@link SomethingMXBean}, to the appropriate methods of the management server with appropriate conversion between Java and open types, according to the MXBean rules. If {@link SomethingMXBean} is specified as follows:
public interface SomethingMXBean { String getName(); void setName(String name); ListgetStatistics(); void setStatistics(List statistics); List getNamedStatistics(String, Map ); }
The proxy created above will provide these five methods using an instance of {@link MBeanServerInvocationHandler}. The two methods, {@code getName} and {@code setName} define an attribute, {@code Name}, so a call to {@code getName()} will return the value of {@code server.getAttribute(name, "Name")}, while {@code setName(newName)} will result in a call to {@code server.setAttribute(name, new Attribute("Name", newName))}. As this uses a simple type, {@link String}, no conversion is necessary.
The two methods, {@code getStatistics} and {@code setStatistics} similarly define another attribute, {@code Statistics}. Calling {@code getStatistics()} will cause a call to the server to be made as before, {@code server.getAttribute(name, "Statistics")}. However, the type of the return value from this call will be an array of {@link Double} objects, as per the {@link MXBean} rules. The proxy converts this back in to a {@link java.util.List} of {@link Double} objects before returning it.
The same process is applied in reverse for {@code setStatistics(newStats)}. The list is converted into an appropriate array before the call to {@link MBeanServerConnection#setAttribute(ObjectName, Attribute)} is made. Finally, a call to {@code getNamedStatistics} will require both a Java to open type conversion on the arguments, and then an open type to Java conversion of the return value. Thus, a proxy enables an {@link MXBean} to be used in cases where the appropriate Java types are available and the user wishes to access the bean using the types directly defined in its interface, just as with standard management beans.
Calling this method is equivalent to calling {@link #newMXBeanProxy(MBeanServerConnection, ObjectName, Class, boolean)}.
Parameters: conn the server connection over which to forward calls to the bean. name the registered name of the bean to use to implement the given interface. iface the interface to provide a proxy for.
Returns: a proxy implementing the specified interface using calls to the methods of the bean registered with the supplied server using the given name.
See Also: JMX
Parameters: conn the server connection over which to forward calls to the bean. name the registered name of the bean to use to implement the given interface. iface the interface to provide a proxy for. bcast true if the proxy should implement {@link NotificationEmitter}.
Returns: a proxy implementing the specified interface using calls to the methods of the bean registered with the supplied server using the given name.
See Also: JMX