Java Reference
In-Depth Information
requests to specific MBean operations and executes them. In addition, the proto-
col adapter can send an SNMP trap to an NMS in place of JMX notifications.
Using the SNMP protocol adapter, an NMS can access the MBeans in the
MBean server that represent various MIB s. SNMP does not support the richness
of JMX capabilities, but MBeans can be built that support all the capabilities of
SNMP . This means your MBeans may have more capabilities than can be
accessed using SNMP , but existing NMS systems can take advantage of the
exposed capabilities that adhere to the SNMP standard. Java Community Pro-
cess ( JCP ) efforts are underway to standardize the mappings between JMX and
existing SNMP standards.
For more information about the SNMP protocol adapter and the JDMK , visit
the JDMK product page on the Sun web site (http://java.sun.com/products/jdmk).
9.5 Connecting by using a TCP adapter
Up to this point, you have seen how you can distribute access to your JMX agents
with a number of different technologies. For example, you can use the RMI con-
nector provided by Sun, or you can use Jini to allow your agents to be discov-
ered. In this section, you will write a TCP protocol adapter.
Note that you won't use any object serialization—we don't want you to re-
create an RMI -like connector. Instead, the TCP adapter is a socket-based adapter
that allows any capable client to connect and send simple commands in order to
interact with your agent. This command approach allows non-Java clients to
connect to your agent and work with MBeans. For instance, a C++ program
could open a socket to your remote agent and acquire attribute values from
existing MBeans.
The TCP adapter presented in this section can create MBeans, get and set
attributes, and invoke operations. It places a few restrictions on the order and
manner that arguments are sent by the client, as you will see when we walk
through the code. The adapter is modeled as an MBean that creates a Server-
Socket object to listen to a particular port. Figure 9.4 illustrates the use of the
TCP adapter MBean.
When a client connects, the MBean creates a TCPAdapter object in a new
Thread to handle the client request, and continues listening.
9.5.1
Writing the code
To complete this new protocol adapter, you need to create three classes and
one interface:
Search WWH ::




Custom Search