Java Reference
In-Depth Information
StringTokenizer toks = new StringTokenizer( siglist, "," );
String[] result = new String[ toks.countTokens() ];
int i = 0;
while( toks.hasMoreTokens() )
{
result[ i++ ] = toks.nextToken();
}
return result;
}
private Object[] createObjectList( String objects,
String[] sig ) throws Exception
{
if( objects == null )
return null;
Object[] results = new Object[ sig.length ];
StringTokenizer toks = new StringTokenizer( objects, "," );
int i = 0;
while( toks.hasMoreTokens() )
{
String object = toks.nextToken();
Class conSig[] = { Class.forName( sig[i] ) };
Object[] conParams = { object };
Class c = Class.forName( sig[i] );
Constructor con = c.getConstructor( conSig );
results[ i ] = con.newInstance( conParams );
i++;
}
return results;
}
}
B
Once the
TCPAdapter
object has been created by the
TCPServer
MBean, it is con-
tinuously in its
run()
method until it reads the
SHUTDOWN
message from the client.
Upon receiving that message, the adapter object closes the socket and stops com-
munication.
In the
run()
method, the adapter reads messages from the client until it finds
one of its four available tasks (
CREATE_MBEAN
,
GET_ATTRIBUTE
,
SET_ATTRIBUTE
, or
INVOKE
). When it reads a valid command, it invokes the appropriate private
method to complete the task. Because the output and input streams are class
variables, they can be used in every method.
The
createMBean()
method allows clients to create new MBeans in the agent. If
any exceptions occur during this process, the method fails and returns an error
C