Author: adietish
Date: 2011-04-14 09:50:42 -0400 (Thu, 14 Apr 2011)
New Revision: 30574
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/DetypedDeployer.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DetypedDeployerIntegrationTest.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java
Log:
added redeploy capability to detyped deployer
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java
===================================================================
---
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java 2011-04-14
13:34:36 UTC (rev 30573)
+++
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java 2011-04-14
13:50:42 UTC (rev 30574)
@@ -37,7 +37,6 @@
private static final long TIMEOUT = 15 * 1000;
-
public static void undeploy(String name, String host, int port) throws DeployerException
{
ModelControllerClient client = null;
try {
@@ -71,30 +70,7 @@
}
}
- // public static void deploy(File file, String host, int port) throws DeployerException
{
-// ModelControllerClient client = null;
-// try {
-// client = ModelControllerClient.Factory.create(host, port);
-// String name = file.getName();
//
-// ModelNode request = new ModelNode();
-// request.get("operation").set("add");
-// request.get("address").add("deployment", name);
-// request.get("enabled").set(true);
-//
-// OperationBuilder operation = OperationBuilder.Factory.create(request);
-// operation.addInputStream(new BufferedInputStream(new FileInputStream(file)));
-// request.get("input-stream-index").set(0);
-// ModelNode result = client.execute(operation.build());
-//
-// throwOnFailure(result);
-// } catch(Exception e) {
-// throw new DeployerException(e);
-// } finally {
-// StreamUtils.safeClose(client);
-// }
-// }
-//
// public static boolean isDeployed(String name, String host, int port) throws
CancellationException, IOException {
// ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
// try {
@@ -115,4 +91,8 @@
// }
// }
+ private TypedDeployer() {
+ // inhibit instantiation
+ }
+
}
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/DetypedDeployer.java
===================================================================
---
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/DetypedDeployer.java 2011-04-14
13:34:36 UTC (rev 30573)
+++
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/DetypedDeployer.java 2011-04-14
13:50:42 UTC (rev 30574)
@@ -30,6 +30,7 @@
import java.util.concurrent.CancellationException;
import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.Operation;
import org.jboss.as.controller.client.OperationBuilder;
import org.jboss.as.protocol.StreamUtils;
import org.jboss.dmr.ModelNode;
@@ -73,11 +74,13 @@
request.get("address").add("deployment", name);
request.get("enabled").set(true);
- OperationBuilder operation = OperationBuilder.Factory.create(request);
- operation.addInputStream(new BufferedInputStream(new FileInputStream(file)));
+ OperationBuilder builder = OperationBuilder.Factory.create(request);
+ builder.addInputStream(new BufferedInputStream(new FileInputStream(file)));
+ Operation operation = builder.build();
request.get("input-stream-index").set(0);
- ModelNode result = client.execute(operation.build());
+ ModelNode result = client.execute(operation);
+
throwOnFailure(result);
} catch(Exception e) {
throw new DeployerException(e);
@@ -86,6 +89,31 @@
}
}
+ public static void redeploy(File file, String host, int port) throws DeployerException
{
+ ModelControllerClient client = null;
+ try {
+ client = ModelControllerClient.Factory.create(host, port);
+ String name = file.getName();
+
+ ModelNode request = new ModelNode();
+ request.get("operation").set("full-replace-deployment");
+ request.get("name").set(name);
+
+ OperationBuilder builder = OperationBuilder.Factory.create(request);
+ builder.addInputStream(new BufferedInputStream(new FileInputStream(file)));
+ Operation operation = builder.build();
+ request.get("input-stream-index").set(0);
+
+ ModelNode result = client.execute(operation);
+
+ throwOnFailure(result);
+ } catch(Exception e) {
+ throw new DeployerException(e);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
public static boolean isDeployed(String name, String host, int port) throws
CancellationException, IOException {
ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
try {
@@ -106,4 +134,7 @@
}
}
+ private DetypedDeployer() {
+ // inhibit instantiation
+ }
}
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DetypedDeployerIntegrationTest.java
===================================================================
---
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DetypedDeployerIntegrationTest.java 2011-04-14
13:34:36 UTC (rev 30573)
+++
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DetypedDeployerIntegrationTest.java 2011-04-14
13:50:42 UTC (rev 30574)
@@ -31,6 +31,7 @@
import java.text.MessageFormat;
import java.util.List;
+import org.jboss.ide.eclipse.as7.deployment.detyped.DeployerException;
import org.jboss.ide.eclipse.as7.deployment.detyped.DetypedDeployer;
import org.junit.Test;
@@ -62,7 +63,7 @@
}
}
- @Test(expected = Exception.class)
+ @Test(expected = DeployerException.class)
public void cannotDeployWarTwice() throws Exception {
File warFile = DeployerTestUtils.getWarFile(MINIMALISTIC_WAR);
try {
@@ -74,6 +75,17 @@
}
@Test
+ public void canRedeployWar() throws Exception {
+ File warFile = DeployerTestUtils.getWarFile(MINIMALISTIC_WAR);
+ try {
+ DetypedDeployer.deploy(warFile, HOST, MGMT_PORT);
+ DetypedDeployer.redeploy(warFile, HOST, MGMT_PORT);
+ } finally {
+ quietlyUndeploy(warFile);
+ }
+ }
+
+ @Test
public void canQueryDeploymentdeployedState() throws Exception {
File warFile = DeployerTestUtils.getWarFile(MINIMALISTIC_WAR);
File warFile2 = DeployerTestUtils.getWarFile(GWT_HELLOWORLD_WAR);
@@ -85,6 +97,7 @@
assertThat(deployments, hasItems( MINIMALISTIC_WAR, GWT_HELLOWORLD_WAR));
} finally {
quietlyUndeploy(warFile);
+ quietlyUndeploy(warFile2);
}
}