[jboss-cvs] JBossAS SVN: r101336 - in projects/jboss-deployers/trunk: deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Feb 23 11:20:16 EST 2010
Author: adrian at jboss.org
Date: 2010-02-23 11:20:15 -0500 (Tue, 23 Feb 2010)
New Revision: 101336
Added:
projects/jboss-deployers/trunk/deployers-client-spi/src/main/java/org/jboss/deployers/client/spi/DeployerClientChangeExt.java
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/main/test/ChangeExtTestCase.java
projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/DeployersChangeExt.java
Modified:
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/main/MainDeployerImpl.java
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/main/support/TestSimpleDeployer.java
Log:
[JBDEPLOY-226] - DeployerClient Extension to change multiple deployments at the same time.
Added: projects/jboss-deployers/trunk/deployers-client-spi/src/main/java/org/jboss/deployers/client/spi/DeployerClientChangeExt.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-client-spi/src/main/java/org/jboss/deployers/client/spi/DeployerClientChangeExt.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-client-spi/src/main/java/org/jboss/deployers/client/spi/DeployerClientChangeExt.java 2010-02-23 16:20:15 UTC (rev 101336)
@@ -0,0 +1,44 @@
+/*
+ * 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.deployers.client.spi;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStage;
+
+/**
+ * DeployerClient Change Extensions.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface DeployerClientChangeExt
+{
+ /**
+ * Change the state of a number of deployments and check the changes are complete
+ *
+ * @param stage the stage
+ * @param checkComplete whether to check the deployments are complete
+ * @param deploymentNames the deployment names
+ * @throws DeploymentException for any error
+ */
+ void change(DeploymentStage stage, boolean checkComplete, String... deploymentNames) throws DeploymentException;
+}
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java 2010-02-23 15:01:28 UTC (rev 101335)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/deployers/DeployersImpl.java 2010-02-23 16:20:15 UTC (rev 101336)
@@ -22,6 +22,7 @@
package org.jboss.deployers.plugins.deployers;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -57,6 +58,7 @@
import org.jboss.deployers.spi.DeploymentState;
import org.jboss.deployers.spi.deployer.Deployer;
import org.jboss.deployers.spi.deployer.Deployers;
+import org.jboss.deployers.spi.deployer.DeployersChangeExt;
import org.jboss.deployers.spi.deployer.DeploymentStage;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.exceptions.ExceptionNotificationListener;
@@ -78,7 +80,7 @@
* @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision$
*/
-public class DeployersImpl implements Deployers, ControllerContextActions, DeployersImplMBean, MBeanRegistration
+public class DeployersImpl implements Deployers, DeployersChangeExt, ControllerContextActions, DeployersImplMBean, MBeanRegistration
{
/**
* The log
@@ -771,6 +773,144 @@
throw DeploymentException.rethrowAsDeploymentException("Error changing to stage " + stage + " for " + context.getName(), problem);
}
+ public void change(DeploymentStage stage, boolean checkComplete, DeploymentContext... contexts) throws DeploymentException
+ {
+ if (contexts == null)
+ throw new DeploymentException("Null contexts");
+ if (stage == null)
+ throw new DeploymentException("Null stage");
+
+ String stageName = stage.getName();
+ if (stages.containsKey(stage.getName()) == false)
+ throw new DeploymentException("Unknown deployment stage: " + stage);
+ ControllerState requiredState = ControllerState.getInstance(stageName);
+
+ if (contexts.length == 0)
+ return;
+
+ List<DeploymentControllerContext> toRetreat = null;
+ List<DeploymentControllerContext> toAdvance = null;
+
+ boolean trace = log.isTraceEnabled();
+
+ // Work out what we are going to do
+ ControllerStateModel states = controller.getStates();
+ for (DeploymentContext context : contexts)
+ {
+ if (context == null)
+ throw new DeploymentException("Null context in " + Arrays.asList(contexts));
+ DeploymentControllerContext deploymentControllerContext = context.getTransientAttachments().getAttachment(ControllerContext.class.getName(), DeploymentControllerContext.class);
+ if (deploymentControllerContext == null)
+ throw new DeploymentException("Deployment " + context.getName() + " has no deployment controller context");
+ ControllerState current = deploymentControllerContext.getState();
+ if (ControllerState.ERROR.equals(current))
+ {
+ // Ignore contexts in error
+ if (trace)
+ log.trace("Not moving " + deploymentControllerContext + " to state " + requiredState + " it is currently in **ERROR**.");
+ }
+ else
+ {
+ // This is beyond the required state
+ if (states.isAfterState(current, requiredState))
+ {
+ if (toRetreat == null)
+ toRetreat = new ArrayList<DeploymentControllerContext>();
+ toRetreat.add(deploymentControllerContext);
+ }
+ // This needs advancing
+ else if (states.isBeforeState(current, requiredState))
+ {
+ if (toAdvance == null)
+ toAdvance = new ArrayList<DeploymentControllerContext>();
+ toAdvance.add(deploymentControllerContext);
+ }
+ // It is already in the required state
+ else
+ {
+ if (trace)
+ log.trace("Not moving " + deploymentControllerContext + " to state " + requiredState + " it is already there.");
+ }
+ }
+ context.setRequiredStage(stage);
+ }
+
+ checkShutdown();
+
+ // First move those contexts that are beyond the required state
+ if (toRetreat != null)
+ {
+ ListIterator<ControllerState> iter = states.listIteraror();
+ while (iter.hasPrevious())
+ {
+ ControllerState state = iter.previous();
+
+ for (DeploymentControllerContext deploymentControllerContext : toRetreat)
+ {
+ ControllerState current = deploymentControllerContext.getState();
+ if (ControllerState.ERROR.equals(current) == false && states.isAfterState(current, state))
+ {
+ DeploymentContext context = deploymentControllerContext.getDeploymentContext();
+ try
+ {
+ controller.change(deploymentControllerContext, state);
+ }
+ catch (Throwable t)
+ {
+ log.warn("Error during change for " + context, t);
+ context.setState(DeploymentState.ERROR);
+ context.setProblem(t);
+ }
+ }
+ else
+ {
+ if (trace)
+ log.trace("Not moving " + deploymentControllerContext + " to state " + state + " it is at " + current);
+ }
+ }
+ if (requiredState.equals(state))
+ break;
+ }
+ }
+
+ // Now move those contexts that are before the required state
+ if (toAdvance != null)
+ {
+ for (ControllerState state : states)
+ {
+ for (DeploymentControllerContext deploymentControllerContext : toAdvance)
+ {
+ ControllerState current = deploymentControllerContext.getState();
+ if (ControllerState.ERROR.equals(current) == false && states.isBeforeState(current, state))
+ {
+ DeploymentContext context = deploymentControllerContext.getDeploymentContext();
+ try
+ {
+ controller.change(deploymentControllerContext, state);
+ }
+ catch (Throwable t)
+ {
+ log.warn("Error during change for " + context, t);
+ context.setState(DeploymentState.ERROR);
+ context.setProblem(t);
+ }
+ }
+ else
+ {
+ if (trace)
+ log.trace("Not moving " + deploymentControllerContext + " to state " + state + " it is at " + current);
+ }
+ }
+ if (requiredState.equals(state))
+ break;
+ }
+ }
+
+ // Now do any completeness check
+ if (checkComplete)
+ checkComplete(contexts);
+ }
+
public void process(List<DeploymentContext> deploy, List<DeploymentContext> undeploy)
{
boolean trace = log.isTraceEnabled();
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/main/MainDeployerImpl.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/main/MainDeployerImpl.java 2010-02-23 15:01:28 UTC (rev 101335)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/main/MainDeployerImpl.java 2010-02-23 16:20:15 UTC (rev 101336)
@@ -36,11 +36,13 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.jboss.deployers.client.spi.DeployerClientChangeExt;
import org.jboss.deployers.client.spi.Deployment;
import org.jboss.deployers.client.spi.main.MainDeployer;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.DeploymentState;
import org.jboss.deployers.spi.deployer.Deployers;
+import org.jboss.deployers.spi.deployer.DeployersChangeExt;
import org.jboss.deployers.spi.deployer.DeploymentStage;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.managed.ManagedDeploymentCreator;
@@ -63,7 +65,7 @@
* @author <a href="ales.justin at jboss.com">Ales Justin</a>
* @version $Revision$
*/
-public class MainDeployerImpl implements MainDeployer, MainDeployerStructure, MainDeployerInternals
+public class MainDeployerImpl implements MainDeployer, DeployerClientChangeExt, MainDeployerStructure, MainDeployerInternals
{
/** The log */
private static final Logger log = Logger.getLogger(MainDeployerImpl.class);
@@ -744,6 +746,60 @@
}
}
+ public void change(DeploymentStage stage, boolean checkComplete, String... deploymentNames) throws DeploymentException
+ {
+ if (deployers == null)
+ throw new IllegalStateException("No deployers");
+
+ if (deploymentNames == null)
+ throw new IllegalArgumentException("Null deploymentNames");
+ if (deploymentNames.length == 0)
+ return;
+
+ lockRead();
+ try
+ {
+ DeploymentContext[] contexts = new DeploymentContext[deploymentNames.length];
+ for (int i = 0; i < contexts.length; ++i)
+ {
+ String deploymentName = deploymentNames[i];
+ DeploymentContext context = getTopLevelDeploymentContext(deploymentName);
+ if (context == null)
+ throw new DeploymentException("Top level deployment " + deploymentName + " not found");
+ contexts[i] = context;
+ }
+
+ // If we have the extension
+ if (deployers instanceof DeployersChangeExt)
+ {
+ try
+ {
+ ((DeployersChangeExt) deployers).change(stage, checkComplete, contexts);
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ throw DeploymentException.rethrowAsDeploymentException("Error changing contexts " + Arrays.asList(deploymentNames) + " to stage " + stage, t);
+ }
+ }
+ else
+ {
+ // Do it the hard way
+ for (DeploymentContext context : contexts)
+ deployers.change(context, stage);
+ if (checkComplete)
+ deployers.checkComplete(contexts);
+ }
+ }
+ finally
+ {
+ unlockRead();
+ }
+ }
+
public void prepareShutdown()
{
if (deployers != null)
Modified: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/main/support/TestSimpleDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/main/support/TestSimpleDeployer.java 2010-02-23 15:01:28 UTC (rev 101335)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/main/support/TestSimpleDeployer.java 2010-02-23 16:20:15 UTC (rev 101336)
@@ -67,6 +67,12 @@
name = super.toString();
}
+ public TestSimpleDeployer(String name, DeploymentStage stage)
+ {
+ setStage(stage);
+ this.name = name;
+ }
+
public String toString()
{
return name;
Added: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/main/test/ChangeExtTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/main/test/ChangeExtTestCase.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/main/test/ChangeExtTestCase.java 2010-02-23 16:20:15 UTC (rev 101336)
@@ -0,0 +1,324 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2010, Red Hat Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.test.deployers.main.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.DeployerClientChangeExt;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.client.spi.IncompleteDeploymentException;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+import org.jboss.deployers.spi.attachments.PredeterminedManagedObjectAttachments;
+import org.jboss.deployers.spi.deployer.Deployer;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.test.deployers.AbstractDeployerTest;
+import org.jboss.test.deployers.main.support.TestSimpleDeployer;
+
+/**
+ * DeployerClient Change Extension TestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ChangeExtTestCase extends AbstractDeployerTest
+{
+ protected TestSimpleDeployer deployer1 = new TestSimpleDeployer("1", DeploymentStages.PARSE);
+ protected TestSimpleDeployer deployer2 = new TestSimpleDeployer("2", DeploymentStages.DESCRIBE);
+ protected TestSimpleDeployer deployer3 = new TestSimpleDeployer("3", DeploymentStages.CLASSLOADER);
+ protected TestSimpleDeployer deployer4 = new TestSimpleDeployer("4", DeploymentStages.PRE_REAL);
+ protected TestSimpleDeployer deployer5 = new TestSimpleDeployer("5", DeploymentStages.REAL);
+
+ private static ArrayList<String> NOTHING = new ArrayList<String>();
+
+ public ChangeExtTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return suite(ChangeExtTestCase.class);
+ }
+
+ public void testSmoke() throws Throwable
+ {
+ DeployerClient main = getMainDeployer();
+
+ Deployment single = createSimpleDeployment("single");
+ main.deploy(single);
+ List<String> expected = new ArrayList<String>();
+ expected.add(single.getName());
+ assertDeployed(expected);
+ assertUndeployed(NOTHING);
+
+ DeploymentUnit unit = assertDeploymentUnit(main, single.getName());
+ assertEquals(main, unit.getMainDeployer());
+
+ clear();
+ main.undeploy(single);
+ assertNull(unit.getMainDeployer());
+ assertDeployed(NOTHING);
+ assertUndeployed(expected);
+ }
+
+ public void testSimple() throws Throwable
+ {
+ DeployerClient main = getMainDeployer();
+ DeployerClientChangeExt change = getChangeExt(main);
+
+ Deployment single = createSimpleDeployment("single");
+ main.deploy(single);
+ List<String> expected = new ArrayList<String>();
+ expected.add(single.getName());
+ assertDeployed(expected);
+ assertUndeployed(NOTHING);
+
+ DeploymentUnit unit = assertDeploymentUnit(main, single.getName());
+ assertEquals(main, unit.getMainDeployer());
+
+ clear();
+ change.change(deployer1.getStage(), true, single.getName());
+ assertDeployed(NOTHING);
+ assertUndeployed(NOTHING, deployer1);
+ assertUndeployed(expected, deployer2);
+ assertUndeployed(expected, deployer3);
+ assertUndeployed(expected, deployer4);
+ assertUndeployed(expected, deployer5);
+
+ clear();
+ change.change(deployer5.getStage(), true, single.getName());
+ assertDeployed(NOTHING, deployer1);
+ assertDeployed(expected, deployer2);
+ assertDeployed(expected, deployer3);
+ assertDeployed(expected, deployer4);
+ assertDeployed(expected, deployer5);
+ assertUndeployed(NOTHING);
+ }
+
+ public void testNoMove() throws Throwable
+ {
+ DeployerClient main = getMainDeployer();
+ DeployerClientChangeExt change = getChangeExt(main);
+
+ Deployment single = createSimpleDeployment("single");
+ main.deploy(single);
+ List<String> expected = new ArrayList<String>();
+ expected.add(single.getName());
+ assertDeployed(expected);
+ assertUndeployed(NOTHING);
+
+ DeploymentUnit unit = assertDeploymentUnit(main, single.getName());
+ assertEquals(main, unit.getMainDeployer());
+
+ clear();
+ change.change(deployer5.getStage(), true, single.getName());
+ assertDeployed(NOTHING);
+ assertUndeployed(NOTHING);
+
+ clear();
+ change.change(deployer1.getStage(), true, single.getName());
+ clear();
+ change.change(deployer1.getStage(), true, single.getName());
+ assertDeployed(NOTHING);
+ assertUndeployed(NOTHING);
+ }
+
+ public void testError() throws Throwable
+ {
+ DeployerClient main = getMainDeployer();
+ DeployerClientChangeExt change = getChangeExt(main);
+
+ Deployment single = createSimpleDeployment("single");
+ main.deploy(single);
+ List<String> expected = new ArrayList<String>();
+ expected.add(single.getName());
+ assertDeployed(expected);
+ assertUndeployed(NOTHING);
+
+ DeploymentUnit unit = assertDeploymentUnit(main, single.getName());
+ assertEquals(main, unit.getMainDeployer());
+
+ clear();
+ change.change(deployer1.getStage(), true, single.getName());
+ clear();
+ makeFail(single, deployer2);
+ change.change(deployer5.getStage(), false, single.getName());
+ assertDeployed(NOTHING, deployer1);
+ assertDeployed(expected, deployer2);
+ assertDeployed(NOTHING, deployer3);
+ assertDeployed(NOTHING, deployer4);
+ assertDeployed(NOTHING, deployer5);
+ assertUndeployed(expected, deployer1);
+ assertUndeployed(NOTHING, deployer2);
+ assertUndeployed(NOTHING, deployer3);
+ assertUndeployed(NOTHING, deployer4);
+ assertUndeployed(NOTHING, deployer5);
+ }
+
+ public void testCheckComplete() throws Throwable
+ {
+ DeployerClient main = getMainDeployer();
+ DeployerClientChangeExt change = getChangeExt(main);
+
+ Deployment single = createSimpleDeployment("single");
+ main.deploy(single);
+ List<String> expected = new ArrayList<String>();
+ expected.add(single.getName());
+ assertDeployed(expected);
+ assertUndeployed(NOTHING);
+
+ DeploymentUnit unit = assertDeploymentUnit(main, single.getName());
+ assertEquals(main, unit.getMainDeployer());
+
+ clear();
+ change.change(deployer1.getStage(), true, single.getName());
+ clear();
+ makeFail(single, deployer2);
+ try
+ {
+ change.change(deployer5.getStage(), true, single.getName());
+ fail("Should not be here!");
+ }
+ catch (Throwable t)
+ {
+ checkThrowable(IncompleteDeploymentException.class, t);
+ }
+ }
+
+ public void testMultiple() throws Throwable
+ {
+ DeployerClient main = getMainDeployer();
+ DeployerClientChangeExt change = getChangeExt(main);
+
+ Deployment a = createSimpleDeployment("A");
+ main.deploy(a);
+ List<String> A = new ArrayList<String>();
+ A.add(a.getName());
+ Deployment b = createSimpleDeployment("B");
+ main.deploy(b);
+ List<String> B = new ArrayList<String>();
+ B.add(b.getName());
+ List<String> all = new ArrayList<String>();
+ all.add(a.getName());
+ all.add(b.getName());
+ assertDeployed(all);
+ assertUndeployed(NOTHING);
+
+ clear();
+ change.change(deployer1.getStage(), true, a.getName(), b.getName());
+ assertDeployed(NOTHING);
+ assertUndeployed(NOTHING, deployer1);
+ assertUndeployed(all, deployer2);
+ assertUndeployed(all, deployer3);
+ assertUndeployed(all, deployer4);
+ assertUndeployed(all, deployer5);
+
+ clear();
+ change.change(deployer5.getStage(), true, a.getName(), b.getName());
+ assertDeployed(NOTHING, deployer1);
+ assertDeployed(all, deployer2);
+ assertDeployed(all, deployer3);
+ assertDeployed(all, deployer4);
+ assertDeployed(all, deployer5);
+ assertUndeployed(NOTHING);
+
+ clear();
+ change.change(deployer1.getStage(), true, a.getName());
+ assertDeployed(NOTHING);
+ assertUndeployed(NOTHING, deployer1);
+ assertUndeployed(A, deployer2);
+ assertUndeployed(A, deployer3);
+ assertUndeployed(A, deployer4);
+ assertUndeployed(A, deployer5);
+
+ clear();
+ change.change(deployer3.getStage(), true, a.getName(), b.getName());
+ assertDeployed(NOTHING, deployer1);
+ assertDeployed(A, deployer2);
+ assertDeployed(A, deployer3);
+ assertDeployed(NOTHING, deployer4);
+ assertDeployed(NOTHING, deployer5);
+ assertUndeployed(NOTHING, deployer1);
+ assertUndeployed(NOTHING, deployer2);
+ assertUndeployed(NOTHING, deployer3);
+ assertUndeployed(B, deployer4);
+ assertUndeployed(B, deployer5);
+ }
+
+ protected DeployerClient getMainDeployer()
+ {
+ return createMainDeployer(deployer1, deployer2, deployer3, deployer4, deployer5);
+ }
+
+ protected DeployerClientChangeExt getChangeExt(DeployerClient deployerClient)
+ {
+ return assertInstanceOf(deployerClient, DeployerClientChangeExt.class);
+ }
+
+ protected void clear()
+ {
+ deployer1.clear();
+ deployer2.clear();
+ deployer3.clear();
+ deployer4.clear();
+ deployer5.clear();
+ }
+
+ protected static void makeFail(PredeterminedManagedObjectAttachments attachments, Deployer deployer)
+ {
+ MutableAttachments mutable = (MutableAttachments) attachments.getPredeterminedManagedObjects();
+ mutable.addAttachment("fail", deployer);
+ }
+
+ protected void assertDeployed(List<String> expected)
+ {
+ assertDeployed(expected, deployer1);
+ assertDeployed(expected, deployer2);
+ assertDeployed(expected, deployer3);
+ assertDeployed(expected, deployer4);
+ assertDeployed(expected, deployer5);
+ }
+
+ protected void assertDeployed(List<String> expected, TestSimpleDeployer deployer)
+ {
+ assertEquals(deployer.toString(), expected, deployer.getDeployedUnits());
+ }
+
+ protected void assertUndeployed(List<String> expected)
+ {
+ assertUndeployed(expected, deployer1);
+ assertUndeployed(expected, deployer2);
+ assertUndeployed(expected, deployer3);
+ assertUndeployed(expected, deployer4);
+ assertUndeployed(expected, deployer5);
+ }
+
+ protected void assertUndeployed(List<String> expected, TestSimpleDeployer deployer)
+ {
+ assertEquals(deployer.toString(), expected, deployer.getUndeployedUnits());
+ }
+}
Added: projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/DeployersChangeExt.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/DeployersChangeExt.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/DeployersChangeExt.java 2010-02-23 16:20:15 UTC (rev 101336)
@@ -0,0 +1,45 @@
+/*
+ * 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.deployers.spi.deployer;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStage;
+import org.jboss.deployers.structure.spi.DeploymentContext;
+
+/**
+ * Deployers Change Extensions.
+ *
+ * @author <a href="adrian at jboss.org">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface DeployersChangeExt
+{
+ /**
+ * Change the state of a number of deployments and check the changes are complete
+ *
+ * @param stage the stage
+ * @param checkComplete whether to check the deployments are complete
+ * @param contexts the deployment contexts
+ * @throws DeploymentException for any error
+ */
+ void change(DeploymentStage stage, boolean checkComplete, DeploymentContext... contexts) throws DeploymentException;
+}
More information about the jboss-cvs-commits
mailing list