简体   繁体   English

如何在Java应用程序中从远程Websphere应用程序服务器获取正在运行的应用程序列表?

[英]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.

相关问题 如何从在服务器外部运行的 Java 客户端访问 WebSphere 身份验证别名信息? - How can I access WebSphere authentication alias info from a Java client running outside of the server? 如何在 websphere 应用服务器(WAS)中添加 java 14 - how to add java 14 in websphere app server(WAS) 如何检索Java Web应用程序的更改列表? - How can I retrieve a list of changes for my Java web app? 我如何获取包含远程Websphere应用程序服务器中所有队列名称的列表? - How i can get list with names of all queues in remote websphere application server? 如何将安全连接到远程Websphere服务器? - How i can connect secure to remote websphere server? 我可以确定我的星巴克客户看不到我在localhost:8080上运行的Java Web应用程序吗? - Can I be sure my Java web app running on localhost:8080 is invisible from my fellow Starbucks customers? 如何以编程方式从我的应用程序过滤和清除其他应用程序缓存? - how can i filter and clear other apps cache from my app programmatically? 如何防止我的应用在 startActivity() 上显示特定应用 - How can I prevent my app from showing specific apps on startActivity() 如何远程连接到在本地主机上运行的 WebSphere 服务器? - How can I connect remotely to a WebSphere Server running on localhost? 如何为我的应用终止远程进程? - How can I kill a remote process for my app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM