[英]How to check if my Application was correctly deployed by Wildfly 8.2.1 programmatically?
I need to check the deployment status of my application which is deployed by Wildfly 8.2.1 programmatically (preferably java). 我需要检查Wildfly 8.2.1以编程方式(最好是java)部署的应用程序的部署状态。 As far I am concerned, there can be multiple ways to achieve this:
就我而言,可以通过多种方式实现这一目标:
There might be other ways too, which I am not yet aware of. 可能还有其他方式,我尚未意识到。 But I am more interested in learning the ways of using JMX mbeans .
但是我对学习使用JMX mbean的方式更感兴趣。 But unfortunately my online search is not giving me any good direction.
但不幸的是,我的在线搜索没有给我任何好的指导。 If anyone can shed some light to this that would be really helpful.
如果有人可以对此有所了解,那将是非常有帮助的。
You could use management operations to check to see if you're deployment exists. 您可以使用管理操作来检查是否存在部署。 It's a little old, but there's a tutorial on the deypted API.
它有些旧,但是有一个有关已开发API的教程 。
try (final ModelControllerClient client = ModelControllerClient.Factory.create(InetAddress.getLocalHost(), 9990)) {
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 ModelNode deployments = Operations.readResult(result);
for (String deploymentName : deployments.keys()) {
final ModelNode deploymentDetails = deployments.get(deploymentName);
// do stuff
}
} else {
throw new RuntimeException("Failed to list deployments: " + Operations.getFailureDescription(result).asString());
}
}
From the result you can read various information about the deployment. 从结果中,您可以阅读有关部署的各种信息。 The output looks like:
输出如下:
{
"content" => [{"hash" => bytes {
0x77, 0x1f, 0x1a, 0xa1, 0x9e, 0x46, 0x11, 0x75,
0x2f, 0x58, 0xce, 0x1b, 0x01, 0x29, 0x45, 0x43,
0x16, 0x87, 0x22, 0x9a
}}],
"enabled" => true,
"enabled-time" => 1443485828919L,
"enabled-timestamp" => "2015-09-28 17:17:08,919 PDT",
"name" => "batch-chunk.war",
"owner" => undefined,
"persistent" => true,
"runtime-name" => "batch-chunk.war",
"subdeployment" => undefined,
"subsystem" => {
"jaxrs" => undefined,
"batch" => undefined,
"undertow" => undefined
}
}
If you wanted to see whether it was enabled you could do 如果您想查看是否已启用它,可以执行
if (!deploymentDetails.get("enabled")) {
throw new RuntimeException(String.format("Deployment %s is not enabled", deploymentName);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.