Java Reference
In-Depth Information
Table 9.4
The possible commands used by the TCP client
(continued)
TCPAdapter
variable
Actual value
GET_ATTRIBUTE
get attribute
SET_ATTRIBUTE
set attribute
INVOKE
invoke
SHUTDOWN
shutdown
Not every message sent from a client will be one of the commands from table 9.4.
Other messages might be a classname or argument value, for instance. Table 9.5
lists the tasks the
TCP
adapter can perform, along with the messages needed to
perform the tasks. The messages and commands are listed in the order they
must be received. Messages in bold are expected values from the client (for
example,
classname
is an actual classname
String
). Those in italic are optional.
Table 9.5
Commands to send to complete a function of the adapter
Adapter function
Command order
Create an MBean
CREATE_MBEAN
,
classname
,
objectname
,
ARGS
,
arglist
,
siglist
Get attribute
GET_ATTRIBUTE
,
attname
,
objectname
Set attribute
SET_ATTRIBUTE
,
attname
,
objectname
,
ARGS
,
arglist
,
siglist
Invoke an operation
INVOKE
,
operation
,
objectname
,
ARGS
,
arglist
,
siglist
For each object name sent, the adapter expects the whole
String
value (such as a
String
like
JMXBookAgent:name=myValue
). The
arglist
and
siglist
messages are
expected to be comma-separated lists of arguments. The
arglist
parameters
must correspond to the types in the
siglist
message. In addition, each object
value being passed in the
arglist
must be able to create an
Object
from the
String
value. This is similar to what the
HTML
adapter expects from clients.
Listing 9.9 shows the
TCPAdapter
class. After examining this class, you will
add the
TCP
adapter to your
JMXBookAgent
class and write a simple test program.
Listing 9.9
TCPAdapter.java
package jmxbook.ch9;
import java.net.*;
import javax.management.*;
import java.io.*;