Java Reference
In-Depth Information
Thread t = new Thread( new TCPAdapter( client, mbs ) )
t.start();
}
Create TCPAdapter
object to handle
new client
ss.close();
}
catch( Exception e )
{
e.printStackTrace();
stopped = true;
}
}
public void postDeregister()
{}
public void postRegister( Boolean done )
{}
public void preDeregister()
{}
public ObjectName preRegister(
MBeanServer server, ObjectName name )
{
this.mbs = server;
return name;
}
}
As you can see in the code, upon invocation of the start() method, the TCPServer
MBean runs continuously in a Thread until told to stop (via the stop() method).
Once inside the run() method, the MBean opens the ServerSocket object to the
specified port (the default value is 1555 ) and begins listening for clients.
When a socket is accepted, the MBean creates a new TCPAdapter instance,
gives it the new client and a reference to the MBeanServer , and runs it in a new
Thread . Each instance of the TCPAdapter class needs a reference to the MBean-
Server in order to work with MBeans on behalf of its client.
The real work of the TCP adapter is done in the TCPAdapter class. It defines
the commands clients can send, as well as the order in which it expects them to
be sent. Table 9.4 lists the possible commands that can be sent by a TCP client.
Table 9.4
The possible commands used by the TCP client
TCPAdapter variable
Actual value
CREATE_MBEAN
create mbean
ARGS
args
Search WWH ::




Custom Search