[jboss-cvs] JBossAS SVN: r101715 - in projects/jboss-deployers/trunk: deployers-impl/src/main/java/org/jboss/deployers/plugins/classloading and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 2 08:33:52 EST 2010
Author: adrian at jboss.org
Date: 2010-03-02 08:33:52 -0500 (Tue, 02 Mar 2010)
New Revision: 101715
Added:
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/classloading/DeploymentLifeCycle.java
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockDeployer.java
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockDeployerImpl.java
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/ClassLoadingLifeCycleUnitTestCase.java
Modified:
projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/classloading/AbstractDeploymentClassLoaderPolicyModule.java
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/DeployersClassLoadingTestSuite.java
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockClassLoaderDescribeDeployer.java
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockLevelClassLoaderSystemDeployer.java
projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/ClassLoaderDependenciesTest.java
projects/jboss-deployers/trunk/pom.xml
Log:
[JBDEPLOY-247] - Implement ClassLoading LifeCycle callbacks for deployments
Modified: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/classloading/AbstractDeploymentClassLoaderPolicyModule.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/classloading/AbstractDeploymentClassLoaderPolicyModule.java 2010-03-02 13:11:14 UTC (rev 101714)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/classloading/AbstractDeploymentClassLoaderPolicyModule.java 2010-03-02 13:33:52 UTC (rev 101715)
@@ -25,9 +25,9 @@
import org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule;
import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.dependency.spi.Controller;
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.Controller;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.structure.spi.DeploymentUnit;
@@ -121,6 +121,7 @@
this.unit = unit;
ControllerContext context = unit.getTopLevel().getAttachment(ControllerContext.class);
setControllerContext(context);
+ setLifeCycle(createDeploymentLifeCycle());
}
/**
@@ -151,4 +152,14 @@
determineContextName(unit, false);
}
}
+
+ /**
+ * Create the deployment lifecycle
+ *
+ * @return the lifecycle
+ */
+ protected DeploymentLifeCycle createDeploymentLifeCycle()
+ {
+ return new DeploymentLifeCycle(this);
+ }
}
Added: projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/classloading/DeploymentLifeCycle.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/classloading/DeploymentLifeCycle.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-impl/src/main/java/org/jboss/deployers/plugins/classloading/DeploymentLifeCycle.java 2010-03-02 13:33:52 UTC (rev 101715)
@@ -0,0 +1,244 @@
+/*
+ * 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.plugins.classloading;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.jboss.classloading.spi.dependency.LifeCycle;
+import org.jboss.deployers.client.spi.DeployerClientChangeExt;
+import org.jboss.deployers.client.spi.main.MainDeployer;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+
+/**
+ * Our lifecycle
+ */
+public class DeploymentLifeCycle extends LifeCycle
+{
+ /**
+ * Get deployment lifecycles for the lifecycles
+ *
+ * @param lifecycles the lifecycles
+ * @return the lifecycles or null if there are no lifecycles or some of the lifecycles are not for deployments
+ */
+ protected static Set<DeploymentLifeCycle> getDeploymentLifeCycles(LifeCycle[] lifecycles)
+ {
+ if (lifecycles == null || lifecycles.length == 0)
+ return null;
+
+ Set<DeploymentLifeCycle> result = new LinkedHashSet<DeploymentLifeCycle>(lifecycles.length);
+ for (LifeCycle lifecycle : lifecycles)
+ {
+ if (lifecycle == null)
+ throw new IllegalArgumentException("Null lifecycle");
+ if (lifecycle instanceof DeploymentLifeCycle)
+ return null;
+ result.add((DeploymentLifeCycle) lifecycle);
+ }
+ return result;
+ }
+
+ /**
+ * Create a new DeploymentLifeCycle
+ *
+ * @param module the module
+ */
+ public DeploymentLifeCycle(AbstractDeploymentClassLoaderPolicyModule module)
+ {
+ super(module);
+ }
+
+ @Override
+ public AbstractDeploymentClassLoaderPolicyModule getModule()
+ {
+ return (AbstractDeploymentClassLoaderPolicyModule) super.getModule();
+ }
+
+ @Override
+ public void resolve() throws Exception
+ {
+ if (isResolved() == false)
+ getMainDeployer().change(getModule().getDeploymentUnit().getName(), DeploymentStages.CLASSLOADER);
+ }
+
+ @Override
+ public void resolve(LifeCycle... lifecycles) throws Exception
+ {
+ DeployerClientChangeExt changer = getChanger();
+ Set<DeploymentLifeCycle> deploymentLifeCycles = null;
+ if (changer != null)
+ deploymentLifeCycles = getDeploymentLifeCycles(lifecycles);
+ if (deploymentLifeCycles == null)
+ {
+ super.resolve(lifecycles);
+ return;
+ }
+ Set<String> names = new LinkedHashSet<String>(lifecycles.length);
+ for (DeploymentLifeCycle lifeCycle : deploymentLifeCycles)
+ {
+ if (lifeCycle.isResolved() == false)
+ names.add(lifeCycle.getModule().getDeploymentUnit().getName());
+ }
+ if (names.isEmpty() == false)
+ changer.change(DeploymentStages.CLASSLOADER, false, names.toArray(new String[names.size()]));
+ }
+
+ @Override
+ public void unresolve() throws Exception
+ {
+ if (isResolved())
+ getMainDeployer().change(getModule().getDeploymentUnit().getName(), DeploymentStages.DESCRIBE);
+ }
+
+ @Override
+ public void unresolve(LifeCycle... lifecycles) throws Exception
+ {
+ DeployerClientChangeExt changer = getChanger();
+ Set<DeploymentLifeCycle> deploymentLifeCycles = null;
+ if (changer != null)
+ deploymentLifeCycles = getDeploymentLifeCycles(lifecycles);
+ if (deploymentLifeCycles == null)
+ {
+ super.unresolve(lifecycles);
+ return;
+ }
+ Set<String> names = new LinkedHashSet<String>(lifecycles.length);
+ for (DeploymentLifeCycle lifeCycle : deploymentLifeCycles)
+ {
+ if (lifeCycle.isResolved())
+ names.add(lifeCycle.getModule().getDeploymentUnit().getName());
+ }
+ if (names.isEmpty() == false)
+ changer.change(DeploymentStages.DESCRIBE, false, names.toArray(new String[names.size()]));
+ }
+
+ @Override
+ public void bounce() throws Exception
+ {
+ DeployerClientChangeExt changer = getChanger();
+ if (changer == null)
+ throw new IllegalStateException("Don't know how to bounce " + getModule().getDeploymentUnit().getName());
+ changer.bounce(DeploymentStages.DESCRIBE, false, getModule().getDeploymentUnit().getName());
+ }
+
+ @Override
+ public void bounce(LifeCycle... lifecycles) throws Exception
+ {
+ DeployerClientChangeExt changer = getChanger();
+ Set<DeploymentLifeCycle> deploymentLifeCycles = null;
+ if (changer != null)
+ deploymentLifeCycles = getDeploymentLifeCycles(lifecycles);
+ if (deploymentLifeCycles == null)
+ {
+ super.bounce(lifecycles);
+ return;
+ }
+ Set<String> names = new LinkedHashSet<String>(lifecycles.length);
+ for (DeploymentLifeCycle lifeCycle : deploymentLifeCycles)
+ names.add(lifeCycle.getModule().getDeploymentUnit().getName());
+ changer.change(DeploymentStages.DESCRIBE, false, names.toArray(new String[names.size()]));
+ }
+
+ @Override
+ public void start() throws Exception
+ {
+ if (isStarted() == false)
+ getMainDeployer().change(getModule().getDeploymentUnit().getName(), DeploymentStages.INSTALLED);
+ }
+
+ @Override
+ public void start(LifeCycle... lifecycles) throws Exception
+ {
+ DeployerClientChangeExt changer = getChanger();
+ Set<DeploymentLifeCycle> deploymentLifeCycles = null;
+ if (changer != null)
+ deploymentLifeCycles = getDeploymentLifeCycles(lifecycles);
+ if (deploymentLifeCycles == null)
+ {
+ super.start(lifecycles);
+ return;
+ }
+ Set<String> names = new LinkedHashSet<String>(lifecycles.length);
+ for (DeploymentLifeCycle lifeCycle : deploymentLifeCycles)
+ {
+ if (lifeCycle.isStarted() == false)
+ names.add(lifeCycle.getModule().getDeploymentUnit().getName());
+ }
+ if (names.isEmpty() == false)
+ changer.change(DeploymentStages.INSTALLED, false, names.toArray(new String[names.size()]));
+ }
+
+ @Override
+ public void stop() throws Exception
+ {
+ if (isResolved())
+ getMainDeployer().change(getModule().getDeploymentUnit().getName(), DeploymentStages.CLASSLOADER);
+ }
+
+ @Override
+ public void stop(LifeCycle... lifecycles) throws Exception
+ {
+ DeployerClientChangeExt changer = getChanger();
+ Set<DeploymentLifeCycle> deploymentLifeCycles = null;
+ if (changer != null)
+ deploymentLifeCycles = getDeploymentLifeCycles(lifecycles);
+ if (deploymentLifeCycles == null)
+ {
+ super.stop(lifecycles);
+ return;
+ }
+ Set<String> names = new LinkedHashSet<String>(lifecycles.length);
+ for (DeploymentLifeCycle lifeCycle : deploymentLifeCycles)
+ {
+ if (lifeCycle.isResolved())
+ names.add(lifeCycle.getModule().getDeploymentUnit().getName());
+ }
+ if (names.isEmpty() == false)
+ changer.change(DeploymentStages.CLASSLOADER, false, names.toArray(new String[names.size()]));
+ }
+
+ /**
+ * Get the main deployer
+ *
+ * @return the main deployer
+ */
+ protected MainDeployer getMainDeployer()
+ {
+ MainDeployer result = getModule().getDeploymentUnit().getAttachment(MainDeployer.class);
+ if (result == null)
+ throw new IllegalStateException("Unable to access main deployer");
+ return result;
+ }
+
+ /**
+ * Get the change extension
+ *
+ * @return the changer or null if one isn't available
+ */
+ protected DeployerClientChangeExt getChanger()
+ {
+ MainDeployer main = getMainDeployer();
+ if (main instanceof DeployerClientChangeExt)
+ return (DeployerClientChangeExt) main;
+ return null;
+ }
+}
\ No newline at end of file
Modified: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/DeployersClassLoadingTestSuite.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/DeployersClassLoadingTestSuite.java 2010-03-02 13:11:14 UTC (rev 101714)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/DeployersClassLoadingTestSuite.java 2010-03-02 13:33:52 UTC (rev 101715)
@@ -25,7 +25,9 @@
import junit.framework.TestSuite;
import junit.textui.TestRunner;
+import org.jboss.test.deployers.classloading.test.ClassLoadingLifeCycleUnitTestCase;
import org.jboss.test.deployers.classloading.test.MockClassLoaderDependenciesUnitTestCase;
+import org.jboss.test.deployers.classloading.test.ModuleRemoveUnitTestCase;
import org.jboss.test.deployers.classloading.test.SubDeploymentMockClassLoaderUnitTestCase;
import org.jboss.test.deployers.classloading.test.UndeployOrderClassLoaderUnitTestCase;
import org.jboss.test.deployers.classloading.test.MockResourceVisitorDeployerUnitTestCase;
@@ -51,6 +53,8 @@
suite.addTest(UndeployOrderClassLoaderUnitTestCase.suite());
suite.addTest(SubDeploymentMockClassLoaderUnitTestCase.suite());
suite.addTest(MockResourceVisitorDeployerUnitTestCase.suite());
+ suite.addTest(ModuleRemoveUnitTestCase.suite());
+ suite.addTest(ClassLoadingLifeCycleUnitTestCase.suite());
return suite;
}
Modified: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockClassLoaderDescribeDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockClassLoaderDescribeDeployer.java 2010-03-02 13:11:14 UTC (rev 101714)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockClassLoaderDescribeDeployer.java 2010-03-02 13:33:52 UTC (rev 101715)
@@ -21,6 +21,9 @@
*/
package org.jboss.test.deployers.classloading.support;
+import java.util.ArrayList;
+import java.util.List;
+
import org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule;
import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.deployers.plugins.classloading.AbstractClassLoaderDescribeDeployer;
@@ -33,10 +36,47 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class MockClassLoaderDescribeDeployer extends AbstractClassLoaderDescribeDeployer
+public class MockClassLoaderDescribeDeployer extends AbstractClassLoaderDescribeDeployer implements MockDeployer
{
+ public List<String> deployed = new ArrayList<String>();
+ public List<String> undeployed = new ArrayList<String>();
+
protected ClassLoaderPolicyModule createModule(DeploymentUnit unit, ClassLoadingMetaData metaData) throws DeploymentException
{
return new MockDeploymentClassLoaderPolicyModule(unit);
}
+
+ public void internalDeploy(DeploymentUnit unit) throws DeploymentException
+ {
+ deployed.add(unit.getName());
+ super.internalDeploy(unit);
+ }
+
+ public void internalUndeploy(DeploymentUnit unit)
+ {
+ undeployed.add(unit.getName());
+ super.internalUndeploy(unit);
+ }
+
+ public void clear()
+ {
+ deployed.clear();
+ undeployed.clear();
+ }
+
+ public List<String> getDeployed()
+ {
+ return deployed;
+ }
+
+ public List<String> getUnDeployed()
+ {
+ return undeployed;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getClass().getSimpleName();
+ }
}
Added: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockDeployer.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockDeployer.java 2010-03-02 13:33:52 UTC (rev 101715)
@@ -0,0 +1,37 @@
+/*
+* 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.classloading.support;
+
+import java.util.List;
+
+/**
+ * MockDeployer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MockDeployer
+{
+ List<String> getDeployed();
+ List<String> getUnDeployed();
+ void clear();
+}
Added: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockDeployerImpl.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockDeployerImpl.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockDeployerImpl.java 2010-03-02 13:33:52 UTC (rev 101715)
@@ -0,0 +1,80 @@
+/*
+* 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.classloading.support;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * MockDeployer
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MockDeployerImpl extends AbstractRealDeployer implements MockDeployer
+{
+ public List<String> deployed = new ArrayList<String>();
+ public List<String> undeployed = new ArrayList<String>();
+
+ String name;
+
+ public MockDeployerImpl(String name)
+ {
+ this.name = name;
+ }
+
+ public void internalDeploy(DeploymentUnit unit) throws DeploymentException
+ {
+ deployed.add(unit.getName());
+ }
+
+ public void internalUndeploy(DeploymentUnit unit)
+ {
+ undeployed.add(unit.getName());
+ }
+
+ public void clear()
+ {
+ deployed.clear();
+ undeployed.clear();
+ }
+
+ public List<String> getDeployed()
+ {
+ return deployed;
+ }
+
+ public List<String> getUnDeployed()
+ {
+ return undeployed;
+ }
+
+ @Override
+ public String toString()
+ {
+ return name;
+ }
+}
Modified: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockLevelClassLoaderSystemDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockLevelClassLoaderSystemDeployer.java 2010-03-02 13:11:14 UTC (rev 101714)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/support/MockLevelClassLoaderSystemDeployer.java 2010-03-02 13:33:52 UTC (rev 101715)
@@ -34,7 +34,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class MockLevelClassLoaderSystemDeployer extends AbstractLevelClassLoaderSystemDeployer
+public class MockLevelClassLoaderSystemDeployer extends AbstractLevelClassLoaderSystemDeployer implements MockDeployer
{
public List<String> deployed = new ArrayList<String>();
public List<String> undeployed = new ArrayList<String>();
@@ -50,4 +50,26 @@
undeployed.add(unit.getName());
super.undeploy(unit);
}
+
+ public void clear()
+ {
+ deployed.clear();
+ undeployed.clear();
+ }
+
+ public List<String> getDeployed()
+ {
+ return deployed;
+ }
+
+ public List<String> getUnDeployed()
+ {
+ return undeployed;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getClass().getSimpleName();
+ }
}
Modified: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/ClassLoaderDependenciesTest.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/ClassLoaderDependenciesTest.java 2010-03-02 13:11:14 UTC (rev 101714)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/ClassLoaderDependenciesTest.java 2010-03-02 13:33:52 UTC (rev 101715)
@@ -40,7 +40,6 @@
import org.jboss.classloading.spi.version.Version;
import org.jboss.classloading.spi.version.VersionRange;
import org.jboss.deployers.client.spi.DeployerClient;
-import org.jboss.deployers.plugins.classloading.AbstractClassLoaderDescribeDeployer;
import org.jboss.deployers.spi.attachments.MutableAttachments;
import org.jboss.deployers.spi.attachments.PredeterminedManagedObjectAttachments;
import org.jboss.deployers.spi.deployer.Deployer;
@@ -61,6 +60,8 @@
private ClassLoaderSystem system;
+ protected ClassLoading classLoading;
+
public static final String NameA = "A";
public static final String NameB = "B";
@@ -80,7 +81,7 @@
return result;
}
- protected AbstractClassLoaderDescribeDeployer deployer1;
+ protected MockClassLoaderDescribeDeployer deployer1;
protected MockLevelClassLoaderSystemDeployer deployer2;
protected ClassLoaderDependenciesTest(String name)
@@ -219,7 +220,7 @@
protected DeployerClient getMainDeployer(Deployer... deployers)
{
- ClassLoading classLoading = new ClassLoading();
+ classLoading = new ClassLoading();
system = new DefaultClassLoaderSystem();
system.getDefaultDomain().setParentPolicy(ParentPolicy.BEFORE_BUT_JAVA_ONLY);
Added: projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/ClassLoadingLifeCycleUnitTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/ClassLoadingLifeCycleUnitTestCase.java (rev 0)
+++ projects/jboss-deployers/trunk/deployers-impl/src/test/java/org/jboss/test/deployers/classloading/test/ClassLoadingLifeCycleUnitTestCase.java 2010-03-02 13:33:52 UTC (rev 101715)
@@ -0,0 +1,747 @@
+/*
+* 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.classloading.test;
+
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.classloading.spi.dependency.LifeCycle;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+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.classloading.support.MockDeployer;
+import org.jboss.test.deployers.classloading.support.MockDeployerImpl;
+import org.jboss.test.deployers.classloading.support.a.A;
+import org.jboss.test.deployers.classloading.support.b.B;
+
+/**
+ * ClassLoadingLifeCycleUnitTestCase
+ *
+ * TODO test multiples
+ * TODO test non deployment lifecycles
+ * @author adrian at jboss.org
+ */
+public class ClassLoadingLifeCycleUnitTestCase extends ClassLoaderDependenciesTest
+{
+ MockDeployerImpl deployer3 = new MockDeployerImpl("Real");
+
+ public static Test suite()
+ {
+ return new TestSuite(ClassLoadingLifeCycleUnitTestCase.class);
+ }
+
+ public ClassLoadingLifeCycleUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ protected DeployerClient getMainDeployer(Deployer... deployers)
+ {
+ return super.getMainDeployer(deployer3);
+ }
+
+ public void testSmoke() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+ LifeCycle lifeCycle = assertLifeCycle(unit);
+
+ assertDeployed(A);
+ assertUndeployed(NONE);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+
+ clear();
+ assertUndeploy(deployer, deployment);
+ assertDeployed(NONE);
+ assertUndeployed(A);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+ }
+
+ public void testResolve() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+ LifeCycle lifeCycle = assertLifeCycle(unit);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ deployer.change(unit.getName(), DeploymentStages.DESCRIBE);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ clear();
+ lifeCycle.resolve();
+ assertDeployed(NONE, deployer1);
+ assertDeployed(A, deployer2);
+ assertDeployed(NONE, deployer3);
+ assertUndeployed(NONE);
+ assertTrue(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+
+ clear();
+ assertUndeploy(deployer, deployment);
+ assertDeployed(NONE);
+ assertUndeployed(A, deployer1);
+ assertUndeployed(A, deployer2);
+ assertUndeployed(NONE, deployer3);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+ }
+
+ public void testResolveNoMove() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+ LifeCycle lifeCycle = assertLifeCycle(unit);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ deployer.change(unit.getName(), DeploymentStages.CLASSLOADER);
+ assertTrue(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ clear();
+ lifeCycle.resolve();
+ assertDeployed(NONE);
+ assertUndeployed(NONE);
+ assertTrue(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+
+ clear();
+ assertUndeploy(deployer, deployment);
+ assertDeployed(NONE);
+ assertUndeployed(A, deployer1);
+ assertUndeployed(A, deployer2);
+ assertUndeployed(NONE, deployer3);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+ }
+
+ public void testUnresolve() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+ LifeCycle lifeCycle = assertLifeCycle(unit);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ clear();
+ lifeCycle.unresolve();
+ assertDeployed(NONE);
+ assertUndeployed(NONE, deployer1);
+ assertUndeployed(A, deployer2);
+ assertUndeployed(A, deployer3);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ clear();
+ lifeCycle.resolve();
+ assertDeployed(NONE, deployer1);
+ assertDeployed(A, deployer2);
+ assertDeployed(NONE, deployer3);
+ assertUndeployed(NONE);
+ assertTrue(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+
+ clear();
+ lifeCycle.unresolve();
+ assertDeployed(NONE);
+ assertUndeployed(NONE, deployer1);
+ assertUndeployed(A, deployer2);
+ assertUndeployed(NONE, deployer3);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ clear();
+ assertUndeploy(deployer, deployment);
+ assertDeployed(NONE);
+ assertUndeployed(A, deployer1);
+ assertUndeployed(NONE, deployer2);
+ assertUndeployed(NONE, deployer3);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+ }
+
+ public void testUnresolveNoMove() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+ LifeCycle lifeCycle = assertLifeCycle(unit);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ clear();
+ lifeCycle.unresolve();
+ assertDeployed(NONE);
+ assertUndeployed(NONE, deployer1);
+ assertUndeployed(A, deployer2);
+ assertUndeployed(A, deployer3);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ clear();
+ lifeCycle.unresolve();
+ assertDeployed(NONE);
+ assertUndeployed(NONE);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ clear();
+ assertUndeploy(deployer, deployment);
+ assertDeployed(NONE);
+ assertUndeployed(A, deployer1);
+ assertUndeployed(NONE, deployer2);
+ assertUndeployed(NONE, deployer3);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+ }
+
+ public void testStartFromUnResolved() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+ LifeCycle lifeCycle = assertLifeCycle(unit);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ lifeCycle.unresolve();
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ clear();
+ lifeCycle.start();
+ assertDeployed(NONE, deployer1);
+ assertDeployed(A, deployer2);
+ assertDeployed(A, deployer3);
+ assertUndeployed(NONE);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+
+
+ clear();
+ assertUndeploy(deployer, deployment);
+ assertDeployed(NONE);
+ assertUndeployed(A);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+ }
+
+ public void testStartFromResolved() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+ LifeCycle lifeCycle = assertLifeCycle(unit);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ deployer.change(unit.getName(), DeploymentStages.CLASSLOADER);
+ assertTrue(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ clear();
+ lifeCycle.start();
+ assertDeployed(NONE, deployer1);
+ assertDeployed(NONE, deployer2);
+ assertDeployed(A, deployer3);
+ assertUndeployed(NONE);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+
+ clear();
+ assertUndeploy(deployer, deployment);
+ assertDeployed(NONE);
+ assertUndeployed(A);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+ }
+
+ public void testStartNoMove() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+ LifeCycle lifeCycle = assertLifeCycle(unit);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ clear();
+ lifeCycle.start();
+ assertDeployed(NONE);
+ assertUndeployed(NONE);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+
+ clear();
+ assertUndeploy(deployer, deployment);
+ assertDeployed(NONE);
+ assertUndeployed(A);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+ }
+
+ public void testStop() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+ LifeCycle lifeCycle = assertLifeCycle(unit);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ clear();
+ lifeCycle.stop();
+ assertDeployed(NONE);
+ assertUndeployed(NONE, deployer1);
+ assertUndeployed(NONE, deployer2);
+ assertUndeployed(A, deployer3);
+ assertTrue(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+
+ clear();
+ assertUndeploy(deployer, deployment);
+ assertDeployed(NONE);
+ assertUndeployed(A, deployer1);
+ assertUndeployed(A, deployer2);
+ assertUndeployed(NONE, deployer3);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+ }
+
+ public void testStopNoMove() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+ LifeCycle lifeCycle = assertLifeCycle(unit);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ lifeCycle.stop();
+
+ clear();
+ lifeCycle.stop();
+ assertDeployed(NONE);
+ assertUndeployed(NONE);
+ assertTrue(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+
+ clear();
+ assertUndeploy(deployer, deployment);
+ assertDeployed(NONE);
+ assertUndeployed(A, deployer1);
+ assertUndeployed(A, deployer2);
+ assertUndeployed(NONE, deployer3);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+ }
+
+ public void testStopNoMoveWhenUnresolved() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+ LifeCycle lifeCycle = assertLifeCycle(unit);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ lifeCycle.unresolve();
+
+ clear();
+ lifeCycle.stop();
+ assertDeployed(NONE);
+ assertUndeployed(NONE);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ clear();
+ assertUndeploy(deployer, deployment);
+ assertDeployed(NONE);
+ assertUndeployed(A, deployer1);
+ assertUndeployed(NONE, deployer2);
+ assertUndeployed(NONE, deployer3);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+ }
+
+ public void testBounceFromStart() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+ LifeCycle lifeCycle = assertLifeCycle(unit);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ clear();
+ lifeCycle.bounce();
+ assertDeployed(NONE, deployer1);
+ assertDeployed(A, deployer2);
+ assertDeployed(A, deployer3);
+ assertUndeployed(NONE, deployer1);
+ assertUndeployed(A, deployer2);
+ assertUndeployed(A, deployer3);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+
+ clear();
+ assertUndeploy(deployer, deployment);
+ assertDeployed(NONE);
+ assertUndeployed(A);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+ }
+
+ public void testBounceFromResolved() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+ LifeCycle lifeCycle = assertLifeCycle(unit);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ lifeCycle.stop();
+
+ clear();
+ lifeCycle.bounce();
+ assertDeployed(NONE, deployer1);
+ assertDeployed(A, deployer2);
+ assertDeployed(NONE, deployer3);
+ assertUndeployed(NONE, deployer1);
+ assertUndeployed(A, deployer2);
+ assertUndeployed(NONE, deployer3);
+ assertTrue(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+
+ clear();
+ assertUndeploy(deployer, deployment);
+ assertDeployed(NONE);
+ assertUndeployed(A, deployer1);
+ assertUndeployed(A, deployer2);
+ assertUndeployed(NONE, deployer3);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+ }
+
+ public void testBounceFromUnresolved() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+ LifeCycle lifeCycle = assertLifeCycle(unit);
+ assertTrue(lifeCycle.isResolved());
+ assertTrue(lifeCycle.isStarted());
+
+ lifeCycle.unresolve();
+
+ clear();
+ lifeCycle.bounce();
+ assertDeployed(NONE);
+ assertUndeployed(NONE);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+
+ assertNoClassLoader(unit);
+
+ clear();
+ assertUndeploy(deployer, deployment);
+ assertDeployed(NONE);
+ assertUndeployed(A, deployer1);
+ assertUndeployed(NONE, deployer2);
+ assertUndeployed(NONE, deployer3);
+ assertFalse(lifeCycle.isResolved());
+ assertFalse(lifeCycle.isStarted());
+ }
+
+ public void testLazyResolve() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deploymentA = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deploymentA, deploymentA.getName(), null, A.class);
+
+ DeploymentUnit unitA = assertDeploy(deployer, deploymentA);
+ LifeCycle lifeCycleA = assertLifeCycle(unitA);
+ assertTrue(lifeCycleA.isResolved());
+ assertTrue(lifeCycleA.isStarted());
+
+ Deployment deploymentB = createSimpleDeployment(NameB);
+ ClassLoadingMetaData clmdB = addClassLoadingMetaData(deploymentB, deploymentB.getName(), null, B.class);
+ addRequireModule(clmdB, deploymentA.getName(), null);
+
+ DeploymentUnit unitB = assertDeploy(deployer, deploymentB);
+ LifeCycle lifeCycleB = assertLifeCycle(unitB);
+ assertTrue(lifeCycleB.isResolved());
+ assertTrue(lifeCycleB.isStarted());
+
+ ClassLoader clA = unitA.getClassLoader();
+ assertLoadClass(clA, A.class);
+
+ ClassLoader clB = unitB.getClassLoader();
+ assertLoadClass(clB, A.class, clA);
+
+ clear();
+ lifeCycleA.unresolve();
+ assertDeployed(NONE);
+ assertUndeployed(NONE, deployer1);
+ assertUndeployed(BA, deployer2);
+ assertUndeployed(AB, deployer3);
+ assertFalse(lifeCycleA.isResolved());
+ assertFalse(lifeCycleA.isStarted());
+ assertFalse(lifeCycleB.isResolved());
+ assertFalse(lifeCycleB.isStarted());
+
+ clear();
+ lifeCycleA.setLazyResolve(true);
+ lifeCycleB.resolve();
+ assertDeployed(NONE, deployer1);
+ assertDeployed(AB, deployer2);
+ assertDeployed(NONE, deployer3);
+ assertUndeployed(NONE);
+ assertTrue(lifeCycleA.isResolved());
+ assertFalse(lifeCycleA.isStarted());
+ assertTrue(lifeCycleB.isResolved());
+ assertFalse(lifeCycleB.isStarted());
+
+ clA = unitA.getClassLoader();
+ assertLoadClass(clA, A.class);
+
+ clB = unitB.getClassLoader();
+ assertLoadClass(clB, A.class, clA);
+
+ clear();
+ assertUndeploy(deployer, deploymentB);
+ assertUndeploy(deployer, deploymentA);
+ assertDeployed(NONE);
+ assertUndeployed(BA, deployer1);
+ assertUndeployed(BA, deployer2);
+ assertUndeployed(NONE, deployer3);
+ assertFalse(lifeCycleA.isResolved());
+ assertFalse(lifeCycleA.isStarted());
+ assertFalse(lifeCycleB.isResolved());
+ assertFalse(lifeCycleB.isStarted());
+ }
+
+ public void testLazyStart() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deploymentA = createSimpleDeployment(NameA);
+ addClassLoadingMetaData(deploymentA, deploymentA.getName(), null, A.class);
+
+ DeploymentUnit unitA = assertDeploy(deployer, deploymentA);
+ LifeCycle lifeCycleA = assertLifeCycle(unitA);
+ assertTrue(lifeCycleA.isResolved());
+ assertTrue(lifeCycleA.isStarted());
+
+ Deployment deploymentB = createSimpleDeployment(NameB);
+ ClassLoadingMetaData clmdB = addClassLoadingMetaData(deploymentB, deploymentB.getName(), null, B.class);
+ addRequireModule(clmdB, deploymentA.getName(), null);
+
+ DeploymentUnit unitB = assertDeploy(deployer, deploymentB);
+ LifeCycle lifeCycleB = assertLifeCycle(unitB);
+ assertTrue(lifeCycleB.isResolved());
+ assertTrue(lifeCycleB.isStarted());
+
+ clear();
+ lifeCycleA.stop();
+ assertDeployed(NONE);
+ assertUndeployed(NONE, deployer1);
+ assertUndeployed(NONE, deployer2);
+ assertUndeployed(A, deployer3);
+ assertTrue(lifeCycleA.isResolved());
+ assertFalse(lifeCycleA.isStarted());
+ assertTrue(lifeCycleB.isResolved());
+ assertTrue(lifeCycleB.isStarted());
+
+ clear();
+ lifeCycleA.setLazyStart(true);
+ assertDeployed(NONE);
+ assertUndeployed(NONE);
+ assertTrue(lifeCycleA.isResolved());
+ assertFalse(lifeCycleA.isStarted());
+ assertTrue(lifeCycleB.isResolved());
+ assertTrue(lifeCycleB.isStarted());
+
+ clear();
+ ClassLoader clA = unitA.getClassLoader();
+ ClassLoader clB = unitB.getClassLoader();
+ assertLoadClass(clB, A.class, clA);
+ assertDeployed(NONE, deployer1);
+ assertDeployed(NONE, deployer2);
+ assertDeployed(A, deployer3);
+ assertUndeployed(NONE);
+ assertTrue(lifeCycleA.isResolved());
+ assertTrue(lifeCycleA.isStarted());
+ assertTrue(lifeCycleB.isResolved());
+ assertTrue(lifeCycleB.isStarted());
+
+ clear();
+ assertUndeploy(deployer, deploymentB);
+ assertUndeploy(deployer, deploymentA);
+ assertDeployed(NONE);
+ assertUndeployed(BA, deployer1);
+ assertUndeployed(BA, deployer2);
+ assertUndeployed(BA, deployer3);
+ assertFalse(lifeCycleA.isResolved());
+ assertFalse(lifeCycleA.isStarted());
+ assertFalse(lifeCycleB.isResolved());
+ assertFalse(lifeCycleB.isStarted());
+ }
+
+ protected LifeCycle assertLifeCycle(DeploymentUnit unit)
+ {
+ Module module = assertModule(unit);
+ LifeCycle lifeCycle = module.getLifeCycle();
+ assertNotNull(lifeCycle);
+ return lifeCycle;
+ }
+
+ protected Module assertModule(DeploymentUnit unit)
+ {
+ Module module = unit.getAttachment(Module.class);
+ assertNotNull(module);
+ return module;
+ }
+
+ protected void clear()
+ {
+ deployer1.clear();
+ deployer2.clear();
+ deployer3.clear();
+ }
+
+ protected void assertDeployed(List<String> expected)
+ {
+ assertDeployed(expected, deployer1);
+ assertDeployed(expected, deployer2);
+ assertDeployed(expected, deployer3);
+ }
+
+ protected void assertDeployed(List<String> expected, MockDeployer deployer)
+ {
+ assertEquals(deployer.toString(), expected, deployer.getDeployed());
+ }
+
+ protected void assertUndeployed(List<String> expected)
+ {
+ assertUndeployed(expected, deployer1);
+ assertUndeployed(expected, deployer2);
+ assertUndeployed(expected, deployer3);
+ }
+
+ protected void assertUndeployed(List<String> expected, MockDeployer deployer)
+ {
+ assertEquals(deployer.toString(), expected, deployer.getUnDeployed());
+ }
+}
Modified: projects/jboss-deployers/trunk/pom.xml
===================================================================
--- projects/jboss-deployers/trunk/pom.xml 2010-03-02 13:11:14 UTC (rev 101714)
+++ projects/jboss-deployers/trunk/pom.xml 2010-03-02 13:33:52 UTC (rev 101715)
@@ -27,7 +27,7 @@
<version.jboss.man>2.1.1.SP1</version.jboss.man>
<version.jboss.mdr>2.2.0.Alpha1</version.jboss.mdr>
<version.jboss.kernel>2.2.0.Alpha1</version.jboss.kernel>
- <version.jboss.classloader>2.2.0.Alpha3</version.jboss.classloader>
+ <version.jboss.classloader>2.2.0-SNAPSHOT</version.jboss.classloader>
<version.jboss.classloading.spi>5.1.0.SP1</version.jboss.classloading.spi>
<version.jboss.common.core>2.2.17.GA</version.jboss.common.core>
<version.jboss.logging.spi>2.2.0.CR1</version.jboss.logging.spi>
More information about the jboss-cvs-commits
mailing list