Basic Example of JMX Technology--转载
原文地址:http://nick-lab.gs.washington.edu/java/jdk1.5b/guide/jmx/tutorial/connectors.html
,?,??and?. This example demonstrates standard and dynamic MBeans only.
?and a? ?and a?
Open the?
?directory.
?class is shown in several code excerpts.
?class creates a new MBean server called? ?method of the? ?is also identified by a variable,in this case the string? ,is defined as the combination of the domain,plus the following key=value pairs: ,which in this case is the? ,to differentiate this MBean from other MBeans of the same type that might be created subsequently. In this case the index number is? ?is to give the MBean a human-readable identifier.
,and? ?is created and registered in the MBean server in exactly the same way as the? ?creates a new service URL called? . ?on the local host,and the server address will be registered under the name? ?is created by calling the constructor? >> Create the " + mbeanClassName +
" MBean within the MBeanServer");
echo( "ObjectName = " + mbeanObjectNameStr);
try {
ObjectName mbeanObjectName =
ObjectName.getInstance(mbeanObjectNameStr);
mbs.createMBean(mbeanClassName,mbeanObjectName);
return mbeanObjectName;
} catch (Exception e) {
echo( "!!! Could not create the " +
mbeanClassName + " MBean !!!");
e.printStackTrace();
echo("nEXITING...n");
System.exit(1);
}
return null;
}
[...]
?method. In this method,the MBean instance with the object name? 0) {
for (int i = 0; i < attrInfo.length; i++) {
echo(" ** NAME: " + attrInfo[i].getName());
echo(" DESCR: " + attrInfo[i].getDescription());
echo(" TYPE: " + attrInfo[i].getType() +
"READ: "+ attrInfo[i].isReadable() +
"WRITE: "+ attrInfo[i].isWritable());
}
} else echo(" ** No attributes **");
[...]
. The? ,to obtain the attribute’s name. ,to obtain the human readable description of the attribute. ,to obtain the class name of the attribute. ,to determine whether or not the attribute is readable. ,to determine whether or not the attribute is writeable. ?MBean’s constructors,operations and notifications: ,to obtain information about the MBean’s Java class. ,to learn what operations the MBean performs,and what parameters it takes. ,to find out what notifications the MBean sends when its operations are performed.
?method first of all calls the? ?method then defines an attribute called? ?method? ?class is shown in?. ?class is a straightforward JMX specification management interface for the MBean? ?class is shown in?. ?class defines a straightforward JMX specification standard MBean. ?MBean exposes operations and attributes for management by implementing the corresponding?
,which collects information about the number of changes carried out on the? ?class is shown in?. ?dynamic MBean shows how to expose attributes and operations for management at runtime,by implementing the? ?corresponds to the implementation of the? ?class is shown in?. ?class implements a straightforward JMX specification notification listener. ?method of the? ?class is shown in?. ?class creates an RMI connector client that is configured to connect to the RMI connector server created by? ?defines the same service URL? ,is an instance of the interface? ,to listen for notifications,as shown in?. ,named? ,and can register MBeans and perform operations on themwith the connection remaining completely transparent to both ends. ?MBean and the SimpleDynamic MBean in the MBean server with a call to the? ?MBean and closes the connection. The final? ?file: Compile the Java classes.
?of the local host.
?to register the RMI connector stub.
?class.
?MBean in the MBean server. You will then be prompted to press the Enter key to obtain information about,and then to perform operations on,the? ?have completed,the process will be repeated for the? .
?class in another terminal window.
?and SimpleDynamic MBeans. The client will then perform operations on? (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |