Skip to content

Commit

Permalink
Merge pull request #563 from jamezp/WFMP-244
Browse files Browse the repository at this point in the history
[WFMP-244] Allow the known management configuration system properties…
  • Loading branch information
jamezp committed Sep 9, 2024
2 parents 06e6ab6 + 8771e41 commit e6f5ce1
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,38 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}
}

@Override
protected int getManagementPort() {
// Check the java-opts for a management port override
if (javaOpts != null) {
for (String opt : javaOpts) {
if (opt.startsWith("-Djboss.management.http.port=") || opt.startsWith("-Djboss.management.https.port=")) {
final int equals = opt.indexOf('=');
return Integer.parseInt(opt.substring(equals + 1).trim());
}
if (opt.startsWith("-Djboss.socket.binding.port-offset=")) {
final int equals = opt.indexOf('=');
return super.getManagementPort() + Integer.parseInt(opt.substring(equals + 1).trim());
}
}
}
return super.getManagementPort();
}

@Override
protected String getManagementHostName() {
// Check the java-opts for a management port override
if (javaOpts != null) {
for (String opt : javaOpts) {
if (opt.startsWith("-Djboss.bind.address.management=")) {
final int equals = opt.indexOf('=');
return opt.substring(equals + 1).trim();
}
}
}
return super.getManagementHostName();
}

/**
* Allows the {@link #javaOpts} to be set as a string. The string is assumed to be space delimited.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ protected synchronized MavenModelControllerClientConfiguration getClientConfigur
}
final ModelControllerClientConfiguration.Builder builder = new ModelControllerClientConfiguration.Builder()
.setProtocol(protocol)
.setHostName(hostname)
.setPort(port)
.setHostName(getManagementHostName())
.setPort(getManagementPort())
.setConnectionTimeout(timeout * 1000);
if (authenticationConfig != null) {
try {
Expand All @@ -175,6 +175,14 @@ protected synchronized MavenModelControllerClientConfiguration getClientConfigur
return new MavenModelControllerClientConfiguration(builder.build(), username, password);
}

protected int getManagementPort() {
return port;
}

protected String getManagementHostName() {
return hostname;
}

private String decrypt(final Server server) {
SettingsDecryptionResult decrypt = settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(server));
return decrypt.getServer().getPassword();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,36 @@ protected ServerContext actOnServerState(final ModelControllerClient client, fin
}
return context;
}

@Override
protected int getManagementPort() {
// Check the java-opts for a management port override
if (javaOpts != null) {
for (String opt : javaOpts) {
if (opt.startsWith("-Djboss.management.http.port=") || opt.startsWith("-Djboss.management.https.port=")) {
final int equals = opt.indexOf('=');
return Integer.parseInt(opt.substring(equals + 1).trim());
}
if (opt.startsWith("-Djboss.socket.binding.port-offset=")) {
final int equals = opt.indexOf('=');
return super.getManagementPort() + Integer.parseInt(opt.substring(equals + 1).trim());
}
}
}
return super.getManagementPort();
}

@Override
protected String getManagementHostName() {
// Check the java-opts for a management port override
if (javaOpts != null) {
for (String opt : javaOpts) {
if (opt.startsWith("-Djboss.bind.address.management=")) {
final int equals = opt.indexOf('=');
return opt.substring(equals + 1).trim();
}
}
}
return super.getManagementHostName();
}
}

0 comments on commit e6f5ce1

Please sign in to comment.