Skip to content

Commit

Permalink
[#199] default to WildFly connection configuration
Browse files Browse the repository at this point in the history
fixes #199

- switch default protocol to `http-remoting`
- switch default port to 9990
- drop `creaper.wildfly` property
- drop `remoting` protocol support
  • Loading branch information
simkam authored and jstourac committed Jan 10, 2023
1 parent eb20986 commit 2f4af02
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 94 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 2.0.0 (not yet released)

- switch default protocol to `http-remoting`
- switch default port to 9990
- drop `creaper.wildfly` property
- drop `remoting` protocol support

## 2.0.0-Alpha.4

- compatibility with WildFly Core 20.0.0.Beta3 (WildFly 28)
Expand Down
54 changes: 7 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Creaper

Creaper is a small library for JBoss AS 7 and WildFly management with a slight
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
Expand All @@ -26,7 +26,7 @@ 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 JBoss AS 7/WildFly making sure that Creaper remains rock solid piece of code :-)
executed against different versions of WildFly making sure that Creaper remains rock solid piece of code :-)


## Install
Expand Down Expand Up @@ -62,7 +62,7 @@ The latest and greatest released version is __`1.6.2`__.
Creaper follows [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html)
(aka _SemVer_) for versioning and also as a compatibility promise.

### JBoss AS 7 / WildFly Client Libraries
### 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
Expand Down Expand Up @@ -531,7 +531,7 @@ Build a management client like this:

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

Expand All @@ -552,7 +552,7 @@ This was for standalone mode. For domain, it looks very similar:
.forProfile("default")
.forHost("master")
.build()
.hostAndPort("localhost", 9999)
.hostAndPort("localhost", 9990)
.build()
);

Expand Down Expand Up @@ -595,46 +595,6 @@ 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.

#### WildFly

By default, `OnlineOptions.standalone().localDefault()` configures a management
client that connects to `localhost:9999` using the `remote` protocol, which
makes sense for JBoss AS 7.

If you want to connect to WildFly (any version), you can use the `protocol`
method:

ManagementClient.online(OnlineOptions
.standalone()
.localDefault()
.protocol(ManagementProtocol.HTTP_REMOTING)
.build()
);

This changes the protocol to `http-remoting` and also changes the default port
to `9990`. If you define the port directly (using `hostAndPort`), you still
have to define the correct protocol.

Also, you can use `.protocol(ManagementProtocol.REMOTE)` to switch
the protocol back to `remote`, which is useful when using WildFly client
libraries against an AS7-based server. (It can't work the other way around,
so if you have AS7 client libraries and specify `http-remoting`, you'll get
an exception.)

Alternatively, you can define a system property `creaper.wildfly` (its value
is ignored, the system property just needs to be defined). This switches
the default protocol to `http-remoting` and the default port to `9990`
(in case SSL is configured, this switches the default protocol to
`https-remoting` and the default port to `9993`).

This way, you can run the same code against JBoss AS 7 and WildFly without
the need to rewrite or recompile anything. Just define a system property, and
provide a proper version of client libraries (as explained above).

Note that it would actually be possible to implement handling
of the `creaper.wildfly` system property completely outside of Creaper just
in terms of the `protocol` method.

#### HTTP transport

If you want to use HTTP transport for executing operation (`.protocol(ManagementProtocol.HTTP)`),
Expand All @@ -648,7 +608,7 @@ server looks like this:

ManagementClient.offline(OfflineOptions
.standalone()
.rootDirectory(new File("/tmp/jboss-eap-6.3"))
.rootDirectory(new File("/tmp/widfly-10"))
.configurationFile("standalone.xml")
.build()
);
Expand All @@ -657,7 +617,7 @@ server looks like this:
.domain()
.forProfile("default")
.build()
.rootDirectory(new File("/tmp/jboss-eap-6.3"))
.rootDirectory(new File("/tmp/wildfly-10"))
.configurationFile("standalone.xml")
.build()
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.wildfly.extras.creaper.core.online;

public enum ManagementProtocol {
/** Used in JBoss AS 7. Default port 9999. */
REMOTE("remote"),
/** Used in WildFly. Default port 9990. */
HTTP_REMOTING("http-remoting"),
/** Used in WildFly. Default port 9993. */
Expand All @@ -17,8 +15,7 @@ public enum ManagementProtocol {
HTTP("http"),
/**
* {@code HTTPS} imposes the same limitations as {@link #HTTP}.
* <b>Default port is 9443 (AS7)</b> and can be set to <b>9993 (WildFly)</b> by setting the system property
* {@code creaper.wildfly} or by configuring the port explicitly.
* Default port 9993.
*/
HTTPS("https"),
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* quite a number of public types.
*/
public final class OnlineOptions {
private static final String CREAPER_WILDFLY = "creaper.wildfly";

public final boolean isStandalone;

Expand All @@ -48,26 +47,22 @@ public final class OnlineOptions {
final boolean isWrappedClient; // see OnlineManagementClientImpl.reconnect

private OnlineOptions(Data data) {
if (data.protocol == null && System.getProperty(CREAPER_WILDFLY) != null) {
if (data.protocol == null) {
if (data.sslOptions == null) {
data.protocol = ManagementProtocol.HTTP_REMOTING;
} else {
data.protocol = ManagementProtocol.HTTPS_REMOTING;
}
// if the protocol wasn't set manually and the system property isn't set,
// it _doesn't_ mean that it's "remote"! see also OptionalOnlineOptions.protocol below
// if the protocol wasn't set manually, it _doesn't_ mean that it's "http-remoting"!
// see also OptionalOnlineOptions.protocol below
}

if (data.localDefault) {
data.host = "localhost";
if (data.protocol == ManagementProtocol.HTTP_REMOTING || data.protocol == ManagementProtocol.HTTP) {
data.port = 9990;
} else if (data.protocol == ManagementProtocol.HTTPS_REMOTING) {
if (data.protocol == ManagementProtocol.HTTPS_REMOTING || data.protocol == ManagementProtocol.HTTPS) {
data.port = 9993;
} else if (data.protocol == ManagementProtocol.HTTPS) {
data.port = System.getProperty(CREAPER_WILDFLY) != null ? 9993 : 9443;
} else {
data.port = 9999;
data.port = 9990;
}
}

Expand Down Expand Up @@ -196,10 +191,9 @@ private ConnectionOnlineOptions(Data data) {

/**
* <p>Connect to {@code localhost} and use the default management port of the application server.
* This is {@code 9999} by default (JBoss AS 7), and if the system property {@code creaper.wildfly} is defined,
* it changes to 9990 or (if {@link OptionalOnlineOptions#ssl(SslOptions) ssl} is used) to 9993 (WildFly).
* This makes it easy to run the same code against both AS7 and WildFly only by defining a single system
* property.</p>
* This is {@code 9990} by default, but if {@link OptionalOnlineOptions#ssl(SslOptions) ssl} is not null,
* then it is 9993.
* </p>
*
* <p>Alternatively, the {@link OptionalOnlineOptions#protocol(ManagementProtocol) protocol()} method
* can be used, which takes precedence over the methods described above. When it is called, the default port
Expand Down Expand Up @@ -324,22 +318,13 @@ public OptionalOnlineOptions bootTimeout(int timeoutInMillis) {
* <p>This also affects the <i>server port</i>, if {@link ConnectionOnlineOptions#localDefault() localDefault}
* is used.</p>
*
* <p>AS7 uses a native remoting protocol, called {@code remote}. WildFly uses the remoting protocol wrapped
* in HTTP (using the HTTP upgrade mechanism), called {@code http-remoting}, or uses its secured version
* called {@code https-remoting}. When the client libraries on classpath match the server version, they should
* choose the correct protocol automatically, so in this situation, this method is not required. However, when
* using a single set of client libraries for all server versions (which is possible, because the client
* libraries should be backward compatible), this method must be used to specify the type of the server.</p>
* <p>WildFly uses the remoting protocol wrapped in HTTP (using the HTTP upgrade mechanism),
* called {@code http-remoting}, or uses its secured version called {@code https-remoting}.
*
* <p>The server port is only affected by this method when
* {@link ConnectionOnlineOptions#localDefault() localDefault} is used. When server port is specified directly
* (using {@link ConnectionOnlineOptions#hostAndPort(String, int) hostAndPort}), this method doesn't change it.
* </p>
*
* <p>If the {@code creaper.wildfly} system property is set (because of
* {@link ConnectionOnlineOptions#localDefault() localDefault}), it is also used as a signal that the protocol
* should be {@code http-remoting}, but this method has a priority. When the system property is not set,
* it <i>doesn't</i> mean that the protocol should be {@code remote}; we simply don't know.</p>
*/
public OptionalOnlineOptions protocol(ManagementProtocol protocol) {
if (protocol == null) {
Expand Down
34 changes: 16 additions & 18 deletions testsuite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@
<ignoredCategory.wildfly>org.wildfly.extras.creaper.test.WildFly11Tests</ignoredCategory.wildfly>
<ignoredCategory.wildfly11 />

<specialJvmArgs.wildfly>-Dcreaper.wildfly</specialJvmArgs.wildfly>

<wildfly10.applicationServer.groupId>org.wildfly</wildfly10.applicationServer.groupId>
<wildfly10.applicationServer.artifactId>wildfly-dist</wildfly10.applicationServer.artifactId>
<wildfly10.applicationServer.version>${version.wildfly10}</wildfly10.applicationServer.version>
Expand Down Expand Up @@ -421,7 +419,7 @@
<arquillianContainer.version>${wildfly10.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -467,7 +465,7 @@
<arquillianContainer.version>${wildfly11.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -514,7 +512,7 @@
<arquillianContainer.version>${wildfly12.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -561,7 +559,7 @@
<arquillianContainer.version>${wildfly13.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -608,7 +606,7 @@
<arquillianContainer.version>${wildfly14.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -655,7 +653,7 @@
<arquillianContainer.version>${wildfly15.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -702,7 +700,7 @@
<arquillianContainer.version>${wildfly16.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -749,7 +747,7 @@
<arquillianContainer.version>${wildfly17.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -796,7 +794,7 @@
<arquillianContainer.version>${wildfly18.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -843,7 +841,7 @@
<arquillianContainer.version>${wildfly19.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -890,7 +888,7 @@
<arquillianContainer.version>${wildfly20.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -937,7 +935,7 @@
<arquillianContainer.version>${wildfly21.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -984,7 +982,7 @@
<arquillianContainer.version>${wildfly22.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -1031,7 +1029,7 @@
<arquillianContainer.version>${wildfly23.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -1078,7 +1076,7 @@
<arquillianContainer.version>${wildfly24.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down Expand Up @@ -1125,7 +1123,7 @@
<arquillianContainer.version>${wildfly25.arquillianContainer.version}</arquillianContainer.version>

<tests.ignoredCategory>${ignoredCategory.wildfly11}</tests.ignoredCategory>
<tests.specialJvmArgs>${specialJvmArgs.wildfly}</tests.specialJvmArgs>
<tests.specialJvmArgs></tests.specialJvmArgs>
</properties>

<dependencies>
Expand Down

0 comments on commit 2f4af02

Please sign in to comment.