[英]How i can take list of running apps from remote websphere app server in my java app?
How i can take list of running apps from remote websphere app server in my java app? 如何在Java应用程序中从远程Websphere应用程序服务器获取正在运行的应用程序列表? If i have login, pass and url to admin console.
如果我已登录,请通过url并进入管理控制台。
我将使用AdminClientFactory API来找到type=Application,*
MBean。
So, this is it: 就是这样:
java.util.Properties props = new java.util.Properties();
props.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP);
props.setProperty(AdminClient.CONNECTOR_HOST, "localhost");
props.setProperty(AdminClient.CONNECTOR_PORT, "8880");
props.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "true");
props.setProperty(AdminClient.USERNAME, "admin");
props.setProperty(AdminClient.PASSWORD, "111111");
client = AdminClientFactory.createAdminClient(props);
//Проверяем список запущенных приложений
AppManagement appM = AppManagementProxy.getJMXProxyForClient(client);
Vector apps = appM.listApplications(null, null, null);
System.out.println(" Status | Application ");
for (int i = 0; i < apps.size(); i++) {
String queryString = "WebSphere:type=Application,name=" + apps.get(i) + ",*";
ObjectName queryAppObj = new ObjectName(queryString);
Set<?> result = client.queryNames(queryAppObj, null);
if (result.size() == 0) {
System.out.println(" Stopped | " + apps.get(i));
} else {
System.out.println(" Running | " + apps.get(i));
}
}
Simple output: 简单输出:
Status | Application
Running | query
Running | SamplesGallery
Stopped | ivtApp
Stopped | DefaultApplication
Running | PlantsByWebSphere
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.