2017-06-13 3 views
0

Wildfly 9ネイティブ管理APIを使用して配備済みアプリのステータスを表示しようとしています。 JBossの-cliを実行し、結果は以下の通りです:Java Wildfly 9ネイティブ管理APIを使用して配備されたアプリステータスを表示

jboss-cli.sh --connect --controller=myserver.com:9990 --commands="/deployment=my-deployment.war :read-attribute(name=status)" 
{ 
    "outcome" => "success", 
    "result" => "OK" 
} 

以下のコードを使用して、私はアプリがを有効にしているが、かどうかを判断することはできていない彼らがアップしていると、実行中の場合:

ModelNode op = new ModelNode(); 
op.get("operation").set("read-children-names"); 
op.get("child-type").set(ClientConstants.DEPLOYMENT); 

私のjboss-cliコマンドをJavaに翻訳するのに助けてくれる人はいますか?私は配備スキャナサブシステムにもフックしようとしましたが、それはどこでも役に立たないようです。

答えて

0

をあなたが展開リソースを取得するためにread-children-resource操作を使用することができます。

次のようなものが動作するはずです。

try (final ModelControllerClient client = ModelControllerClient.Factory.create(InetAddress.getLocalHost(), 9990)) { 
    ServerHelper.waitForStandalone(client, 20L); 
    final ModelNode op = Operations.createOperation("read-children-resources"); 
    op.get(ClientConstants.CHILD_TYPE).set(ClientConstants.DEPLOYMENT); 
    final ModelNode result = client.execute(op); 
    if (Operations.isSuccessfulOutcome(result)) { 
     final List<Property> deployments = Operations.readResult(result).asPropertyList(); 
     for (Property deployment : deployments) { 
      System.out.printf("Deployment %-20s enabled? %s%n", deployment.getName(), deployment.getValue().get("enabled")); 
     } 
    } else { 
     throw new RuntimeException(Operations.getFailureDescription(result).asString()); 
    } 
} 
関連する問題