Java Reference
In-Depth Information
Up to this point, we have defined the problem and presented a solution. You
now need to write the code for all the MBeans, as well as the code for building
the relation and adding the relation service to your JMXBookAgent class. The fol-
lowing sections will walk you through writing the code to build this example.
11.3 Constructing the MBean relationship
As you have in previous chapters, you will use the JMXBookAgent class constructed
in chapter 3. You will add the relation service and your MBeans to the agent.
Finally, you will execute a test using the HTML adapter to disable the fax and
phone cards. To complete this example, you must write code to complete the
steps shown in the following list:
Create the MBeans. Before any relation can be created, the MBeans that
will participate in the relation must be created in the current agent.
These are Standard MBeans, and they must be registered in the agent.
1
Create the RelationType object that will declare the role information and
constraints about your relation.
2
Create role objects to participate in the new relation.
3
Create the relation object that corresponds to the situation described.
4
Add a method to your JMXBookAgent class that adds the relation service to
the agent when it is started.
5
Write code that will add your new relation to the relation service for retrieval.
6
Let's begin this process by writing the code for all your MBeans.
11.3.1
Creating the MBeans
The first step is to write the MBeans that model each component of the scenario,
including the PhoneCard , FaxCard , and RoutingTable MBeans. You will create
them as Standard MBeans. (For more information about Standard MBeans, refer
back to chapter 4.)
The listings in the following sections show the classes for these MBean
classes, as well as their interfaces.
Writing the PhoneCard MBean
Each MBean will be placed in the jmxbook.ch11 package. The PhoneCardMBean
interface for the PhoneCard class is as follows. It declares a single method, dis-
able() , which disables the managed phone card from operation:
Search WWH ::




Custom Search