@Override
public void doMain(String[] args) throws Exception {
CommandLine commandLine = this.getCommandLine(args);
String host = commandLine.getOptionValue("host", "127.0.0.1");
int port = Integer.parseInt(commandLine.getOptionValue("port", "9999"));
JMXClient jmxClient = JMXClient.getJMXClient(host, port);
this.println("connected to " + jmxClient.getAddressAsString());
ObjectInstance ttInstance = jmxClient.queryMBeanForOne(TT_NAME);
if (ttInstance == null) {
this.println("û���ҵ� " + TT_NAME);
return;
}
if (commandLine.hasOption("start")) {
jmxClient.invoke(ttInstance.getObjectName(), "startSub", new Object[0], new String[0]);
this.println("invoke " + ttInstance.getClassName() + "#startSub success");
}
else if (commandLine.hasOption("stop")) {
jmxClient.invoke(ttInstance.getObjectName(), "stopSub", new Object[0], new String[0]);
this.println("invoke " + ttInstance.getClassName() + "#stopSub success");
}
else if (commandLine.hasOption("look")) {
String ret = (String) jmxClient.getAttribute(ttInstance.getObjectName(), "SubStatus");
this.println(ret);
}
else {
this.println("unknown option");
}
jmxClient.close();
}