JBoss Tools SVN: r30733 - branches.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2011-04-21 17:53:26 -0400 (Thu, 21 Apr 2011)
New Revision: 30733
Added:
branches/dead/
Log:
I see dead branches.
14 years, 11 months
JBoss Tools SVN: r30732 - in trunk/as/plugins: org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-04-21 17:46:05 -0400 (Thu, 21 Apr 2011)
New Revision: 30732
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/IJBoss7DeploymentManager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossDeploymentManager.java
Log:
[JBIDE-8769] implemented state checking
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/IJBoss7DeploymentManager.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/IJBoss7DeploymentManager.java 2011-04-21 21:03:47 UTC (rev 30731)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/IJBoss7DeploymentManager.java 2011-04-21 21:46:05 UTC (rev 30732)
@@ -75,5 +75,16 @@
public Object syncUndeploy(String host, int port,
String deploymentName, boolean removeFile, IProgressMonitor monitor) throws Exception;
+ /**
+ * Returns the state for a given deployment name on a given host and port.
+ *
+ * @param host the host to query
+ * @param port the port to contact it on
+ * @param deploymentName the name of the deployment that shall be queried
+ *
+ * @return the state of the deployment
+ * @throws Exception
+ */
+ public Object getDeploymentState(String host, int port, String deploymentName) throws Exception;
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossDeploymentManager.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossDeploymentManager.java 2011-04-21 21:03:47 UTC (rev 30731)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossDeploymentManager.java 2011-04-21 21:46:05 UTC (rev 30732)
@@ -33,25 +33,31 @@
public DeploymentOperationResult deployAsync(String host, int port, String deploymentName,
File file, IProgressMonitor monitor) throws Exception {
- AS7Manager deployer = new AS7Manager(host, port);
- return deployer.deploy(deploymentName, file);
+ AS7Manager manager = new AS7Manager(host, port);
+ return manager.deploy(deploymentName, file);
}
public DeploymentOperationResult deploySync(String host, int port, String deploymentName,
File file, IProgressMonitor monitor) throws Exception {
- AS7Manager deployer = new AS7Manager(host, port);
- return deployer.deploySync(deploymentName, file, monitor);
+ AS7Manager manager = new AS7Manager(host, port);
+ return manager.deploySync(deploymentName, file, monitor);
}
public DeploymentOperationResult undeployAsync(String host, int port, String deploymentName,
- boolean removeFile, IProgressMonitor monitor) throws Exception {
- AS7Manager deployer = new AS7Manager(host, port);
- return deployer.undeploy(deploymentName);
+ boolean removeFile, IProgressMonitor monitor) throws Exception {
+ AS7Manager manager = new AS7Manager(host, port);
+ return manager.undeploy(deploymentName);
}
public DeploymentOperationResult syncUndeploy(String host, int port, String deploymentName,
boolean removeFile, IProgressMonitor monitor) throws Exception {
- AS7Manager deployer = new AS7Manager(host, port);
- return deployer.undeploySync(deploymentName, monitor);
+ AS7Manager manager = new AS7Manager(host, port);
+ return manager.undeploySync(deploymentName, monitor);
}
+
+ public DeploymentState getDeploymentState(String host, int port, String deploymentName) throws Exception {
+ AS7Manager manager = new AS7Manager(host, port);
+ return manager.getDeploymentState(deploymentName);
+
+ }
}
14 years, 11 months
JBoss Tools SVN: r30731 - in trunk/as: plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-04-21 17:03:47 -0400 (Thu, 21 Apr 2011)
New Revision: 30731
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/AS7Manager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/AS7ManagerUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DeploymentOperationResult.java
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DeploymentState.java
Removed:
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/DeploymentManagerIntegratonTest.java
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DeploymentManager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossManagementUtil.java
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossManager.java
Modified:
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementIntegrationTest.java
trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementTestUtils.java
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DetypedDeployer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossDeploymentManager.java
trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossManagementService.java
Log:
[JBIDE-8769] implemented state checking
Deleted: trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/DeploymentManagerIntegratonTest.java
===================================================================
--- trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/DeploymentManagerIntegratonTest.java 2011-04-21 20:46:53 UTC (rev 30730)
+++ trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/DeploymentManagerIntegratonTest.java 2011-04-21 21:03:47 UTC (rev 30731)
@@ -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.as.management.as7.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.as.management.as7.deployment.DeployerException;
-import org.jboss.ide.eclipse.as.management.as7.deployment.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
- }
- }
-}
Modified: trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementIntegrationTest.java
===================================================================
--- trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementIntegrationTest.java 2011-04-21 20:46:53 UTC (rev 30730)
+++ trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementIntegrationTest.java 2011-04-21 21:03:47 UTC (rev 30731)
@@ -33,8 +33,8 @@
import java.util.concurrent.ExecutionException;
import org.jboss.ide.eclipse.as.management.as7.deployment.DeployerException;
-import org.jboss.ide.eclipse.as.management.as7.deployment.JBossManager;
-import org.jboss.ide.eclipse.as.management.as7.deployment.JBossManager.DeploymentState;
+import org.jboss.ide.eclipse.as.management.as7.deployment.DeploymentState;
+import org.jboss.ide.eclipse.as.management.as7.deployment.AS7Manager;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
@@ -46,11 +46,11 @@
*/
public class JBossManagementIntegrationTest {
- private JBossManager manager;
+ private AS7Manager manager;
@Before
public void setUp() throws UnknownHostException {
- this.manager = new JBossManager(JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
+ this.manager = new AS7Manager(JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
}
@After
@@ -135,7 +135,7 @@
JBossManagementTestUtils.waitUntilFinished(manager.deploy(deploymentName, warFile));
DeploymentState state = manager.getDeploymentState(deploymentName);
assertNotNull(state);
- assertThat(state, equalTo(DeploymentState.ENABLEDSTATE));
+ assertThat(state, equalTo(DeploymentState.STARTED));
} finally {
JBossManagementTestUtils.quietlyUndeploy(deploymentName, manager);
}
@@ -149,7 +149,7 @@
JBossManagementTestUtils.waitUntilFinished(manager.add(deploymentName, warFile));
DeploymentState state = manager.getDeploymentState(deploymentName);
assertNotNull(state);
- assertThat(state, equalTo(DeploymentState.DISABLEDSTATE));
+ assertThat(state, equalTo(DeploymentState.STOPPED));
} finally {
JBossManagementTestUtils.quietlyRemove(deploymentName, manager);
}
Modified: trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementTestUtils.java
===================================================================
--- trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementTestUtils.java 2011-04-21 20:46:53 UTC (rev 30730)
+++ trunk/as/org.jboss.ide.eclipse.as.management.as7.tests/src/org/jboss/ide/eclipse/as/management/as7/tests/JBossManagementTestUtils.java 2011-04-21 21:03:47 UTC (rev 30731)
@@ -34,8 +34,8 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.jboss.ide.eclipse.as.management.as7.deployment.DeployerException;
-import org.jboss.ide.eclipse.as.management.as7.deployment.JBossManager;
-import org.jboss.ide.eclipse.as.management.as7.deployment.JBossManager.DeploymentPlanResult;
+import org.jboss.ide.eclipse.as.management.as7.deployment.DeploymentOperationResult;
+import org.jboss.ide.eclipse.as.management.as7.deployment.AS7Manager;
import org.osgi.framework.Bundle;
/**
@@ -67,11 +67,11 @@
return getResponse(name, host, port);
}
- public static void quietlyUndeploy(File file, JBossManager manager) {
+ public static void quietlyUndeploy(File file, AS7Manager manager) {
quietlyUndeploy(file.getName(), manager);
}
- public static void quietlyUndeploy(String name, JBossManager manager) {
+ public static void quietlyUndeploy(String name, AS7Manager manager) {
try {
// DetypedDeployer.undeploy(name, JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
waitUntilFinished(manager.undeploy(name));
@@ -80,7 +80,7 @@
}
}
- public static void quietlyRemove(String name, JBossManager manager) {
+ public static void quietlyRemove(String name, AS7Manager manager) {
try {
//DetypedDeployer.remove(name, JBossManagementTestUtils.HOST, JBossManagementTestUtils.MGMT_PORT);
waitUntilFinished(manager.remove(name));
@@ -89,7 +89,7 @@
}
}
- public static void waitUntilFinished(DeploymentPlanResult result) throws DeployerException {
+ public static void waitUntilFinished(DeploymentOperationResult result) throws DeployerException {
result.getStatus(); // wait for operation to finish
}
Copied: trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/AS7Manager.java (from rev 30722, trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossManager.java)
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/AS7Manager.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/AS7Manager.java 2011-04-21 21:03:47 UTC (rev 30731)
@@ -0,0 +1,159 @@
+/*
+ * 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.as.management.as7.deployment;
+
+import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.ADDRESS;
+import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.DEPLOYMENT;
+import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.FAILURE_DESCRIPTION;
+import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.OP;
+import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.READ_RESOURCE_OPERATION;
+import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.RESULT;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.text.MessageFormat;
+import java.util.concurrent.Future;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.helpers.standalone.DeploymentAction;
+import org.jboss.as.controller.client.helpers.standalone.DeploymentPlanBuilder;
+import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
+import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentPlanResult;
+import org.jboss.as.protocol.StreamUtils;
+import org.jboss.dmr.ModelNode;
+
+/**
+ * @author André Dietisheim
+ */
+public class AS7Manager {
+
+ private ModelControllerClient client;
+ private ServerDeploymentManager manager;
+
+ public AS7Manager(String host, int port) throws UnknownHostException {
+ this.client = ModelControllerClient.Factory.create(host, port);
+ this.manager = ServerDeploymentManager.Factory.create(client);
+ }
+
+ public DeploymentOperationResult undeploySync(String name, IProgressMonitor monitor) throws DeployerException {
+ DeploymentOperationResult result = undeploy(name);
+ result.getStatus();
+ return result;
+ }
+
+ public DeploymentOperationResult deploySync(String name, File file, IProgressMonitor monitor)
+ throws DeployerException {
+ DeploymentOperationResult result = deploy(name, file);
+ result.getStatus();
+ return result;
+ }
+
+ public DeploymentOperationResult undeploy(String name) throws DeployerException {
+ try {
+ DeploymentPlanBuilder builder = manager.newDeploymentPlan();
+ builder = builder.undeploy(name).andRemoveUndeployed();
+ return new DeploymentOperationResult(builder.getLastAction(), manager.execute(builder.build()));
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ }
+ }
+
+ public DeploymentOperationResult remove(String name) throws DeployerException {
+ try {
+ DeploymentPlanBuilder builder = manager.newDeploymentPlan();
+ builder = builder.remove(name);
+ return new DeploymentOperationResult(builder.getLastAction(), manager.execute(builder.build()));
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ }
+ }
+
+ public DeploymentOperationResult deploy(File file) throws DeployerException {
+ return deploy(file.getName(), file);
+ }
+
+ public DeploymentOperationResult add(String name, File file) throws DeployerException {
+ try {
+ return execute(manager.newDeploymentPlan().add(name, file));
+ } catch (IOException e) {
+ throw new DeployerException(e);
+ }
+ }
+
+ public DeploymentOperationResult deploy(String name, File file) throws DeployerException {
+ try {
+ return execute(manager.newDeploymentPlan().add(name, file).andDeploy());
+ } catch (IOException e) {
+ throw new DeployerException(e);
+ }
+ }
+
+ public DeploymentOperationResult replace(File file) throws DeployerException {
+ return replace(file.getName(), file);
+ }
+
+ public DeploymentOperationResult replace(String name, File file) throws DeployerException {
+ try {
+ return execute(manager.newDeploymentPlan().replace(name, file));
+ } catch (IOException e) {
+ throw new DeployerException(e);
+ }
+ }
+
+ public DeploymentState getDeploymentState(String name) throws DeployerException {
+ ModelNode request = new ModelNode();
+ request.get(OP).set(READ_RESOURCE_OPERATION);
+ request.get(ADDRESS).add(DEPLOYMENT, name);
+ ModelNode result = execute(request);
+ return DeploymentState.getForResultNode(result);
+ }
+
+ public void dispose() {
+ StreamUtils.safeClose(client);
+ }
+
+ private ModelNode execute(ModelNode node) throws DeployerException {
+ try {
+ ModelNode response = client.execute(node);
+ if (!AS7ManagerUtil.isSuccess(response)) {
+ throw new DeployerException(
+ MessageFormat.format("Could not execute {0} for {1}. Failure was {2}.", node.get(OP),
+ node.get(ADDRESS), response.get(FAILURE_DESCRIPTION)));
+ }
+ return response.get(RESULT);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ }
+ }
+
+ private DeploymentOperationResult execute(DeploymentPlanBuilder builder) throws DeployerException {
+ try {
+ DeploymentAction action = builder.getLastAction();
+ Future<ServerDeploymentPlanResult> planResult = manager.execute(builder.build());
+ return new DeploymentOperationResult(action, planResult);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ }
+ }
+}
Copied: trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/AS7ManagerUtil.java (from rev 30703, trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossManagementUtil.java)
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/AS7ManagerUtil.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/AS7ManagerUtil.java 2011-04-21 21:03:47 UTC (rev 30731)
@@ -0,0 +1,168 @@
+/*
+ * 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.as.management.as7.deployment;
+
+import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.CHILD_TYPE;
+import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.FAILURE_DESCRIPTION;
+import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.OUTCOME;
+import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.READ_CHILDREN_NAMES_OPERATION;
+import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.REQUEST_PROPERTIES;
+import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.RESULT;
+import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.SUCCESS;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.Operation;
+import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.ModelType;
+import org.jboss.dmr.Property;
+import org.jboss.ide.eclipse.as.management.as7.internal.DefaultOperationRequestBuilder;
+import org.jboss.ide.eclipse.as.management.as7.internal.OperationFormatException;
+
+/**
+ * Various utility methods to deal with the as7 management api.
+ *
+ * @author Alexey Loubyansky
+ * @author André Dietisheim
+ */
+public class AS7ManagerUtil {
+
+ 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 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_OPERATION);
+ 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 Boolean getBooleanProperty(String propertyName, ModelNode node) {
+ if (node == null) {
+ return null;
+ }
+ ModelNode valueNode = node.get(propertyName);
+ if (valueNode == null) {
+ return null;
+ }
+ String value = valueNode.toString();
+ if (value == null
+ || valueNode.getType() != ModelType.BOOLEAN) {
+ return null;
+ }
+ return Boolean.valueOf(value);
+ }
+
+ public static ModelNode execute(Operation operation, ModelControllerClient client) throws DeployerException {
+ try {
+ ModelNode result = client.execute(operation);
+ if (result.hasDefined(OUTCOME)
+ && SUCCESS.equals(result.get("outcome").asString())) {
+ return result.get(RESULT);
+ }
+ else if (result.hasDefined(FAILURE_DESCRIPTION)) {
+ throw new DeployerException(result.get(FAILURE_DESCRIPTION).toString());
+ }
+ else {
+ throw new DeployerException("Operation outcome is " + result.get(OUTCOME).asString());
+ }
+ } catch (IOException e) {
+ throw new DeployerException(e);
+ }
+ }
+}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DeploymentManager.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DeploymentManager.java 2011-04-21 20:46:53 UTC (rev 30730)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DeploymentManager.java 2011-04-21 21:03:47 UTC (rev 30731)
@@ -1,169 +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.as.management.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="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;
-
- }
-}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DeploymentOperationResult.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DeploymentOperationResult.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DeploymentOperationResult.java 2011-04-21 21:03:47 UTC (rev 30731)
@@ -0,0 +1,98 @@
+/*
+ * 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.as.management.as7.deployment;
+
+import java.text.MessageFormat;
+import java.util.concurrent.Future;
+
+import org.eclipse.core.runtime.Assert;
+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.as.management.as7.Activator;
+
+/**
+ * A class that holds the status of a deployment operation.
+ *
+ * @author André Dietisheim
+ *
+ */
+public class DeploymentOperationResult {
+
+ private Future<ServerDeploymentPlanResult> planResult;
+ private DeploymentAction action;
+
+ DeploymentOperationResult(DeploymentAction action, Future<ServerDeploymentPlanResult> planResult) {
+ Assert.isNotNull(action);
+ this.action = action;
+ Assert.isNotNull(planResult);
+ this.planResult = planResult;
+ }
+
+ public IStatus getStatus() throws DeployerException {
+ try {
+ ServerDeploymentActionResult actionResult = planResult.get().getDeploymentActionResult(action.getId());
+ return createStatus(action.getDeploymentUnitUniqueName(), action.getType().name(), actionResult);
+ } catch (Exception e) {
+ throw new DeployerException(e);
+ }
+ }
+
+ private IStatus createStatus(String deploymentName, String actionName, 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}",
+ actionName, deploymentName);
+ break;
+ case EXECUTED:
+ status = Status.OK_STATUS;
+ break;
+ case FAILED:
+ status = createStatus(IStatus.ERROR, "The operation {0} failed for unit {1}",
+ actionName, deploymentName);
+ break;
+ case ROLLED_BACK:
+ status = createStatus(IStatus.ERROR, "The operation {0} for unit {1} was rolled back",
+ actionName, deploymentName);
+ 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",
+ actionName, deploymentName);
+ 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
Property changes on: trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DeploymentOperationResult.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DeploymentState.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DeploymentState.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DeploymentState.java 2011-04-21 21:03:47 UTC (rev 30731)
@@ -0,0 +1,62 @@
+/*
+ * 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.as.management.as7.deployment;
+
+import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.ENABLED;
+
+import org.jboss.dmr.ModelNode;
+
+/**
+ * An enum that reflects the state of a deployment.
+ *
+ * @author André Dietisheim
+ */
+public enum DeploymentState {
+ STARTED {
+ protected boolean matches(boolean enabled) {
+ return enabled == true;
+ }
+ },
+ STOPPED {
+ protected boolean matches(boolean enabled) {
+ return enabled == false;
+ }
+ };
+
+ public static DeploymentState getForResultNode(ModelNode node) {
+ Boolean enabled = AS7ManagerUtil.getBooleanProperty(ENABLED, node);
+ if (enabled == null) {
+ return null;
+ }
+
+ DeploymentState matchingState = null;
+ for(DeploymentState state : values()) {
+ if (state.matches(enabled)) {
+ matchingState = state;
+ }
+ }
+ return matchingState;
+ }
+
+ protected abstract boolean matches(boolean enabled);
+
+}
\ No newline at end of file
Property changes on: trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DeploymentState.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DetypedDeployer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DetypedDeployer.java 2011-04-21 20:46:53 UTC (rev 30730)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/DetypedDeployer.java 2011-04-21 21:03:47 UTC (rev 30731)
@@ -78,7 +78,7 @@
ModelNode request = new ModelNode();
request.get(OP).set(REMOVE);
request.get(ADDRESS).add(DEPLOYMENT, name);
- ModelNode result = client.execute(request);
+ client.execute(request);
} catch (Exception e) {
throw new DeployerException(e);
} finally {
@@ -143,7 +143,7 @@
public static boolean isDeployed(String name, String host, int port) throws CancellationException, IOException {
ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
try {
- return JBossManagementUtil.isDeployed(name, client);
+ return AS7ManagerUtil.isDeployed(name, client);
} finally {
StreamUtils.safeClose(client);
}
@@ -151,12 +151,12 @@
public static List<String> getDeployments(String host, int port) throws UnknownHostException {
ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
- return JBossManagementUtil.getDeployments(client);
+ return AS7ManagerUtil.getDeployments(client);
}
private static void throwOnFailure(ModelNode result) throws DeployerException {
- if (!JBossManagementUtil.isSuccess(result)) {
- throw new DeployerException(JBossManagementUtil.getFailureDescription(result));
+ if (!AS7ManagerUtil.isSuccess(result)) {
+ throw new DeployerException(AS7ManagerUtil.getFailureDescription(result));
}
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossDeploymentManager.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossDeploymentManager.java 2011-04-21 20:46:53 UTC (rev 30730)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossDeploymentManager.java 2011-04-21 21:03:47 UTC (rev 30731)
@@ -1,3 +1,24 @@
+/*
+ * 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.as.management.as7.deployment;
import java.io.File;
@@ -4,32 +25,33 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.jboss.ide.eclipse.as.core.server.internal.v7.IJBoss7DeploymentManager;
-import org.jboss.ide.eclipse.as.management.as7.deployment.JBossManager.DeploymentPlanResult;
+/**
+ * @author Rob Stryker
+ */
public class JBossDeploymentManager implements IJBoss7DeploymentManager {
- public DeploymentPlanResult deployAsync(String host, int port, String deploymentName,
+ public DeploymentOperationResult deployAsync(String host, int port, String deploymentName,
File file, IProgressMonitor monitor) throws Exception {
- JBossManager deployer = new JBossManager(host, port);
+ AS7Manager deployer = new AS7Manager(host, port);
return deployer.deploy(deploymentName, file);
}
- public DeploymentPlanResult deploySync(String host, int port, String deploymentName,
+ public DeploymentOperationResult deploySync(String host, int port, String deploymentName,
File file, IProgressMonitor monitor) throws Exception {
- JBossManager deployer = new JBossManager(host, port);
+ AS7Manager deployer = new AS7Manager(host, port);
return deployer.deploySync(deploymentName, file, monitor);
}
- public DeploymentPlanResult undeployAsync(String host, int port, String deploymentName,
+ public DeploymentOperationResult undeployAsync(String host, int port, String deploymentName,
boolean removeFile, IProgressMonitor monitor) throws Exception {
- JBossManager deployer = new JBossManager(host, port);
+ AS7Manager deployer = new AS7Manager(host, port);
return deployer.undeploy(deploymentName);
}
- public DeploymentPlanResult syncUndeploy(String host, int port, String deploymentName,
+ public DeploymentOperationResult syncUndeploy(String host, int port, String deploymentName,
boolean removeFile, IProgressMonitor monitor) throws Exception {
- JBossManager deployer = new JBossManager(host, port);
+ AS7Manager deployer = new AS7Manager(host, port);
return deployer.undeploySync(deploymentName, monitor);
}
-
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossManagementService.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossManagementService.java 2011-04-21 20:46:53 UTC (rev 30730)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossManagementService.java 2011-04-21 21:03:47 UTC (rev 30731)
@@ -1,3 +1,24 @@
+/*
+ * 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.as.management.as7.deployment;
import org.jboss.ide.eclipse.as.core.server.internal.v7.IJBoss7DeploymentManager;
@@ -4,7 +25,9 @@
import org.jboss.ide.eclipse.as.core.server.internal.v7.IJBoss7ManagementInterface;
import org.jboss.ide.eclipse.as.core.server.internal.v7.IJBoss7ManagementService;
-
+/**
+ * @author Rob Stryker
+ */
public class JBossManagementService implements IJBoss7ManagementService {
private IJBoss7DeploymentManager deploymentManager = null;
@@ -20,5 +43,4 @@
// TODO Auto-generated method stub
return null;
}
-
}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossManagementUtil.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossManagementUtil.java 2011-04-21 20:46:53 UTC (rev 30730)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossManagementUtil.java 2011-04-21 21:03:47 UTC (rev 30731)
@@ -1,168 +0,0 @@
-/*
- * 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.as.management.as7.deployment;
-
-import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.CHILD_TYPE;
-import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.FAILURE_DESCRIPTION;
-import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.OUTCOME;
-import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.READ_CHILDREN_NAMES_OPERATION;
-import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.REQUEST_PROPERTIES;
-import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.RESULT;
-import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.SUCCESS;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.as.controller.client.ModelControllerClient;
-import org.jboss.as.controller.client.Operation;
-import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
-import org.jboss.dmr.Property;
-import org.jboss.ide.eclipse.as.management.as7.internal.DefaultOperationRequestBuilder;
-import org.jboss.ide.eclipse.as.management.as7.internal.OperationFormatException;
-
-/**
- * Various utility methods to deal with the as7 management api.
- *
- * @author Alexey Loubyansky
- * @author André Dietisheim
- */
-public class JBossManagementUtil {
-
- 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 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_OPERATION);
- 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 Boolean getBooleanProperty(String propertyName, ModelNode node) {
- if (node == null) {
- return null;
- }
- ModelNode valueNode = node.get(propertyName);
- if (valueNode == null) {
- return null;
- }
- String value = valueNode.toString();
- if (value == null
- || valueNode.getType() != ModelType.BOOLEAN) {
- return null;
- }
- return Boolean.valueOf(value);
- }
-
- public static ModelNode execute(Operation operation, ModelControllerClient client) throws DeployerException {
- try {
- ModelNode result = client.execute(operation);
- if (result.hasDefined(OUTCOME)
- && SUCCESS.equals(result.get("outcome").asString())) {
- return result.get(RESULT);
- }
- else if (result.hasDefined(FAILURE_DESCRIPTION)) {
- throw new DeployerException(result.get(FAILURE_DESCRIPTION).toString());
- }
- else {
- throw new DeployerException("Operation outcome is " + result.get(OUTCOME).asString());
- }
- } catch (IOException e) {
- throw new DeployerException(e);
- }
- }
-}
Deleted: trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossManager.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossManager.java 2011-04-21 20:46:53 UTC (rev 30730)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.management.as7/src/org/jboss/ide/eclipse/as/management/as7/deployment/JBossManager.java 2011-04-21 21:03:47 UTC (rev 30731)
@@ -1,253 +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.as.management.as7.deployment;
-
-import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.ADDRESS;
-import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.DEPLOYMENT;
-import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.ENABLED;
-import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.FAILURE_DESCRIPTION;
-import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.OP;
-import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.READ_RESOURCE_OPERATION;
-import static org.jboss.ide.eclipse.as.management.as7.deployment.ModelDescriptionConstants.RESULT;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.text.MessageFormat;
-import java.util.concurrent.Future;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.jboss.as.controller.client.ModelControllerClient;
-import org.jboss.as.controller.client.helpers.standalone.DeploymentAction;
-import org.jboss.as.controller.client.helpers.standalone.DeploymentPlanBuilder;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentActionResult;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentPlanResult;
-import org.jboss.as.protocol.StreamUtils;
-import org.jboss.dmr.ModelNode;
-import org.jboss.ide.eclipse.as.management.as7.Activator;
-
-/**
- * @author André Dietisheim
- */
-public class JBossManager {
-
- private ModelControllerClient client;
- private ServerDeploymentManager manager;
-
- public JBossManager(String host, int port) throws UnknownHostException {
- this.client = ModelControllerClient.Factory.create(host, port);
- this.manager = ServerDeploymentManager.Factory.create(client);
- }
-
- public DeploymentPlanResult undeploySync(String name, IProgressMonitor monitor) throws DeployerException {
- DeploymentPlanResult result = undeploy(name);
- result.getStatus();
- return result;
- }
-
- public DeploymentPlanResult deploySync(String name, File file, IProgressMonitor monitor) throws DeployerException {
- DeploymentPlanResult result = deploy(name, file);
- result.getStatus();
- return result;
- }
-
- public DeploymentPlanResult undeploy(String name) throws DeployerException {
- try {
- DeploymentPlanBuilder builder = manager.newDeploymentPlan();
- builder = builder.undeploy(name).andRemoveUndeployed();
- return new DeploymentPlanResult(builder.getLastAction(), manager.execute(builder.build()));
- } catch (Exception e) {
- throw new DeployerException(e);
- }
- }
-
- public DeploymentPlanResult remove(String name) throws DeployerException {
- try {
- DeploymentPlanBuilder builder = manager.newDeploymentPlan();
- builder = builder.remove(name);
- return new DeploymentPlanResult(builder.getLastAction(), manager.execute(builder.build()));
- } catch (Exception e) {
- throw new DeployerException(e);
- }
- }
-
- public DeploymentPlanResult deploy(File file) throws DeployerException {
- return deploy(file.getName(), file);
- }
-
- public DeploymentPlanResult add(String name, File file) throws DeployerException {
- try {
- return execute(manager.newDeploymentPlan().add(name, file));
- } catch (IOException e) {
- throw new DeployerException(e);
- }
- }
-
- public DeploymentPlanResult deploy(String name, File file) throws DeployerException {
- try {
- return execute(manager.newDeploymentPlan().add(name, file).andDeploy());
- } catch (IOException e) {
- throw new DeployerException(e);
- }
- }
-
- public DeploymentPlanResult replace(File file) throws DeployerException {
- return replace(file.getName(), file);
- }
-
- public DeploymentPlanResult replace(String name, File file) throws DeployerException {
- try {
- return execute(manager.newDeploymentPlan().replace(name, file));
- } catch (IOException e) {
- throw new DeployerException(e);
- }
- }
-
- public DeploymentState getDeploymentState(String name) throws DeployerException {
- ModelNode request = new ModelNode();
- request.get(OP).set(READ_RESOURCE_OPERATION);
- request.get(ADDRESS).add(DEPLOYMENT, name);
- ModelNode result = execute(request);
- return DeploymentState.getForResultNode(result);
- }
-
- public void dispose() {
- StreamUtils.safeClose(client);
- }
-
- private ModelNode execute(ModelNode node) throws DeployerException {
- try {
- ModelNode response = client.execute(node);
- if (!JBossManagementUtil.isSuccess(response)) {
- throw new DeployerException(
- MessageFormat.format("Could not execute {0} for {1}. Failure was {2}.", node.get(OP), node.get(ADDRESS), response.get(FAILURE_DESCRIPTION)));
- }
- return response.get(RESULT);
- } catch (Exception e) {
- throw new DeployerException(e);
- }
- }
-
- private DeploymentPlanResult execute(DeploymentPlanBuilder builder) throws DeployerException {
- try {
- DeploymentAction action = builder.getLastAction();
- Future<ServerDeploymentPlanResult> planResult = manager.execute(builder.build());
- return new DeploymentPlanResult(action, planResult);
- } catch (Exception e) {
- throw new DeployerException(e);
- }
- }
-
- public static class DeploymentPlanResult {
-
- private Future<ServerDeploymentPlanResult> planResult;
- private DeploymentAction action;
-
- public DeploymentPlanResult(DeploymentAction action, Future<ServerDeploymentPlanResult> planResult) {
- Assert.isNotNull(action);
- this.action = action;
- Assert.isNotNull(planResult);
- this.planResult = planResult;
- }
-
- public IStatus getStatus() throws DeployerException {
- try {
- ServerDeploymentActionResult actionResult = planResult.get().getDeploymentActionResult(action.getId());
- return createStatus(action.getDeploymentUnitUniqueName(), action.getType().name(), actionResult);
- } catch (Exception e) {
- throw new DeployerException(e);
- }
- }
-
- private IStatus createStatus(String deploymentName, String actionName, 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}",
- actionName, deploymentName);
- break;
- case EXECUTED:
- status = Status.OK_STATUS;
- break;
- case FAILED:
- status = createStatus(IStatus.ERROR, "The operation {0} failed for unit {1}",
- actionName, deploymentName);
- break;
- case ROLLED_BACK:
- status = createStatus(IStatus.ERROR, "The operation {0} for unit {1} was rolled back",
- actionName, deploymentName);
- 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",
- actionName, deploymentName);
- break;
- }
- return status;
- }
-
- private IStatus createStatus(int severity, String messagePattern, Object... messageArguments) {
- return new Status(severity, Activator.getContext().getBundle().getSymbolicName(), MessageFormat.format(
- messagePattern, messageArguments));
- }
- }
-
- public enum DeploymentState {
- ENABLEDSTATE {
- protected boolean matches(boolean enabled) {
- return enabled == true;
- }
- },
- DISABLEDSTATE {
- protected boolean matches(boolean enabled) {
- return enabled == false;
- }
- };
-
- public static DeploymentState getForResultNode(ModelNode resultNode) {
- Boolean enabled = JBossManagementUtil.getBooleanProperty(ENABLED, resultNode);
- if (enabled == null) {
- return null;
- }
-
- DeploymentState matchingState = null;
- for(DeploymentState state : values()) {
- if (state.matches(enabled)) {
- matchingState = state;
- }
- }
- return matchingState;
- }
-
- protected abstract boolean matches(boolean enabled);
-
- }
-}
14 years, 11 months
JBoss Tools SVN: r30730 - trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/rules.
by jbosstools-commits@lists.jboss.org
Author: bbrodt
Date: 2011-04-21 16:46:53 -0400 (Thu, 21 Apr 2011)
New Revision: 30730
Modified:
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/rules/ProcessValidator.java
Log:
https://issues.jboss.org/browse/JBIDE-8775
minor change to ProcessValidator
Modified: trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/rules/ProcessValidator.java
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/rules/ProcessValidator.java 2011-04-21 20:46:25 UTC (rev 30729)
+++ trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/rules/ProcessValidator.java 2011-04-21 20:46:53 UTC (rev 30730)
@@ -361,10 +361,10 @@
// implemented missing code
public void CheckReferencedTypes () {
IProblem problem;
+ Process process = (Process) mModelQuery.lookupProcess(mNode);
for(INode node : fTypeToCheckList) {
- Process process = (Process) mModelQuery.lookupProcess(mNode);
List<Import> conflicts = mModelQuery.findConflictingXSD(process, node);
if (conflicts!=null) {
14 years, 11 months