Author: adietish
Date: 2011-04-11 07:04:25 -0400 (Mon, 11 Apr 2011)
New Revision: 30467
Added:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/jboss-threads-2.0.0.CR8-sources.jar
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/DeploymentException.java
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Session.java
Removed:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentBuilderException.java
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentBuilder.java
Log:
added jboss-thread source jar
Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath 2011-04-11 09:54:41
UTC (rev 30466)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment/.classpath 2011-04-11 11:04:25
UTC (rev 30467)
@@ -2,7 +2,7 @@
<classpath>
<classpathentry exported="true" kind="lib"
path="jboss-marshalling-1.3.0.CR8.jar"/>
<classpathentry exported="true" kind="lib"
path="jboss-logging-3.0.0.Beta3.jar"/>
- <classpathentry exported="true" kind="lib"
path="jboss-threads-2.0.0.CR8.jar"/>
+ <classpathentry exported="true" kind="lib"
path="jboss-threads-2.0.0.CR8.jar"
sourcepath="jboss-threads-2.0.0.CR8-sources.jar"/>
<classpathentry exported="true" kind="lib"
path="shrinkwrap-api-1.0.0-alpha-11.jar"/>
<classpathentry exported="true" kind="lib"
path="jboss-dmr-1.0.0.Beta5.jar"/>
<classpathentry exported="true" kind="lib"
path="jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT.jar"
sourcepath="jboss-as-controller-client-7.0.0.Beta3-SNAPSHOT-sources.jar"/>
Added:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/jboss-threads-2.0.0.CR8-sources.jar
===================================================================
(Binary files differ)
Property changes on:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/jboss-threads-2.0.0.CR8-sources.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
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
(rev 0)
+++
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Deployable.java 2011-04-11
11:04:25 UTC (rev 30467)
@@ -0,0 +1,90 @@
+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 DeploymentException {
+ 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 DeploymentException(e);
+ }
+ }
+
+ private IStatus createStatus(DeploymentAction action, ServerDeploymentActionResult
actionResult) {
+ 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
Property changes on:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Deployable.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentBuilder.java
===================================================================
---
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentBuilder.java 2011-04-11
09:54:41 UTC (rev 30466)
+++
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentBuilder.java 2011-04-11
11:04:25 UTC (rev 30467)
@@ -12,24 +12,16 @@
import java.io.File;
import java.io.IOException;
-import java.net.InetAddress;
import java.net.UnknownHostException;
-import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
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.ModelControllerClient;
-import org.jboss.as.controller.client.helpers.standalone.DeploymentAction;
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.ServerDeploymentActionResult;
+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;
-import org.jboss.as.protocol.StreamUtils;
/**
* @author André Dietisheim
@@ -38,14 +30,16 @@
public static final long DEFAULT_TIMEOUT = 15 * 1000;
- private ModelControllerClient client;
- private ServerDeploymentManager manager;
private final List<Deployable> deployables = new ArrayList<Deployable>();
private long timeout = DEFAULT_TIMEOUT;
+ private Session session;
+ public DeploymentBuilder(Session session) {
+ this.session = session;
+ }
+
public DeploymentBuilder(String host, int port) throws UnknownHostException {
- this.client = ModelControllerClient.Factory.create(InetAddress.getByName(host), port);
- this.manager = ServerDeploymentManager.Factory.create(client);
+ this.session = new Session(host, port);
}
public DeploymentBuilder add(String name, File file) {
@@ -62,19 +56,21 @@
return this;
}
- public List<Deployable> deploy() throws DeploymentBuilderException {
+ public List<Deployable> deploy() throws DeploymentException {
if (deployables.isEmpty()) {
- throw new DeploymentBuilderException("no files to deploy.");
+ throw new DeploymentException("no files to deploy.");
}
+ ServerDeploymentManager manager = session.getManager();
+ InitialDeploymentPlanBuilder builder = manager.newDeploymentPlan();
try {
- DeploymentPlanBuilder builder = addToBuilder(deployables,
manager.newDeploymentPlan().withoutRollback());
+ addToBuilder(deployables, builder);
DeploymentPlan plan = builder.build();
Future<ServerDeploymentPlanResult> planResult = manager.execute(plan);
setResult(planResult, deployables);
return deployables;
} catch (Exception e) {
- throw new DeploymentBuilderException(e);
+ throw new DeploymentException(e);
} finally {
cleanup();
}
@@ -86,99 +82,15 @@
}
}
- private DeploymentPlanBuilder addToBuilder(List<Deployable> deployables,
DeploymentPlanBuilder builder)
- throws IOException {
+ 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());
}
- return builder;
}
private void cleanup() {
- StreamUtils.safeClose(client);
+ session.close();
}
-
- public class Deployable {
-
- private String name;
- private File file;
- private Future<ServerDeploymentPlanResult> resultFuture;
- private long timeout;
- private DeploymentAction action;
-
- private Deployable(String name, File file, long timeout) {
- this.name = name;
- this.file = file;
- this.timeout = timeout;
- }
-
- private void setDeploymentAction(DeploymentAction action) {
- this.action = action;
- }
-
- private void setResultFuture(Future<ServerDeploymentPlanResult> resultFuture) {
- this.resultFuture = resultFuture;
- }
-
- public File getFile() {
- return file;
- }
-
- public String getName() {
- return name;
- }
-
- public IStatus getStatus() throws DeploymentBuilderException {
- 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 DeploymentBuilderException(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));
- }
- }
}
Deleted:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentBuilderException.java
===================================================================
---
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentBuilderException.java 2011-04-11
09:54:41 UTC (rev 30466)
+++
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentBuilderException.java 2011-04-11
11:04:25 UTC (rev 30467)
@@ -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 DeploymentBuilderException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public DeploymentBuilderException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public DeploymentBuilderException(Throwable cause) {
- super(cause);
- }
-
- public DeploymentBuilderException(String message) {
- super(message);
- }
-
-}
Copied:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentException.java
(from rev 30454,
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentBuilderException.java)
===================================================================
---
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentException.java
(rev 0)
+++
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentException.java 2011-04-11
11:04:25 UTC (rev 30467)
@@ -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 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);
+ }
+
+}
Property changes on:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/DeploymentException.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Session.java 2011-04-11
11:04:25 UTC (rev 30467)
@@ -0,0 +1,51 @@
+/*
+ * 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 {
+
+ 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 ServerDeploymentManager getManager() {
+ return manager;
+ }
+
+ public void close() {
+ StreamUtils.safeClose(client);
+ }
+}
Property changes on:
workspace/adietish/org.jboss.ide.eclipse.as7.deployment/src/org/jboss/ide/eclipse/as7/deployment/Session.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain