Configuring JBoss 7 without manually editing the s

2019-07-03 15:55发布

问题:

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.



标签: jboss7.x