[jbosstools-commits] JBoss Tools SVN: r30525 - workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue Apr 12 14:02:50 EDT 2011
Author: adietish
Date: 2011-04-12 14:02:49 -0400 (Tue, 12 Apr 2011)
New Revision: 30525
Added:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeployerException.java
Removed:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Session.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDeployment.java
Modified:
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/StandaloneDeployer.java
Log:
Modified: 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-12 17:48:37 UTC (rev 30524)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Deployable.java 2011-04-12 18:02:49 UTC (rev 30525)
@@ -41,7 +41,7 @@
return name;
}
- public IStatus getStatus() throws DeploymentException {
+ public IStatus getStatus() throws DeployerException {
if (resultFuture == null
|| action == null) {
return null;
@@ -51,7 +51,7 @@
ServerDeploymentActionResult actionResult = result.getDeploymentActionResult(action.getId());
return createStatus(action, actionResult);
} catch (Exception e) {
- throw new DeploymentException(e);
+ throw new DeployerException(e);
}
}
Copied: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeployerException.java (from rev 30467, workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentException.java)
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeployerException.java (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeployerException.java 2011-04-12 18:02:49 UTC (rev 30525)
@@ -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;
+
+/**
+ * @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);
+ }
+
+}
Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeployerException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentException.java 2011-04-12 17:48:37 UTC (rev 30524)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentException.java 2011-04-12 18:02:49 UTC (rev 30525)
@@ -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 DeploymentException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public DeploymentException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public DeploymentException(Throwable cause) {
- super(cause);
- }
-
- public DeploymentException(String message) {
- super(message);
- }
-
-}
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Session.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Session.java 2011-04-12 17:48:37 UTC (rev 30524)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Session.java 2011-04-12 18:02:49 UTC (rev 30525)
@@ -1,55 +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 java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import org.jboss.as.controller.client.ModelControllerClient;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
-import org.jboss.as.protocol.StreamUtils;
-
-/**
- * @author André Dietisheim
- */
-public class Session {
-
- protected ServerDeploymentManager getManager() {
- return manager;
- }
-
- private ModelControllerClient client;
- private ServerDeploymentManager manager;
-
- public Session(String host, int port) throws UnknownHostException {
- this.client = ModelControllerClient.Factory.create(InetAddress.getByName(host), port);
- this.manager = ServerDeploymentManager.Factory.create(client);
- }
-
- public StandaloneDeployment newStandaloneDeployment() {
- return new StandaloneDeployment(this);
- }
-
- public void close() {
- StreamUtils.safeClose(client);
- }
-}
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDeployer.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDeployer.java 2011-04-12 17:48:37 UTC (rev 30524)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDeployer.java 2011-04-12 18:02:49 UTC (rev 30525)
@@ -68,10 +68,14 @@
manager = ServerDeploymentManager.Factory.create(client);
}
- public synchronized void addWarFileDeployment(File file) {
+ public synchronized void addWarDeployment(File file) {
deployments.add(new WarDeployable(file));
}
+ public synchronized void addWarDeployment(String name, File file) {
+ deployments.add(new WarDeployable(name,file));
+ }
+
public synchronized void deploy() throws DuplicateDeploymentNameException, IOException, ExecutionException, InterruptedException, TimeoutException {
DeploymentPlanBuilder builder = manager.newDeploymentPlan();
for (AbstractDeployable deployment : deployments) {
@@ -127,28 +131,36 @@
private abstract class AbstractDeployable{
private boolean deployed;
- private String name;
- public synchronized DeploymentPlanBuilder addDeployment(DeploymentPlanBuilder builder) throws DuplicateDeploymentNameException, IOException, ExecutionException, InterruptedException {
- this.name = getFile().getName();
+ public synchronized DeploymentPlanBuilder addDeployment(DeploymentPlanBuilder builder) throws DuplicateDeploymentNameException, IOException, ExecutionException, InterruptedException {
+ String name = getName();
return builder.add(name, getFile()).deploy(name);
}
public synchronized DeploymentPlanBuilder removeDeployment(DeploymentPlanBuilder builder) {
- if (deployed) {
+ String name = getName();
+ if (deployed) {
return builder.undeploy(name).remove(name);
}
else {
return builder;
}
}
-
+
+ protected abstract String getName();
+
protected abstract File getFile();
}
private class WarDeployable extends AbstractDeployable {
private File file;
+ private String name;
+
+ public WarDeployable(String name, File file) {
+ this(file);
+ this.name = name;
+ }
public WarDeployable(File file) {
this.file = file;
@@ -158,6 +170,15 @@
protected File getFile() {
return file;
}
+
+ @Override
+ protected String getName() {
+ if (name != null) {
+ return name;
+ } else {
+ return file.getName();
+ }
+ }
}
}
Deleted: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDeployment.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDeployment.java 2011-04-12 17:48:37 UTC (rev 30524)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/StandaloneDeployment.java 2011-04-12 18:02:49 UTC (rev 30525)
@@ -1,85 +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;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Future;
-
-import org.jboss.as.controller.client.helpers.standalone.DeploymentPlan;
-import org.jboss.as.controller.client.helpers.standalone.DeploymentPlanBuilder;
-import org.jboss.as.controller.client.helpers.standalone.InitialDeploymentPlanBuilder;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
-import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentPlanResult;
-
-/**
- * @author André Dietisheim
- */
-public class StandaloneDeployment {
-
- public static final long DEFAULT_TIMEOUT = 30 * 1000;
-
- private final List<Deployable> deployables = new ArrayList<Deployable>();
- private long timeout = DEFAULT_TIMEOUT;
- private Session session;
-
- protected StandaloneDeployment(Session session) {
- this.session = session;
- }
-
- public StandaloneDeployment add(String name, File file) {
- deployables.add(new Deployable(name, file, timeout));
- return this;
- }
-
- public StandaloneDeployment add(File file) {
- return add(file.getName(), file);
- }
-
- public StandaloneDeployment setTimeout(long timeout) {
- this.timeout = timeout;
- return this;
- }
-
- public List<Deployable> deploy() throws DeploymentException {
- if (deployables.isEmpty()) {
- throw new DeploymentException("no files to deploy.");
- }
-
- ServerDeploymentManager manager = session.getManager();
- InitialDeploymentPlanBuilder builder = manager.newDeploymentPlan();
- try {
- addToBuilder(deployables, builder);
- DeploymentPlan plan = builder.build();
- Future<ServerDeploymentPlanResult> planResult = manager.execute(plan);
- setResult(planResult, deployables);
- return deployables;
- } catch (Exception e) {
- throw new DeploymentException(e);
- }
- }
-
- private void setResult(Future<ServerDeploymentPlanResult> planResult, List<Deployable> deployables) {
- for (Deployable deployable : deployables) {
- deployable.setResultFuture(planResult);
- }
- }
-
- private void addToBuilder(List<Deployable> deployables, DeploymentPlanBuilder builder) throws IOException {
- for (int i = 0; i < deployables.size(); i++) {
- Deployable deployable = deployables.get(i);
- builder = builder.add(deployable.getName(), deployable.getFile()).andDeploy();
- deployable.setDeploymentAction(builder.getLastAction());
- }
- }
-}
More information about the jbosstools-commits
mailing list