Skip to content

Latest commit

 

History

History
948 lines (726 loc) · 30.1 KB

README.md

File metadata and controls

948 lines (726 loc) · 30.1 KB

Creaper

Creaper is a small library for WildFly management with a slight bias towards testing. It provides a simple API for managing a running server (online) or rewriting a configuration XML file of a stopped server (offline). Note that manipulating the XML files is generally discouraged and should only be used when absolutely necessary.

Please refer to these WildFly wiki pages for an in-depth description of the management functionalities:

Structure

Creaper consists of several artifacts (modules), where the most significant are core, commands and testsuite:

Creaper-core

It is the most important part which contains all the APIs and abstraction for doing management operations in a user friendly fashion.

Creaper-commands

It enhances creaper-core by providing implementations of commonly used commands. The goal is to host in this project only the commonly used commands. For commands which are not so commonly used, they should be written in separate projects as extensions of the creaper and maintained there.

Creaper-testsuite

Contains integration tests for the operations, commands and other functionalities provided by creaper, which are executed against different versions of WildFly making sure that Creaper remains rock solid piece of code :-)

Install

Creaper artifacts are available in Maven Central. However, they are primarily released through the JBoss.org Maven repository and synchronization to Central can take some time. If you are eager, you can configure the JBoss.org Maven repository like this:

<repositories>
    <repository>
        <id>jboss-public-repository-group</id>
        <name>JBoss Public Maven Repository Group</name>
        <url>http://repository.jboss.org/nexus/content/groups/public/</url>
    </repository>
</repositories>

Then, declare the dependencies like this:

<dependency>
    <groupId>org.wildfly.extras.creaper</groupId>
    <artifactId>creaper-core</artifactId>
    <version>${version.org.wildfly.extras.creaper}</version>
</dependency>
<dependency>
    <groupId>org.wildfly.extras.creaper</groupId>
    <artifactId>creaper-commands</artifactId>
    <version>${version.org.wildfly.extras.creaper}</version>
</dependency>

The latest and greatest released version is 2.0.3.

Creaper follows Semantic Versioning 2.0.0 (aka SemVer) for versioning and also as a compatibility promise.

WildFly Client Libraries

You have to provide both *-controller-client and *-cli yourself. If you want to use commands for patching, you also have to provide wildfly-patching.

Other dependencies might be required if you're using "local" CLI operations, such as jms-queue add ... on WildFly 10 (it was a built-in operation in previous WildFly versions, but was moved to a separate module due to messaging changes). These dependencies are not listed here, because there are no commands in Creaper that use them.

WildFly 10 (based on WildFly Core 2)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>2.2.0.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>2.2.0.Final</version>
</dependency>

<!-- see https://issues.jboss.org/browse/WFCORE-1580 -->
<!-- not required if the dependency on wildfly-patching below is also added -->
<dependency>
    <groupId>org.jboss.logmanager</groupId>
    <artifactId>jboss-logmanager</artifactId>
    <version>2.0.4.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>2.2.0.Final</version>
</dependency>

WildFly 11 (based on WildFly Core 3)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>3.0.8.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>3.0.8.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>3.0.8.Final</version>
</dependency>

WildFly 12 (based on WildFly Core 4)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>4.0.0.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>4.0.0.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>4.0.0.Final</version>
</dependency>

WildFly 13 (based on WildFly Core 5)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>5.0.0.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>5.0.0.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>5.0.0.Final</version>
</dependency>

WildFly 14 (14.0.1) (based on WildFly Core 6)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>6.0.2.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>6.0.2.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>6.0.2.Final</version>
</dependency>

WildFly 15 (15.0.0) (based on WildFly Core 7)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>7.0.0.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>7.0.0.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>7.0.0.Final</version>
</dependency>

WildFly 16 (16.0.0) (based on WildFly Core 8)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>8.0.0.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>8.0.0.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>8.0.0.Final</version>
</dependency>

WildFly 17 (17.0.0) (based on WildFly Core 9)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>9.0.1.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>9.0.1.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>9.0.1.Final</version>
</dependency>

WildFly 18 (18.0.0) (based on WildFly Core 10)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>10.0.0.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>10.0.0.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>10.0.0.Final</version>
</dependency>

WildFly 19 (19.0.0) (based on WildFly Core 11)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>11.0.0.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>11.0.0.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>11.0.0.Final</version>
</dependency>

WildFly 20 (20.0.0) (based on WildFly Core 12)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>12.0.1.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>12.0.1.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>12.0.1.Final</version>
</dependency>

WildFly 21 (21.0.2) (based on WildFly Core 13)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>13.0.3.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>13.0.3.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>13.0.3.Final</version>
</dependency>

WildFly 22 (22.0.1) (based on WildFly Core 14)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>14.0.1.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>14.0.1.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>14.0.1.Final</version>
</dependency>

WildFly 23 (23.0.2) (based on WildFly Core 15)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>15.0.1.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>15.0.1.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>15.0.1.Final</version>
</dependency>

WildFly 24 (24.0.1) (based on WildFly Core 16)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>16.0.1.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>16.0.1.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>16.0.1.Final</version>
</dependency>

WildFly 25 (25.0.1) (based on WildFly Core 17)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>17.0.3.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>17.0.3.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>17.0.3.Final</version>
</dependency>

WildFly 26 (26.1.1) (based on WildFly Core 18)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>18.1.1.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>18.1.1.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>18.1.1.Final</version>
</dependency>

WildFly 27 (27.0.1) (based on WildFly Core 19)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>19.0.1.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>19.0.1.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>19.0.1.Final</version>
</dependency>

WildFly 28 (28.0.1) (based on WildFly Core 20)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>20.0.2.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>20.0.2.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>20.0.2.Final</version>
</dependency>

WildFly 29 (29.0.1) (based on WildFly Core 21)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>21.1.1.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>21.1.1.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>21.1.1.Final</version>
</dependency>

WildFly 30 (30.0.1) (based on WildFly Core 22)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>22.0.2.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>22.0.2.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>22.0.2.Final</version>
</dependency>

WildFly 31 (31.0.1) (based on WildFly Core 23)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>23.0.3.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>23.0.3.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>23.0.3.Final</version>
</dependency>

WildFly 32 (32.0.1) (based on WildFly Core 24)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>24.0.1.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>24.0.1.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>24.0.1.Final</version>
</dependency>

WildFly 33 (33.0.1) (based on WildFly Core 25)

Dependencies for creaper-core:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-controller-client</artifactId>
    <version>25.0.1.Final</version>
</dependency>
<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-cli</artifactId>
    <version>25.0.1.Final</version>
</dependency>

Dependencies for creaper-commands:

<dependency>
    <groupId>org.wildfly.core</groupId>
    <artifactId>wildfly-patching</artifactId>
    <version>25.0.1.Final</version>
</dependency>

Transitive Dependencies

These are the dependencies that you will get transitively when you depend on Creaper:

  • creaper-core:
    • com.google.guava:guava
    • org.jboss.logging:jboss-logging
  • creaper-commands:
    • everything from creaper-core
    • org.codehaus.groovy:groovy
    • org.codehaus.groovy:groovy-xml

If you need to bring your own version of some of these libraries, you should use dependency exclusions.

Specifically for Groovy: this is only needed for offline management (i.e, XML configuration files manipulation). Creaper only needs groovy and groovy-xml, but excluding them and providing groovy-all should work too.

Use

The entrypoint is org.wildfly.extras.creaper.core.ManagementClient. From this class, you can get management clients for both online and offline use.

After reading this document, consider reading the design document as well (DESIGN.md), it can help you understand some of the design constraints and motivations.

Online

Build a management client like this:

ManagementClient.online(OnlineOptions
        .standalone()
        .hostAndPort("localhost", 9990)
        .build()
);

Instead of specifying host and port directly, it's possible to connect to the default port of the application server on localhost:

ManagementClient.online(OnlineOptions.standalone().localDefault().build());

There are options for setting up authentication, disabling local auth and even for setting up a connection timeout. The builder API is strongly typed, so the IDE will guide you and if your code compiles, you can be sure that you didn't forget anything mandatory.

This was for standalone mode. For domain, it looks very similar:

ManagementClient.online(OnlineOptions
        .domain()
        .forProfile("default")
        .forHost("master")
        .build()
        .hostAndPort("localhost", 9990)
        .build()
);

The forProfile and forHost methods specify a default profile and a default host. These defaults will be used to automatically transform a standalone-like operation to the domain one (e.g. /subsystem=infinispan:read-resource will be transformed to /profile=default-profile/subsystem-infinispan:read-resource). If you don't specify a default profile or a default host, you'll have to use the full form of the operation.

You can only specify one default profile and one default host. After calling the first build, the rest is exactly the same as for standalone mode.

Once you have a OnlineManagementClient, you can use it to perform management operations:

ModelNodeResult result = client.execute(":whoami");
result.assertSuccess();
System.out.println(result.get("result", "identity", "username"));

You can pass management operations either as a String using CLI syntax or as a ModelNode. Return value is ModelNodeResult, which you can use as a plain old ModelNode (it is a subclass, in fact), but it offers some nice utility methods for working with operation results.

Using "local" CLI operations such as batch, if or patch is possible, using the executeCli method. This method, however, doesn't return a result. It can only signal success (by returning normally) or failure (by throwing an exception).

client.executeCli("patch apply .../path/to/patch.zip");

In addition to performing plain old management operations, you can also perform higher-level management commands:

client.apply(new CliFile(new File("/tmp/foobar.cli")));

Commands have no return value. Normal return means success, errors are expressed by throwing an exception. These exceptions are considered fatal; that is, if an exception happens, the server is in an unknown state and the only reasonable action is aborting everything and reporting a major fail.

HTTP transport

If you want to use HTTP transport for executing operation (.protocol(ManagementProtocol.HTTP)), you need to provide Apache HttpComponents Client 4 by yourself. Please notice that reload operation through HTTP transport may fail with WildFly 10.0.0.

Offline

The API closely resembles the online counterpart. "Connecting" to an offline server looks like this:

ManagementClient.offline(OfflineOptions
        .standalone()
        .rootDirectory(new File("/tmp/widfly-10"))
        .configurationFile("standalone.xml")
        .build()
);

ManagementClient.offline(OfflineOptions
        .domain()
        .forProfile("default")
        .build()
        .rootDirectory(new File("/tmp/wildfly-10"))
        .configurationFile("standalone.xml")
        .build()
);

This assumes standard application server directory layout. Custom directory layouts are also supported. For example, you can specify a configuration file directly:

ManagementClient.offline(OfflineOptions
        .standalone()
        .configurationFile(new File("/tmp/standalone.xml"))
        .build()
);

It is not possible to perform management operations against an offline server. The only thing you can do is manipulate the configuration XML file:

ConfigurationFileBackup backupRestore = new ConfigurationFileBackup();
client.apply(
        backupRestore.backup(),
        GroovyXmlTransform.of(SomeClass.class, "/my-transform.groovy"),
        backupRestore.destroy()
);

This example shows that it's possible to perform more commands at once (this is of course also possible in the online case). Specifically, this example first takes a backup of the configuration file, than applies a XML transformation described by a Groovy script loaded from classpath, and then destroys the backup (there's of course a command to restore it, too).

Building Commands

Those 3 commands shown above (CliFile, ConfigurationFileBackup and XmlTransform) are foundational. They are meant to be used as building blocks for more higher-level commands, rather than being used directly.

For example, you can have a CLI file that configures a datasource. Instead of applying a CliFile command directly, you should create a command with a descriptive name:

public class SetupDatasource implements OnlineCommand {
    @Override
    public void apply(OnlineCommandContext ctx) throws CommandFailedException {
        ctx.client.apply(new CliFile(SetupDatasource.class));
    }
}

In this example, the CLI file is loaded from classpath. It must be a sibling of the SetupDatasource class and be named SetupDatasource.cli.

In the same way, you can create a command for offline usage:

public class SetupDatasource implements OfflineCommand {
    @Override
    public void apply(OfflineCommandContext ctx) throws CommandFailedException {
        ctx.client.apply(GroovyXmlTransform.of(SetupDatasource.class));
    }
}

In this example, the Groovy script that does the XML transformation is loaded from classpath. It must be a sibling of the SetupDatasource class and be named SetupDatasource.groovy.

If you have both online and offline implementations of a command, it is preferrable to merge them into a single class:

public class SetupDatasource implements OnlineCommand, OfflineCommand {
    @Override
    public void apply(OnlineCommandContext ctx) throws CommandFailedException {
        ctx.client.apply(new CliFile(SetupDatasource.class));
    }

    @Override
    public void apply(OfflineCommandContext ctx) throws CommandFailedException {
        ctx.client.apply(GroovyXmlTransform.of(SetupDatasource.class));
    }

    @Override
    public String toString() {
        return "SetupDatasource";
    }
}

Note the toString method -- it should return a short description useful for logging purposes. It's not mandatory, but highly recommended at least for often used commands.

Your new command can be used in the same way the built-in commands are:

client.apply(new SetupDatasource());

Common Management Operations

There is a standalone API for performing common management operations (e.g. read-attribute, write-attribute etc.). Create an Operations object from an OnlineManagementClient:

OnlineManagementClient client = ...;
Operations ops = new Operations(client);

Then, you use the Operations object to perform operations:

ModelNodeResult result = ops.readAttribute(
        Address.subsystem("web").and("configuration", "jsp-configuration"), "development"
);

Some operations have options you can apply:

ModelNodeResult result = ops.readAttribute(
        Address.subsystem("web").and("configuration", "jsp-configuration"), "development",
        ReadAttributeOption.NOT_INCLUDE_DEFAULTS
);

Sometimes, it makes sense to apply more options:

ModelNodeResult result = ops.readResource(
        Address.subsystem("web").and("configuration", "jsp-configuration"),
        ReadResourceOption.NOT_INCLUDE_DEFAULTS, ReadResourceOption.RecursiveDepth.of(1)
);

You can also perform a batch (composite) operation:

ops.batch(new Batch()
        .writeAttribute(Address.subsystem("web").and("configuration", "jsp-configuration"),
                "development", true)
        .writeAttribute(Address.subsystem("web").and("configuration", "jsp-configuration"),
                "display-source-fragment", true)
);

Common Administrative Management Operations

As a part of the API for common management operations, there is also a standalone API for performing common administrative operations such as server reload. Its design is similar to the Operations class:

OnlineManagementClient client = ...;
Administration admin = new Administration(client);

The Administration object can be used to perform administrative tasks:

admin.reload();

These operations typically don't have a return value, and if they do, it isn't a ModelNodeResult. For example, the reloadIfRequired operation returns whether at least 1 server was in fact reloaded:

boolean reloaded = admin.reloadIfRequired();

All these operations are available both for standalone server and for managed domain. In addition to that, there are domain-only operations in a separate class DomainAdministration, which is a subclass of Administration:

DomainAdministration admin = new DomainAdministration(client);
admin.restartAllServers();

Patterns

Consider creating your own factory/holder for *ManagementClient objects

When you are writing a larger project where you need a ManagementClient on a lot of places (e.g. a testsuite), consider creating a factory/holder object. Most of the time, you will only need a single configuration of the client (or a small number of configurations); having a centralized place makes it easier to do globally-affecting changes (e.g. changing a management interface hostname or port).

Creaper is not able to provide you with such a factory, because it can't know the specifics of your project. It only makes it very easy to create a client, so your factory will be just a few lines of simple code.

Consider using a lazy variant of OnlineManagementClient

When you are in an environment that doesn't give you precise lifecycle control (e.g. Arquillian with WildFly's @ServerSetup), you can use a lazy variant of the OnlineManagementClient. You can create such client eagerly, so that it's instantly available, but it will only be initialized when it is first used.

Creaper doesn't make it the default variant of the OnlineManagementClient, because lazy initialization also means deferred error checking. Error checking is something that you usually want to do as soon as possible.

Contribute

Please use GitHub Issues to file bugs, feature requests or any other communication.

For anything more involved, please read DESIGN.md, CONTRIBUTING.md and GOVERNANCE.md first.

Pull requests are always welcome!