Java Reference
In-Depth Information
This interface defines two methods that will be exposed in the external relation.
The first method disables the phone card, and the second method disables the
fax card. Invoking these methods will cause the relation MBean to look up the
device MBean (phone or fax) and disable it. The relation MBean will also update
the routing table by using the RoutingTable MBean. Notice the use of the Rela-
tionSupportMBean interface, which exposes certain operations so that the relation
service can access the roles of the relation represented by this MBean. The rela-
tion service needs access to this information so that it can validate relations rep-
resented by this MBean. Listing 11.8 shows the MBean implementation.
Listing 11.8
CtlRelation.java
package jmxbook.ch11;
import javax.management.*;
import javax.management.relation.*;
import java.util.*;
public class CtlRelation extends RelationSupport
implements CtlRelationMBean, MBeanRegistration
{
private MBeanServer server = null;
public CtlRelation(String relationId,
ObjectName relationServiceName,
String relationTypeName,
RoleList roleList)
throws InvalidRoleValueException, IllegalArgumentException
{
super(relationId, relationServiceName,
relationTypeName, roleList);
}
B
Set up MBean in
constructor
public void disablePhoneCard( int cardNum )
throws MBeanException
{
System.out.println("Relation MBean::Disabling Phone Card");
try
{
ObjectName phoneCardName = new ObjectName(
"JMXBookAgent:name=phoneCard,slot="+cardNum);
ObjectName routingTableName = new ObjectName(
"JMXBookAgent:name=routingTable");
server.invoke(phoneCardName, "disable", null, null);
Object[] params = new Object[1];
params[0] = new Integer(cardNum);
String[] sig = new String[1];
sig[0] = "java.lang.Integer";
C
Implement
disablePhoneCard()
method
Search WWH ::




Custom Search