[jboss-cvs] JBossAS SVN: r70169 - in projects/microcontainer/trunk: deployers-client-spi/src/main/org/jboss/deployers/spi/deployer and 19 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 27 05:08:46 EST 2008
Author: adrian at jboss.org
Date: 2008-02-27 05:08:45 -0500 (Wed, 27 Feb 2008)
New Revision: 70169
Added:
projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractLevelClassLoaderSystemDeployer.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/support/MockLevelClassLoaderSystemDeployer.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/SubDeploymentMockClassLoaderUnitTestCase.java
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/sub/
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/sub/META-INF/
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/sub/META-INF/jboss-classloading.xml
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/sub/test-resource-sub-classloader
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/test-resource-top-classloader
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/sub/
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/sub/META-INF/
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/sub/META-INF/empty
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/sub/test-resource-sub-no-classloader
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/test-resource-top-no-classloader
projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/support/TestLevelClassLoaderSystemDeployer.java
projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/NotVFSClassLoaderUnitTestCase.java
projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/SubDeploymentClassLoaderUnitTestCase.java
Removed:
projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractTopLevelClassLoaderSystemDeployer.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/support/MockTopLevelClassLoaderSystemDeployer.java
projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/support/TestTopLevelClassLoaderSystemDeployer.java
Modified:
projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/dependency/policy/ClassLoaderPolicyModule.java
projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/spi/deployer/DeploymentStages.java
projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractClassLoaderDescribeDeployer.java
projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractDeploymentClassLoaderPolicyModule.java
projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/ClassLoadingDefaultDeployer.java
projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/deployers/DeployersImpl.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/DeployersClassLoadingTestSuite.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/ClassLoaderDependenciesTest.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/MockClassLoaderDependenciesUnitTestCase.java
projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/UndeployOrderClassLoaderUnitTestCase.java
projects/microcontainer/trunk/deployers-vfs-spi/.classpath
projects/microcontainer/trunk/deployers-vfs-spi/pom.xml
projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/ClassPathVisitor.java
projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderDescribeDeployer.java
projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/VFSDeploymentClassLoaderPolicyModule.java
projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/bootstrap.xml
projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java
projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/InMemoryClasesUnitTestCase.java
projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/VFSClassLoaderDependenciesTest.java
Log:
[JBMICROCONT-241] - Add support for subdeployment classloaders. The MBeanServer should be set on the ClassLoaderSystem now. Also added new deployment stages for POST_PARSE, PRE_DESCRIBE and PRE_REAL
Modified: projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/dependency/policy/ClassLoaderPolicyModule.java
===================================================================
--- projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/dependency/policy/ClassLoaderPolicyModule.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/classloading/src/main/org/jboss/classloading/spi/dependency/policy/ClassLoaderPolicyModule.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -21,9 +21,11 @@
*/
package org.jboss.classloading.spi.dependency.policy;
+import org.jboss.classloader.plugins.loader.ClassLoaderToLoaderAdapter;
import org.jboss.classloader.spi.ClassLoaderPolicy;
import org.jboss.classloader.spi.ClassLoaderSystem;
import org.jboss.classloader.spi.DelegateLoader;
+import org.jboss.classloader.spi.Loader;
import org.jboss.classloader.spi.ParentPolicy;
import org.jboss.classloading.spi.dependency.Module;
import org.jboss.classloading.spi.dependency.helpers.ClassLoadingMetaDataModule;
@@ -76,8 +78,45 @@
this.system = system;
return result;
}
+
+ /**
+ * Register the classloader policy with a classloader system
+ *
+ * @param system the classloader system
+ * @param parent the parent classloader
+ * @return the classloader
+ */
+ public ClassLoader registerClassLoaderPolicy(ClassLoaderSystem system, ClassLoader parent)
+ {
+ if (system == null)
+ throw new IllegalArgumentException("Null classloader system");
+ if (parent == null)
+ throw new IllegalArgumentException("Null parent");
+ Loader loader = new ClassLoaderToLoaderAdapter(parent);
+ return registerClassLoaderPolicy(system, loader);
+ }
+
/**
+ * Register the classloader policy with a classloader system
+ *
+ * @param system the classloader system
+ * @param loader the parent loader
+ * @return the classloader
+ */
+ public ClassLoader registerClassLoaderPolicy(ClassLoaderSystem system, Loader loader)
+ {
+ if (system == null)
+ throw new IllegalArgumentException("Null classloader system");
+
+ String domainName = getDeterminedDomainName();
+ ParentPolicy parentPolicy = getDeterminedParentPolicy();
+ ClassLoader result = system.registerClassLoaderPolicy(domainName, parentPolicy, loader, getPolicy());
+ this.system = system;
+ return result;
+ }
+
+ /**
* Get the policy
*
* @return the policy
Modified: projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/spi/deployer/DeploymentStages.java
===================================================================
--- projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/spi/deployer/DeploymentStages.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-client-spi/src/main/org/jboss/deployers/spi/deployer/DeploymentStages.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -35,8 +35,14 @@
/** The parse stage - where metadata is read */
DeploymentStage PARSE = new DeploymentStage("Parse", NOT_INSTALLED);
+ /** The post parse stage - where metadata can be fixed up */
+ DeploymentStage POST_PARSE = new DeploymentStage("PostParse", PARSE);
+
+ /** The pre describe stage - where default dependencies metadata can be created */
+ DeploymentStage PRE_DESCRIBE = new DeploymentStage("PreDescribe", POST_PARSE);
+
/** The describe stage - where dependencies are established */
- DeploymentStage DESCRIBE = new DeploymentStage("Describe", PARSE);
+ DeploymentStage DESCRIBE = new DeploymentStage("Describe", PRE_DESCRIBE);
/** The classloader stage - where classloaders are created */
DeploymentStage CLASSLOADER = new DeploymentStage("ClassLoader", DESCRIBE);
@@ -44,8 +50,11 @@
/** The post classloader stage - e.g. aop */
DeploymentStage POST_CLASSLOADER = new DeploymentStage("PostClassLoader", CLASSLOADER);
+ /** The pre real stage - where before real deployments are done */
+ DeploymentStage PRE_REAL = new DeploymentStage("PreReal", POST_CLASSLOADER);
+
/** The real stage - where real deployment processing is done */
- DeploymentStage REAL = new DeploymentStage("Real", POST_CLASSLOADER);
+ DeploymentStage REAL = new DeploymentStage("Real", PRE_REAL);
/** The installed stage - could be used to provide valve in future? */
DeploymentStage INSTALLED = new DeploymentStage("Installed", REAL);
Modified: projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractClassLoaderDescribeDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractClassLoaderDescribeDeployer.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractClassLoaderDescribeDeployer.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -48,7 +48,6 @@
{
super(ClassLoadingMetaData.class);
setStage(DeploymentStages.DESCRIBE);
- setTopLevelOnly(true);
}
/**
@@ -84,6 +83,18 @@
public void deploy(DeploymentUnit unit, ClassLoadingMetaData deployment) throws DeploymentException
{
+ // We only look at non top level deployments that have classloading metadata
+ if (unit.isTopLevel() == false)
+ {
+ if (deployment == null)
+ return;
+
+ // For non top level classloaders, we need to control the domain
+ // since the parent is the deployment classloader
+ deployment.setDomain(unit.getName());
+ }
+
+ // Create the module
ClassLoaderPolicyModule module = createModule(unit, deployment);
if (module != null)
{
Modified: projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractDeploymentClassLoaderPolicyModule.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractDeploymentClassLoaderPolicyModule.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractDeploymentClassLoaderPolicyModule.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -21,6 +21,8 @@
*/
package org.jboss.deployers.plugins.classloading;
+import java.util.Set;
+
import org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule;
import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.dependency.spi.ControllerContext;
@@ -68,10 +70,31 @@
{
if (unit == null)
throw new IllegalArgumentException("Null unit");
- ControllerContext context = unit.getAttachment(ControllerContext.class);
+ ControllerContext context = unit.getTopLevel().getAttachment(ControllerContext.class);
if (context == null)
throw new IllegalStateException("Deployment has no controller context");
- return (String) context.getName();
+
+ // We use the deployment name
+ String contextName = unit.getName();
+
+ // Check to see whether we need to add our name as an alias
+ if (contextName.equals(context.getName()) == false)
+ {
+ Set<Object> aliases = context.getAliases();
+ if (aliases != null && aliases.contains(contextName) == false)
+ {
+ try
+ {
+ context.getController().addAlias(contextName, context.getName());
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error adding deployment alias " + contextName + " to " + context, t);
+ }
+ }
+ }
+
+ return contextName;
}
/**
@@ -84,7 +107,7 @@
{
super(determineClassLoadingMetaData(unit), determineContextName(unit));
this.unit = unit;
- ControllerContext context = unit.getAttachment(ControllerContext.class);
+ ControllerContext context = unit.getTopLevel().getAttachment(ControllerContext.class);
setControllerContext(context);
}
Copied: projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractLevelClassLoaderSystemDeployer.java (from rev 70083, projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractTopLevelClassLoaderSystemDeployer.java)
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractLevelClassLoaderSystemDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractLevelClassLoaderSystemDeployer.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, 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 org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloading.spi.dependency.ClassLoading;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule;
+import org.jboss.deployers.spi.deployer.helpers.AbstractClassLoaderDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * AbstractLevelClassLoaderSystemDeployer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractLevelClassLoaderSystemDeployer extends AbstractClassLoaderDeployer
+{
+ /** The classloading */
+ private ClassLoading classLoading;
+
+ /** The classloader system */
+ private ClassLoaderSystem system;
+
+ /**
+ * Get the classLoading.
+ *
+ * @return the classLoading.
+ */
+ public ClassLoading getClassLoading()
+ {
+ return classLoading;
+ }
+
+ /**
+ * Set the classLoading.
+ *
+ * @param classLoading the classLoading.
+ */
+ public void setClassLoading(ClassLoading classLoading)
+ {
+ this.classLoading = classLoading;
+ }
+
+ /**
+ * Get the system.
+ *
+ * @return the system.
+ */
+ public ClassLoaderSystem getSystem()
+ {
+ return system;
+ }
+
+ /**
+ * Set the system.
+ *
+ * @param system the system.
+ */
+ public void setSystem(ClassLoaderSystem system)
+ {
+ this.system = system;
+ }
+
+ /**
+ * Validate the config
+ */
+ public void create()
+ {
+ if (classLoading == null)
+ throw new IllegalStateException("The classLoading has not been set");
+ if (system == null)
+ throw new IllegalStateException("The system has not been set");
+ }
+
+ public ClassLoader createClassLoader(DeploymentUnit unit) throws Exception
+ {
+ if (classLoading == null)
+ throw new IllegalStateException("The classLoading has not been set");
+ if (system == null)
+ throw new IllegalStateException("The system has not been set");
+
+ Module module = unit.getAttachment(Module.class);
+ if (module == null)
+ {
+ if (isTopLevelOnly())
+ throw new IllegalStateException("No module for top level deployment " + unit.getName());
+ else
+ return unit.getParent().getClassLoader();
+ }
+
+ if (module instanceof ClassLoaderPolicyModule == false)
+ throw new IllegalStateException("Module is not an instance of " + ClassLoaderPolicyModule.class.getName() + " actual=" + module.getClass().getName());
+ ClassLoaderPolicyModule classLoaderPolicyModule = (ClassLoaderPolicyModule) module;
+
+ if (unit.isTopLevel())
+ {
+ // Top level, just create the classloader
+ return classLoaderPolicyModule.registerClassLoaderPolicy(system);
+ }
+ else
+ {
+ // Subdeployment that wants a classloader
+ ClassLoader parentClassLoader = unit.getParent().getClassLoader();
+ return classLoaderPolicyModule.registerClassLoaderPolicy(system, parentClassLoader);
+ }
+ }
+
+ @Override
+ public void removeClassLoader(DeploymentUnit unit) throws Exception
+ {
+ Module module = unit.getAttachment(Module.class);
+ if (module == null)
+ return;
+
+ ClassLoader classLoader = unit.getClassLoader();
+ try
+ {
+ // Remove the classloader
+ system.unregisterClassLoader(classLoader);
+ }
+ finally
+ {
+ cleanup(unit, module);
+ module.reset();
+ }
+ }
+
+ /**
+ * Hook to perform cleanup on destruction of classloaader
+ *
+ * @param unit the deployment unit
+ * @param module the module
+ * @throws Exception for any error
+ */
+ protected void cleanup(DeploymentUnit unit, Module module) throws Exception
+ {
+ }
+}
Deleted: projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractTopLevelClassLoaderSystemDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractTopLevelClassLoaderSystemDeployer.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/AbstractTopLevelClassLoaderSystemDeployer.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -1,224 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2007, Red Hat Middleware LLC, 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 javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloading.spi.RealClassLoader;
-import org.jboss.classloading.spi.dependency.ClassLoading;
-import org.jboss.classloading.spi.dependency.Module;
-import org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule;
-import org.jboss.deployers.spi.deployer.helpers.AbstractTopLevelClassLoaderDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-
-/**
- * AbstractTopLevelClassLoaderSystemDeployer.
- *
- * @author <a href="adrian at jboss.org">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class AbstractTopLevelClassLoaderSystemDeployer extends AbstractTopLevelClassLoaderDeployer
-{
- /** The classloading */
- private ClassLoading classLoading;
-
- /** The classloader system */
- private ClassLoaderSystem system;
-
- /** The MBeanServer */
- private MBeanServer mbeanServer;
-
- /**
- * Get the classLoading.
- *
- * @return the classLoading.
- */
- public ClassLoading getClassLoading()
- {
- return classLoading;
- }
-
- /**
- * Set the classLoading.
- *
- * @param classLoading the classLoading.
- */
- public void setClassLoading(ClassLoading classLoading)
- {
- this.classLoading = classLoading;
- }
-
- /**
- * Get the system.
- *
- * @return the system.
- */
- public ClassLoaderSystem getSystem()
- {
- return system;
- }
-
- /**
- * Set the system.
- *
- * @param system the system.
- */
- public void setSystem(ClassLoaderSystem system)
- {
- this.system = system;
- }
-
- /**
- * Get the mbeanServer.
- *
- * @return the mbeanServer.
- */
- public MBeanServer getMbeanServer()
- {
- return mbeanServer;
- }
-
- /**
- * Set the mbeanServer.
- *
- * @param mbeanServer the mbeanServer.
- */
- public void setMbeanServer(MBeanServer mbeanServer)
- {
- this.mbeanServer = mbeanServer;
- }
-
- @Override
- protected ClassLoader createTopLevelClassLoader(DeploymentUnit unit) throws Exception
- {
- if (classLoading == null)
- throw new IllegalStateException("The classLoading has not been set");
- if (system == null)
- throw new IllegalStateException("The system has not been set");
-
- // No module means no classloader for the deployment, use the deployer's classloader
- Module module = unit.getAttachment(Module.class);
- if (module == null)
- return null;
-
- if (module instanceof ClassLoaderPolicyModule == false)
- throw new IllegalStateException("Module is not an instance of " + ClassLoaderPolicyModule.class.getName() + " actual=" + module.getClass().getName());
- ClassLoaderPolicyModule classLoaderPolicyModule = (ClassLoaderPolicyModule) module;
-
- ClassLoader classLoader = classLoaderPolicyModule.registerClassLoaderPolicy(system);
- try
- {
- registerClassLoaderWithMBeanServer(classLoader);
- }
- catch (Throwable t)
- {
- log.warn("Unable to register classloader with mbeanserver: " + classLoader, t);
- }
- return classLoader;
- }
-
- @Override
- protected void removeTopLevelClassLoader(DeploymentUnit unit) throws Exception
- {
- // No module means no for the deployment classloader
- Module module = unit.getAttachment(Module.class);
- if (module == null)
- return;
-
- ClassLoader classLoader = unit.getClassLoader();
- try
- {
- unregisterClassLoaderFromMBeanServer(classLoader);
- }
- catch (Throwable t)
- {
- log.warn("Unable to unregister classloader from mbeanserver: " + classLoader, t);
- }
-
- try
- {
- // Remove the classloader
- system.unregisterClassLoader(classLoader);
- }
- finally
- {
- cleanup(unit, module);
- module.reset();
- }
- }
-
- /**
- * Register the classloader with the mbeanserver
- *
- * @param classLoader the classloader
- * @throws Exception for any error
- */
- protected void registerClassLoaderWithMBeanServer(ClassLoader classLoader) throws Exception
- {
- if (mbeanServer == null)
- return;
-
- if (classLoader instanceof RealClassLoader == false)
- return;
-
- RealClassLoader jmxClassLoader = (RealClassLoader) classLoader;
- ObjectName name = jmxClassLoader.getObjectName();
- if (mbeanServer.isRegistered(name))
- return;
-
- mbeanServer.registerMBean(classLoader, name);
- }
-
- /**
- * Unregister the classloader from the mbeanserver
- *
- * @param classLoader the classloader
- * @throws Exception for any error
- */
- protected void unregisterClassLoaderFromMBeanServer(ClassLoader classLoader) throws Exception
- {
- if (mbeanServer == null)
- return;
-
- if (classLoader instanceof RealClassLoader == false)
- return;
-
- RealClassLoader jmxClassLoader = (RealClassLoader) classLoader;
- ObjectName name = jmxClassLoader.getObjectName();
- if (mbeanServer.isRegistered(name) == false)
- return;
- mbeanServer.unregisterMBean(name);
- }
-
- /**
- * Hook to perform cleanup on destruction of classloaader
- *
- * @param unit the deployment unit
- * @param module the module
- * @throws Exception for any error
- */
- protected void cleanup(DeploymentUnit unit, Module module) throws Exception
- {
- }
-}
Modified: projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/ClassLoadingDefaultDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/ClassLoadingDefaultDeployer.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/classloading/ClassLoadingDefaultDeployer.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -45,7 +45,7 @@
{
super(ClassLoadingMetaData.class);
setOutput(ClassLoadingMetaData.class);
- setStage(DeploymentStages.DESCRIBE);
+ setStage(DeploymentStages.PRE_DESCRIBE);
setTopLevelOnly(true);
}
Modified: projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/deployers/DeployersImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/deployers/DeployersImpl.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/deployers/DeployersImpl.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -116,9 +116,12 @@
// Add the standard stages
addDeploymentStage(DeploymentStages.NOT_INSTALLED);
addDeploymentStage(DeploymentStages.PARSE);
+ addDeploymentStage(DeploymentStages.POST_PARSE);
+ addDeploymentStage(DeploymentStages.PRE_DESCRIBE);
addDeploymentStage(DeploymentStages.DESCRIBE);
addDeploymentStage(DeploymentStages.CLASSLOADER);
addDeploymentStage(DeploymentStages.POST_CLASSLOADER);
+ addDeploymentStage(DeploymentStages.PRE_REAL);
addDeploymentStage(DeploymentStages.REAL);
addDeploymentStage(DeploymentStages.INSTALLED);
Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/DeployersClassLoadingTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/DeployersClassLoadingTestSuite.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/DeployersClassLoadingTestSuite.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -26,6 +26,8 @@
import junit.textui.TestRunner;
import org.jboss.test.deployers.classloading.test.MockClassLoaderDependenciesUnitTestCase;
+import org.jboss.test.deployers.classloading.test.SubDeploymentMockClassLoaderUnitTestCase;
+import org.jboss.test.deployers.classloading.test.UndeployOrderClassLoaderUnitTestCase;
/**
* Deployers Deployer Test Suite.
@@ -45,6 +47,8 @@
TestSuite suite = new TestSuite("Deployers ClassLoading Tests");
suite.addTest(MockClassLoaderDependenciesUnitTestCase.suite());
+ suite.addTest(UndeployOrderClassLoaderUnitTestCase.suite());
+ suite.addTest(SubDeploymentMockClassLoaderUnitTestCase.suite());
return suite;
}
Copied: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/support/MockLevelClassLoaderSystemDeployer.java (from rev 70083, projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/support/MockTopLevelClassLoaderSystemDeployer.java)
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/support/MockLevelClassLoaderSystemDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/support/MockLevelClassLoaderSystemDeployer.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, 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.test.deployers.classloading.support;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.plugins.classloading.AbstractLevelClassLoaderSystemDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * MockLevelClassLoaderSystemDeployer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MockLevelClassLoaderSystemDeployer extends AbstractLevelClassLoaderSystemDeployer
+{
+ public List<String> deployed = new ArrayList<String>();
+ public List<String> undeployed = new ArrayList<String>();
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ deployed.add(unit.getName());
+ super.deploy(unit);
+ }
+
+ public void undeploy(DeploymentUnit unit)
+ {
+ undeployed.add(unit.getName());
+ super.undeploy(unit);
+ }
+}
Deleted: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/support/MockTopLevelClassLoaderSystemDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/support/MockTopLevelClassLoaderSystemDeployer.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/support/MockTopLevelClassLoaderSystemDeployer.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2007, Red Hat Middleware LLC, 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.test.deployers.classloading.support;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.deployers.plugins.classloading.AbstractTopLevelClassLoaderSystemDeployer;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-
-/**
- * MockTopLevelClassLoaderSystemDeployer.
- *
- * @author <a href="adrian at jboss.org">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class MockTopLevelClassLoaderSystemDeployer extends AbstractTopLevelClassLoaderSystemDeployer
-{
- public List<String> deployed = new ArrayList<String>();
- public List<String> undeployed = new ArrayList<String>();
-
- public void deploy(DeploymentUnit unit) throws DeploymentException
- {
- deployed.add(unit.getName());
- super.deploy(unit);
- }
-
- public void undeploy(DeploymentUnit unit)
- {
- undeployed.add(unit.getName());
- super.undeploy(unit);
- }
-}
Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/ClassLoaderDependenciesTest.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/ClassLoaderDependenciesTest.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/ClassLoaderDependenciesTest.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -39,19 +39,19 @@
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.client.spi.Deployment;
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.structure.spi.DeploymentUnit;
import org.jboss.test.deployers.AbstractDeployerTest;
import org.jboss.test.deployers.classloading.support.MockClassLoaderDescribeDeployer;
-import org.jboss.test.deployers.classloading.support.MockTopLevelClassLoaderSystemDeployer;
+import org.jboss.test.deployers.classloading.support.MockLevelClassLoaderSystemDeployer;
/**
- * ClassLoadersDependencies test.
- *
- * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * ClassLoaderDependenciesTest.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
*/
public abstract class ClassLoaderDependenciesTest extends AbstractDeployerTest
{
@@ -78,7 +78,7 @@
}
protected AbstractClassLoaderDescribeDeployer deployer1;
- protected MockTopLevelClassLoaderSystemDeployer deployer2;
+ protected MockLevelClassLoaderSystemDeployer deployer2;
protected ClassLoaderDependenciesTest(String name)
{
@@ -137,26 +137,25 @@
}
}
- protected static ClassLoadingMetaData addClassLoadingMetaData(Deployment deployment, Version version, Class<?>... packages)
+ protected static ClassLoadingMetaData addClassLoadingMetaData(PredeterminedManagedObjectAttachments deployment, String name, Version version, Class<?>... packages)
{
- return addClassLoadingMetaData(deployment, version, false, packages);
+ return addClassLoadingMetaData(deployment, name, version, false, packages);
}
- protected static ClassLoadingMetaData addClassLoadingMetaData(Deployment deployment, Version version, boolean useVersionOnPackages, Class<?>... packages)
+ protected static ClassLoadingMetaData addClassLoadingMetaData(PredeterminedManagedObjectAttachments deployment, String name, Version version, boolean useVersionOnPackages, Class<?>... packages)
{
- ClassLoadingMetaData classLoadingMetaData = createMetaData(deployment, version, useVersionOnPackages, packages);
+ ClassLoadingMetaData classLoadingMetaData = createMetaData(deployment, name, version, useVersionOnPackages, packages);
addMetaData(deployment, classLoadingMetaData);
return classLoadingMetaData;
}
- protected static ClassLoadingMetaData createMetaData(Deployment deployment, Version version, Class<?>... packages)
+ protected static ClassLoadingMetaData createMetaData(PredeterminedManagedObjectAttachments deployment, String name, Version version, Class<?>... packages)
{
- return createMetaData(deployment, version, false, packages);
+ return createMetaData(deployment, name, version, false, packages);
}
- protected static ClassLoadingMetaData createMetaData(Deployment deployment, Version version, boolean useVersionOnPackages, Class<?>... packages)
+ protected static ClassLoadingMetaData createMetaData(PredeterminedManagedObjectAttachments deployment, String name, Version version, boolean useVersionOnPackages, Class<?>... packages)
{
- String name = deployment.getName();
MockClassLoadingMetaData classLoadingMetaData = new MockClassLoadingMetaData(name, version);
classLoadingMetaData.setPaths(packages);
@@ -212,7 +211,7 @@
deployer1 = new MockClassLoaderDescribeDeployer();
deployer1.setClassLoading(classLoading);
- deployer2 = new MockTopLevelClassLoaderSystemDeployer();
+ deployer2 = new MockLevelClassLoaderSystemDeployer();
deployer2.setClassLoading(classLoading);
deployer2.setSystem(system);
Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/MockClassLoaderDependenciesUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/MockClassLoaderDependenciesUnitTestCase.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/MockClassLoaderDependenciesUnitTestCase.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -54,7 +54,7 @@
DeployerClient deployer = getMainDeployer();
Deployment deployment = createSimpleDeployment(NameA);
- addClassLoadingMetaData(deployment, null, A.class);
+ addClassLoadingMetaData(deployment, deployment.getName(), null, A.class);
DeploymentUnit unit = assertDeploy(deployer, deployment);
@@ -77,7 +77,7 @@
DeployerClient deployer = getMainDeployer();
Deployment deploymentB = createSimpleDeployment(NameB);
- addClassLoadingMetaData(deploymentB, null, B.class);
+ addClassLoadingMetaData(deploymentB, deploymentB.getName(), null, B.class);
DeploymentUnit unitB = assertDeploy(deployer, deploymentB);
ClassLoader clB = unitB.getClassLoader();
@@ -87,7 +87,7 @@
assertEquals(NONE, deployer2.undeployed);
Deployment deploymentA = createSimpleDeployment(NameA);
- ClassLoadingMetaData classLoadingMetaData = addClassLoadingMetaData(deploymentA, null, A.class);
+ ClassLoadingMetaData classLoadingMetaData = addClassLoadingMetaData(deploymentA, deploymentA.getName(), null, A.class);
addRequireModule(classLoadingMetaData, "B", null);
DeploymentUnit unitA = assertDeploy(deployer, deploymentA);
@@ -115,7 +115,7 @@
DeployerClient deployer = getMainDeployer();
Deployment deploymentA = createSimpleDeployment(NameA);
- ClassLoadingMetaData classLoaderMetaData = addClassLoadingMetaData(deploymentA, null, A.class);
+ ClassLoadingMetaData classLoaderMetaData = addClassLoadingMetaData(deploymentA, deploymentA.getName(), null, A.class);
addRequireModule(classLoaderMetaData, "B", null);
DeploymentUnit unitA = addDeployment(deployer, deploymentA);
@@ -125,7 +125,7 @@
assertEquals(NONE, deployer2.undeployed);
Deployment deploymentB = createSimpleDeployment(NameB);
- addClassLoadingMetaData(deploymentB, null, B.class);
+ addClassLoadingMetaData(deploymentB, deploymentB.getName(), null, B.class);
DeploymentUnit unitB = assertDeploy(deployer, deploymentB);
ClassLoader clB = unitB.getClassLoader();
@@ -155,7 +155,7 @@
DeployerClient deployer = getMainDeployer();
Deployment deploymentA = createSimpleDeployment(NameA);
- ClassLoadingMetaData classLoaderMetaData = addClassLoadingMetaData(deploymentA, null, A.class);
+ ClassLoadingMetaData classLoaderMetaData = addClassLoadingMetaData(deploymentA, deploymentA.getName(), null, A.class);
addRequireModule(classLoaderMetaData, "B", null);
DeploymentUnit unitA = addDeployment(deployer, deploymentA);
@@ -165,7 +165,7 @@
assertEquals(NONE, deployer2.undeployed);
Deployment deploymentB = createSimpleDeployment(NameB);
- addClassLoadingMetaData(deploymentB, null, B.class);
+ addClassLoadingMetaData(deploymentB, deploymentB.getName(), null, B.class);
DeploymentUnit unitB = assertDeploy(deployer, deploymentB);
ClassLoader clB = unitB.getClassLoader();
@@ -196,7 +196,7 @@
DeployerClient deployer = getMainDeployer();
Deployment deploymentA = createSimpleDeployment(NameA);
- ClassLoadingMetaData classLoaderMetaData = addClassLoadingMetaData(deploymentA, null, A.class);
+ ClassLoadingMetaData classLoaderMetaData = addClassLoadingMetaData(deploymentA, deploymentA.getName(), null, A.class);
addRequireModule(classLoaderMetaData, "B", null);
DeploymentUnit unitA = addDeployment(deployer, deploymentA);
@@ -206,7 +206,7 @@
assertEquals(NONE, deployer2.undeployed);
Deployment deploymentB = createSimpleDeployment(NameB);
- addClassLoadingMetaData(deploymentB, null, B.class);
+ addClassLoadingMetaData(deploymentB, deploymentB.getName(), null, B.class);
DeploymentUnit unitB = assertDeploy(deployer, deploymentB);
ClassLoader clB = unitB.getClassLoader();
Added: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/SubDeploymentMockClassLoaderUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/SubDeploymentMockClassLoaderUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/SubDeploymentMockClassLoaderUnitTestCase.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -0,0 +1,182 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss 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.Arrays;
+import java.util.List;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+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.structure.ContextInfo;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.test.deployers.classloading.support.a.A;
+import org.jboss.test.deployers.classloading.support.b.B;
+
+/**
+ * SubDeploymentMockClassLoaderUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SubDeploymentMockClassLoaderUnitTestCase extends ClassLoaderDependenciesTest
+{
+ public static Test suite()
+ {
+ return new TestSuite(SubDeploymentMockClassLoaderUnitTestCase.class);
+ }
+
+ public SubDeploymentMockClassLoaderUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testNoSubDeploymentClassLoader() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment("top");
+ addClassLoadingMetaData(deployment, "top", null, A.class);
+
+ addChild(deployment, "sub");
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+
+ DeploymentUnit subDeployment = assertChild(unit, "top/sub");
+ ClassLoader clSub = subDeployment.getClassLoader();
+ assertEquals(cl, clSub);
+ assertLoadClass(clSub, A.class, cl);
+
+ assertUndeploy(deployer, deployment);
+ }
+
+ public void testSubDeploymentClassLoader() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment("top");
+ addClassLoadingMetaData(deployment, "top", null, A.class);
+
+ ContextInfo sub = addChild(deployment, "sub");
+ addClassLoadingMetaData(sub, "top/sub", null, A.class, B.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+
+ assertEquals(Arrays.asList("top", "top/sub"), deployer2.deployed);
+ assertEquals(NONE, deployer2.undeployed);
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+ assertLoadClassFail(cl, B.class);
+
+ DeploymentUnit subDeployment = assertChild(unit, "top/sub");
+ ClassLoader clSub = subDeployment.getClassLoader();
+ assertLoadClass(clSub, A.class, cl);
+ assertLoadClass(clSub, B.class);
+
+ assertUndeploy(deployer, deployment);
+
+ assertEquals(Arrays.asList("top", "top/sub"), deployer2.deployed);
+ assertEquals(Arrays.asList("top/sub", "top"), deployer2.undeployed);
+ }
+
+ public void testMultipleSubDeploymentClassLoader() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment("top");
+ addClassLoadingMetaData(deployment, "top", null, A.class);
+
+ ContextInfo sub1 = addChild(deployment, "sub1");
+ addClassLoadingMetaData(sub1, "top/sub1", null, B.class);
+
+ ContextInfo sub2 = addChild(deployment, "sub2");
+ addClassLoadingMetaData(sub2, "top/sub2", null, B.class);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+ assertLoadClassFail(cl, B.class);
+
+ DeploymentUnit subDeployment1 = assertChild(unit, "top/sub1");
+ ClassLoader clSub1 = subDeployment1.getClassLoader();
+ assertLoadClass(clSub1, A.class, cl);
+ Class<?> bFrom1 = assertLoadClass(clSub1, B.class);
+
+ DeploymentUnit subDeployment2 = assertChild(unit, "top/sub2");
+ ClassLoader clSub2 = subDeployment2.getClassLoader();
+ assertLoadClass(clSub2, A.class, cl);
+ Class<?> bFrom2 = assertLoadClass(clSub2, B.class);
+
+ assertNotSame(clSub1, clSub2);
+ assertNotSame(bFrom1, bFrom2);
+
+ assertUndeploy(deployer, deployment);
+ }
+
+ public void testSubDeploymentClassLoaderParentLast() throws Exception
+ {
+ DeployerClient deployer = getMainDeployer();
+
+ Deployment deployment = createSimpleDeployment("top");
+ addClassLoadingMetaData(deployment, "top", null, A.class);
+
+ ContextInfo sub = addChild(deployment, "sub");
+ ClassLoadingMetaData clmd = addClassLoadingMetaData(sub, "top/sub", null, A.class, B.class);
+ clmd.setJ2seClassLoadingCompliance(false);
+
+ DeploymentUnit unit = assertDeploy(deployer, deployment);
+
+ ClassLoader cl = unit.getClassLoader();
+ assertLoadClass(cl, A.class);
+ assertLoadClassFail(cl, B.class);
+
+ DeploymentUnit subDeployment = assertChild(unit, "top/sub");
+ ClassLoader clSub = subDeployment.getClassLoader();
+ assertLoadClass(clSub, A.class);
+ assertLoadClass(clSub, B.class);
+
+ assertUndeploy(deployer, deployment);
+
+ assertEquals(Arrays.asList("top", "top/sub"), deployer2.deployed);
+ assertEquals(Arrays.asList("top/sub", "top"), deployer2.undeployed);
+ }
+
+ protected DeploymentUnit assertChild(DeploymentUnit parent, String name)
+ {
+ List<DeploymentUnit> children = parent.getChildren();
+ for (DeploymentUnit child : children)
+ {
+ if (name.equals(child.getSimpleName()))
+ return child;
+ }
+ throw new AssertionFailedError("Child " + name + " not found in " + children);
+ }
+}
Modified: projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/UndeployOrderClassLoaderUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/UndeployOrderClassLoaderUnitTestCase.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-impl/src/tests/org/jboss/test/deployers/classloading/test/UndeployOrderClassLoaderUnitTestCase.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -57,16 +57,16 @@
Version v2 = Version.parseVersion("2");
Deployment ad = createSimpleDeployment("A");
- addClassLoadingMetaData(ad, v1, true, A.class);
+ addClassLoadingMetaData(ad, ad.getName(), v1, true, A.class);
assertDeploy(mainDeployer, ad);
Deployment bd = createSimpleDeployment("B");
- addClassLoadingMetaData(bd, v2, true, B.class);
+ addClassLoadingMetaData(bd, bd.getName(), v2, true, B.class);
assertDeploy(mainDeployer, bd);
mainDeployer.checkComplete(bd);
Deployment cd = createSimpleDeployment("C");
- ClassLoadingMetaData clmd = addClassLoadingMetaData(cd, null);
+ ClassLoadingMetaData clmd = addClassLoadingMetaData(cd, cd.getName(), null);
addRequirePackage(clmd, A.class, new VersionRange(v1, true, v2, true));
addRequirePackage(clmd, B.class, new VersionRange(v1, true, v2, true));
assertDeploy(mainDeployer, cd);
Modified: projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderDescribeDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderDescribeDeployer.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/VFSClassLoaderDescribeDeployer.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -26,7 +26,6 @@
import org.jboss.deployers.plugins.classloading.AbstractClassLoaderDescribeDeployer;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
/**
* VFSClassLoaderDescribeDeployer.
@@ -38,8 +37,6 @@
{
protected ClassLoaderPolicyModule createModule(DeploymentUnit unit, ClassLoadingMetaData metaData) throws DeploymentException
{
- if (unit instanceof VFSDeploymentUnit == false)
- return null;
- return new VFSDeploymentClassLoaderPolicyModule((VFSDeploymentUnit) unit);
+ return new VFSDeploymentClassLoaderPolicyModule(unit);
}
}
Modified: projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/VFSDeploymentClassLoaderPolicyModule.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/VFSDeploymentClassLoaderPolicyModule.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/plugins/classloader/VFSDeploymentClassLoaderPolicyModule.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -33,7 +33,7 @@
import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
import org.jboss.deployers.plugins.classloading.AbstractDeploymentClassLoaderPolicyModule;
import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.helpers.ClassPathVisitor;
import org.jboss.virtual.VirtualFile;
@@ -57,16 +57,10 @@
* @param unit the deployment unit
* @throws IllegalArgumentException for a null deployment unit
*/
- public VFSDeploymentClassLoaderPolicyModule(VFSDeploymentUnit unit)
+ public VFSDeploymentClassLoaderPolicyModule(DeploymentUnit unit)
{
super(unit);
}
-
- @Override
- public VFSDeploymentUnit getDeploymentUnit()
- {
- return (VFSDeploymentUnit) super.getDeploymentUnit();
- }
@Override
protected List<Capability> determineCapabilities()
@@ -115,7 +109,7 @@
if (vfsRoots != null)
return vfsRoots;
- ClassPathVisitor visitor = new ClassPathVisitor();
+ ClassPathVisitor visitor = new ClassPathVisitor(getDeploymentUnit());
try
{
getDeploymentUnit().visit(visitor);
Modified: projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/bootstrap.xml
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/bootstrap.xml 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-vfs/src/resources/tests/bootstrap/bootstrap.xml 2008-02-27 10:08:45 UTC (rev 70169)
@@ -119,7 +119,7 @@
<bean name="ClassLoaderDescribeDeployer" class="org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderDescribeDeployer">
<property name="classLoading"><inject bean="ClassLoading"/></property>
</bean>
- <bean name="ClassLoaderDeployer" class="org.jboss.deployers.plugins.classloading.AbstractTopLevelClassLoaderSystemDeployer">
+ <bean name="ClassLoaderDeployer" class="org.jboss.deployers.plugins.classloading.AbstractLevelClassLoaderSystemDeployer">
<property name="classLoading"><inject bean="ClassLoading"/></property>
<property name="system"><inject bean="ClassLoaderSystem"/></property>
</bean>
Added: projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/sub/META-INF/jboss-classloading.xml
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/sub/META-INF/jboss-classloading.xml (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/sub/META-INF/jboss-classloading.xml 2008-02-27 10:08:45 UTC (rev 70169)
@@ -0,0 +1,3 @@
+<classloading xmlns="urn:jboss:classloading:1.0">
+</classloading>
+
Added: projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/sub/test-resource-sub-classloader
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/sub/test-resource-sub-classloader (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/sub/test-resource-sub-classloader 2008-02-27 10:08:45 UTC (rev 70169)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/test-resource-top-classloader
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/test-resource-top-classloader (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-classloader/test-resource-top-classloader 2008-02-27 10:08:45 UTC (rev 70169)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/sub/META-INF/empty
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/sub/META-INF/empty (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/sub/META-INF/empty 2008-02-27 10:08:45 UTC (rev 70169)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/sub/test-resource-sub-no-classloader
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/sub/test-resource-sub-no-classloader (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/sub/test-resource-sub-no-classloader 2008-02-27 10:08:45 UTC (rev 70169)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Added: projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/test-resource-top-no-classloader
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/test-resource-top-no-classloader (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/resources/tests/classloader/top-sub-no-classloader/test-resource-top-no-classloader 2008-02-27 10:08:45 UTC (rev 70169)
@@ -0,0 +1 @@
+empty
\ No newline at end of file
Modified: projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/ClassLoaderTestSuite.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -27,6 +27,8 @@
import org.jboss.test.deployers.vfs.classloader.test.InMemoryClasesUnitTestCase;
import org.jboss.test.deployers.vfs.classloader.test.ManagedObjectClassLoadingParserUnitTestCase;
import org.jboss.test.deployers.vfs.classloader.test.ManualDependsOnDeploymentClassLoaderUnitTestCase;
+import org.jboss.test.deployers.vfs.classloader.test.NotVFSClassLoaderUnitTestCase;
+import org.jboss.test.deployers.vfs.classloader.test.SubDeploymentClassLoaderUnitTestCase;
import org.jboss.test.deployers.vfs.classloader.test.VFSClassLoaderDependenciesUnitTestCase;
import org.jboss.test.deployers.vfs.classloader.test.VFSUndeployOrderClassLoaderUnitTestCase;
@@ -59,6 +61,8 @@
suite.addTest(ManualDependsOnDeploymentClassLoaderUnitTestCase.suite());
suite.addTest(DeploymentDependsOnDeploymentClassLoaderUnitTestCase.suite());
suite.addTest(ManagedObjectClassLoadingParserUnitTestCase.suite());
+ suite.addTest(SubDeploymentClassLoaderUnitTestCase.suite());
+ suite.addTest(NotVFSClassLoaderUnitTestCase.suite());
return suite;
}
Copied: projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/support/TestLevelClassLoaderSystemDeployer.java (from rev 70083, projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/support/TestTopLevelClassLoaderSystemDeployer.java)
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/support/TestLevelClassLoaderSystemDeployer.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/support/TestLevelClassLoaderSystemDeployer.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, 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.test.deployers.vfs.classloader.support;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.deployers.plugins.classloading.AbstractLevelClassLoaderSystemDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * TestLevelClassLoaderSystemDeployer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestLevelClassLoaderSystemDeployer extends AbstractLevelClassLoaderSystemDeployer
+{
+ public List<String> deployed = new ArrayList<String>();
+ public List<String> undeployed = new ArrayList<String>();
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ deployed.add(unit.getName());
+ super.deploy(unit);
+ }
+
+ public void undeploy(DeploymentUnit unit)
+ {
+ undeployed.add(unit.getName());
+ super.undeploy(unit);
+ }
+}
Deleted: projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/support/TestTopLevelClassLoaderSystemDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/support/TestTopLevelClassLoaderSystemDeployer.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/support/TestTopLevelClassLoaderSystemDeployer.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, 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.test.deployers.vfs.classloader.support;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.deployers.plugins.classloading.AbstractTopLevelClassLoaderSystemDeployer;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-
-/**
- * TestTopLevelClassLoaderSystemDeployer.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class TestTopLevelClassLoaderSystemDeployer extends AbstractTopLevelClassLoaderSystemDeployer
-{
- public List<String> deployed = new ArrayList<String>();
- public List<String> undeployed = new ArrayList<String>();
-
- public void deploy(DeploymentUnit unit) throws DeploymentException
- {
- deployed.add(unit.getName());
- super.deploy(unit);
- }
-
- public void undeploy(DeploymentUnit unit)
- {
- undeployed.add(unit.getName());
- super.undeploy(unit);
- }
-}
Modified: projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/InMemoryClasesUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/InMemoryClasesUnitTestCase.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/InMemoryClasesUnitTestCase.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -39,7 +39,7 @@
import org.jboss.deployers.vfs.plugins.classloader.InMemoryClassesDeployer;
import org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderDescribeDeployer;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.test.deployers.vfs.classloader.support.TestTopLevelClassLoaderSystemDeployer;
+import org.jboss.test.deployers.vfs.classloader.support.TestLevelClassLoaderSystemDeployer;
import org.jboss.test.deployers.vfs.classloader.support.a.A;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.plugins.context.memory.MemoryContextFactory;
@@ -111,7 +111,7 @@
deployer1 = new VFSClassLoaderDescribeDeployer();
deployer1.setClassLoading(classLoading);
- deployer2 = new TestTopLevelClassLoaderSystemDeployer();
+ deployer2 = new TestLevelClassLoaderSystemDeployer();
deployer2.setClassLoading(classLoading);
deployer2.setSystem(system);
Added: projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/NotVFSClassLoaderUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/NotVFSClassLoaderUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/NotVFSClassLoaderUnitTestCase.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, 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.test.deployers.vfs.classloader.test;
+
+import junit.framework.Test;
+
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory;
+import org.jboss.deployers.client.plugins.deployment.AbstractDeployment;
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.client.spi.DeploymentFactory;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.test.deployers.BootstrapDeployersTest;
+
+/**
+ * NotVFSClassLoaderUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class NotVFSClassLoaderUnitTestCase extends BootstrapDeployersTest
+{
+ public static Test suite()
+ {
+ return suite(NotVFSClassLoaderUnitTestCase.class);
+ }
+
+ public NotVFSClassLoaderUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testNotVFSClassLoaderSmokeTest() throws Exception
+ {
+ DeploymentFactory factory = new DeploymentFactory();
+
+ Deployment deployment = new AbstractDeployment("test");
+ factory.addContext(deployment, "");
+
+ DeployerClient main = assertBean("MainDeployer", DeployerClient.class);
+ main.deploy(deployment);
+ try
+ {
+ MainDeployerStructure mds = (MainDeployerStructure) main;
+ DeploymentUnit unit = mds.getDeploymentUnit(deployment.getName());
+ ClassLoader cl = unit.getClassLoader();
+ assertNoResource("a/b/c/test-resource-deployment5", cl);
+ }
+ finally
+ {
+ main.undeploy(deployment);
+ }
+ }
+
+ public void testVFSClassLoaderDependsOnVFS() throws Exception
+ {
+ DeploymentFactory factory = new DeploymentFactory();
+
+ VFSDeploymentUnit unit5 = assertDeploy("/classloader", "deployment5");
+ try
+ {
+ ClassLoader cl5 = getClassLoader(unit5);
+ assertGetResource("a/b/c/test-resource-deployment5", cl5);
+
+ Deployment deployment = new AbstractDeployment("test");
+ factory.addContext(deployment, "");
+ ClassLoadingMetaDataFactory clmdf = ClassLoadingMetaDataFactory.getInstance();
+ ClassLoadingMetaData clmd = new ClassLoadingMetaData();
+ clmd.getRequirements().addRequirement(clmdf.createRequireModule("test5"));
+ ((MutableAttachments) deployment.getPredeterminedManagedObjects()).addAttachment(ClassLoadingMetaData.class, clmd);
+
+ DeployerClient main = assertBean("MainDeployer", DeployerClient.class);
+ main.deploy(deployment);
+ try
+ {
+ MainDeployerStructure mds = (MainDeployerStructure) main;
+ DeploymentUnit unit = mds.getDeploymentUnit(deployment.getName());
+ ClassLoader cl = unit.getClassLoader();
+ assertGetResource("a/b/c/test-resource-deployment5", cl);
+ }
+ finally
+ {
+ main.undeploy(deployment);
+ }
+ }
+ finally
+ {
+ undeploy(unit5);
+ }
+ }
+}
Added: projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/SubDeploymentClassLoaderUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/SubDeploymentClassLoaderUnitTestCase.java (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/SubDeploymentClassLoaderUnitTestCase.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, 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.test.deployers.vfs.classloader.test;
+
+import java.util.List;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.test.deployers.BootstrapDeployersTest;
+
+/**
+ * DeploymentDependsOnManualClassLoaderUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SubDeploymentClassLoaderUnitTestCase extends BootstrapDeployersTest
+{
+ public static Test suite()
+ {
+ return suite(SubDeploymentClassLoaderUnitTestCase.class);
+ }
+
+ public SubDeploymentClassLoaderUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testNoSubDeploymentClassLoader() throws Exception
+ {
+ VFSDeploymentUnit top = assertDeploy("/classloader", "top-sub-no-classloader");
+ try
+ {
+ ClassLoader clTop = getClassLoader(top);
+ assertGetResource("test-resource-top-no-classloader", clTop);
+ assertGetResource("test-resource-sub-no-classloader", clTop);
+
+ DeploymentUnit sub = assertChild(top, "sub/");
+ ClassLoader clSub = getClassLoader(sub);
+ assertGetResource("test-resource-top-no-classloader", clSub);
+ assertGetResource("test-resource-sub-no-classloader", clSub);
+
+ assertEquals(clTop, clSub);
+ }
+ finally
+ {
+ undeploy(top);
+ }
+ }
+
+ public void testSubDeploymentClassLoader() throws Exception
+ {
+ VFSDeploymentUnit top = assertDeploy("/classloader", "top-sub-classloader");
+ try
+ {
+ ClassLoader clTop = getClassLoader(top);
+ assertGetResource("test-resource-top-classloader", clTop);
+ assertNoResource("test-resource-sub-classloader", clTop);
+
+ DeploymentUnit sub = assertChild(top, "sub/");
+ ClassLoader clSub = getClassLoader(sub);
+ assertGetResource("test-resource-top-classloader", clSub);
+ assertGetResource("test-resource-sub-classloader", clSub);
+
+ assertNotSame(clTop, clSub);
+ }
+ finally
+ {
+ undeploy(top);
+ }
+ }
+
+ protected DeploymentUnit assertChild(DeploymentUnit parent, String name)
+ {
+ name = parent.getName() + name;
+ List<DeploymentUnit> children = parent.getChildren();
+ for (DeploymentUnit child : children)
+ {
+ if (name.equals(child.getName()))
+ return child;
+ }
+ throw new AssertionFailedError("Child " + name + " not found in " + children);
+ }
+}
Modified: projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/VFSClassLoaderDependenciesTest.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/VFSClassLoaderDependenciesTest.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/classloader/test/VFSClassLoaderDependenciesTest.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -51,7 +51,7 @@
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.test.deployers.BaseDeployersVFSTest;
-import org.jboss.test.deployers.vfs.classloader.support.TestTopLevelClassLoaderSystemDeployer;
+import org.jboss.test.deployers.vfs.classloader.support.TestLevelClassLoaderSystemDeployer;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
@@ -85,7 +85,7 @@
}
protected AbstractClassLoaderDescribeDeployer deployer1;
- protected TestTopLevelClassLoaderSystemDeployer deployer2;
+ protected TestLevelClassLoaderSystemDeployer deployer2;
protected VFSClassLoaderDependenciesTest(String name)
{
@@ -251,7 +251,7 @@
deployer1 = new VFSClassLoaderDescribeDeployer();
deployer1.setClassLoading(classLoading);
- deployer2 = new TestTopLevelClassLoaderSystemDeployer();
+ deployer2 = new TestLevelClassLoaderSystemDeployer();
deployer2.setClassLoading(classLoading);
deployer2.setSystem(system);
Modified: projects/microcontainer/trunk/deployers-vfs-spi/.classpath
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/.classpath 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-vfs-spi/.classpath 2008-02-27 10:08:45 UTC (rev 70169)
@@ -30,4 +30,5 @@
<classpathentry kind="src" path="/jboss-deployers-structure-spi"/>
<classpathentry kind="src" path="/jboss-dependency"/>
<classpathentry kind="src" path="/jboss-deployers-core"/>
+ <classpathentry kind="src" path="/jboss-classloading"/>
</classpath>
\ No newline at end of file
Modified: projects/microcontainer/trunk/deployers-vfs-spi/pom.xml
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/pom.xml 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-vfs-spi/pom.xml 2008-02-27 10:08:45 UTC (rev 70169)
@@ -34,6 +34,10 @@
<artifactId>jboss-deployers-spi</artifactId>
</dependency>
<dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-classloading</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-common-core</artifactId>
<exclusions>
Modified: projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/ClassPathVisitor.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/ClassPathVisitor.java 2008-02-27 10:00:38 UTC (rev 70168)
+++ projects/microcontainer/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/structure/helpers/ClassPathVisitor.java 2008-02-27 10:08:45 UTC (rev 70169)
@@ -25,6 +25,7 @@
import java.util.List;
import java.util.Set;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.structure.spi.DeploymentUnitVisitor;
@@ -39,10 +40,34 @@
*/
public class ClassPathVisitor implements DeploymentUnitVisitor
{
+ /** The initial deployment unit */
+ private DeploymentUnit initial;
+
/** The full classpath */
private Set<VirtualFile> classPath = new LinkedHashSet<VirtualFile>();
/**
+ * Create a new ClassPathVisitor.
+ */
+ @Deprecated // pass the initial unit to weed subdeployments with their own classloader
+ public ClassPathVisitor()
+ {
+
+ }
+
+ /**
+ * Create a new ClassPathVisitor.
+ *
+ * @param initial the initial unit
+ */
+ public ClassPathVisitor(DeploymentUnit initial)
+ {
+ if (initial == null)
+ throw new IllegalArgumentException("Null initial");
+ this.initial = initial;
+ }
+
+ /**
* Get the full classpath after the visit
*
* @return the full classpath
@@ -56,6 +81,11 @@
{
if (unit instanceof VFSDeploymentUnit == false)
return;
+
+ // This part of the deployment wants its own classloader
+ if (unit != initial && unit.getAttachment(ClassLoadingMetaData.class) != null)
+ return;
+
VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit) unit;
List<VirtualFile> paths = vfsUnit.getClassPath();
if (paths != null)
More information about the jboss-cvs-commits
mailing list