Skip to content

Commit

Permalink
Merge pull request #408 from jamezp/WFARQ-147
Browse files Browse the repository at this point in the history
[WFARQ-147] Migrate to using the wildfly-plugin-tools as the maven-pl…
  • Loading branch information
jamezp authored Jan 9, 2024
2 parents 726ea2c + dcf022a commit e80aefe
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 97 deletions.
2 changes: 1 addition & 1 deletion common-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</dependency>
<dependency>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-plugin-core</artifactId>
<artifactId>wildfly-plugin-tools</artifactId>
</dependency>

<!-- Test dependencies -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
import org.wildfly.common.Assert;
import org.wildfly.plugin.core.Deployment;
import org.wildfly.plugin.core.DeploymentManager;
import org.wildfly.plugin.core.DeploymentResult;
import org.wildfly.plugin.core.UndeployDescription;
import org.wildfly.plugin.tools.Deployment;
import org.wildfly.plugin.tools.DeploymentManager;
import org.wildfly.plugin.tools.DeploymentResult;
import org.wildfly.plugin.tools.UndeployDescription;

/**
* Allows deployment operations to be executed on a running server.
Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</dependency>
<dependency>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-plugin-core</artifactId>
<artifactId>wildfly-plugin-tools</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.shrinkwrap.descriptors</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
import org.wildfly.plugin.core.Deployment;
import org.wildfly.plugin.core.DeploymentManager;
import org.wildfly.plugin.core.DeploymentResult;
import org.wildfly.plugin.core.UndeployDescription;
import org.wildfly.plugin.tools.Deployment;
import org.wildfly.plugin.tools.DeploymentManager;
import org.wildfly.plugin.tools.DeploymentResult;
import org.wildfly.plugin.tools.UndeployDescription;

/**
* Allows deployment operations to be executed on a running server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.descriptor.api.Descriptor;
import org.wildfly.plugin.tools.ContainerDescription;

/**
* A JBossAS deployable container
Expand Down Expand Up @@ -171,10 +172,35 @@ public ContainerDescription getContainerDescription() {
// The management client should be set when the container is started
if (client == null)
return null;
containerDescription = ContainerDescription.lookup(client);
containerDescription = ContainerDescription.lookup(client.getControllerClient());
} catch (IOException e) {
Logger.getLogger(getClass()).warn("Failed to lookup the container description.", e);
containerDescription = StandardContainerDescription.NULL_DESCRIPTION;
containerDescription = new ContainerDescription() {
@Override
public String getProductName() {
return "WildFly";
}

@Override
public String getProductVersion() {
return "";
}

@Override
public String getReleaseVersion() {
return "";
}

@Override
public String getLaunchType() {
return "UNKNOWN";
}

@Override
public boolean isDomain() {
return false;
}
};
}
}
return containerDescription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@

import java.io.IOException;

import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.dmr.ModelNode;
import org.jboss.logging.Logger;

/**
* Information about the running container.
*
* @author <a href="mailto:[email protected]">James R. Perkins</a>
*/
@Deprecated(forRemoval = true)
public interface ContainerDescription {

/**
Expand Down Expand Up @@ -79,42 +76,8 @@ default ModelVersion getModelVersion() {
* @throws IOException if an error occurs while executing the management operation
*/
static ContainerDescription lookup(final ManagementClient client) throws IOException {
final ModelNode op = Operations.createReadResourceOperation(new ModelNode().setEmptyList());
final ModelNode result = client.getControllerClient().execute(op);
if (Operations.isSuccessfulOutcome(result)) {
final ModelNode model = Operations.readResult(result);
final String productName;
if (model.hasDefined("product-name")) {
productName = model.get("product-name").asString();
} else {
productName = "WildFly";
}

String productVersion = null;
if (model.hasDefined("product-version")) {
productVersion = model.get("product-version").asString();
}

String releaseCodename = null;
if (model.hasDefined("release-codename")) {
releaseCodename = model.get("release-codename").asString();
}

String releaseVersion = null;
if (model.hasDefined("release-version")) {
releaseVersion = model.get("release-version").asString();
}
final ModelVersion modelVersion = new ModelVersion(
model.get("management-major-version").asInt(0),
model.get("management-minor-version").asInt(0),
model.get("management-micro-version").asInt(0));
return new StandardContainerDescription(productName, productVersion, releaseCodename, releaseVersion, modelVersion);
} else {
Logger.getLogger(ContainerDescription.class).errorf("Failed to read the root resource: ",
Operations.getFailureDescription(result));
}

return StandardContainerDescription.NULL_DESCRIPTION;
return new StandardContainerDescription(
org.wildfly.plugin.tools.ContainerDescription.lookup(client.getControllerClient()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,33 @@
* @author <a href="mailto:[email protected]">James R. Perkins</a>
*/
class StandardContainerDescription implements ContainerDescription {

static final StandardContainerDescription NULL_DESCRIPTION = new StandardContainerDescription("WildFly",
null, null, null, ModelVersion.DEFAULT);

private final String productName;
private final String productVersion;
private final String releaseCodename;
private final String releaseVersion;
private final org.wildfly.plugin.tools.ContainerDescription delegate;
private final ModelVersion modelVersion;

StandardContainerDescription(final String productName, final String productVersion,
final String releaseCodename, final String releaseVersion,
final ModelVersion modelVersion) {
this.productName = productName;
this.productVersion = productVersion;
this.releaseCodename = releaseCodename;
this.releaseVersion = releaseVersion;
this.modelVersion = modelVersion;
StandardContainerDescription(final org.wildfly.plugin.tools.ContainerDescription delegate) {
this.delegate = delegate;
final var modelVersion = delegate.getModelVersion();
this.modelVersion = new ModelVersion(modelVersion.major(), modelVersion.minor(), modelVersion.micro());
}

@Override
public String getProductName() {
return productName;
return delegate.getProductName();
}

@Override
public String getProductVersion() {
return productVersion;
return delegate.getProductVersion();
}

@Override
public String getReleaseCodename() {
return releaseCodename;
return "";
}

@Override
public String getReleaseVersion() {
return releaseVersion;
return delegate.getReleaseVersion();
}

@Override
Expand All @@ -69,24 +58,6 @@ public ModelVersion getModelVersion() {

@Override
public String toString() {
final StringBuilder result = new StringBuilder(64);
result.append(productName);
if (productVersion != null) {
result.append(' ').append(productVersion);
if (releaseCodename != null) {
result.append(' ').append('"').append(releaseCodename).append('"');
}
if (releaseVersion != null) {
result.append(" (WildFly Core ").append(releaseVersion).append(')');
}
} else {
if (releaseVersion != null) {
result.append(' ').append(releaseVersion);
}
if (releaseCodename != null) {
result.append(' ').append('"').append(releaseCodename).append('"');
}
}
return result.toString();
return delegate.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

import org.jboss.as.arquillian.container.ParameterUtils;
import org.jboss.logging.Logger;
import org.wildfly.plugin.core.ServerHelper;
import org.wildfly.plugin.tools.ServerHelper;

/**
* A wrapper for an application client process. Allows interacting with the application client process.
Expand Down
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<version.org.wildfly.common.wildfly-common>1.7.0.Final</version.org.wildfly.common.wildfly-common>
<version.org.wildfly.plugins.wildfly-jar-maven-plugin>10.0.0.Final</version.org.wildfly.plugins.wildfly-jar-maven-plugin>
<version.org.wildfly.plugins.wildfly-maven-plugin>4.2.1.Final</version.org.wildfly.plugins.wildfly-maven-plugin>
<version.org.wildfly.plugins.wildfly-plugin-tools>1.0.0.Beta2</version.org.wildfly.plugins.wildfly-plugin-tools>
<version.org.wildfly.security.wildfly-elytron>2.1.0.Final</version.org.wildfly.security.wildfly-elytron>

<!-- keep this in sync with version that is used in arquillian -->
Expand Down Expand Up @@ -750,8 +751,8 @@
</dependency>
<dependency>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-plugin-core</artifactId>
<version>${version.org.wildfly.plugins.wildfly-maven-plugin}</version>
<artifactId>wildfly-plugin-tools</artifactId>
<version>${version.org.wildfly.plugins.wildfly-plugin-tools}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.core.api.annotation.Observes;
import org.jboss.as.arquillian.container.ContainerDescription;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.arquillian.container.NetworkUtils;
import org.jboss.as.arquillian.protocol.jmx.ExtendedJMXProtocol.ServiceArchiveHolder;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.wildfly.plugin.tools.ContainerDescription;

/**
* A deployer for the Arquillian JMXProtocol endpoint.
Expand Down Expand Up @@ -71,8 +71,8 @@ public synchronized void doServiceDeploy(@Observes(precedence = 1) BeforeDeploy
// As of WildFly Arquillian 3.0.0 a minimum of WildFly 13 or JBoss EAP 7.2 is required. This is due to the
// WFARQ-50 changes which use the new MSC service API's. The model version of this is 7.0.0 so it's best to
// test that as WildFly 13 is at 7.0.0 and EAP 7.2 is at 8.0.0. Also the product-version may be null.
final ContainerDescription containerDescription = ContainerDescription.lookup(client);
if (containerDescription.getModelVersion().getMajor() < 7) {
final ContainerDescription containerDescription = ContainerDescription.lookup(client.getControllerClient());
if (containerDescription.getModelVersion().major() < 7) {
String productName = containerDescription.getProductName();
if (productName == null) {
productName = "WildFly";
Expand Down

0 comments on commit e80aefe

Please sign in to comment.