![]() |
JMX Reference Implementation Tutorial |
![]() Instantiating and Managing MBeans |
![]() Contents |
![]() Filtering the MBean List |
Action: With an agent view open on another machine, go to the administration page on your machine. Fill in the fields as follows and request the constructors:
Domain: Standard_MBeans Keys : name=Simple,number=1 Java Class: SimpleThe list of constructors for the
Simple
class is given at the bottom of the page. The MBean Name is also given: this is the object name that will be assigned to the MBean when using one of the listed constructors. As you can see, theSimple
class only has one constructor that takes no parameters.Action: Click on its "Create" button: the creation result will be appended to the bottom of the page. Scroll down and go to the MBean view with the provided link.
Simple
is a standard MBean so all of its description strings are generic: this shows the necessity of programming meaningful attribute names.Action: In the browser on the other machine, click in the filter field and hit Return to refresh the agent view. Click on the new MBean's name and set its reload period to 15. Back on your machine, type in a different different string for the "State" attribute and click "Apply".
On the other machine, you should see the MBean's attributes get updated when the MBean view is periodically reloaded.
Action: Back on your machine, click the "performReset" operation button at the bottom of the MBean view page. This brings up the operation result page which indicates the success of the operation. This page also gives the return value of the operation when it is not void. If you go back to the MBean view, you will see the result of the operation on the attributes. You should also see it on the other machine after it reloads.
Note: The browser on the other machine is no longer needed for the rest of this tutorial.
Action: Go to the administration page, create an MBean with the following values, and go to its MBean view:
Domain: Dynamic_MBeans Keys : name=SimpleDynamic,number=1 Java Class: SimpleDynamicThe management interface of this dynamic MBean looks similar to that of the
Simple
class which is a standard MBean. This is because it is programmed to expose a similar interface at run-time. Notice that it has the advantage of providing meaningful description strings. Look at the following source files and compare their features (use your browser's "Previous Page" function to return to the tutorial):
- SimpleMBean.java - The MBean interface which statically defines the management interface for the
Simple
MBean.
- Simple.java - The code that implements the methods of the
SimpleMBean
interface. For example, you can see exacltly what theperformReset
operation does in its corresponding method. Also, compare this code with that of the dynamic MBean.
- SimpleDynamic.java - The code that implements the
DynamicMBean
interface (see the JMX specification chapter on instrumentation). Towards the end of the file, you can see the method that dynamically constructs a data structure representing the management interface. From the code we can also see that the "reset" operation has a different implementation than "performReset" in the standard MBean.
![]() Instantiating and Managing MBeans |
![]() Contents |
![]() Filtering the MBean List |
Copyright © 2000
Sun Microsystems, Inc.,
901 San Antonio Road, Palo Alto, CA 94303, USA.
All rights reserved.