2014-09-27 72 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

相关问题