在不手动编辑 standalone.xml(或 domain.xml)的情况下配置 JBoss 7 的合适选项是什么。
我们有一个相当复杂的配置(JavaMail、许多数据源等),编辑 XML 不是一个好的选择,因为重写时注释会丢失,而且通常这使得部署更改变得非常困难。
我看到的一个选项是命令行界面,至少您可以在其中编写脚本,但改变它似乎不同于创建它。还有其他好的选择吗?
最佳答案
对于批量配置更改,CLI 脚本可能是您最好的选择。
另一种选择是创建您自己的程序来执行此操作。有一个native Java API您可以使用,另请参阅 detyped API供模型引用。这将使您可以选择在添加或更改之前检查资源和/或资源值。
final ModelNode op = new ModelNode();
op.get(ClientConstants.OP).set("read-resource");
op.get(ClientConstants.OP_ADDR).set("/subsystem=logging/console-handler=CONSOLE");
final ModelControllerClient client = ModelControllerClient.Factory.create("localhost", 9999);
final ModelNode result = client.execute(op);
if (result.get(ClientConstants.OUTCOME).asString().equals(ClientConstants.SUCCESS)) {
// The operation was successful
} else {
// Unsuccessful get the failure description
final String msg;
if (result.hasDefined(ClientConstants.FAILURE_DESCRIPTION)) {
if (result.hasDefined(ClientConstants.OP)) {
msg = String.format("Operation '%s' at address '%s' failed: %s", result.get(ClientConstants.OP), result.get(ClientConstants.OP_ADDR), result.get(ClientConstants.FAILURE_DESCRIPTION));
} else {
msg = String.format("Operation failed: %s", result.get(ClientConstants.FAILURE_DESCRIPTION));
}
} else {
msg = String.format("An unexpected response was found. Result: %s", result);
}
}
关于jboss7.x - 在不手动编辑 standalone.xml 的情况下配置 JBoss 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12164787/