- 论坛徽章:
- 0
|
我想通过java写程序控制Websphere中已安装应用的启动、停止、重启,可是不知道怎么写?
通过创建AdminClient来控制?我没试成功:(
//--代码:
private void createAdminClient() {
// Set up a Properties object for the JMX connector attributes
Properties connectProps = new Properties();
connectProps.setProperty(AdminClient.CONNECTOR_TYPE,
AdminClient.CONNECTOR_TYPE_SOAP);
connectProps.setProperty(AdminClient.CONNECTOR_HOST, "192.168.0.211");
connectProps.setProperty(AdminClient.CONNECTOR_PORT, "8880");
connectProps.setProperty(AdminClient.USERNAME, "administrator");
connectProps.setProperty(AdminClient.PASSWORD, "abc");
connectProps.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED , "true");
try {
adminClient = AdminClientFactory.createAdminClient(connectProps);
} catch (ConnectorException e) {
System.out.println("Exception creating admin client.");
e.printStackTrace();
System.exit(-1);
} catch (Exception e){
System.out.println(e);
}
}
//--
private void invokeStopApplication(String serverName) {
// Use the launchProcess operation on the NodeAgent MBean to start
// the given server
String opName = "stopApplication";
String signature[] = { "java.lang.String" };
String params[] = { serverName };
boolean launched = false;
try {
Boolean b = (Boolean) adminClient.invoke(
nodeAgent, opName, params, signature);
launched = b.booleanValue();
if (launched)
System.out.println(serverName + " was stoped");
else
System.out.println(serverName + " was not stoped");
} catch (Exception e) {
System.out.println("Exception invoking stopApplication: " + e);
}
}
有谁帮我么?应该怎么做? |
|