Skip to content

Commit

Permalink
[WFMP-286] Upgrade the wildfly-plugin-tools to 1.2.0.Final.
Browse files Browse the repository at this point in the history
https://issues.redhat.com/browse/WFMP-286
Signed-off-by: James R. Perkins <jperkins@redhat.com>
  • Loading branch information
jamezp committed Dec 16, 2024
1 parent 4de445d commit 6cfe5e5
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 285 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.function.Supplier;

import org.jboss.as.controller.client.ModelControllerClient;
import org.wildfly.plugin.common.MavenModelControllerClientConfiguration;
import org.jboss.as.controller.client.ModelControllerClientConfiguration;

/**
* The configuration used to execute CLI commands.
Expand All @@ -17,7 +17,7 @@
public class CommandConfiguration extends BaseCommandConfiguration {

private final Supplier<ModelControllerClient> client;
private final Supplier<MavenModelControllerClientConfiguration> clientConfiguration;
private final Supplier<ModelControllerClientConfiguration> clientConfiguration;
private final boolean fork;
private final boolean offline;

Expand All @@ -27,13 +27,13 @@ protected abstract static class AbstractBuilder<T extends AbstractBuilder<T>>
extends BaseCommandConfiguration.AbstractBuilder<T> {

private final Supplier<ModelControllerClient> client;
private final Supplier<MavenModelControllerClientConfiguration> clientConfiguration;
private final Supplier<ModelControllerClientConfiguration> clientConfiguration;
private boolean fork;
private boolean offline;
private boolean autoReload;

AbstractBuilder(final Supplier<ModelControllerClient> clientSupplier,
final Supplier<MavenModelControllerClientConfiguration> clientConfigurationSupplier) {
final Supplier<ModelControllerClientConfiguration> clientConfigurationSupplier) {
this.client = clientSupplier;
this.clientConfiguration = clientConfigurationSupplier;
}
Expand Down Expand Up @@ -92,7 +92,7 @@ public CommandConfiguration build() {
public static class Builder extends AbstractBuilder<Builder> {

Builder(Supplier<ModelControllerClient> clientSupplier,
Supplier<MavenModelControllerClientConfiguration> clientConfigurationSupplier) {
Supplier<ModelControllerClientConfiguration> clientConfigurationSupplier) {
super(clientSupplier, clientConfigurationSupplier);
}

Expand Down Expand Up @@ -121,7 +121,7 @@ protected CommandConfiguration(AbstractBuilder<?> builder) {
* @return a new command configuration Builder.
*/
public static Builder of(final Supplier<ModelControllerClient> clientSupplier,
final Supplier<MavenModelControllerClientConfiguration> clientConfigurationSupplier) {
final Supplier<ModelControllerClientConfiguration> clientConfigurationSupplier) {
return new Builder(clientSupplier, clientConfigurationSupplier);
}

Expand All @@ -139,7 +139,7 @@ public ModelControllerClient getClient() {
*
* @return the management client configuration
*/
public MavenModelControllerClientConfiguration getClientConfiguration() {
public ModelControllerClientConfiguration getClientConfiguration() {
return clientConfiguration.get();
}

Expand Down
22 changes: 19 additions & 3 deletions plugin/src/main/java/org/wildfly/plugin/cli/CommandExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.controller.client.ModelControllerClientConfiguration;
import org.jboss.galleon.universe.maven.repo.MavenRepoManager;
import org.wildfly.core.launcher.CliCommandBuilder;
import org.wildfly.plugin.common.MavenModelControllerClientConfiguration;
import org.wildfly.plugin.common.StandardOutput;
import org.wildfly.plugin.tools.server.ServerManager;

Expand Down Expand Up @@ -81,11 +81,11 @@ public void execute(final CommandConfiguration config, MavenRepoManager artifact
@Override
protected int executeInNewProcess(final CommandConfiguration config, final Path scriptFile, final StandardOutput stdout)
throws MojoExecutionException, IOException {
try (MavenModelControllerClientConfiguration clientConfiguration = config.getClientConfiguration()) {
try (ModelControllerClientConfiguration clientConfiguration = config.getClientConfiguration()) {

final CliCommandBuilder builder = createCommandBuilder(config, scriptFile);
if (!config.isOffline()) {
builder.setConnection(clientConfiguration.getController());
builder.setConnection(getController(clientConfiguration));
}
// Configure the authentication config url if defined
if (clientConfiguration != null && clientConfiguration.getAuthenticationConfigUri() != null) {
Expand Down Expand Up @@ -173,4 +173,20 @@ private LocalCLIExecutor createCommandContext(Path jbossHome, final boolean reso
}
return commandContext;
}

private static String getController(final ModelControllerClientConfiguration configuration) {
final StringBuilder controller = new StringBuilder();
if (configuration.getProtocol() != null) {
controller.append(configuration.getProtocol()).append("://");
}
if (configuration.getHost() != null) {
controller.append(configuration.getHost());
} else {
controller.append("localhost");
}
if (configuration.getPort() > 0) {
controller.append(':').append(configuration.getPort());
}
return controller.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.maven.settings.crypto.SettingsDecryptionResult;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.controller.client.ModelControllerClientConfiguration;
import org.wildfly.plugin.tools.client.ClientCallbackHandler;

/**
* The default implementation for connecting to a running WildFly instance
Expand Down Expand Up @@ -131,7 +132,7 @@ protected ModelControllerClient createClient() {
*
* @return the configuration to use
*/
protected synchronized MavenModelControllerClientConfiguration getClientConfiguration() {
protected synchronized ModelControllerClientConfiguration getClientConfiguration() {
final Log log = getLog();
String username = this.username;
String password = this.password;
Expand Down Expand Up @@ -171,8 +172,10 @@ protected synchronized MavenModelControllerClientConfiguration getClientConfigur
} catch (URISyntaxException e) {
throw new RuntimeException("Failed to create URI from " + authenticationConfig, e);
}
} else {
builder.setHandler(new ClientCallbackHandler(username, password));
}
return new MavenModelControllerClientConfiguration(builder.build(), username, password);
return builder.build();
}

protected int getManagementPort() {
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6cfe5e5

Please sign in to comment.