JBoss Tools SVN: r30572 - in workspace/adietish: org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-04-14 09:27:36 -0400 (Thu, 14 Apr 2011)
New Revision: 30572
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java
Log:
starting minimalistic typed deployer with tests
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 12:56:45 UTC (rev 30571)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java 2011-04-14 13:27:36 UTC (rev 30572)
@@ -21,9 +21,11 @@
*/
package org.jboss.ide.eclipse.as7.deployment.internal;
+import java.io.File;
import java.util.concurrent.TimeUnit;
import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.helpers.standalone.DeploymentPlan;
import org.jboss.as.controller.client.helpers.standalone.InitialDeploymentPlanBuilder;
import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
import org.jboss.as.protocol.StreamUtils;
@@ -41,10 +43,10 @@
try {
client = ModelControllerClient.Factory.create(host, port);
ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client);
- InitialDeploymentPlanBuilder plan = manager.newDeploymentPlan();
+ InitialDeploymentPlanBuilder builder = manager.newDeploymentPlan();
- plan.undeploy(name).undeploy(name).andRemoveUndeployed();
- manager.execute(plan.build()).get(TIMEOUT, TimeUnit.MILLISECONDS);
+ DeploymentPlan plan = builder.undeploy(name).andRemoveUndeployed().build();
+ manager.execute(plan).get(TIMEOUT, TimeUnit.MILLISECONDS);
} catch(Exception e) {
throw new DeployerException(e);
} finally {
@@ -52,7 +54,24 @@
}
}
-// public static void deploy(File file, String host, int port) throws DeployerException {
+ public static void deploy(File file, String host, int port) throws DeployerException {
+ ModelControllerClient client = null;
+ try {
+ client = ModelControllerClient.Factory.create(host, port);
+ ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client);
+ InitialDeploymentPlanBuilder builder = manager.newDeploymentPlan();
+
+ String name = file.getName();
+ DeploymentPlan plan = builder.add(name, file).deploy(name).build();
+ manager.execute(plan).get(TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch(Exception e) {
+ throw new DeployerException(e);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
+ // public static void deploy(File file, String host, int port) throws DeployerException {
// ModelControllerClient client = null;
// try {
// client = ModelControllerClient.Factory.create(host, port);
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java 2011-04-14 12:56:45 UTC (rev 30571)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java 2011-04-14 13:27:36 UTC (rev 30572)
@@ -27,7 +27,7 @@
import java.net.URL;
import java.text.MessageFormat;
-import org.jboss.ide.eclipse.as7.deployment.detyped.DetypedDeployer;
+import org.jboss.ide.eclipse.as7.deployment.internal.TypedDeployer;
import org.junit.Test;
/**
@@ -48,7 +48,7 @@
public void canDeploy() throws Exception {
File warFile = DeployerTestUtils.getWarFile(MINIMALISTIC_WAR);
try {
- DetypedDeployer.deploy(warFile, HOST, MGMT_PORT);
+ TypedDeployer.deploy(warFile, HOST, MGMT_PORT);
String response = DeployerTestUtils.getServerResponse(new URL(
MessageFormat.format(
@@ -114,7 +114,7 @@
//
private void quietlyUndeploy(File file) {
try {
- DetypedDeployer.undeploy(file.getName(), HOST, MGMT_PORT);
+ TypedDeployer.undeploy(file.getName(), HOST, MGMT_PORT);
} catch (Exception e) {
e.printStackTrace();
// ignore
15 years
JBoss Tools SVN: r30571 - in workspace/adietish: org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-04-14 08:56:45 -0400 (Thu, 14 Apr 2011)
New Revision: 30571
Added:
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/DeployerTestUtils.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DeploymentManagerIntegratonTest.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.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Activator.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeploymentManager.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java
Removed:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneOperationsIntegrationTest.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Activator.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/StandaloneTypedOperations.java
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/MANIFEST.MF
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Deployable.java
Log:
starting minimalistic typed deployer with tests
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-14 12:34:04 UTC (rev 30570)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/MANIFEST.MF 2011-04-14 12:56:45 UTC (rev 30571)
@@ -3,7 +3,7 @@
Bundle-Name: Deployment
Bundle-SymbolicName: org.jboss.ide.eclipse.as7.deployment
Bundle-Version: 0.0.1.qualifier
-Bundle-Activator: org.jboss.ide.eclipse.as7.deployment.Activator
+Bundle-Activator: org.jboss.ide.eclipse.as7.deployment.internal.Activator
Require-Bundle: org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Activator.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Activator.java 2011-04-14 12:34:04 UTC (rev 30570)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Activator.java 2011-04-14 12:56:45 UTC (rev 30571)
@@ -1,30 +0,0 @@
-package org.jboss.ide.eclipse.as7.deployment;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class Activator implements BundleActivator {
-
- private static BundleContext context;
-
- public static BundleContext getContext() {
- return context;
- }
-
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext bundleContext) throws Exception {
- Activator.context = bundleContext;
- }
-
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext bundleContext) throws Exception {
- Activator.context = null;
- }
-
-}
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Activator.java (from rev 30566, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Activator.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Activator.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Activator.java 2011-04-14 12:56:45 UTC (rev 30571)
@@ -0,0 +1,30 @@
+package org.jboss.ide.eclipse.as7.deployment.internal;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ public static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Activator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Deployable.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Deployable.java 2011-04-14 12:34:04 UTC (rev 30570)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Deployable.java 2011-04-14 12:56:45 UTC (rev 30571)
@@ -10,7 +10,6 @@
import org.jboss.as.controller.client.helpers.standalone.DeploymentAction;
import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentActionResult;
import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentPlanResult;
-import org.jboss.ide.eclipse.as7.deployment.Activator;
public class Deployable {
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeploymentManager.java (from rev 30566, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/StandaloneTypedOperations.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeploymentManager.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeploymentManager.java 2011-04-14 12:56:45 UTC (rev 30571)
@@ -0,0 +1,169 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.ide.eclipse.as7.deployment.internal;
+
+import static org.jboss.as.protocol.StreamUtils.safeClose;
+
+import java.io.File;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.helpers.standalone.DeploymentPlanBuilder;
+import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
+
+/**
+ * Used to deploy/undeploy deployments to a running <b>standalone</b>
+ * application server
+ *
+ * @author <a href="adietish(a)redhat.com">André Dietisheim</a>
+ */
+public class DeploymentManager {
+
+ public static final long DEFAULT_TIMEOUT = 15000;
+
+ private final List<IDeploymentPlanBuilderOperation> deployments = new ArrayList<IDeploymentPlanBuilderOperation>();
+ private final ModelControllerClient client;
+ private final ServerDeploymentManager manager;
+ private long timeout = DEFAULT_TIMEOUT;
+
+ public DeploymentManager(String host, int port) throws UnknownHostException {
+ client = ModelControllerClient.Factory.create(host, port);
+ manager = ServerDeploymentManager.Factory.create(client);
+ }
+
+ public synchronized DeploymentManager deploy(File file) {
+ deployments.add(new DeployOperation(file));
+ return this;
+ }
+
+ public synchronized DeploymentManager deploy(String name, File file) {
+ deployments.add(new DeployOperation(name, file));
+ return this;
+ }
+
+ public synchronized DeploymentManager undeploy(String name) {
+ deployments.add(new UndeployOperation(name));
+ return this;
+ }
+
+ public synchronized DeploymentManager undeploy(File file) {
+ deployments.add(new UndeployOperation(file));
+ return this;
+ }
+
+ public synchronized void execute() throws DeployerException {
+ try {
+ DeploymentPlanBuilder builder = manager.newDeploymentPlan();
+ for (IDeploymentPlanBuilderOperation deployment : deployments) {
+ builder = deployment.addTo(builder);
+ }
+ manager.execute(builder.build()).get(timeout, TimeUnit.MILLISECONDS);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ }
+ }
+
+ public void setTimeout(long timeout) {
+ this.timeout = timeout;
+ }
+
+ public void dispose() {
+ safeClose(client);
+ }
+
+ private static class DeployOperation extends FileOperation {
+
+ private DeployOperation(File file) {
+ super(file);
+ }
+
+ private DeployOperation(String name, File file) {
+ super(name, file);
+ }
+
+ public synchronized DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception {
+ String name = getName();
+ return builder.add(name, getFile()).deploy(name);
+ }
+ }
+
+ private static class UndeployOperation extends FileOperation {
+
+ private UndeployOperation(File file) {
+ super(file);
+ }
+
+ private UndeployOperation(String name) {
+ super(name, null);
+ }
+
+ public synchronized DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception {
+ String name = getName();
+ return builder.undeploy(name).undeploy(name);
+ }
+ }
+
+ private abstract static class FileOperation extends NamedOperation {
+
+ private File file;
+
+ private FileOperation(File file) {
+ this(null, file);
+ }
+
+ private FileOperation(String name, File file) {
+ super(name);
+ this.file = file;
+ }
+
+ protected File getFile() {
+ return file;
+ }
+
+ protected String getName() {
+ if (name != null) {
+ return name;
+ } else {
+ return file.getName();
+ }
+ }
+
+ }
+
+ private abstract static class NamedOperation implements IDeploymentPlanBuilderOperation {
+
+ protected String name;
+
+ private NamedOperation(String name) {
+ this.name = name;
+ }
+ }
+
+ private interface IDeploymentPlanBuilderOperation {
+
+ public DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception;
+
+ }
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeploymentManager.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/StandaloneTypedOperations.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/StandaloneTypedOperations.java 2011-04-14 12:34:04 UTC (rev 30570)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/StandaloneTypedOperations.java 2011-04-14 12:56:45 UTC (rev 30571)
@@ -1,170 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.ide.eclipse.as7.deployment.internal;
-
-import static org.jboss.as.protocol.StreamUtils.safeClose;
-
-import java.io.File;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import org.jboss.as.controller.client.ModelControllerClient;
-import org.jboss.as.controller.client.helpers.standalone.DeploymentPlanBuilder;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
-
-/**
- * Used to deploy/undeploy deployments to a running <b>standalone</b>
- * application server
- *
- * @author <a href="kabir.khan(a)jboss.com">Kabir Khan</a>
- * @author <a href="adietish(a)redhat.com">André Dietisheim</a>
- */
-public class StandaloneTypedOperations {
-
- public static final long DEFAULT_TIMEOUT = 15000;
-
- private final List<IDeploymentPlanBuilderOperation> deployments = new ArrayList<IDeploymentPlanBuilderOperation>();
- private final ModelControllerClient client;
- private final ServerDeploymentManager manager;
- private long timeout = DEFAULT_TIMEOUT;
-
- public StandaloneTypedOperations(String host, int port) throws UnknownHostException {
- client = ModelControllerClient.Factory.create(host, port);
- manager = ServerDeploymentManager.Factory.create(client);
- }
-
- public synchronized StandaloneTypedOperations deploy(File file) {
- deployments.add(new DeployOperation(file));
- return this;
- }
-
- public synchronized StandaloneTypedOperations deploy(String name, File file) {
- deployments.add(new DeployOperation(name, file));
- return this;
- }
-
- public synchronized StandaloneTypedOperations undeploy(String name) {
- deployments.add(new UndeployOperation(name));
- return this;
- }
-
- public synchronized StandaloneTypedOperations undeploy(File file) {
- deployments.add(new UndeployOperation(file));
- return this;
- }
-
- public synchronized void execute() throws DeployerException {
- try {
- DeploymentPlanBuilder builder = manager.newDeploymentPlan();
- for (IDeploymentPlanBuilderOperation deployment : deployments) {
- builder = deployment.addTo(builder);
- }
- manager.execute(builder.build()).get(timeout, TimeUnit.MILLISECONDS);
- } catch (Exception e) {
- throw new DeployerException(e);
- }
- }
-
- public void setTimeout(long timeout) {
- this.timeout = timeout;
- }
-
- public void dispose() {
- safeClose(client);
- }
-
- private static class DeployOperation extends FileOperation {
-
- private DeployOperation(File file) {
- super(file);
- }
-
- private DeployOperation(String name, File file) {
- super(name, file);
- }
-
- public synchronized DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception {
- String name = getName();
- return builder.add(name, getFile()).deploy(name);
- }
- }
-
- private static class UndeployOperation extends FileOperation {
-
- private UndeployOperation(File file) {
- super(file);
- }
-
- private UndeployOperation(String name) {
- super(name, null);
- }
-
- public synchronized DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception {
- String name = getName();
- return builder.undeploy(name).undeploy(name);
- }
- }
-
- private abstract static class FileOperation extends NamedOperation {
-
- private File file;
-
- private FileOperation(File file) {
- this(null, file);
- }
-
- private FileOperation(String name, File file) {
- super(name);
- this.file = file;
- }
-
- protected File getFile() {
- return file;
- }
-
- protected String getName() {
- if (name != null) {
- return name;
- } else {
- return file.getName();
- }
- }
-
- }
-
- private abstract static class NamedOperation implements IDeploymentPlanBuilderOperation {
-
- protected String name;
-
- private NamedOperation(String name) {
- this.name = name;
- }
- }
-
- private interface IDeploymentPlanBuilderOperation {
-
- public DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception;
-
- }
-}
Added: 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 (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java 2011-04-14 12:56:45 UTC (rev 30571)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.ide.eclipse.as7.deployment.internal;
+
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.helpers.standalone.InitialDeploymentPlanBuilder;
+import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
+import org.jboss.as.protocol.StreamUtils;
+
+/**
+ * @author André Dietisheim
+ */
+public class TypedDeployer {
+
+ private static final long TIMEOUT = 15 * 1000;
+
+
+ public static void undeploy(String name, String host, int port) throws DeployerException {
+ ModelControllerClient client = null;
+ try {
+ client = ModelControllerClient.Factory.create(host, port);
+ ServerDeploymentManager manager = ServerDeploymentManager.Factory.create(client);
+ InitialDeploymentPlanBuilder plan = manager.newDeploymentPlan();
+
+ plan.undeploy(name).undeploy(name).andRemoveUndeployed();
+ manager.execute(plan.build()).get(TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch(Exception e) {
+ throw new DeployerException(e);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
+// 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 {
+// return Util.isDeployed(name, client);
+// } finally {
+// StreamUtils.safeClose(client);
+// }
+// }
+//
+// public static List<String> getDeployments(String host, int port) throws UnknownHostException {
+// ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+// return Util.getDeployments(client);
+// }
+//
+// private static void throwOnFailure(ModelNode result) throws DeployerException {
+// if (!Util.isSuccess(result)) {
+// throw new DeployerException(Util.getFailureDescription(result));
+// }
+// }
+
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/TypedDeployer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/DetypedDeployer.java (from rev 30570, workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/DetypedDeployer.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/DetypedDeployer.java 2011-04-14 12:56:45 UTC (rev 30571)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.ide.eclipse.as7.deployment.detyped;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.List;
+import java.util.concurrent.CancellationException;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.OperationBuilder;
+import org.jboss.as.protocol.StreamUtils;
+import org.jboss.dmr.ModelNode;
+import org.jboss.ide.eclipse.as7.deployment.detyped.util.Util;
+
+/**
+ * @author André Dietisheim
+ */
+public class DetypedDeployer {
+
+ public static void undeploy(String name, String host, int port) throws DeployerException {
+ ModelControllerClient client = null;
+ try {
+ client = ModelControllerClient.Factory.create(host, port);
+ // undeploy
+ ModelNode request = new ModelNode();
+ request.get("operation").set("undeploy");
+ request.get("address").add("deployment", name);
+ ModelNode result = client.execute(request);
+
+ // remove
+ request = new ModelNode();
+ request.get("operation").set("remove");
+ request.get("address").add("deployment", name);
+ result = client.execute(request);
+ } catch(Exception e) {
+ throw new DeployerException(e);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
+ 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 {
+ return Util.isDeployed(name, client);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
+
+ public static List<String> getDeployments(String host, int port) throws UnknownHostException {
+ ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+ return Util.getDeployments(client);
+ }
+
+ private static void throwOnFailure(ModelNode result) throws DeployerException {
+ if (!Util.isSuccess(result)) {
+ throw new DeployerException(Util.getFailureDescription(result));
+ }
+ }
+
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/DetypedDeployer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java 2011-04-14 12:34:04 UTC (rev 30570)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java 2011-04-14 12:56:45 UTC (rev 30571)
@@ -1,109 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.ide.eclipse.as7.deployment.detyped;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.List;
-import java.util.concurrent.CancellationException;
-
-import org.jboss.as.controller.client.ModelControllerClient;
-import org.jboss.as.controller.client.OperationBuilder;
-import org.jboss.as.protocol.StreamUtils;
-import org.jboss.dmr.ModelNode;
-import org.jboss.ide.eclipse.as7.deployment.detyped.util.Util;
-
-/**
- * @author André Dietisheim
- */
-public class MinimalisticStandaloneDeployer {
-
- public static void undeploy(String name, String host, int port) throws DeployerException {
- ModelControllerClient client = null;
- try {
- client = ModelControllerClient.Factory.create(host, port);
- // undeploy
- ModelNode request = new ModelNode();
- request.get("operation").set("undeploy");
- request.get("address").add("deployment", name);
- ModelNode result = client.execute(request);
-
- // remove
- request = new ModelNode();
- request.get("operation").set("remove");
- request.get("address").add("deployment", name);
- result = client.execute(request);
- } catch(Exception e) {
- throw new DeployerException(e);
- } finally {
- StreamUtils.safeClose(client);
- }
- }
-
- 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 {
- return Util.isDeployed(name, client);
- } finally {
- StreamUtils.safeClose(client);
- }
- }
-
- public static List<String> getDeployments(String host, int port) throws UnknownHostException {
- ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
- return Util.getDeployments(client);
- }
-
- private static void throwOnFailure(ModelNode result) throws DeployerException {
- if (!Util.isSuccess(result)) {
- throw new DeployerException(Util.getFailureDescription(result));
- }
- }
-
-}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DeployerTestUtils.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DeployerTestUtils.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DeployerTestUtils.java 2011-04-14 12:56:45 UTC (rev 30571)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.ide.eclipse.as7.deployment.tests;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.net.HttpURLConnection;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+
+/**
+ * @author André Dietisheim
+ */
+public class DeployerTestUtils {
+
+ private static final String WAR_FOLDER = "/wars/";
+ private static final String BUNDLE_ID = "org.jboss.ide.eclipse.as7.deployment.tests";
+
+ private static final int WEBAPP_RESPONSE_TIMEOUT = 10 * 1024;
+
+
+ public static File getWarFile(String name) throws URISyntaxException, IOException {
+ Bundle bundle = Platform.getBundle(BUNDLE_ID);
+ URL entryUrl = bundle.getEntry(WAR_FOLDER + name);
+ return new File(FileLocator.resolve(entryUrl).toURI());
+ }
+
+ public static String getServerResponse(URL url) throws IOException {
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setUseCaches(false);
+ connection.setDoInput(true);
+ connection.setAllowUserInteraction(false);
+ connection.setConnectTimeout(WEBAPP_RESPONSE_TIMEOUT);
+ connection.setInstanceFollowRedirects(true);
+ connection.setDoOutput(false);
+ BufferedInputStream in = new BufferedInputStream(connection.getInputStream());
+ return toString(in);
+ }
+
+ public static String toString(InputStream in) throws IOException {
+ StringWriter writer = new StringWriter();
+ for (int data = -1; ((data = in.read()) != -1);) {
+ writer.write(data);
+ }
+ return writer.toString();
+ }
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DeployerTestUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DeploymentManagerIntegratonTest.java (from rev 30566, workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneOperationsIntegrationTest.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DeploymentManagerIntegratonTest.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DeploymentManagerIntegratonTest.java 2011-04-14 12:56:45 UTC (rev 30571)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.ide.eclipse.as7.deployment.tests;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.net.HttpURLConnection;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.jboss.ide.eclipse.as7.deployment.internal.DeployerException;
+import org.jboss.ide.eclipse.as7.deployment.internal.DeploymentManager;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * @author André Dietisheim
+ */
+public class DeploymentManagerIntegratonTest {
+
+ private static final String WAR_FOLDER = "/wars/";
+ private static final String BUNDLE_ID = "org.jboss.ide.eclipse.as7.deployment.tests";
+
+ private static final int WEBAPP_RESPONSE_TIMEOUT = 10 * 1024;
+
+ 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 {
+ DeploymentManager deployer = null;
+ File warFile = getWarFile("minimalistic.war");
+ try {
+ deployer = new DeploymentManager(HOST, MGMT_PORT);
+ deployer.deploy(warFile).execute();
+
+ String response = getServerResponse(new URL(
+ MessageFormat.format(
+ "http://{0}:{1}/{2}", HOST, String.valueOf(WEB_PORT), "minimalistic")));
+ assertTrue(response.indexOf("minimalistic") >= 0);
+
+ } finally {
+ quietlyUndeploy(warFile, deployer);
+ }
+ }
+
+ @Test(expected = DeployerException.class)
+ public void cannotDeployWarTwice() throws Exception {
+ DeploymentManager deployer = null;
+ File warFile = getWarFile("minimalistic.war");
+ try {
+ deployer = new DeploymentManager(HOST, MGMT_PORT);
+ deployer.deploy(warFile).execute();
+ deployer.deploy(warFile).execute();
+ } finally {
+ quietlyUndeploy(warFile, deployer);
+ }
+ }
+
+ private File getWarFile(String name) throws URISyntaxException, IOException {
+ Bundle bundle = Platform.getBundle(BUNDLE_ID);
+ URL entryUrl = bundle.getEntry(WAR_FOLDER + name);
+ return new File(FileLocator.resolve(entryUrl).toURI());
+ }
+
+ private String getServerResponse(URL url) throws IOException {
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setUseCaches(false);
+ connection.setDoInput(true);
+ connection.setAllowUserInteraction(false);
+ connection.setConnectTimeout(WEBAPP_RESPONSE_TIMEOUT);
+ connection.setInstanceFollowRedirects(true);
+ connection.setDoOutput(false);
+ BufferedInputStream in = new BufferedInputStream(connection.getInputStream());
+ return toString(in);
+ }
+
+ private String toString(InputStream in) throws IOException {
+ StringWriter writer = new StringWriter();
+ for (int data = -1; ((data = in.read()) != -1);) {
+ writer.write(data);
+ }
+ return writer.toString();
+ }
+
+ private void quietlyUndeploy(File file, DeploymentManager deployer) {
+ try {
+ if (deployer != null) {
+ deployer.undeploy(file).execute();
+ deployer.dispose();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ // ignore
+ }
+ }
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DeploymentManagerIntegratonTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DetypedDeployerIntegrationTest.java (from rev 30570, workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DetypedDeployerIntegrationTest.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DetypedDeployerIntegrationTest.java 2011-04-14 12:56:45 UTC (rev 30571)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.ide.eclipse.as7.deployment.tests;
+
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.List;
+
+import org.jboss.ide.eclipse.as7.deployment.detyped.DetypedDeployer;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class DetypedDeployerIntegrationTest {
+
+ private static final String GWT_HELLOWORLD_WAR = "gwt-helloworld.war";
+ private static final String MINIMALISTIC_WAR = "minimalistic.war";
+
+ 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 {
+ File warFile = DeployerTestUtils.getWarFile(MINIMALISTIC_WAR);
+ try {
+ DetypedDeployer.deploy(warFile, HOST, MGMT_PORT);
+
+ String response = DeployerTestUtils.getServerResponse(new URL(
+ MessageFormat.format(
+ "http://{0}:{1}/{2}", HOST, String.valueOf(WEB_PORT), "minimalistic")));
+ assertTrue(response.indexOf("minimalistic") >= 0);
+
+ } finally {
+ quietlyUndeploy(warFile);
+ }
+ }
+
+ @Test(expected = Exception.class)
+ public void cannotDeployWarTwice() throws Exception {
+ File warFile = DeployerTestUtils.getWarFile(MINIMALISTIC_WAR);
+ try {
+ DetypedDeployer.deploy(warFile, HOST, MGMT_PORT);
+ DetypedDeployer.deploy(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);
+ try {
+ DetypedDeployer.deploy(warFile, HOST, MGMT_PORT);
+ DetypedDeployer.deploy(warFile2, HOST, MGMT_PORT);
+ List<String> deployments = DetypedDeployer.getDeployments(HOST, MGMT_PORT);
+ assertThat(deployments.size(), is(2));
+ assertThat(deployments, hasItems( MINIMALISTIC_WAR, GWT_HELLOWORLD_WAR));
+ } finally {
+ quietlyUndeploy(warFile);
+ }
+ }
+
+ private void quietlyUndeploy(File file) {
+ try {
+ DetypedDeployer.undeploy(file.getName(), HOST, MGMT_PORT);
+ } catch (Exception e) {
+ e.printStackTrace();
+ // ignore
+ }
+ }
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/DetypedDeployerIntegrationTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java 2011-04-14 12:34:04 UTC (rev 30570)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java 2011-04-14 12:56:45 UTC (rev 30571)
@@ -1,139 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.ide.eclipse.as7.deployment.tests;
-
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.net.HttpURLConnection;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.text.MessageFormat;
-import java.util.List;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Platform;
-import org.jboss.ide.eclipse.as7.deployment.detyped.MinimalisticStandaloneDeployer;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-
-/**
- *
- * @author André Dietisheim
- */
-public class MinimalisticDeployerIntegrationTest {
-
- private static final String GWT_HELLOWORLD_WAR = "gwt-helloworld.war";
- private static final String MINIMALISTIC_WAR = "minimalistic.war";
- private static final String WAR_FOLDER = "/wars/";
- private static final String BUNDLE_ID = "org.jboss.ide.eclipse.as7.deployment.tests";
-
- private static final int WEBAPP_RESPONSE_TIMEOUT = 10 * 1024;
-
- 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 {
- File warFile = getWarFile(MINIMALISTIC_WAR);
- try {
- MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
-
- String response = getServerResponse(new URL(
- MessageFormat.format(
- "http://{0}:{1}/{2}", HOST, String.valueOf(WEB_PORT), "minimalistic")));
- assertTrue(response.indexOf("minimalistic") >= 0);
-
- } finally {
- quietlyUndeploy(warFile);
- }
- }
-
- @Test(expected = Exception.class)
- public void cannotDeployWarTwice() throws Exception {
- File warFile = getWarFile(MINIMALISTIC_WAR);
- try {
- MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
- MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
- } finally {
- quietlyUndeploy(warFile);
- }
- }
-
- @Test
- public void canQueryDeploymentdeployedState() throws Exception {
- File warFile = getWarFile(MINIMALISTIC_WAR);
- File warFile2 = getWarFile(GWT_HELLOWORLD_WAR);
- try {
- MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
- MinimalisticStandaloneDeployer.deploy(warFile2, HOST, MGMT_PORT);
- List<String> deployments = MinimalisticStandaloneDeployer.getDeployments(HOST, MGMT_PORT);
- assertThat(deployments.size(), is(2));
- assertThat(deployments, hasItems( MINIMALISTIC_WAR, GWT_HELLOWORLD_WAR));
- } finally {
- quietlyUndeploy(warFile);
- }
- }
-
- private File getWarFile(String name) throws URISyntaxException, IOException {
- Bundle bundle = Platform.getBundle(BUNDLE_ID);
- URL entryUrl = bundle.getEntry(WAR_FOLDER + name);
- return new File(FileLocator.resolve(entryUrl).toURI());
- }
-
- private String getServerResponse(URL url) throws IOException {
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setUseCaches(false);
- connection.setDoInput(true);
- connection.setAllowUserInteraction(false);
- connection.setConnectTimeout(WEBAPP_RESPONSE_TIMEOUT);
- connection.setInstanceFollowRedirects(true);
- connection.setDoOutput(false);
- BufferedInputStream in = new BufferedInputStream(connection.getInputStream());
- return toString(in);
- }
-
- private String toString(InputStream in) throws IOException {
- StringWriter writer = new StringWriter();
- for (int data = -1; ((data = in.read()) != -1);) {
- writer.write(data);
- }
- return writer.toString();
- }
-
- private void quietlyUndeploy(File file) {
- try {
- MinimalisticStandaloneDeployer.undeploy(file.getName(), HOST, MGMT_PORT);
- } catch (Exception e) {
- e.printStackTrace();
- // ignore
- }
- }
-}
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneOperationsIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneOperationsIntegrationTest.java 2011-04-14 12:34:04 UTC (rev 30570)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneOperationsIntegrationTest.java 2011-04-14 12:56:45 UTC (rev 30571)
@@ -1,126 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.ide.eclipse.as7.deployment.tests;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.net.HttpURLConnection;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.text.MessageFormat;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Platform;
-import org.jboss.ide.eclipse.as7.deployment.internal.DeployerException;
-import org.jboss.ide.eclipse.as7.deployment.internal.StandaloneTypedOperations;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-
-/**
- *
- * @author André Dietisheim
- */
-public class StandaloneOperationsIntegrationTest {
-
- private static final String WAR_FOLDER = "/wars/";
- private static final String BUNDLE_ID = "org.jboss.ide.eclipse.as7.deployment.tests";
-
- private static final int WEBAPP_RESPONSE_TIMEOUT = 10 * 1024;
-
- 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 {
- StandaloneTypedOperations deployer = null;
- File warFile = getWarFile("minimalistic.war");
- try {
- deployer = new StandaloneTypedOperations(HOST, MGMT_PORT);
- deployer.deploy(warFile).execute();
-
- String response = getServerResponse(new URL(
- MessageFormat.format(
- "http://{0}:{1}/{2}", HOST, String.valueOf(WEB_PORT), "minimalistic")));
- assertTrue(response.indexOf("minimalistic") >= 0);
-
- } finally {
- quietlyUndeploy(warFile, deployer);
- }
- }
-
- @Test(expected = DeployerException.class)
- public void cannotDeployWarTwice() throws Exception {
- StandaloneTypedOperations deployer = null;
- File warFile = getWarFile("minimalistic.war");
- try {
- deployer = new StandaloneTypedOperations(HOST, MGMT_PORT);
- deployer.deploy(warFile).execute();
- deployer.deploy(warFile).execute();
- } finally {
- quietlyUndeploy(warFile, deployer);
- }
- }
-
- private File getWarFile(String name) throws URISyntaxException, IOException {
- Bundle bundle = Platform.getBundle(BUNDLE_ID);
- URL entryUrl = bundle.getEntry(WAR_FOLDER + name);
- return new File(FileLocator.resolve(entryUrl).toURI());
- }
-
- private String getServerResponse(URL url) throws IOException {
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setUseCaches(false);
- connection.setDoInput(true);
- connection.setAllowUserInteraction(false);
- connection.setConnectTimeout(WEBAPP_RESPONSE_TIMEOUT);
- connection.setInstanceFollowRedirects(true);
- connection.setDoOutput(false);
- BufferedInputStream in = new BufferedInputStream(connection.getInputStream());
- return toString(in);
- }
-
- private String toString(InputStream in) throws IOException {
- StringWriter writer = new StringWriter();
- for (int data = -1; ((data = in.read()) != -1);) {
- writer.write(data);
- }
- return writer.toString();
- }
-
- private void quietlyUndeploy(File file, StandaloneTypedOperations deployer) {
- try {
- if (deployer != null) {
- deployer.undeploy(file).execute();
- deployer.dispose();
- }
- } catch (Exception e) {
- e.printStackTrace();
- // ignore
- }
- }
-}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java 2011-04-14 12:56:45 UTC (rev 30571)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.ide.eclipse.as7.deployment.tests;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.net.URL;
+import java.text.MessageFormat;
+
+import org.jboss.ide.eclipse.as7.deployment.detyped.DetypedDeployer;
+import org.junit.Test;
+
+/**
+ *
+ * @author André Dietisheim
+ */
+public class TypedDeployerIntegrationTest {
+
+ private static final String GWT_HELLOWORLD_WAR = "gwt-helloworld.war";
+ private static final String MINIMALISTIC_WAR = "minimalistic.war";
+ private static final String WAR_FOLDER = "/wars/";
+
+ 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 {
+ File warFile = DeployerTestUtils.getWarFile(MINIMALISTIC_WAR);
+ try {
+ DetypedDeployer.deploy(warFile, HOST, MGMT_PORT);
+
+ String response = DeployerTestUtils.getServerResponse(new URL(
+ MessageFormat.format(
+ "http://{0}:{1}/{2}", HOST, String.valueOf(WEB_PORT), "minimalistic")));
+ assertTrue(response.indexOf("minimalistic") >= 0);
+
+ } finally {
+ quietlyUndeploy(warFile);
+ }
+ }
+
+// @Test(expected = Exception.class)
+// public void cannotDeployWarTwice() throws Exception {
+// File warFile = getWarFile(MINIMALISTIC_WAR);
+// try {
+// DetypedDeployer.deploy(warFile, HOST, MGMT_PORT);
+// DetypedDeployer.deploy(warFile, HOST, MGMT_PORT);
+// } finally {
+// quietlyUndeploy(warFile);
+// }
+// }
+//
+// @Test
+// public void canQueryDeploymentdeployedState() throws Exception {
+// File warFile = getWarFile(MINIMALISTIC_WAR);
+// File warFile2 = getWarFile(GWT_HELLOWORLD_WAR);
+// try {
+// DetypedDeployer.deploy(warFile, HOST, MGMT_PORT);
+// DetypedDeployer.deploy(warFile2, HOST, MGMT_PORT);
+// List<String> deployments = DetypedDeployer.getDeployments(HOST, MGMT_PORT);
+// assertThat(deployments.size(), is(2));
+// assertThat(deployments, hasItems( MINIMALISTIC_WAR, GWT_HELLOWORLD_WAR));
+// } finally {
+// quietlyUndeploy(warFile);
+// }
+// }
+//
+// private File getWarFile(String name) throws URISyntaxException, IOException {
+// Bundle bundle = Platform.getBundle(BUNDLE_ID);
+// URL entryUrl = bundle.getEntry(WAR_FOLDER + name);
+// return new File(FileLocator.resolve(entryUrl).toURI());
+// }
+//
+// private String getServerResponse(URL url) throws IOException {
+// HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+// connection.setUseCaches(false);
+// connection.setDoInput(true);
+// connection.setAllowUserInteraction(false);
+// connection.setConnectTimeout(WEBAPP_RESPONSE_TIMEOUT);
+// connection.setInstanceFollowRedirects(true);
+// connection.setDoOutput(false);
+// BufferedInputStream in = new BufferedInputStream(connection.getInputStream());
+// return toString(in);
+// }
+//
+// private String toString(InputStream in) throws IOException {
+// StringWriter writer = new StringWriter();
+// for (int data = -1; ((data = in.read()) != -1);) {
+// writer.write(data);
+// }
+// return writer.toString();
+// }
+//
+ private void quietlyUndeploy(File file) {
+ try {
+ DetypedDeployer.undeploy(file.getName(), HOST, MGMT_PORT);
+ } catch (Exception e) {
+ e.printStackTrace();
+ // ignore
+ }
+ }
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/TypedDeployerIntegrationTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
15 years
JBoss Tools SVN: r30570 - in workspace/adietish: org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-04-14 08:34:04 -0400 (Thu, 14 Apr 2011)
New Revision: 30570
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java
Log:
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java 2011-04-14 12:28:48 UTC (rev 30569)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java 2011-04-14 12:34:04 UTC (rev 30570)
@@ -40,9 +40,10 @@
*/
public class MinimalisticStandaloneDeployer {
- public static void undeploy(String name, String host, int port) throws CancellationException, IOException {
- ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+ public static void undeploy(String name, String host, int port) throws DeployerException {
+ ModelControllerClient client = null;
try {
+ client = ModelControllerClient.Factory.create(host, port);
// undeploy
ModelNode request = new ModelNode();
request.get("operation").set("undeploy");
@@ -54,14 +55,17 @@
request.get("operation").set("remove");
request.get("address").add("deployment", name);
result = client.execute(request);
+ } catch(Exception e) {
+ throw new DeployerException(e);
} finally {
StreamUtils.safeClose(client);
}
}
- public static void deploy(File file, String host, int port) throws CancellationException, IOException {
- ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+ 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();
@@ -75,6 +79,8 @@
ModelNode result = client.execute(operation.build());
throwOnFailure(result);
+ } catch(Exception e) {
+ throw new DeployerException(e);
} finally {
StreamUtils.safeClose(client);
}
@@ -94,9 +100,9 @@
return Util.getDeployments(client);
}
- private static void throwOnFailure(ModelNode result) {
+ private static void throwOnFailure(ModelNode result) throws DeployerException {
if (!Util.isSuccess(result)) {
- throw new RuntimeException(Util.getFailureDescription(result));
+ throw new DeployerException(Util.getFailureDescription(result));
}
}
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java 2011-04-14 12:28:48 UTC (rev 30569)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java 2011-04-14 12:34:04 UTC (rev 30570)
@@ -40,7 +40,6 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.jboss.ide.eclipse.as7.deployment.detyped.MinimalisticStandaloneDeployer;
-import org.jboss.ide.eclipse.as7.deployment.internal.StandaloneTypedOperations;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -50,6 +49,8 @@
*/
public class MinimalisticDeployerIntegrationTest {
+ private static final String GWT_HELLOWORLD_WAR = "gwt-helloworld.war";
+ private static final String MINIMALISTIC_WAR = "minimalistic.war";
private static final String WAR_FOLDER = "/wars/";
private static final String BUNDLE_ID = "org.jboss.ide.eclipse.as7.deployment.tests";
@@ -61,7 +62,7 @@
@Test
public void canDeploy() throws Exception {
- File warFile = getWarFile("minimalistic.war");
+ File warFile = getWarFile(MINIMALISTIC_WAR);
try {
MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
@@ -77,7 +78,7 @@
@Test(expected = Exception.class)
public void cannotDeployWarTwice() throws Exception {
- File warFile = getWarFile("minimalistic.war");
+ File warFile = getWarFile(MINIMALISTIC_WAR);
try {
MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
@@ -88,15 +89,14 @@
@Test
public void canQueryDeploymentdeployedState() throws Exception {
- StandaloneTypedOperations deployer = null;
- File warFile = getWarFile("minimalistic.war");
- File warFile2 = getWarFile("gwt-helloworld.war");
+ File warFile = getWarFile(MINIMALISTIC_WAR);
+ File warFile2 = getWarFile(GWT_HELLOWORLD_WAR);
try {
MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
MinimalisticStandaloneDeployer.deploy(warFile2, HOST, MGMT_PORT);
List<String> deployments = MinimalisticStandaloneDeployer.getDeployments(HOST, MGMT_PORT);
assertThat(deployments.size(), is(2));
- assertThat(deployments, hasItems( "minimalistic.war", "gwt-helloworld.war"));
+ assertThat(deployments, hasItems( MINIMALISTIC_WAR, GWT_HELLOWORLD_WAR));
} finally {
quietlyUndeploy(warFile);
}
15 years
JBoss Tools SVN: r30569 - in workspace/adietish: org.jboss.ide.eclipse.as7.deployment.tests/META-INF and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-04-14 08:28:48 -0400 (Thu, 14 Apr 2011)
New Revision: 30569
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/META-INF/MANIFEST.MF
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java
Log:
added deployment queries
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java 2011-04-14 12:03:41 UTC (rev 30568)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java 2011-04-14 12:28:48 UTC (rev 30569)
@@ -25,6 +25,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.net.UnknownHostException;
import java.util.List;
import java.util.concurrent.CancellationException;
@@ -79,27 +80,24 @@
}
}
- private static void throwOnFailure(ModelNode result) {
- if (!Util.isSuccess(result)) {
- throw new RuntimeException(Util.getFailureDescription(result));
- }
- }
-
public static boolean isDeployed(String name, String host, int port) throws CancellationException, IOException {
ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
try {
- ModelNode request = new ModelNode();
- request.get("operation").set("read-children-names");
- request.get("child-type").set("deployment");
-
- ModelNode result = client.execute(request);
- return false;
+ return Util.isDeployed(name, client);
} finally {
StreamUtils.safeClose(client);
}
}
- public static List<String> getDeployments() {
- return null;
+ public static List<String> getDeployments(String host, int port) throws UnknownHostException {
+ ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+ return Util.getDeployments(client);
}
+
+ private static void throwOnFailure(ModelNode result) {
+ if (!Util.isSuccess(result)) {
+ throw new RuntimeException(Util.getFailureDescription(result));
+ }
+ }
+
}
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/META-INF/MANIFEST.MF
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/META-INF/MANIFEST.MF 2011-04-14 12:03:41 UTC (rev 30568)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/META-INF/MANIFEST.MF 2011-04-14 12:28:48 UTC (rev 30569)
@@ -7,6 +7,7 @@
Require-Bundle: org.junit;bundle-version="[4.8.1,5.0.0)",
org.eclipse.core.runtime;bundle-version="3.7.0",
org.jboss.ide.eclipse.as7.deployment,
- org.jboss.ide.eclipse.as7.deployment.detyped
+ org.jboss.ide.eclipse.as7.deployment.detyped,
+ org.hamcrest;bundle-version="1.1.0"
Bundle-ClassPath: .,
wars/
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java 2011-04-14 12:03:41 UTC (rev 30568)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java 2011-04-14 12:28:48 UTC (rev 30569)
@@ -21,6 +21,9 @@
*/
package org.jboss.ide.eclipse.as7.deployment.tests;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.BufferedInputStream;
@@ -32,6 +35,7 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.text.MessageFormat;
+import java.util.List;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
@@ -86,10 +90,13 @@
public void canQueryDeploymentdeployedState() throws Exception {
StandaloneTypedOperations deployer = null;
File warFile = getWarFile("minimalistic.war");
+ File warFile2 = getWarFile("gwt-helloworld.war");
try {
- deployer = new StandaloneTypedOperations(HOST, MGMT_PORT);
- deployer.deploy(warFile).execute();
- deployer.deploy(warFile).execute();
+ MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
+ MinimalisticStandaloneDeployer.deploy(warFile2, HOST, MGMT_PORT);
+ List<String> deployments = MinimalisticStandaloneDeployer.getDeployments(HOST, MGMT_PORT);
+ assertThat(deployments.size(), is(2));
+ assertThat(deployments, hasItems( "minimalistic.war", "gwt-helloworld.war"));
} finally {
quietlyUndeploy(warFile);
}
15 years
JBoss Tools SVN: r30568 - workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-04-14 08:03:41 -0400 (Thu, 14 Apr 2011)
New Revision: 30568
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java
Log:
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java 2011-04-14 12:03:30 UTC (rev 30567)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java 2011-04-14 12:03:41 UTC (rev 30568)
@@ -36,7 +36,6 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.jboss.ide.eclipse.as7.deployment.detyped.MinimalisticStandaloneDeployer;
-import org.jboss.ide.eclipse.as7.deployment.internal.DeployerException;
import org.jboss.ide.eclipse.as7.deployment.internal.StandaloneTypedOperations;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -72,8 +71,19 @@
}
}
- @Test(expected = DeployerException.class)
+ @Test(expected = Exception.class)
public void cannotDeployWarTwice() throws Exception {
+ File warFile = getWarFile("minimalistic.war");
+ try {
+ MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
+ MinimalisticStandaloneDeployer.deploy(warFile, HOST, MGMT_PORT);
+ } finally {
+ quietlyUndeploy(warFile);
+ }
+ }
+
+ @Test
+ public void canQueryDeploymentdeployedState() throws Exception {
StandaloneTypedOperations deployer = null;
File warFile = getWarFile("minimalistic.war");
try {
@@ -113,7 +123,7 @@
private void quietlyUndeploy(File file) {
try {
- MinimalisticStandaloneDeployer.undeploy(file, HOST, MGMT_PORT);
+ MinimalisticStandaloneDeployer.undeploy(file.getName(), HOST, MGMT_PORT);
} catch (Exception e) {
e.printStackTrace();
// ignore
15 years
JBoss Tools SVN: r30567 - in workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped: util and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-04-14 08:03:30 -0400 (Thu, 14 Apr 2011)
New Revision: 30567
Added:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandFormatException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandLineException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestAddress.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestBuilder.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationFormatException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestAddress.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestBuilder.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestParser.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/Util.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/ValidatingOperationCallbackHandler.java
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java
Log:
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java 2011-04-14 00:21:55 UTC (rev 30566)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java 2011-04-14 12:03:30 UTC (rev 30567)
@@ -25,56 +25,81 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.util.List;
import java.util.concurrent.CancellationException;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.controller.client.OperationBuilder;
import org.jboss.as.protocol.StreamUtils;
import org.jboss.dmr.ModelNode;
+import org.jboss.ide.eclipse.as7.deployment.detyped.util.Util;
/**
* @author André Dietisheim
*/
public class MinimalisticStandaloneDeployer {
- public static void undeploy(File file, String host, int port) throws CancellationException, IOException {
+ public static void undeploy(String name, String host, int port) throws CancellationException, IOException {
ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+ try {
+ // undeploy
+ ModelNode request = new ModelNode();
+ request.get("operation").set("undeploy");
+ request.get("address").add("deployment", name);
+ ModelNode result = client.execute(request);
- String name = file.getName();
+ // remove
+ request = new ModelNode();
+ request.get("operation").set("remove");
+ request.get("address").add("deployment", name);
+ result = client.execute(request);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
- // undeploy
- ModelNode request = new ModelNode();
- request.get("operation").set("undeploy");
- request.get("address").add("deployment", name);
- ModelNode result = client.execute(request);
-
- // remove
- request = new ModelNode();
- request.get("operation").set("remove");
- request.get("address").add("deployment", name);
- result = client.execute(request);
-
- StreamUtils.safeClose(client);
- }
-
public static void deploy(File file, String host, int port) throws CancellationException, IOException {
ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+ try {
+ String name = file.getName();
- 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());
- ModelNode request = new ModelNode();
- request.get("operation").set("add");
- request.get("address").add("deployment", name);
- request.get("enabled").set(true);
+ throwOnFailure(result);
+ } finally {
+ StreamUtils.safeClose(client);
+ }
+ }
- OperationBuilder op = OperationBuilder.Factory.create(request);
- op.addInputStream(new BufferedInputStream(new FileInputStream(file)));
- request.get("input-stream-index").set(0);
-
- ModelNode result = client.execute(op.build());
+ private static void throwOnFailure(ModelNode result) {
+ if (!Util.isSuccess(result)) {
+ throw new RuntimeException(Util.getFailureDescription(result));
+ }
+ }
- StreamUtils.safeClose(client);
+ public static boolean isDeployed(String name, String host, int port) throws CancellationException, IOException {
+ ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+ try {
+ ModelNode request = new ModelNode();
+ request.get("operation").set("read-children-names");
+ request.get("child-type").set("deployment");
+
+ ModelNode result = client.execute(request);
+ return false;
+ } finally {
+ StreamUtils.safeClose(client);
+ }
}
+ public static List<String> getDeployments() {
+ return null;
+ }
}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandFormatException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandFormatException.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandFormatException.java 2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.ide.eclipse.as7.deployment.detyped.util;
+
+/**
+ * @author Alexey Loubyansky
+ *
+ */
+public class CommandFormatException extends CommandLineException {
+
+ private static final long serialVersionUID = -5802389813870206943L;
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public CommandFormatException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * @param message
+ */
+ public CommandFormatException(String message) {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public CommandFormatException(Throwable cause) {
+ super(cause);
+ }
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandFormatException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandLineException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandLineException.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandLineException.java 2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.ide.eclipse.as7.deployment.detyped.util;
+
+/**
+ * @author Alexey Loubyansky
+ *
+ */
+public class CommandLineException extends Exception {
+
+ private static final long serialVersionUID = 423938082439473323L;
+
+ public CommandLineException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public CommandLineException(String message) {
+ super(message);
+ }
+
+ public CommandLineException(Throwable cause) {
+ super(cause);
+ }
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandLineException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestAddress.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestAddress.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestAddress.java 2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,258 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.ide.eclipse.as7.deployment.detyped.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * This implementation is not thread-safe.
+ *
+ * @author Alexey Loubyansky
+ */
+public class DefaultOperationRequestAddress implements OperationRequestAddress {
+
+ private final List<NodeImpl> nodes = new ArrayList<NodeImpl>();
+
+ public DefaultOperationRequestAddress() {
+ }
+
+ /**
+ * Creates a prefix and initializes it to the value of the argument.
+ * @param initial the initial value
+ */
+ public DefaultOperationRequestAddress(OperationRequestAddress initial) {
+ if(!initial.isEmpty()) {
+ for(Node node : initial) {
+ toNode(node.getType(), node.getName());
+ }
+ }
+ }
+
+ @Override
+ public void toNodeType(String nodeType) {
+
+ nodes.add(new NodeImpl(nodeType, null));
+ }
+
+ @Override
+ public void toNode(String nodeName) {
+
+ if(nodes.isEmpty())
+ throw new IllegalStateException("The prefix should end with the node type before going to a specific node name.");
+
+ nodes.get(nodes.size() - 1).name = nodeName;
+ }
+
+ @Override
+ public void toNode(String nodeType, String nodeName) {
+
+ if(endsOnType()) {
+ throw new IllegalStateException("The prefix ends on a type. A node name must be specified before this method can be invoked.");
+ }
+ nodes.add(new NodeImpl(nodeType, nodeName));
+ }
+
+ @Override
+ public String toNodeType() {
+
+ if(nodes.isEmpty()) {
+ return null;
+ }
+ String name = nodes.get(nodes.size() - 1).name;
+ nodes.get(nodes.size() - 1).name = null;
+ return name;
+ }
+
+ @Override
+ public Node toParentNode() {
+
+ if(nodes.isEmpty()) {
+ return null;
+ }
+ return nodes.remove(nodes.size() - 1);
+ }
+
+ @Override
+ public void reset() {
+ nodes.clear();
+ }
+
+ @Override
+ public boolean endsOnType() {
+ if(nodes.isEmpty()) {
+ return false;
+ }
+
+ NodeImpl node = nodes.get(nodes.size() - 1);
+ return node.name == null;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return nodes.isEmpty();
+ }
+
+ @Override
+ public Iterator<Node> iterator() {
+
+ final Node[] array = nodes.toArray(new Node[nodes.size()]);
+ return new Iterator<Node>() {
+
+ int i = 0;
+
+ @Override
+ public boolean hasNext() {
+ return i < array.length;
+ }
+
+ @Override
+ public Node next() {
+ return array[i++];
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ };
+ }
+
+ @Override
+ public String getNodeType() {
+
+ if(nodes.isEmpty()) {
+ return null;
+ }
+ return nodes.get(nodes.size() - 1).type;
+ }
+
+ @Override
+ public String getNodeName() {
+
+ if(nodes.isEmpty()) {
+ return null;
+ }
+ return nodes.get(nodes.size() - 1).name;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((nodes == null) ? 0 : nodes.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof OperationRequestAddress))
+ return false;
+
+ OperationRequestAddress other = (OperationRequestAddress) obj;
+
+ if(isEmpty() != other.isEmpty())
+ return false;
+
+ Iterator<Node> thisIterator = iterator();
+ Iterator<Node> otherIterator = other.iterator();
+ boolean result = true;
+ while(result) {
+ if(!thisIterator.next().equals(otherIterator.next())) {
+ result = false;
+ } else {
+ if (!thisIterator.hasNext()) {
+ if (otherIterator.hasNext()) {
+ result = false;
+ }
+ break;
+ }
+ if (!otherIterator.hasNext()) {
+ if (thisIterator.hasNext()) {
+ result = false;
+ }
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ private static final class NodeImpl implements Node {
+
+ String type;
+ String name;
+
+ NodeImpl(String type, String name) {
+ this.type = type;
+ this.name = name;
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+
+ if(!(obj instanceof Node))
+ return false;
+
+ Node other = (Node) obj;
+ if (name == null) {
+ if (other.getName() != null)
+ return false;
+ } else if (!name.equals(other.getName()))
+ return false;
+ if (type == null) {
+ if (other.getType() != null)
+ return false;
+ } else if (!type.equals(other.getType()))
+ return false;
+ return true;
+ }
+ }
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestAddress.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestBuilder.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestBuilder.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestBuilder.java 2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,235 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.ide.eclipse.as7.deployment.detyped.util;
+
+import java.util.Iterator;
+
+import org.jboss.dmr.ModelNode;
+import org.jboss.ide.eclipse.as7.deployment.detyped.util.OperationRequestAddress.Node;
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public class DefaultOperationRequestBuilder extends ValidatingOperationCallbackHandler implements OperationRequestBuilder {
+
+ private ModelNode request = new ModelNode();
+ private OperationRequestAddress prefix;
+
+ public DefaultOperationRequestBuilder() {
+ this.prefix = new DefaultOperationRequestAddress();
+ }
+
+ public DefaultOperationRequestBuilder(OperationRequestAddress prefix) {
+ if(prefix == null) {
+ throw new IllegalArgumentException("Prefix can't be null");
+ }
+ this.prefix = new DefaultOperationRequestAddress(prefix);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#rootNode()
+ */
+ @Override
+ public void rootNode() {
+ prefix.reset();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#parentNode()
+ */
+ @Override
+ public void parentNode() {
+ prefix.toParentNode();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeType()
+ */
+ @Override
+ public void nodeType() {
+ prefix.toNodeType();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeTypeNameSeparator(int)
+ */
+ @Override
+ public void nodeTypeNameSeparator(int index) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeSeparator(int)
+ */
+ @Override
+ public void nodeSeparator(int index) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#addressOperationSeparator(int)
+ */
+ @Override
+ public void addressOperationSeparator(int index) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#operationName(java.lang.String)
+ */
+ @Override
+ public void validatedOperationName(String operationName) {
+ this.setOperationName(operationName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertyListStart(int)
+ */
+ @Override
+ public void propertyListStart(int index) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertyNameValueSeparator(int)
+ */
+ @Override
+ public void propertyNameValueSeparator(int index) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertySeparator(int)
+ */
+ @Override
+ public void propertySeparator(int index) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertyListEnd(int)
+ */
+ @Override
+ public void propertyListEnd(int index) {
+ }
+
+ @Override
+ protected void validatedNodeType(String nodeType)
+ throws OperationFormatException {
+ this.addNodeType(nodeType);
+ }
+
+ @Override
+ protected void validatedNodeName(String nodeName)
+ throws OperationFormatException {
+ this.addNodeName(nodeName);
+ }
+
+ @Override
+ protected void validatedPropertyName(String propertyName)
+ throws OperationFormatException {
+ throw new OperationFormatException("Property '" + propertyName + "' is missing the value.");
+ }
+
+ @Override
+ protected void validatedProperty(String name, String value,
+ int nameValueSeparatorIndex) throws OperationFormatException {
+ this.addProperty(name, value);
+ }
+
+ @Override
+ public void nodeTypeOrName(String typeOrName)
+ throws OperationFormatException {
+
+ if(prefix.endsOnType()) {
+ this.addNodeName(typeOrName);
+ } else {
+ this.addNodeType(typeOrName);
+ }
+ }
+
+ /**
+ * Makes sure that the operation name and the address have been set and returns a ModelNode
+ * representing the operation request.
+ */
+ public ModelNode buildRequest() throws OperationFormatException {
+
+ ModelNode address = request.get("address");
+ if(prefix.isEmpty()) {
+ address.setEmptyList();
+ } else {
+ Iterator<Node> iterator = prefix.iterator();
+ while (iterator.hasNext()) {
+ OperationRequestAddress.Node node = iterator.next();
+ if (node.getName() != null) {
+ address.add(node.getType(), node.getName());
+ } else if (iterator.hasNext()) {
+ throw new OperationFormatException(
+ "The node name is not specified for type '"
+ + node.getType() + "'");
+ }
+ }
+ }
+
+ if(!request.hasDefined("operation")) {
+ throw new OperationFormatException("The operation name is missing or the format of the operation request is wrong.");
+ }
+
+ return request;
+ }
+
+ @Override
+ public void setOperationName(String name) {
+ request.get("operation").set(name);
+ }
+
+ @Override
+ public void addNode(String type, String name) {
+ prefix.toNode(type, name);
+ }
+
+ @Override
+ public void addNodeType(String type) {
+ prefix.toNodeType(type);
+ }
+
+ @Override
+ public void addNodeName(String name) {
+ prefix.toNode(name);
+ }
+
+ @Override
+ public void addProperty(String name, String value) {
+
+ if(name == null || name.trim().isEmpty())
+ throw new IllegalArgumentException("The argument name is not specified: '" + name + "'");
+ if(value == null || value.trim().isEmpty())
+ throw new IllegalArgumentException("The argument value is not specified: '" + value + "'");
+ ModelNode toSet = null;
+ try {
+ toSet = ModelNode.fromString(value);
+ } catch (Exception e) {
+ // just use the string
+ toSet = new ModelNode().set(value);
+ }
+ request.get(name).set(toSet);
+ }
+
+ public ModelNode getModelNode() {
+ return request;
+ }
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestBuilder.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationFormatException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationFormatException.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationFormatException.java 2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.ide.eclipse.as7.deployment.detyped.util;
+
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public class OperationFormatException extends CommandFormatException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3481664048439674648L;
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public OperationFormatException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param message
+ */
+ public OperationFormatException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * @param cause
+ */
+ public OperationFormatException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationFormatException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestAddress.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestAddress.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestAddress.java 2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.ide.eclipse.as7.deployment.detyped.util;
+
+
+
+/**
+ * An instance of this interface represents a prefix for the operation request address part.
+ *
+ * @author Alexey Loubyansky
+ */
+public interface OperationRequestAddress extends Iterable<OperationRequestAddress.Node> {
+
+ /**
+ * Appends the node type to the prefix.
+ * Note, the current prefix must end on the node name before this method
+ * is invoked.
+ *
+ * @param nodeType the node type to append to the prefix.
+ */
+ void toNodeType(String nodeType);
+
+ /**
+ * Appends the node name to the prefix.
+ * Note, the current prefix must end on the node type before this method
+ * is invoked.
+ *
+ * @param nodeName the node name to append to the prefix.
+ */
+ void toNode(String nodeName);
+
+ /**
+ * Appends the node to the prefix.
+ * Note, the current prefix must end on the node (i.e. node name) before
+ * this method is invoked.
+ *
+ * @param nodeType the node type of the node to append to the prefix
+ * @param nodeName the node name of the node to append to the prefix
+ */
+ void toNode(String nodeType, String nodeName);
+
+ /**
+ * Sets the current prefix to the node type of the current node,
+ * i.e. the node name is removed from the end of the prefix.
+ * @return the node name the prefix ended on
+ */
+ String toNodeType();
+
+ /**
+ * Removes the last node in the prefix, i.e. moves the value a node up.
+ * @return the node the prefix ended on
+ */
+ Node toParentNode();
+
+ /**
+ * Resets the prefix, i.e. this will make the prefix empty.
+ */
+ void reset();
+
+ /**
+ * Checks whether the prefix ends on a node type or a node name.
+ * @return true if the prefix ends on a node type, otherwise false.
+ */
+ boolean endsOnType();
+
+ /**
+ * Checks whether the prefix is empty.
+ * @return true if the prefix is empty, otherwise false.
+ */
+ boolean isEmpty();
+
+ /**
+ * Returns the node type of the last node.
+ * @return the node type of the last node or null if the prefix is empty.
+ */
+ String getNodeType();
+
+ /**
+ * Returns the node name of the last node.
+ * @return the node name of the last node or null if the prefix ends
+ * on a type or is empty.
+ */
+ String getNodeName();
+
+ interface Node {
+
+ String getType();
+
+ String getName();
+ }
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestAddress.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestBuilder.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestBuilder.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestBuilder.java 2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.ide.eclipse.as7.deployment.detyped.util;
+
+import org.jboss.dmr.ModelNode;
+
+/**
+ * TODO this is not used for now...
+ *
+ * @author Alexey Loubyansky
+ */
+public interface OperationRequestBuilder {
+
+ /**
+ * Sets the name operation to be invoked.
+ *
+ * @param name the name of the operation to invoke.
+ */
+ void setOperationName(String name);
+
+ /**
+ * The address is specified as a path to the target node. Each element of the path is a node
+ * and is identified by its type and name.
+ *
+ * @param type the type of the node
+ * @param name the name of the node
+ */
+ void addNode(String type, String name);
+
+ /**
+ * This method is supposed to be invoked from applying the prefix with ends on a node type.
+ * @param type the type of the node.
+ */
+ void addNodeType(String type);
+
+ /**
+ * This method assumes there is a non-empty prefix which ends on a node type.
+ * Otherwise, this method will result in an exception.
+ * @param name the name of the node for the type specified by the prefix.
+ */
+ void addNodeName(String name);
+
+ /**
+ * Adds an argument.
+ *
+ * @param name the name of the argument
+ * @param value the value of the argument
+ */
+ void addProperty(String name, String value);
+
+ /**
+ * Builds the operation request based on the collected operation name, address and arguments.
+ *
+ * @return an instance of ModelNode representing the operation request
+ * @throws OperationFormatException
+ */
+ ModelNode buildRequest() throws OperationFormatException;
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestBuilder.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestParser.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestParser.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestParser.java 2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.ide.eclipse.as7.deployment.detyped.util;
+
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public interface OperationRequestParser {
+
+ interface CallbackHandler {
+
+ void start(String operationString);
+
+ void rootNode();
+
+ void parentNode();
+
+ void nodeType();
+
+ void nodeType(String nodeType) throws OperationFormatException;
+
+ void nodeTypeNameSeparator(int index);
+
+ void nodeName(String nodeName) throws OperationFormatException;
+
+ void nodeSeparator(int index);
+
+ void addressOperationSeparator(int index);
+
+ void operationName(String operationName) throws OperationFormatException;
+
+ void propertyListStart(int index);
+
+ void propertyName(String propertyName) throws OperationFormatException;
+
+ void propertyNameValueSeparator(int index);
+
+ void property(String name, String value, int nameValueSeparatorIndex) throws OperationFormatException;
+
+ void propertySeparator(int index);
+
+ void propertyListEnd(int index);
+
+ // TODO this is not good
+ void nodeTypeOrName(String typeOrName) throws OperationFormatException;
+ }
+
+ void parse(String operationRequest, CallbackHandler handler) throws OperationFormatException;
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestParser.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/Util.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/Util.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/Util.java 2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,164 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.ide.eclipse.as7.deployment.detyped.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.Property;
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public class Util {
+
+ public static boolean isSuccess(ModelNode operationResult) {
+ if(operationResult != null) {
+ ModelNode outcome = operationResult.get("outcome");
+ return outcome != null && outcome.asString().equals("success");
+ }
+ return false;
+ }
+
+ public static String getFailureDescription(ModelNode operationResult) {
+ if(operationResult == null) {
+ return null;
+ }
+
+ ModelNode descr = operationResult.get("failure-description");
+ if(descr == null) {
+ return null;
+ }
+
+ return descr.asString();
+ }
+
+ public static List<String> getList(ModelNode operationResult) {
+ if(!operationResult.hasDefined("result"))
+ return Collections.emptyList();
+
+ List<ModelNode> nodeList = operationResult.get("result").asList();
+ if(nodeList.isEmpty())
+ return Collections.emptyList();
+
+ List<String> list = new ArrayList<String>(nodeList.size());
+ for(ModelNode node : nodeList) {
+ list.add(node.asString());
+ }
+ return list;
+ }
+
+ public static byte[] getHash(ModelNode operationResult) {
+ if(!operationResult.hasDefined("result"))
+ return null;
+ return operationResult.get("result").asBytes();
+ }
+
+ public static List<String> getRequestPropertyNames(ModelNode operationResult) {
+ if(!operationResult.hasDefined("result"))
+ return Collections.emptyList();
+
+ ModelNode result = operationResult.get("result");
+ if(!result.hasDefined("request-properties"))
+ return Collections.emptyList();
+
+ List<Property> nodeList = result.get("request-properties").asPropertyList();
+ if(nodeList.isEmpty())
+ return Collections.emptyList();
+
+ List<String> list = new ArrayList<String>(nodeList.size());
+ for(Property node : nodeList) {
+ list.add(node.getName());
+ }
+ return list;
+ }
+
+ public static boolean isDeployed(String name, ModelControllerClient client) {
+ return getDeployments(client).contains(name);
+ }
+
+ public static List<String> getDeployments(ModelControllerClient client) {
+
+ DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
+ final ModelNode request;
+ try {
+ builder.operationName("read-children-names");
+ builder.addProperty("child-type", "deployment");
+ request = builder.buildRequest();
+ } catch (OperationFormatException e) {
+ throw new IllegalStateException("Failed to build operation", e);
+ }
+
+ try {
+ ModelNode outcome = client.execute(request);
+ if (isSuccess(outcome)) {
+ return getList(outcome);
+ }
+ } catch (Exception e) {
+ }
+
+ return Collections.emptyList();
+ }
+
+ public static List<String> getJmsResources(ModelControllerClient client, String type) {
+
+ DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
+ final ModelNode request;
+ try {
+ builder.addNode("subsystem", "jms");
+ builder.operationName("read-children-names");
+ builder.addProperty("child-type", type);
+ request = builder.buildRequest();
+ } catch (OperationFormatException e) {
+ throw new IllegalStateException("Failed to build operation", e);
+ }
+
+ try {
+ ModelNode outcome = client.execute(request);
+ if (isSuccess(outcome)) {
+ return getList(outcome);
+ }
+ } catch (Exception e) {
+ }
+
+ return Collections.emptyList();
+ }
+
+ public static boolean isTopic(ModelControllerClient client, String name) {
+ List<String> topics = getJmsResources(client, "topic");
+ return topics.contains(name);
+ }
+
+ public static boolean isQueue(ModelControllerClient client, String name) {
+ List<String> queues = getJmsResources(client, "queue");
+ return queues.contains(name);
+ }
+
+ public static boolean isConnectionFactory(ModelControllerClient client, String name) {
+ List<String> cf = getJmsResources(client, "connection-factory");
+ return cf.contains(name);
+ }
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/Util.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/ValidatingOperationCallbackHandler.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/ValidatingOperationCallbackHandler.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/ValidatingOperationCallbackHandler.java 2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.ide.eclipse.as7.deployment.detyped.util;
+
+import java.util.regex.Pattern;
+
+import org.jboss.ide.eclipse.as7.deployment.detyped.util.OperationRequestParser.CallbackHandler;
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public abstract class ValidatingOperationCallbackHandler implements CallbackHandler {
+
+ private static final Pattern ALPHANUMERICS_PATTERN = Pattern.compile("[_a-zA-Z](?:[-_a-zA-Z0-9]*[_a-zA-Z0-9])?");
+ private static final Pattern NODE_NAME_PATTERN = Pattern.compile("\\*|[^*\\p{Space}\\p{Cntrl}]+");
+
+
+ protected String operationStr;
+
+ @Override
+ public void start(String operationString) {
+ this.operationStr = operationString;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeType(java.lang.String)
+ */
+ @Override
+ public void nodeType(String nodeType) throws OperationFormatException {
+
+ assertValidType(nodeType);
+ validatedNodeType(nodeType);
+ }
+
+ protected abstract void validatedNodeType(String nodeType) throws OperationFormatException;
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeName(java.lang.String)
+ */
+ @Override
+ public void nodeName(String nodeName) throws OperationFormatException {
+
+ assertValidNodeName(nodeName);
+ validatedNodeName(nodeName);
+ }
+
+ protected abstract void validatedNodeName(String nodeName) throws OperationFormatException;
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#operationName(java.lang.String)
+ */
+ @Override
+ public void operationName(String operationName)
+ throws OperationFormatException {
+
+ if (operationName == null || !ALPHANUMERICS_PATTERN.matcher(operationName).matches()) {
+ throw new OperationFormatException("'" + operationName + "' is not a valid operation name.");
+ }
+
+ validatedOperationName(operationName);
+ }
+
+ protected abstract void validatedOperationName(String operationName) throws OperationFormatException;
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertyName(java.lang.String)
+ */
+ @Override
+ public void propertyName(String propertyName)
+ throws OperationFormatException {
+
+ assertValidParameterName(propertyName);
+ validatedPropertyName(propertyName);
+ }
+
+ protected abstract void validatedPropertyName(String propertyName) throws OperationFormatException;
+
+ /* (non-Javadoc)
+ * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#property(java.lang.String, java.lang.String, int)
+ */
+ @Override
+ public void property(String name, String value, int nameValueSeparatorIndex)
+ throws OperationFormatException {
+
+ assertValidParameterName(name);
+
+ if (value.isEmpty()) {
+ throw new OperationFormatException("Parameter '" + value + "' is missing value.");
+ }
+
+ validatedProperty(name, value, nameValueSeparatorIndex);
+ }
+
+ protected abstract void validatedProperty(String name, String value, int nameValueSeparatorIndex) throws OperationFormatException;
+
+ protected void assertValidType(String nodeType)
+ throws OperationFormatException {
+ if (nodeType == null || !ALPHANUMERICS_PATTERN.matcher(nodeType).matches()) {
+ throw new OperationFormatException("'" + nodeType + "' is not a valid node type name.");
+ }
+ }
+
+ protected void assertValidNodeName(String nodeName)
+ throws OperationFormatException {
+ if (nodeName == null || !NODE_NAME_PATTERN.matcher(nodeName).matches()) {
+ throw new OperationFormatException("'" + nodeName + "' is not a valid node name.");
+ }
+ }
+
+ protected void assertValidParameterName(String name)
+ throws OperationFormatException {
+ if (name == null || !ALPHANUMERICS_PATTERN.matcher(name).matches()) {
+ throw new OperationFormatException("'" + name + "' is not a valid parameter name.");
+ }
+ }
+
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/ValidatingOperationCallbackHandler.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
15 years
JBoss Tools SVN: r30566 - branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2011-04-13 20:21:55 -0400 (Wed, 13 Apr 2011)
New Revision: 30566
Modified:
branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
Log:
https://issues.jboss.org/browse/JBIDE-8727
Modified: branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
===================================================================
--- branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2011-04-13 21:42:11 UTC (rev 30565)
+++ branches/jbosstools-3.2.x/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2011-04-14 00:21:55 UTC (rev 30566)
@@ -44,7 +44,9 @@
ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_MF=Stereotype {0} is defined as @Target(TYPE) and may not be applied to stereotype {1} which is defined as @Target('{METHOD, FIELD}') [JSR-299 �2.7.1.5]
ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE=Interceptor binding type {0} is defined as @Target(TYPE) and may not be applied to interceptor binding type {1} which is defined as @Target('{TYPE, METHOD}') [JSR-299 �9.1.1]
ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE_FOR_STEREOTYPE=Stereotype {0} must be defined as @Target(TYPE) since it declares interceptor bindings ({1}) [JSR-299 �9.1.2]
+NOT_PASSIVATION_CAPABLE_BEAN=Managed bean {0} which declares a passivating scope {1} must be passivation capable [JSR-299 �6.6.4]
+
MULTIPLE_SCOPE_TYPE_ANNOTATIONS=Bean class or producer method or field specifies multiple scope type annotations [JSR-299 �2.4.3]
MULTIPLE_SCOPE_TYPE_ANNOTATIONS_IN_BEAN_CLASS=Bean class specifies multiple scope type annotations [JSR-299 �2.4.3]
MULTIPLE_SCOPE_TYPE_ANNOTATIONS_IN_PRODUCER_METHOD=Producer method specifies multiple scope type annotations [JSR-299 �2.4.3]
15 years
JBoss Tools SVN: r30565 - trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-04-13 17:42:11 -0400 (Wed, 13 Apr 2011)
New Revision: 30565
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/FileSet.java
Log:
JBIDE-8722
https://issues.jboss.org/browse/JBIDE-8722
temporal workaround
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/FileSet.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/FileSet.java 2011-04-13 21:31:08 UTC (rev 30564)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/FileSet.java 2011-04-13 21:42:11 UTC (rev 30565)
@@ -10,6 +10,7 @@
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IPackageDeclaration;
import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.common.model.XModelObject;
public class FileSet {
@@ -36,6 +37,13 @@
public void add(IPath path, IType type) throws CoreException {
if(type == null) return;
allpaths.add(path);
+ //https://bugs.eclipse.org/bugs/show_bug.cgi?id=342757
+ try {
+ type.isAnnotation();
+ } catch (ArrayIndexOutOfBoundsException e) {
+ CDICorePlugin.getDefault().logError("JDT failed to load " + type.getFullyQualifiedName() + " from " + path + "\nSee https://bugs.eclipse.org/bugs/show_bug.cgi?id=342757");
+ return;
+ }
if(type.isAnnotation()) {
add(annotations, path, type);
} else if(type.isInterface()) {
15 years
JBoss Tools SVN: r30564 - in workspace/adietish: org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2011-04-13 17:31:08 -0400 (Wed, 13 Apr 2011)
New Revision: 30564
Added:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossDeploymentManager.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossManagementInterface.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossManagementService.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Deployable.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeployerException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/StandaloneTypedOperations.java
Removed:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Deployable.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeployerException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneTypedOperations.java
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/META-INF/MANIFEST.MF
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneOperationsIntegrationTest.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/MANIFEST.MF
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Activator.java
Log:
fiddling with api creation in workspace
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-13 17:48:20 UTC (rev 30563)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/META-INF/MANIFEST.MF 2011-04-13 21:31:08 UTC (rev 30564)
@@ -24,6 +24,7 @@
org.jboss.as.protocol.mgmt,
org.jboss.dmr,
org.jboss.ide.eclipse.as7.deployment,
+ org.jboss.ide.eclipse.as7.deployment.internal,
org.jboss.logging,
org.jboss.marshalling,
org.jboss.marshalling.cloner,
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Activator.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Activator.java 2011-04-13 17:48:20 UTC (rev 30563)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Activator.java 2011-04-13 21:31:08 UTC (rev 30564)
@@ -7,7 +7,7 @@
private static BundleContext context;
- static BundleContext getContext() {
+ public static BundleContext getContext() {
return context;
}
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Deployable.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Deployable.java 2011-04-13 17:48:20 UTC (rev 30563)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Deployable.java 2011-04-13 21:31:08 UTC (rev 30564)
@@ -1,94 +0,0 @@
-package org.jboss.ide.eclipse.as7.deployment;
-
-import java.io.File;
-import java.text.MessageFormat;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.jboss.as.controller.client.helpers.standalone.DeploymentAction;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentActionResult;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentPlanResult;
-
-public class Deployable {
-
- private String name;
- private File file;
- private Future<ServerDeploymentPlanResult> resultFuture;
- private long timeout;
- private DeploymentAction action;
-
- protected Deployable(String name, File file, long timeout) {
- this.name = name;
- this.file = file;
- this.timeout = timeout;
- }
-
- protected void setDeploymentAction(DeploymentAction action) {
- this.action = action;
- }
-
- protected void setResultFuture(Future<ServerDeploymentPlanResult> resultFuture) {
- this.resultFuture = resultFuture;
- }
-
- public File getFile() {
- return file;
- }
-
- public String getName() {
- return name;
- }
-
- public IStatus getStatus() throws DeployerException {
- if (resultFuture == null
- || action == null) {
- return null;
- }
- try {
- ServerDeploymentPlanResult result = resultFuture.get(timeout, TimeUnit.MILLISECONDS);
- ServerDeploymentActionResult actionResult = result.getDeploymentActionResult(action.getId());
- return createStatus(action, actionResult);
- } catch (Exception e) {
- throw new DeployerException(e);
- }
- }
-
- private IStatus createStatus(DeploymentAction action, ServerDeploymentActionResult actionResult) {
- if (actionResult == null) {
- return null;
- }
-
- IStatus status = null;
- switch (actionResult.getResult()) {
- case NOT_EXECUTED:
- status = createStatus(IStatus.ERROR, "The operation {0} was not executed on unit {1}", action
- .getType().name(), getName());
- break;
- case EXECUTED:
- status = Status.OK_STATUS;
- break;
- case FAILED:
- status = createStatus(IStatus.ERROR, "The operation {0} failed for unit {1}", action.getType()
- .name(), getName());
- break;
- case ROLLED_BACK:
- status = createStatus(IStatus.ERROR, "The operation {0} for unit {1} was rolled back", action
- .getType().name(), getName());
- break;
- case CONFIGURATION_MODIFIED_REQUIRES_RESTART:
- status = createStatus(
- IStatus.WARNING,
- "The operation {0} was not executed on unit {1}. The server configuration was changed though and the server needs to be restarted",
- action.getType().name(), getName());
- break;
- }
- return status;
- }
-
- private IStatus createStatus(int severity, String messagePattern, Object... messageArguments) {
- return new Status(severity, Activator.getContext().getBundle().getSymbolicName(), MessageFormat.format(
- messagePattern, messageArguments));
- }
-}
\ No newline at end of file
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeployerException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeployerException.java 2011-04-13 17:48:20 UTC (rev 30563)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeployerException.java 2011-04-13 21:31:08 UTC (rev 30564)
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.ide.eclipse.as7.deployment;
-
-/**
- * @author André Dietisheim
- */
-public class DeployerException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public DeployerException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public DeployerException(Throwable cause) {
- super(cause);
- }
-
- public DeployerException(String message) {
- super(message);
- }
-
-}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossDeploymentManager.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossDeploymentManager.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossDeploymentManager.java 2011-04-13 21:31:08 UTC (rev 30564)
@@ -0,0 +1,75 @@
+package org.jboss.ide.eclipse.as7.deployment;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ *
+ * This class is interim API and may change drastically
+ * as development on the application server continues.
+ * I expect credentials to be required eventually,
+ * and the API will need to adjust to handle them.
+ *
+ */
+public interface IJBossDeploymentManager {
+ /**
+ * Asynchronously deploy a file to a server
+ *
+ * @param host The host
+ * @param port The port
+ * @param name The deployment's name
+ * @param file The file to be deployed
+ * @param monitor The progress monitor
+ *
+ * @return Not sure what to return yet
+ */
+ public Object asyncDeploy(String host, int port,
+ String deploymentName, File file, IProgressMonitor monitor);
+
+ /**
+ * Synchronously deploy a file to a server
+ *
+ * @param host The host
+ * @param port The port
+ * @param name The deployment's name
+ * @param file The file to be deployed
+ * @param monitor The progress monitor
+ *
+ * @return Not sure what to return yet
+ */
+ public Object syncDeploy(String host, int port,
+ String deploymentName, File file, IProgressMonitor monitor);
+
+
+ /**
+ * Asynchronously undeploy a file to a server
+ *
+ * @param host The host
+ * @param port The port
+ * @param name The deployment's name
+ * @param file The file to be deployed
+ * @param monitor The progress monitor
+ *
+ * @return Not sure what to return yet
+ */
+ public Object asyncUndeploy(String host, int port,
+ String deploymentName, boolean removeFile, IProgressMonitor monitor);
+
+
+ /**
+ * Synchronously undeploy a file to a server
+ *
+ * @param host The host
+ * @param port The port
+ * @param name The deployment's name
+ * @param file The file to be deployed
+ * @param monitor The progress monitor
+ *
+ * @return Not sure what to return yet
+ */
+ public Object syncUndeploy(String host, int port,
+ String deploymentName, boolean removeFile, IProgressMonitor monitor);
+
+
+}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossManagementInterface.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossManagementInterface.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossManagementInterface.java 2011-04-13 21:31:08 UTC (rev 30564)
@@ -0,0 +1,9 @@
+package org.jboss.ide.eclipse.as7.deployment;
+
+public interface IJBossManagementInterface {
+ /**
+ * Need a method to build a request...
+ * we can't just expose the entire ModelNode api, but,
+ * we need a good way for them to be able to build such nodes
+ */
+}
Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossManagementService.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossManagementService.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/IJBossManagementService.java 2011-04-13 21:31:08 UTC (rev 30564)
@@ -0,0 +1,22 @@
+package org.jboss.ide.eclipse.as7.deployment;
+
+/**
+ * This class may belong in the main JBoss AS core plugin,
+ * in case several different plugins need to implement it
+ */
+public interface IJBossManagementService {
+ /**
+ * Get a manager which can be responsible *only* for
+ * deployments, both synchronously and asynchronously.
+ * @return
+ */
+ public IJBossDeploymentManager getDeploymentManager();
+
+ /**
+ * Get an interface which can handle executing any and all remote
+ * management tasks via wrappers of more raw APIs.
+ *
+ * @return
+ */
+ public IJBossManagementInterface getManagementInterface();
+}
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneTypedOperations.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneTypedOperations.java 2011-04-13 17:48:20 UTC (rev 30563)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneTypedOperations.java 2011-04-13 21:31:08 UTC (rev 30564)
@@ -1,170 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.ide.eclipse.as7.deployment;
-
-import static org.jboss.as.protocol.StreamUtils.safeClose;
-
-import java.io.File;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import org.jboss.as.controller.client.ModelControllerClient;
-import org.jboss.as.controller.client.helpers.standalone.DeploymentPlanBuilder;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
-
-/**
- * Used to deploy/undeploy deployments to a running <b>standalone</b>
- * application server
- *
- * @author <a href="kabir.khan(a)jboss.com">Kabir Khan</a>
- * @author <a href="adietish(a)redhat.com">André Dietisheim</a>
- */
-public class StandaloneTypedOperations {
-
- public static final long DEFAULT_TIMEOUT = 15000;
-
- private final List<IDeploymentPlanBuilderOperation> deployments = new ArrayList<IDeploymentPlanBuilderOperation>();
- private final ModelControllerClient client;
- private final ServerDeploymentManager manager;
- private long timeout = DEFAULT_TIMEOUT;
-
- public StandaloneTypedOperations(String host, int port) throws UnknownHostException {
- client = ModelControllerClient.Factory.create(host, port);
- manager = ServerDeploymentManager.Factory.create(client);
- }
-
- public synchronized StandaloneTypedOperations deploy(File file) {
- deployments.add(new DeployOperation(file));
- return this;
- }
-
- public synchronized StandaloneTypedOperations deploy(String name, File file) {
- deployments.add(new DeployOperation(name, file));
- return this;
- }
-
- public synchronized StandaloneTypedOperations undeploy(String name) {
- deployments.add(new UndeployOperation(name));
- return this;
- }
-
- public synchronized StandaloneTypedOperations undeploy(File file) {
- deployments.add(new UndeployOperation(file));
- return this;
- }
-
- public synchronized void execute() throws DeployerException {
- try {
- DeploymentPlanBuilder builder = manager.newDeploymentPlan();
- for (IDeploymentPlanBuilderOperation deployment : deployments) {
- builder = deployment.addTo(builder);
- }
- manager.execute(builder.build()).get(timeout, TimeUnit.MILLISECONDS);
- } catch (Exception e) {
- throw new DeployerException(e);
- }
- }
-
- public void setTimeout(long timeout) {
- this.timeout = timeout;
- }
-
- public void dispose() {
- safeClose(client);
- }
-
- private static class DeployOperation extends FileOperation {
-
- private DeployOperation(File file) {
- super(file);
- }
-
- private DeployOperation(String name, File file) {
- super(name, file);
- }
-
- public synchronized DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception {
- String name = getName();
- return builder.add(name, getFile()).deploy(name);
- }
- }
-
- private static class UndeployOperation extends FileOperation {
-
- private UndeployOperation(File file) {
- super(file);
- }
-
- private UndeployOperation(String name) {
- super(name, null);
- }
-
- public synchronized DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception {
- String name = getName();
- return builder.undeploy(name).undeploy(name);
- }
- }
-
- private abstract static class FileOperation extends NamedOperation {
-
- private File file;
-
- private FileOperation(File file) {
- this(null, file);
- }
-
- private FileOperation(String name, File file) {
- super(name);
- this.file = file;
- }
-
- protected File getFile() {
- return file;
- }
-
- protected String getName() {
- if (name != null) {
- return name;
- } else {
- return file.getName();
- }
- }
-
- }
-
- private abstract static class NamedOperation implements IDeploymentPlanBuilderOperation {
-
- protected String name;
-
- private NamedOperation(String name) {
- this.name = name;
- }
- }
-
- private interface IDeploymentPlanBuilderOperation {
-
- public DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception;
-
- }
-}
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Deployable.java (from rev 30563, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Deployable.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Deployable.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/Deployable.java 2011-04-13 21:31:08 UTC (rev 30564)
@@ -0,0 +1,95 @@
+package org.jboss.ide.eclipse.as7.deployment.internal;
+
+import java.io.File;
+import java.text.MessageFormat;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.jboss.as.controller.client.helpers.standalone.DeploymentAction;
+import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentActionResult;
+import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentPlanResult;
+import org.jboss.ide.eclipse.as7.deployment.Activator;
+
+public class Deployable {
+
+ private String name;
+ private File file;
+ private Future<ServerDeploymentPlanResult> resultFuture;
+ private long timeout;
+ private DeploymentAction action;
+
+ protected Deployable(String name, File file, long timeout) {
+ this.name = name;
+ this.file = file;
+ this.timeout = timeout;
+ }
+
+ protected void setDeploymentAction(DeploymentAction action) {
+ this.action = action;
+ }
+
+ protected void setResultFuture(Future<ServerDeploymentPlanResult> resultFuture) {
+ this.resultFuture = resultFuture;
+ }
+
+ public File getFile() {
+ return file;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public IStatus getStatus() throws DeployerException {
+ if (resultFuture == null
+ || action == null) {
+ return null;
+ }
+ try {
+ ServerDeploymentPlanResult result = resultFuture.get(timeout, TimeUnit.MILLISECONDS);
+ ServerDeploymentActionResult actionResult = result.getDeploymentActionResult(action.getId());
+ return createStatus(action, actionResult);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ }
+ }
+
+ private IStatus createStatus(DeploymentAction action, ServerDeploymentActionResult actionResult) {
+ if (actionResult == null) {
+ return null;
+ }
+
+ IStatus status = null;
+ switch (actionResult.getResult()) {
+ case NOT_EXECUTED:
+ status = createStatus(IStatus.ERROR, "The operation {0} was not executed on unit {1}", action
+ .getType().name(), getName());
+ break;
+ case EXECUTED:
+ status = Status.OK_STATUS;
+ break;
+ case FAILED:
+ status = createStatus(IStatus.ERROR, "The operation {0} failed for unit {1}", action.getType()
+ .name(), getName());
+ break;
+ case ROLLED_BACK:
+ status = createStatus(IStatus.ERROR, "The operation {0} for unit {1} was rolled back", action
+ .getType().name(), getName());
+ break;
+ case CONFIGURATION_MODIFIED_REQUIRES_RESTART:
+ status = createStatus(
+ IStatus.WARNING,
+ "The operation {0} was not executed on unit {1}. The server configuration was changed though and the server needs to be restarted",
+ action.getType().name(), getName());
+ break;
+ }
+ return status;
+ }
+
+ private IStatus createStatus(int severity, String messagePattern, Object... messageArguments) {
+ return new Status(severity, Activator.getContext().getBundle().getSymbolicName(), MessageFormat.format(
+ messagePattern, messageArguments));
+ }
+}
\ No newline at end of file
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeployerException.java (from rev 30563, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeployerException.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeployerException.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/DeployerException.java 2011-04-13 21:31:08 UTC (rev 30564)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat Inc..
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Incorporated - initial API and implementation
+ *******************************************************************************/
+package org.jboss.ide.eclipse.as7.deployment.internal;
+
+/**
+ * @author André Dietisheim
+ */
+public class DeployerException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public DeployerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DeployerException(Throwable cause) {
+ super(cause);
+ }
+
+ public DeployerException(String message) {
+ super(message);
+ }
+
+}
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/StandaloneTypedOperations.java (from rev 30563, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneTypedOperations.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/StandaloneTypedOperations.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/internal/StandaloneTypedOperations.java 2011-04-13 21:31:08 UTC (rev 30564)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.ide.eclipse.as7.deployment.internal;
+
+import static org.jboss.as.protocol.StreamUtils.safeClose;
+
+import java.io.File;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.helpers.standalone.DeploymentPlanBuilder;
+import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
+
+/**
+ * Used to deploy/undeploy deployments to a running <b>standalone</b>
+ * application server
+ *
+ * @author <a href="kabir.khan(a)jboss.com">Kabir Khan</a>
+ * @author <a href="adietish(a)redhat.com">André Dietisheim</a>
+ */
+public class StandaloneTypedOperations {
+
+ public static final long DEFAULT_TIMEOUT = 15000;
+
+ private final List<IDeploymentPlanBuilderOperation> deployments = new ArrayList<IDeploymentPlanBuilderOperation>();
+ private final ModelControllerClient client;
+ private final ServerDeploymentManager manager;
+ private long timeout = DEFAULT_TIMEOUT;
+
+ public StandaloneTypedOperations(String host, int port) throws UnknownHostException {
+ client = ModelControllerClient.Factory.create(host, port);
+ manager = ServerDeploymentManager.Factory.create(client);
+ }
+
+ public synchronized StandaloneTypedOperations deploy(File file) {
+ deployments.add(new DeployOperation(file));
+ return this;
+ }
+
+ public synchronized StandaloneTypedOperations deploy(String name, File file) {
+ deployments.add(new DeployOperation(name, file));
+ return this;
+ }
+
+ public synchronized StandaloneTypedOperations undeploy(String name) {
+ deployments.add(new UndeployOperation(name));
+ return this;
+ }
+
+ public synchronized StandaloneTypedOperations undeploy(File file) {
+ deployments.add(new UndeployOperation(file));
+ return this;
+ }
+
+ public synchronized void execute() throws DeployerException {
+ try {
+ DeploymentPlanBuilder builder = manager.newDeploymentPlan();
+ for (IDeploymentPlanBuilderOperation deployment : deployments) {
+ builder = deployment.addTo(builder);
+ }
+ manager.execute(builder.build()).get(timeout, TimeUnit.MILLISECONDS);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ }
+ }
+
+ public void setTimeout(long timeout) {
+ this.timeout = timeout;
+ }
+
+ public void dispose() {
+ safeClose(client);
+ }
+
+ private static class DeployOperation extends FileOperation {
+
+ private DeployOperation(File file) {
+ super(file);
+ }
+
+ private DeployOperation(String name, File file) {
+ super(name, file);
+ }
+
+ public synchronized DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception {
+ String name = getName();
+ return builder.add(name, getFile()).deploy(name);
+ }
+ }
+
+ private static class UndeployOperation extends FileOperation {
+
+ private UndeployOperation(File file) {
+ super(file);
+ }
+
+ private UndeployOperation(String name) {
+ super(name, null);
+ }
+
+ public synchronized DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception {
+ String name = getName();
+ return builder.undeploy(name).undeploy(name);
+ }
+ }
+
+ private abstract static class FileOperation extends NamedOperation {
+
+ private File file;
+
+ private FileOperation(File file) {
+ this(null, file);
+ }
+
+ private FileOperation(String name, File file) {
+ super(name);
+ this.file = file;
+ }
+
+ protected File getFile() {
+ return file;
+ }
+
+ protected String getName() {
+ if (name != null) {
+ return name;
+ } else {
+ return file.getName();
+ }
+ }
+
+ }
+
+ private abstract static class NamedOperation implements IDeploymentPlanBuilderOperation {
+
+ protected String name;
+
+ private NamedOperation(String name) {
+ this.name = name;
+ }
+ }
+
+ private interface IDeploymentPlanBuilderOperation {
+
+ public DeploymentPlanBuilder addTo(DeploymentPlanBuilder builder) throws Exception;
+
+ }
+}
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java 2011-04-13 17:48:20 UTC (rev 30563)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java 2011-04-13 21:31:08 UTC (rev 30564)
@@ -53,7 +53,7 @@
request.get("operation").set("remove");
request.get("address").add("deployment", name);
result = client.execute(request);
-
+
StreamUtils.safeClose(client);
}
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/META-INF/MANIFEST.MF
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/META-INF/MANIFEST.MF 2011-04-13 17:48:20 UTC (rev 30563)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/META-INF/MANIFEST.MF 2011-04-13 21:31:08 UTC (rev 30564)
@@ -6,7 +6,7 @@
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit;bundle-version="[4.8.1,5.0.0)",
org.eclipse.core.runtime;bundle-version="3.7.0",
- org.jboss.ide.eclipse.as7.deployment;bundle-version="0.0.1",
- org.jboss.ide.eclipse.as7.deployment.detyped;bundle-version="1.0.0"
+ org.jboss.ide.eclipse.as7.deployment,
+ org.jboss.ide.eclipse.as7.deployment.detyped
Bundle-ClassPath: .,
wars/
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java 2011-04-13 17:48:20 UTC (rev 30563)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/MinimalisticDeployerIntegrationTest.java 2011-04-13 21:31:08 UTC (rev 30564)
@@ -35,9 +35,9 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
-import org.jboss.ide.eclipse.as7.deployment.DeployerException;
-import org.jboss.ide.eclipse.as7.deployment.StandaloneTypedOperations;
import org.jboss.ide.eclipse.as7.deployment.detyped.MinimalisticStandaloneDeployer;
+import org.jboss.ide.eclipse.as7.deployment.internal.DeployerException;
+import org.jboss.ide.eclipse.as7.deployment.internal.StandaloneTypedOperations;
import org.junit.Test;
import org.osgi.framework.Bundle;
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneOperationsIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneOperationsIntegrationTest.java 2011-04-13 17:48:20 UTC (rev 30563)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneOperationsIntegrationTest.java 2011-04-13 21:31:08 UTC (rev 30564)
@@ -35,8 +35,8 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
-import org.jboss.ide.eclipse.as7.deployment.DeployerException;
-import org.jboss.ide.eclipse.as7.deployment.StandaloneTypedOperations;
+import org.jboss.ide.eclipse.as7.deployment.internal.DeployerException;
+import org.jboss.ide.eclipse.as7.deployment.internal.StandaloneTypedOperations;
import org.junit.Test;
import org.osgi.framework.Bundle;
15 years
JBoss Tools SVN: r30563 - in workspace/adietish: org.jboss.ide.eclipse.as7.deployment.detyped/META-INF and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-04-13 13:48:20 -0400 (Wed, 13 Apr 2011)
New Revision: 30563
Removed:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/jboss-as-cli-7.0.0.Beta3-SNAPSHOT.jar
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/StandaloneDetypedOperations.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneDetypedOperationsIntegrationTest.java
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/.classpath
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/META-INF/MANIFEST.MF
workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/build.properties
Log:
removed jboss-as-cli jar
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/.classpath
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/.classpath 2011-04-13 17:45:07 UTC (rev 30562)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/.classpath 2011-04-13 17:48:20 UTC (rev 30563)
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="jboss-logging-3.0.0.Beta3.jar"/>
- <classpathentry exported="true" kind="lib" path="jboss-as-cli-7.0.0.Beta3-SNAPSHOT.jar" sourcepath="/jboss-as-cli"/>
<classpathentry exported="true" kind="lib" path="jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT.jar" sourcepath="/jboss-as-controller-client"/>
<classpathentry exported="true" kind="lib" path="jboss-as-protocol-7.0.0.Beta3-SNAPSHOT.jar"/>
<classpathentry exported="true" kind="lib" path="jboss-dmr-1.0.0.Beta5.jar" sourcepath="/home/adietish/jboss-workspaces/jboss-tools/jbosstools-src/jboss-dmr-1.0.0.Beta5-sources.jar"/>
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/META-INF/MANIFEST.MF
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/META-INF/MANIFEST.MF 2011-04-13 17:45:07 UTC (rev 30562)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/META-INF/MANIFEST.MF 2011-04-13 17:48:20 UTC (rev 30563)
@@ -5,18 +5,13 @@
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: .,
- jboss-as-cli-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-dmr-1.0.0.Beta5.jar,
jboss-marshalling-1.3.0.CR8.jar,
jboss-threads-2.0.0.CR8.jar,
jboss-logging-3.0.0.Beta3.jar
-Export-Package: org.jboss.as.cli,
- org.jboss.as.cli.handlers,
- org.jboss.as.cli.operation,
- org.jboss.as.cli.operation.impl,
- org.jboss.as.cli.operation.parsing,
+Export-Package:
org.jboss.as.controller.client,
org.jboss.as.controller.client.helpers,
org.jboss.as.controller.client.helpers.domain,
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/build.properties
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/build.properties 2011-04-13 17:45:07 UTC (rev 30562)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/build.properties 2011-04-13 17:48:20 UTC (rev 30563)
@@ -2,7 +2,6 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
- jboss-as-cli-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-dmr-1.0.0.Beta5.jar,\
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/jboss-as-cli-7.0.0.Beta3-SNAPSHOT.jar
===================================================================
(Binary files differ)
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/StandaloneDetypedOperations.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/StandaloneDetypedOperations.java 2011-04-13 17:45:07 UTC (rev 30562)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/StandaloneDetypedOperations.java 2011-04-13 17:48:20 UTC (rev 30563)
@@ -1,176 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.ide.eclipse.as7.deployment.detyped;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CancellationException;
-
-import org.jboss.as.cli.operation.OperationFormatException;
-import org.jboss.as.cli.operation.OperationRequestBuilder;
-import org.jboss.as.cli.operation.impl.DefaultOperationRequestBuilder;
-import org.jboss.as.controller.client.ModelControllerClient;
-import org.jboss.as.protocol.StreamUtils;
-import org.jboss.dmr.ModelNode;
-
-/**
- * @author André Dietisheim
- */
-public class StandaloneDetypedOperations {
-
- private final List<IDeploymentOperation> deployments = new ArrayList<IDeploymentOperation>();
- private final ModelControllerClient client;
-
- public StandaloneDetypedOperations(String host, int port) throws UnknownHostException {
- client = ModelControllerClient.Factory.create(host, port);
- }
-
- public synchronized StandaloneDetypedOperations deploy(File file) {
- deployments.add(new DeployOperation(file));
- return this;
- }
-
- public synchronized StandaloneDetypedOperations deploy(String name, File file) {
- deployments.add(new DeployOperation(name, file));
- return this;
- }
-
- public synchronized StandaloneDetypedOperations undeploy(String name) {
- deployments.add(new UndeployOperation(name));
- return this;
- }
-
- public synchronized StandaloneDetypedOperations undeploy(File file) {
- deployments.add(new UndeployOperation(file));
- return this;
- }
-
- public synchronized void execute() throws DeployerException {
- try {
- for (IDeploymentOperation operation : deployments) {
- operation.execute();
- }
- } catch (Exception e) {
- throw new DeployerException(e);
- }
- finally {
- dispose();
- }
- }
-
- public void dispose() {
- StreamUtils.safeClose(client);
- }
-
- private class DeployOperation extends FileOperation {
-
- private DeployOperation(File file) {
- super(file);
- }
-
- private DeployOperation(String name, File file) {
- super(name, file);
- }
-
- public void execute() throws OperationFormatException, CancellationException, IOException {
- OperationRequestBuilder builder = new DefaultOperationRequestBuilder();
- builder.setOperationName("deploy");
- builder.addNode("deployment", name);
- ModelNode request = builder.buildRequest();
- ModelNode result = client.execute(request);
- }
- }
-
- private class UndeployOperation extends FileOperation {
-
- private UndeployOperation(File file) {
- super(file);
- }
-
- private UndeployOperation(String name) {
- super(name, null);
- }
-
- public void execute() throws OperationFormatException, CancellationException, IOException {
- DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
-
- builder = new DefaultOperationRequestBuilder();
- builder.setOperationName("undeploy");
- builder.addNode("deployment", getName());
-
- ModelNode request = builder.buildRequest();
- ModelNode result = client.execute(request);
-
- // remove
- builder = new DefaultOperationRequestBuilder();
- builder.setOperationName("remove");
- builder.addNode("deployment", getName());
- request = builder.buildRequest();
- result = client.execute(request);
- }
- }
-
- private abstract static class FileOperation extends NamedOperation {
-
- private File file;
-
- private FileOperation(File file) {
- this(null, file);
- }
-
- private FileOperation(String name, File file) {
- super(name);
- this.file = file;
- }
-
- protected File getFile() {
- return file;
- }
-
- protected String getName() {
- if (name != null) {
- return name;
- } else {
- return file.getName();
- }
- }
- }
-
- private abstract static class NamedOperation implements IDeploymentOperation {
-
- protected String name;
-
- private NamedOperation(String name) {
- this.name = name;
- }
- }
-
- private interface IDeploymentOperation {
-
- public void execute() throws Exception;
-
- }
-
-}
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneDetypedOperationsIntegrationTest.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneDetypedOperationsIntegrationTest.java 2011-04-13 17:45:07 UTC (rev 30562)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.tests/src/org/jboss/ide/eclipse/as7/deployment/tests/StandaloneDetypedOperationsIntegrationTest.java 2011-04-13 17:48:20 UTC (rev 30563)
@@ -1,126 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.ide.eclipse.as7.deployment.tests;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.net.HttpURLConnection;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.text.MessageFormat;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Platform;
-import org.jboss.ide.eclipse.as7.deployment.DeployerException;
-import org.jboss.ide.eclipse.as7.deployment.detyped.StandaloneDetypedOperations;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-
-/**
- * @author André Dietisheim
- */
-public class StandaloneDetypedOperationsIntegrationTest {
-
- private static final String WAR_FOLDER = "/wars/";
- private static final String BUNDLE_ID = "org.jboss.ide.eclipse.as7.deployment.tests";
-
- private static final int WEBAPP_RESPONSE_TIMEOUT = 10 * 1024;
-
- 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 {
- StandaloneDetypedOperations deployer = null;
- File warFile = getWarFile("minimalistic.war");
- try {
- deployer = new StandaloneDetypedOperations(HOST, MGMT_PORT);
- quietlyUndeploy(warFile, deployer);
- deployer.deploy(warFile).execute();
-
- String response = getServerResponse(new URL(
- MessageFormat.format(
- "http://{0}:{1}/{2}", HOST, String.valueOf(WEB_PORT), "minimalistic")));
- assertTrue(response.indexOf("minimalistic") >= 0);
-
- } finally {
- quietlyUndeploy(warFile, deployer);
- }
- }
-
- @Test(expected = DeployerException.class)
- public void cannotDeployWarTwice() throws Exception {
- StandaloneDetypedOperations deployer = null;
- File warFile = getWarFile("minimalistic.war");
- try {
- deployer = new StandaloneDetypedOperations(HOST, MGMT_PORT);
- deployer.deploy(warFile).execute();
- deployer.deploy(warFile).execute();
- } finally {
- quietlyUndeploy(warFile, deployer);
- }
- }
-
- private File getWarFile(String name) throws URISyntaxException, IOException {
- Bundle bundle = Platform.getBundle(BUNDLE_ID);
- URL entryUrl = bundle.getEntry(WAR_FOLDER + name);
- return new File(FileLocator.resolve(entryUrl).toURI());
- }
-
- private String getServerResponse(URL url) throws IOException {
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setUseCaches(false);
- connection.setDoInput(true);
- connection.setAllowUserInteraction(false);
- connection.setConnectTimeout(WEBAPP_RESPONSE_TIMEOUT);
- connection.setInstanceFollowRedirects(true);
- connection.setDoOutput(false);
- BufferedInputStream in = new BufferedInputStream(connection.getInputStream());
- return toString(in);
- }
-
- private String toString(InputStream in) throws IOException {
- StringWriter writer = new StringWriter();
- for (int data = -1; ((data = in.read()) != -1);) {
- writer.write(data);
- }
- return writer.toString();
- }
-
- private void quietlyUndeploy(File file, StandaloneDetypedOperations deployer) {
- try {
- if (deployer != null) {
- deployer.undeploy(file).execute();
- deployer.dispose();
- }
- } catch (Exception e) {
- e.printStackTrace();
- // ignore
- }
- }
-}
15 years