Permalink
Browse files

Wrap the Mojo exceptions for non-mojo's.

  • Loading branch information...
1 parent b27e68d commit 543291e687f7028be8b015fc42d767aa19490152 @jamezp jamezp committed Jun 13, 2012
View
46 src/main/java/org/jboss/as/plugin/common/DeploymentExecutionException.java
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.plugin.common;
+
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
+ */
+public class DeploymentExecutionException extends MojoExecutionException {
+ public DeploymentExecutionException(Object source, String shortMessage, String longMessage) {
+ super(source, shortMessage, longMessage);
+ }
+
+ public DeploymentExecutionException(String message, Exception cause) {
+ super(message, cause);
+ }
+
+ public DeploymentExecutionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DeploymentExecutionException(String message) {
+ super(message);
+ }
+}
View
42 src/main/java/org/jboss/as/plugin/common/DeploymentFailureException.java
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.plugin.common;
+
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
+ */
+public class DeploymentFailureException extends MojoFailureException {
+ public DeploymentFailureException(Object source, String shortMessage, String longMessage) {
+ super(source, shortMessage, longMessage);
+ }
+
+ public DeploymentFailureException(String message) {
+ super(message);
+ }
+
+ public DeploymentFailureException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
View
16 src/main/java/org/jboss/as/plugin/deployment/Deployment.java
@@ -26,6 +26,9 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.plugin.common.DeploymentExecutionException;
+import org.jboss.as.plugin.common.DeploymentFailureException;
/**
* @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
@@ -56,10 +59,17 @@
*
* @return the status of the execution.
*
- * @throws MojoExecutionException if the deployment fails
- * @throws MojoFailureException if a failure occurs.
+ * @throws DeploymentExecutionException if the deployment fails
+ * @throws DeploymentFailureException if a failure occurs.
*/
- Status execute() throws MojoExecutionException, MojoFailureException;
+ Status execute() throws DeploymentExecutionException, DeploymentFailureException;
+
+ /**
+ * Gets the client associated with the deployment.
+ *
+ * @return the client associated with the deployment
+ */
+ ModelControllerClient getClient();
/**
* The type of the deployment.
View
15 src/main/java/org/jboss/as/plugin/deployment/domain/DomainDeployment.java
@@ -53,6 +53,8 @@
import org.jboss.as.controller.client.helpers.domain.ServerStatus;
import org.jboss.as.controller.client.helpers.domain.ServerUpdateResult;
import org.jboss.as.plugin.common.ConnectionInfo;
+import org.jboss.as.plugin.common.DeploymentExecutionException;
+import org.jboss.as.plugin.common.DeploymentFailureException;
import org.jboss.as.plugin.deployment.Deployment;
import org.jboss.dmr.ModelNode;
@@ -174,7 +176,7 @@ private DeploymentPlan createPlan(final DeploymentPlanBuilder builder) throws IO
}
@Override
- public Status execute() throws MojoExecutionException, MojoFailureException {
+ public Status execute() throws DeploymentExecutionException, DeploymentFailureException {
try {
validate();
final DomainDeploymentManager manager = client.getDeploymentManager();
@@ -183,16 +185,21 @@ public Status execute() throws MojoExecutionException, MojoFailureException {
if (plan != null) {
executePlan(manager, plan);
}
- } catch (MojoFailureException e) {
+ } catch (DeploymentFailureException e) {
throw e;
- } catch (MojoExecutionException e) {
+ } catch (DeploymentExecutionException e) {
throw e;
} catch (Exception e) {
- throw new MojoExecutionException(String.format("Error executing %s", type), e);
+ throw new DeploymentExecutionException(String.format("Error executing %s", type), e);
}
return Status.SUCCESS;
}
+ @Override
+ public DomainClient getClient() {
+ return client;
+ }
+
void validate() throws MojoFailureException {
final Map<ServerIdentity, ServerStatus> statuses = client.getServerStatuses();
final List<String> serverGroups = domain.getServerGroups();
View
21 src/main/java/org/jboss/as/plugin/deployment/standalone/StandaloneDeployment.java
@@ -34,8 +34,6 @@
import java.util.Collections;
import java.util.List;
-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.helpers.standalone.DeploymentAction;
import org.jboss.as.controller.client.helpers.standalone.DeploymentPlan;
@@ -45,6 +43,8 @@
import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentPlanResult;
import org.jboss.as.controller.client.helpers.standalone.ServerUpdateActionResult;
import org.jboss.as.plugin.common.ConnectionInfo;
+import org.jboss.as.plugin.common.DeploymentExecutionException;
+import org.jboss.as.plugin.common.DeploymentFailureException;
import org.jboss.as.plugin.deployment.Deployment;
import org.jboss.dmr.ModelNode;
@@ -151,7 +151,7 @@ private DeploymentPlan createPlan(final DeploymentPlanBuilder builder) throws IO
}
@Override
- public Status execute() throws MojoExecutionException, MojoFailureException {
+ public Status execute() throws DeploymentExecutionException, DeploymentFailureException {
Status resultStatus = Status.SUCCESS;
try {
final ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client);
@@ -166,27 +166,32 @@ public Status execute() throws MojoExecutionException, MojoFailureException {
final ServerUpdateActionResult.Result result = actionResult.getResult();
switch (result) {
case FAILED:
- throw new MojoExecutionException("Deployment failed.", actionResult.getDeploymentException());
+ throw new DeploymentExecutionException("Deployment failed.", actionResult.getDeploymentException());
case NOT_EXECUTED:
- throw new MojoExecutionException("Deployment not executed.", actionResult.getDeploymentException());
+ throw new DeploymentExecutionException("Deployment not executed.", actionResult.getDeploymentException());
case ROLLED_BACK:
- throw new MojoExecutionException("Deployment failed and was rolled back.", actionResult.getDeploymentException());
+ throw new DeploymentExecutionException("Deployment failed and was rolled back.", actionResult.getDeploymentException());
case CONFIGURATION_MODIFIED_REQUIRES_RESTART:
resultStatus = Status.REQUIRES_RESTART;
break;
}
}
}
}
- } catch (MojoExecutionException e) {
+ } catch (DeploymentExecutionException e) {
throw e;
} catch (Exception e) {
- throw new MojoExecutionException(String.format("Error executing %s", type), e);
+ throw new DeploymentExecutionException(String.format("Error executing %s", type), e);
}
return resultStatus;
}
@Override
+ public ModelControllerClient getClient() {
+ return client;
+ }
+
+ @Override
public Type getType() {
return type;
}
View
4 src/main/java/org/jboss/as/plugin/server/StandaloneServer.java
@@ -32,6 +32,8 @@
import org.apache.maven.plugin.MojoFailureException;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.controller.client.helpers.ClientConstants;
+import org.jboss.as.plugin.common.DeploymentExecutionException;
+import org.jboss.as.plugin.common.DeploymentFailureException;
import org.jboss.as.plugin.common.Files;
import org.jboss.as.plugin.common.Streams;
import org.jboss.as.plugin.deployment.Deployment;
@@ -154,7 +156,7 @@ public synchronized ModelControllerClient getClient() {
}
@Override
- public synchronized void deploy(final File file, final String deploymentName) throws MojoExecutionException, MojoFailureException, IOException {
+ public synchronized void deploy(final File file, final String deploymentName) throws DeploymentExecutionException, DeploymentFailureException, IOException {
if (isStarted) {
switch (StandaloneDeployment.create(client, file, deploymentName, Deployment.Type.DEPLOY).execute()) {
case REQUIRES_RESTART: {

0 comments on commit 543291e

Please sign in to comment.