2014-09-27 73 views

回答

1

用我的研究,我已經找到了答案。這裏是API https://github.com/jbossas/jboss-as-maven-plugin在服務器上獲取運行應用程序。

在下面的代碼片段中創建客戶端後,將得到結果。

import static org.jboss.as.controller.client.helpers.ClientConstants.CHILD_TYPE; 
import static org.jboss.as.controller.client.helpers.ClientConstants.DEPLOYMENT; 
import org.jboss.as.controller.client.helpers.Operations; 

ModelNode op = Operations.createOperation("read-children-names"); 
op.get(CHILD_TYPE).set(DEPLOYMENT); 
final ModelNode listDeploymentsResult = client.execute(op); 
0

你將不得不使用一些技巧來完成你的工作。以下是幾個選項:

  1. 檢查JBOSS_HOME/standalone/deployments文件夾名稱爲app.war.deployed或app.war.failed的文件。
  2. 在文件夾中的server.log文件中,檢查字符串Deployed "app.war"。如果字符串在那裏,那麼你的應用程序不會部署。
+0

感謝AKHIL,但我使用集羣域模式部署和使用JBoss的管理API URL https://docs.jboss.org/author/display/AS71/The+native+management+API#ThenativemanagementAPI-requestformat部署,但無法獲取已在服務器中運行的應用程序列表。 – bharat 2014-09-28 09:39:00

0

Check this

static ModelControllerClient createClient(final InetAddress host, final int port, 
        final String username, final char[] password, final String securityRealmName) { 

    final CallbackHandler callbackHandler = new CallbackHandler() { 

     public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { 
      for (Callback current : callbacks) { 
       if (current instanceof NameCallback) { 
        NameCallback ncb = (NameCallback) current; 
        ncb.setName(username); 
       } else if (current instanceof PasswordCallback) { 
        PasswordCallback pcb = (PasswordCallback) current; 
        pcb.setPassword(password.toCharArray()); 
       } else if (current instanceof RealmCallback) { 
        RealmCallback rcb = (RealmCallback) current; 
        rcb.setText(rcb.getDefaultText()); 
       } else { 
        throw new UnsupportedCallbackException(current); 
       } 
      } 
     } 
    }; 

    return ModelControllerClient.Factory.create(host, port, callbackHandler); 
} 
+0

嗨,你可以讓我知道使用ModelControllerClient獲取正在運行的應用程序在服務器上的API .. – bharat 2014-09-29 06:46:29

+0

是的,你可以測試從POJO類 – ashokhein 2014-09-29 07:22:32

相關問題