在不手动编辑standalone.xml的情况下配置JBoss 7 [英] Configuring JBoss 7 without manually editing the standalone.xml

查看:119
本文介绍了在不手动编辑standalone.xml的情况下配置JBoss 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是用于配置的JBoss 7而不手动编辑standalone.xml(或domain.xml中)合适的选项.

我们有一个相当复杂的配置(JavaMail,许多数据源等),并且编辑XML并不是一个好选择,因为在重写XML时,注释会丢失,并且通常使部署更改变得非常困难. /p>

我看到的一个选项是命令行界面,至少可以在其中编写脚本,但这似乎使更改与创建有所不同.还有其他好的选择吗?

解决方案

对于批量配置更改,CLI脚本可能是最好的选择.

另一种选择就是创建自己的程序来执行此操作.您还可以使用本地Java API 请参阅已改型的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);
    }
}
 

What are the appropriate options for configuring JBoss 7 without manually editing the standalone.xml (or the domain.xml).

We have a fairly complex configuration (JavaMail, many datasources, etc.) and editing the XML is not a good option, as comments are lost when it is rewritten, and in general it makes it very hard to deploy changes.

One option I'm seeing is the Command Line Interface, where at least you could script that stuff, but it would seem to make changing it different than creating it. Anything other good options?

解决方案

For bulk configuration changes the CLI scripting is probably your best bet.

Another option would be just to create your own program to do it. There is a native Java API you could use, also see the detyped API for the model reference. That would give you the option to check for resources and/or values of resources before adding or changing.

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);
    }
}

这篇关于在不手动编辑standalone.xml的情况下配置JBoss 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆