[jbosstools-commits] JBoss Tools SVN: r30533 - in workspace/adietish: org.jboss.ide.eclipse.as7.deployment/META-INF and 2 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue Apr 12 15:28:16 EDT 2011
Author: adietish
Date: 2011-04-12 15:28:16 -0400 (Tue, 12 Apr 2011)
New Revision: 30533
Removed:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/jboss-as-controller-7.0.0.Beta3-SNAPSHOT-sources.jar
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/jboss-as-controller-7.0.0.Beta3-SNAPSHOT.jar
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneDeployerIntegrationTest.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/MANIFEST.MF
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/build.properties
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDeployer.java
Log:
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath 2011-04-12 19:13:44 UTC (rev 30532)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath 2011-04-12 19:28:16 UTC (rev 30533)
@@ -4,7 +4,6 @@
<classpathentry exported="true" kind="lib" path="jboss-logging-3.0.0.Beta5.jar"/>
<classpathentry exported="true" kind="lib" path="jboss-dmr-1.0.0.Beta5.jar"/>
<classpathentry exported="true" kind="lib" path="jboss-threads-2.0.0.CR8.jar" sourcepath="jboss-threads-2.0.0.CR8-sources.jar"/>
- <classpathentry exported="true" kind="lib" path="jboss-as-controller-7.0.0.Beta3-SNAPSHOT.jar"/>
<classpathentry exported="true" kind="lib" path="jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT.jar" sourcepath="jboss-as-controller-client-7.0.0.Beta2-sources.jar"/>
<classpathentry exported="true" kind="lib" path="jboss-as-protocol-7.0.0.Beta3-SNAPSHOT.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
@@ -14,7 +13,6 @@
<classpathentry kind="lib" path="jboss-threads-2.0.0.CR8-sources.jar"/>
<classpathentry kind="lib" path="jboss-marshalling-1.3.0.CR8-sources.jar"/>
<classpathentry kind="lib" path="jboss-logging-3.0.0.Beta5-sources.jar"/>
- <classpathentry kind="lib" path="jboss-as-controller-7.0.0.Beta3-SNAPSHOT-sources.jar"/>
<classpathentry kind="lib" path="jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT-sources.jar"/>
<classpathentry kind="lib" path="jboss-as-protocol-7.0.0.Beta3-SNAPSHOT-sources.jar"/>
<classpathentry kind="output" path="bin"/>
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/MANIFEST.MF
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/MANIFEST.MF 2011-04-12 19:13:44 UTC (rev 30532)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/MANIFEST.MF 2011-04-12 19:28:16 UTC (rev 30533)
@@ -8,7 +8,6 @@
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: .,
- jboss-as-controller-7.0.0.Beta3-SNAPSHOT.jar,
jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT.jar,
jboss-as-protocol-7.0.0.Beta3-SNAPSHOT.jar,
jboss-threads-2.0.0.CR8.jar,
@@ -17,23 +16,12 @@
jboss-marshalling-1.3.0.CR8.jar,
shrinkwrap-api-1.0.0-alpha-11.jar,
shrinkwrap-impl-base-1.0.0-alpha-12.jar
-Export-Package: org.jboss.as.controller,
- org.jboss.as.controller.client,
+Export-Package: org.jboss.as.controller.client,
org.jboss.as.controller.client.helpers,
org.jboss.as.controller.client.helpers.domain,
org.jboss.as.controller.client.helpers.domain.impl,
org.jboss.as.controller.client.helpers.standalone,
org.jboss.as.controller.client.helpers.standalone.impl,
- org.jboss.as.controller.descriptions,
- org.jboss.as.controller.descriptions.common,
- org.jboss.as.controller.interfaces,
- org.jboss.as.controller.operations.common,
- org.jboss.as.controller.operations.global,
- org.jboss.as.controller.operations.validation,
- org.jboss.as.controller.parsing,
- org.jboss.as.controller.persistence,
- org.jboss.as.controller.registry,
- org.jboss.as.controller.remote,
org.jboss.as.protocol,
org.jboss.as.protocol.mgmt,
org.jboss.ide.eclipse.as7.deployment,
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/build.properties
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/build.properties 2011-04-12 19:13:44 UTC (rev 30532)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/build.properties 2011-04-12 19:28:16 UTC (rev 30533)
@@ -2,7 +2,6 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
- jboss-as-controller-7.0.0.Beta3-SNAPSHOT.jar,\
jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT.jar,\
jboss-as-protocol-7.0.0.Beta3-SNAPSHOT.jar,\
jboss-threads-2.0.0.CR8.jar,\
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/jboss-as-controller-7.0.0.Beta3-SNAPSHOT-sources.jar
===================================================================
(Binary files differ)
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/jboss-as-controller-7.0.0.Beta3-SNAPSHOT.jar
===================================================================
(Binary files differ)
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDeployer.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDeployer.java 2011-04-12 19:13:44 UTC (rev 30532)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDeployer.java 2011-04-12 19:28:16 UTC (rev 30533)
@@ -45,113 +45,119 @@
import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
/**
- * Used to deploy/undeploy deployments to a running <b>standalone</b> application server
- *
+ * Used to deploy/undeploy deployments to a running <b>standalone</b>
+ * application server
+ *
* @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
* @author <a href="adietish at redhat.com">André Dietisheim</a>
*/
public class StandaloneDeployer {
- public static final long DEFAULT_TIMEOUT = 15000;
+ public static final long DEFAULT_TIMEOUT = 15000;
- private final List<AbstractDeployable> deployments = new ArrayList<AbstractDeployable>();
- private final ModelControllerClient client;
- private final ServerDeploymentManager manager;
- private long timeout = DEFAULT_TIMEOUT;
+ private final List<AbstractDeployable> deployments = new ArrayList<AbstractDeployable>();
+ private final ModelControllerClient client;
+ private final ServerDeploymentManager manager;
+ private long timeout = DEFAULT_TIMEOUT;
- public StandaloneDeployer(String host, int port) throws UnknownHostException {
- client = ModelControllerClient.Factory.create(host, port);
- manager = ServerDeploymentManager.Factory.create(client);
- }
+ public StandaloneDeployer(String host, int port) throws UnknownHostException {
+ client = ModelControllerClient.Factory.create(host, port);
+ manager = ServerDeploymentManager.Factory.create(client);
+ }
- public synchronized void addWar(File file) {
- deployments.add(new WarDeployable(file));
- }
+ public synchronized StandaloneDeployer addWar(File file) {
+ deployments.add(new WarDeployable(file));
+ return this;
+ }
- public synchronized void addWarDeployment(String name, File file) {
- deployments.add(new WarDeployable(name,file));
- }
+ public synchronized StandaloneDeployer addWarDeployment(String name, File file) {
+ deployments.add(new WarDeployable(name, file));
+ return this;
+ }
- public synchronized void deploy() throws DuplicateDeploymentNameException, IOException, ExecutionException, InterruptedException, TimeoutException {
- DeploymentPlanBuilder builder = manager.newDeploymentPlan();
- for (AbstractDeployable deployment : deployments) {
- builder = deployment.addDeployment(builder);
- }
+ public synchronized void deploy() throws DuplicateDeploymentNameException, IOException, ExecutionException,
+ InterruptedException, TimeoutException {
+ DeploymentPlanBuilder builder = manager.newDeploymentPlan();
+ for (AbstractDeployable deployment : deployments) {
+ builder = deployment.addDeployment(builder);
+ }
- try {
- manager.execute(builder.build()).get(timeout, TimeUnit.MILLISECONDS);
- } finally {
- markDeploymentsDeployed();
- }
- }
+ try {
+ manager.execute(builder.build()).get(timeout, TimeUnit.MILLISECONDS);
+ } finally {
+ markDeploymentsDeployed();
+ }
+ }
- private void markDeploymentsDeployed() {
- for (AbstractDeployable deployment : deployments) {
- deployment.deployed = true;
- }
- }
+ private void markDeploymentsDeployed() {
+ for (AbstractDeployable deployment : deployments) {
+ deployment.deployed = true;
+ }
+ }
- public synchronized void undeploy() throws ExecutionException, InterruptedException, TimeoutException {
- DeploymentPlanBuilder builder = manager.newDeploymentPlan();
- for (AbstractDeployable deployment : deployments) {
- builder = deployment.removeDeployment(builder);
- }
- DeploymentPlan plan = builder.build();
- if (plan.getDeploymentActions().size() > 0) {
- manager.execute(builder.build()).get(timeout, TimeUnit.MILLISECONDS);
- }
- }
+ public synchronized void undeploy() throws ExecutionException, InterruptedException, TimeoutException {
+ DeploymentPlanBuilder builder = manager.newDeploymentPlan();
+ for (AbstractDeployable deployment : deployments) {
+ builder = deployment.removeDeployment(builder);
+ }
+ DeploymentPlan plan = builder.build();
+ if (plan.getDeploymentActions().size() > 0) {
+ manager.execute(builder.build()).get(timeout, TimeUnit.MILLISECONDS);
+ }
+ }
- public MBeanServerConnection getConnection() throws Exception {
- return JMXConnectorFactory.connect(new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi"),
- new HashMap<String, Object>()).getMBeanServerConnection();
- }
+ public MBeanServerConnection getConnection() throws Exception {
+ return JMXConnectorFactory.connect(new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi"),
+ new HashMap<String, Object>()).getMBeanServerConnection();
+ }
- public String showJndi() throws Exception {
- return (String)getConnection().invoke(new ObjectName("jboss:type=JNDIView"), "list", new Object[] {true}, new String[] {"boolean"});
- }
+ public String showJndi() throws Exception {
+ return (String) getConnection().invoke(new ObjectName("jboss:type=JNDIView"), "list", new Object[] { true },
+ new String[] { "boolean" });
+ }
- public long getTimeout() {
- return timeout;
- }
+ public long getTimeout() {
+ return timeout;
+ }
- public void setTimeout(long timeout) {
- this.timeout = timeout;
- }
+ public void setTimeout(long timeout) {
+ this.timeout = timeout;
+ }
- public void dispose() {
- safeClose(client);
- }
+ public void dispose() {
+ safeClose(client);
+ }
- private abstract class AbstractDeployable{
+ private abstract class AbstractDeployable {
- private boolean deployed;
+ private boolean deployed;
- public synchronized DeploymentPlanBuilder addDeployment(DeploymentPlanBuilder builder) throws DuplicateDeploymentNameException, IOException, ExecutionException, InterruptedException {
- String name = getName();
- return builder.add(name, getFile()).deploy(name);
- }
+ public synchronized DeploymentPlanBuilder addDeployment(DeploymentPlanBuilder builder)
+ throws DuplicateDeploymentNameException, IOException, ExecutionException, InterruptedException {
+ String name = getName();
+ return builder.add(name, getFile()).deploy(name);
+ }
- public synchronized DeploymentPlanBuilder removeDeployment(DeploymentPlanBuilder builder) {
- String name = getName();
- if (deployed) {
- return builder.undeploy(name).remove(name);
- }
- else {
- return builder;
- }
- }
-
- protected abstract String getName();
-
- protected abstract File getFile();
- }
+ public synchronized DeploymentPlanBuilder removeDeployment(DeploymentPlanBuilder builder) {
+ String name = getName();
+ if (deployed) {
+ return builder.undeploy(name).remove(name);
+ }
+ else {
+ return builder;
+ }
+ }
- private class WarDeployable extends AbstractDeployable {
+ protected abstract String getName();
+ protected abstract File getFile();
+ }
+
+ private class WarDeployable extends AbstractDeployable {
+
private File file;
private String name;
-
+
public WarDeployable(String name, File file) {
this(file);
this.name = name;
@@ -162,9 +168,9 @@
}
@Override
- protected File getFile() {
- return file;
- }
+ protected File getFile() {
+ return file;
+ }
@Override
protected String getName() {
@@ -174,6 +180,6 @@
return file.getName();
}
}
-
- }
+
+ }
}
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneDeployerIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneDeployerIntegrationTest.java 2011-04-12 19:13:44 UTC (rev 30532)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneDeployerIntegrationTest.java 2011-04-12 19:28:16 UTC (rev 30533)
@@ -54,15 +54,14 @@
private static final String HOST = "localhost";
private static final int MGMT_PORT = 9999;
private static final int WEB_PORT = 8080;
-
+
@Test
public void canDeploy() throws Exception {
StandaloneDeployer deployer = null;
try {
File warFile = getWarFile("minimalistic.war");
deployer = new StandaloneDeployer(HOST, MGMT_PORT);
- deployer.addWar(warFile);
- deployer.deploy();
+ deployer.addWar(warFile).deploy();
String response = getServerResponse(new URL(
MessageFormat.format("http://{0}:{1}/{2}",
@@ -70,11 +69,23 @@
assertTrue(response.indexOf("minimalistic") >= 0);
} finally {
- deployer.undeploy();
- deployer.dispose();
+ quietlyCleanup(deployer);
}
}
+ @Test
+ public void cannotDeployWarTwice() throws Exception {
+ StandaloneDeployer deployer = null;
+ try {
+ File warFile = getWarFile("minimalistic.war");
+ deployer = new StandaloneDeployer(HOST, MGMT_PORT);
+ deployer.addWar(warFile).deploy();
+ deployer.addWar(warFile).deploy();
+ } finally {
+ quietlyCleanup(deployer);
+ }
+ }
+
private File getWarFile(String name) throws URISyntaxException, IOException {
Bundle bundle = Platform.getBundle(BUNDLE_ID);
URL entryUrl = bundle.getEntry(WAR_FOLDER + name);
@@ -100,4 +111,16 @@
}
return writer.toString();
}
+
+ private void quietlyCleanup(StandaloneDeployer deployer) {
+ try {
+ if (deployer != null) {
+ deployer.undeploy();
+ deployer.dispose();
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+
+ }
}
More information about the jbosstools-commits
mailing list