[jbosstools-commits] JBoss Tools SVN: r30564 - in workspace/adietish: org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment and 4 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Apr 13 17:31:08 EDT 2011


Author: rob.stryker at 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 at jboss.com">Kabir Khan</a>
- * @author <a href="adietish at 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 at jboss.com">Kabir Khan</a>
+ * @author <a href="adietish at 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;
 



More information about the jbosstools-commits mailing list