Configuring JBoss 7 without manually editing the standalone.xml

烈酒焚心 提交于 2019-12-23 16:59:26

问题


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?


回答1:


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



回答2:


Why don't you use the web admin console? Most of properties included in standalone.xml can be configured with UI.



来源:https://stackoverflow.com/questions/12164787/configuring-jboss-7-without-manually-editing-the-standalone-xml

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!