簡體   English   中英

如何在Java應用程序中從遠程Websphere應用程序服務器獲取正在運行的應用程序列表?

[英]How i can take list of running apps from remote websphere app server in my java app?

如何在Java應用程序中從遠程Websphere應用程序服務器獲取正在運行的應用程序列表? 如果我已登錄,請通過url並進入管理控制台。

我將使用AdminClientFactory API來找到type=Application,* MBean。

就是這樣:

        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));
            }
        }

簡單輸出:

 Status    |   Application   

 Running   |   query
 Running   |   SamplesGallery
 Stopped   |   ivtApp
 Stopped   |   DefaultApplication
 Running   |   PlantsByWebSphere

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM