Java Reference
In-Depth Information
Listing 11.2
FaxCard.java
package jmxbook.ch11;
public class FaxCard implements FaxCardMBean
{
public FaxCard(){}
public void disable()
{
System.out.println(
"FaxCardMBean::The FaxCard has been disabled");
}
}
Like the PhoneCard MBean, this class exposes a single method and a constructor.
Like the previous MBean, in the real world it would interface to a fax board and,
when called, take the card out of service. For this example, you will print an
informative message to the screen. Because you can have only one fax board per
system, you do not include a card number with this MBean.
Writing the RoutingTable MBean
Now that you have the code for the two types of device card MBeans, you need to
write the MBean that represents the routing table. The RoutingTable MBean
contains the routing information for both the fax and phone cards. The inter-
face for the RoutingTable MBean is as follows:
package jmxbook.ch11;
public interface RoutingTableMBean
{
public void removePhoneRoute(Integer cardNum);
public void removeFaxRoute();
}
The interface exposes two methods: removePhoneRoute() and removeFaxRoute() .
The method for removing a phone route accepts a phone card number to iden-
tify the correct phone card. Listing 11.3 shows the implementation class, Rout-
ingTable .
Listing 11.3
RoutingTable.java
package jmxbook.ch11;
public class RoutingTable implements RoutingTableMBean
{
Search WWH ::




Custom Search