[jboss-cvs] JBossAS SVN: r104426 - in projects/jboss-classpool/trunk: jbosscl and 12 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 4 08:08:40 EDT 2010
Author: kabir.khan at jboss.com
Date: 2010-05-04 08:08:38 -0400 (Tue, 04 May 2010)
New Revision: 104426
Added:
projects/jboss-classpool/trunk/jbosscl-as/
projects/jboss-classpool/trunk/jbosscl-as/pom.xml
projects/jboss-classpool/trunk/jbosscl-as/src/
projects/jboss-classpool/trunk/jbosscl-as/src/main/
projects/jboss-classpool/trunk/jbosscl-as/src/main/java/
projects/jboss-classpool/trunk/jbosscl-as/src/main/java/org/
projects/jboss-classpool/trunk/jbosscl-as/src/main/java/org/jboss/
projects/jboss-classpool/trunk/jbosscl-as/src/main/java/org/jboss/classpool/
projects/jboss-classpool/trunk/jbosscl-as/src/main/java/org/jboss/classpool/plugins/
projects/jboss-classpool/trunk/jbosscl-as/src/main/java/org/jboss/classpool/plugins/jbosscl/
projects/jboss-classpool/trunk/jbosscl-as/src/main/java/org/jboss/classpool/plugins/jbosscl/as/
projects/jboss-classpool/trunk/jbosscl-as/src/main/java/org/jboss/classpool/plugins/jbosscl/as/AbstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/BootstrapParentUnitFinder.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolConfig.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ParentUnitLoaderFinder.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ParentUnitLoaderFinders.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ConfigClassPoolTestCase.java
Modified:
projects/jboss-classpool/trunk/jbosscl/pom.xml
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/DomainRegistry.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/SecurityActions.java
projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/VFSClassLoaderDomainRegistry.java
projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTest.java
projects/jboss-classpool/trunk/pom.xml
Log:
[CLASSPOOL-7] Easy config for AS bootstrap. Move references to AbstractDeploymentClassLoaderPolicyModule to a new jar jboss-classpook-jbosscl-as so it can be picked up once deployers.xml has been deployed
Modified: projects/jboss-classpool/trunk/jbosscl/pom.xml
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/pom.xml 2010-05-04 11:57:29 UTC (rev 104425)
+++ projects/jboss-classpool/trunk/jbosscl/pom.xml 2010-05-04 12:08:38 UTC (rev 104426)
@@ -49,10 +49,6 @@
<artifactId>jboss-vfs</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-impl</artifactId>
- </dependency>
- <dependency>
<groupId>org.jboss.cl</groupId>
<artifactId>jboss-classloading</artifactId>
</dependency>
@@ -73,6 +69,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.kernel</groupId>
<artifactId>jboss-kernel</artifactId>
<scope>test</scope>
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/BootstrapParentUnitFinder.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/BootstrapParentUnitFinder.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/BootstrapParentUnitFinder.java 2010-05-04 12:08:38 UTC (rev 104426)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import org.jboss.classloader.plugins.loader.ClassLoaderToLoaderAdapter;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloading.spi.dependency.Module;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class BootstrapParentUnitFinder implements ParentUnitLoaderFinder
+{
+
+ public ClassLoader findParentUnitLoader(Module module)
+ {
+ ClassLoaderDomain domain = ClassLoaderSystem.getInstance().getDomain(module.getDeterminedDomainName());
+ if (domain.getParent() instanceof ClassLoaderToLoaderAdapter)
+ {
+ ClassLoaderToLoaderAdapter cp2la = (ClassLoaderToLoaderAdapter)domain.getParent();
+ return SecurityActions.getClassLoader(cp2la);
+ }
+ return null;
+ }
+
+ public boolean handle(Module module)
+ {
+ return true;
+ }
+
+}
Modified: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/DomainRegistry.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/DomainRegistry.java 2010-05-04 11:57:29 UTC (rev 104425)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/DomainRegistry.java 2010-05-04 12:08:38 UTC (rev 104426)
@@ -48,4 +48,18 @@
Module getModule(ClassLoader loader);
ClassLoader getClassLoader(Module module);
+
+ public void addCallback(Callback callback);
+
+ public void removeCallback(Callback callback);
+
+ public interface Callback
+ {
+ void validateInitMaps(ClassLoader loader, ClassLoaderDomain loaderDomain, Module module, ClassLoader parentUnitLoader);
+
+ void initMapsDone(ClassLoader loader, ClassLoaderDomain loaderDomain, Module module, ClassLoader parentUnitLoader);
+
+ void cleanupLoaderDone(ClassLoader loader, ClassLoaderDomain loaderDomain, int domainReferences);
+ }
+
}
\ No newline at end of file
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolConfig.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolConfig.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolConfig.java 2010-05-04 12:08:38 UTC (rev 104426)
@@ -0,0 +1,148 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import org.jboss.classloading.spi.dependency.ClassLoading;
+import org.jboss.classpool.scoped.ScopedClassPoolFactory;
+import org.jboss.classpool.spi.ClassPoolRepository;
+
+/**
+ * This sets up the ClassPools in JBoss AS. It gets installed in JBoss AS under
+ * the name 'JBossClClassPoolConfig' and provides the items for other subsystems
+ * used in AS.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBossClClassPoolConfig
+{
+ private static volatile JBossClClassPoolConfig config;
+
+ private final DomainRegistry domainRegistry;
+
+ private final RegisterModuleCallback registerModuleCallback;
+
+ private ClassLoading classLoading;
+
+ private JBossClDelegatingClassPoolFactory classPoolFactory;
+
+ private ClassPoolRepository classPoolRepository;
+
+ private JBossClClassPoolConfig(DomainRegistry domainRegistry, RegisterModuleCallback registerModuleCallback, JBossClDelegatingClassPoolFactory classPoolFactory)
+ {
+ this.domainRegistry = domainRegistry;
+ this.registerModuleCallback = registerModuleCallback;
+ this.classPoolFactory = classPoolFactory;
+ classPoolRepository = ClassPoolRepository.getInstance();
+ classPoolRepository.setClassPoolFactory(classPoolFactory);
+ }
+
+ public static JBossClClassPoolConfig getInstance()
+ {
+ if (config == null)
+ {
+ initialize();
+ }
+ return config;
+ }
+
+ private static synchronized void initialize()
+ {
+ if (config != null)
+ return;
+
+ DomainRegistry domainRegistry = new VFSClassLoaderDomainRegistry();
+ RegisterModuleCallback registerModuleCallback = new RegisterModuleCallback(domainRegistry);
+ JBossClDelegatingClassPoolFactory classPoolFactory = new JBossClDelegatingClassPoolFactory(domainRegistry, registerModuleCallback);
+
+ config = new JBossClClassPoolConfig(domainRegistry, registerModuleCallback, classPoolFactory);
+ }
+
+ /**
+ * Get the domainRegistry
+ * @return the domainRegistry
+ */
+ public DomainRegistry getDomainRegistry()
+ {
+ return domainRegistry;
+ }
+ /**
+ * Get the classLoading
+ * @return the classLoading
+ */
+ public ClassLoading getClassLoading()
+ {
+ return classLoading;
+ }
+
+ /**
+ * Set the classLoading. This should be set via a property
+ * by the MC
+ *
+ * @param cl the classLoading to set
+ */
+ public void setClassLoading(ClassLoading cl)
+ {
+ if (cl != null)
+ cl.addModuleRegistry(registerModuleCallback);
+ else if (classLoading != null)
+ classLoading.removeModuleRegistry(registerModuleCallback);
+
+ classLoading = cl;
+ }
+
+ /**
+ * Get the registerModuleCallback
+ * @return the registerModuleCallback
+ */
+ public RegisterModuleCallback getRegisterModuleCallback()
+ {
+ return registerModuleCallback;
+ }
+
+ /**
+ * Get the classPoolFactory
+ * @return the classPoolFactory
+ */
+ public ScopedClassPoolFactory getClassPoolFactory()
+ {
+ return classPoolFactory;
+ }
+
+ /**
+ * Set the classPoolFactory
+ * @param classPoolFactory the classPoolFactory to set
+ */
+ public void setClassPoolFactory(JBossClDelegatingClassPoolFactory classPoolFactory)
+ {
+ this.classPoolFactory = classPoolFactory;
+ }
+
+ /**
+ * Get the classPoolRepository
+ * @return the classPoolRepository
+ */
+ public ClassPoolRepository getClassPoolRepository()
+ {
+ return classPoolRepository;
+ }
+}
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ParentUnitLoaderFinder.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ParentUnitLoaderFinder.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ParentUnitLoaderFinder.java 2010-05-04 12:08:38 UTC (rev 104426)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import org.jboss.classloading.spi.dependency.Module;
+
+/**
+ * Ab
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ParentUnitLoaderFinder
+{
+ boolean handle(Module module);
+
+ ClassLoader findParentUnitLoader(Module module);
+}
Added: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ParentUnitLoaderFinders.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ParentUnitLoaderFinders.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/ParentUnitLoaderFinders.java 2010-05-04 12:08:38 UTC (rev 104426)
@@ -0,0 +1,92 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl;
+
+import org.jboss.classloading.spi.dependency.ClassLoading;
+import org.jboss.classloading.spi.dependency.Module;
+
+/**
+ * Entry point to determining the parent classloader.
+ *
+ * AbstractDeploymentClassLoaderPolicyModule is only available after deploying deployers.xml in AS
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ParentUnitLoaderFinders
+{
+ private static final ParentUnitLoaderFinders INSTANCE = new ParentUnitLoaderFinders();
+
+ private final ParentUnitLoaderFinder defaultUnitLoaderFinder = new BootstrapParentUnitFinder();
+
+ private volatile ParentUnitLoaderFinder abstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder;
+
+ static ParentUnitLoaderFinders getInstance()
+ {
+ return INSTANCE;
+ }
+
+ ClassLoader findParentUnitLoader(Module module)
+ {
+ if (module == null)
+ throw new IllegalArgumentException("Null module");
+
+ if (abstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder == null)
+ initAbstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder(module);
+
+ if (abstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder != null &&
+ abstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder.handle(module))
+ return abstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder.findParentUnitLoader(module);
+ else
+ return defaultUnitLoaderFinder.findParentUnitLoader(module);
+ }
+
+ private synchronized void initAbstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder(Module module)
+ {
+ if (abstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder == null)
+ {
+ ClassLoader loader = ClassLoading.getClassLoaderForModule(module);
+ Class<?> finder;
+ try
+ {
+ finder = SecurityActions.loadClass(loader, "org.jboss.classpool.plugins.jbosscl.as.AbstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder");
+ }
+ catch (ClassNotFoundException e)
+ {
+ //The loader for this class has not been loaded yet
+ return;
+ }
+ try
+ {
+ abstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder = (ParentUnitLoaderFinder)finder.newInstance();
+ }
+ catch (InstantiationException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+}
Modified: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/SecurityActions.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/SecurityActions.java 2010-05-04 11:57:29 UTC (rev 104425)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/SecurityActions.java 2010-05-04 12:08:38 UTC (rev 104426)
@@ -115,4 +115,52 @@
throw new RuntimeException(e);
}
}
+
+ private interface LoadClassAction
+ {
+ Class<?> loadClass(ClassLoader loader, String name) throws ClassNotFoundException;
+
+ LoadClassAction NON_PRIVILEGED = new LoadClassAction()
+ {
+ public Class<?> loadClass(ClassLoader loader, String name) throws ClassNotFoundException
+ {
+ return loader.loadClass(name);
+ }
+ };
+
+ LoadClassAction PRIVILEGED = new LoadClassAction()
+ {
+
+ public Class<?> loadClass(final ClassLoader loader, final String name) throws ClassNotFoundException
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>()
+ {
+
+ public Class<?> run() throws Exception
+ {
+ return loader.loadClass(name);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ if (e.getCause() instanceof RuntimeException)
+ throw new RuntimeException(e.getCause());
+ if (e.getCause() instanceof ClassNotFoundException)
+ throw (ClassNotFoundException)e.getCause();
+ throw new RuntimeException(e.getCause());
+ }
+ }
+ };
+ }
+
+
+ static Class<?> loadClass(ClassLoader loader, String name) throws ClassNotFoundException
+ {
+ if (System.getSecurityManager() == null)
+ return LoadClassAction.NON_PRIVILEGED.loadClass(loader, name);
+ return LoadClassAction.PRIVILEGED.loadClass(loader, name);
+ }
}
Modified: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/VFSClassLoaderDomainRegistry.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/VFSClassLoaderDomainRegistry.java 2010-05-04 11:57:29 UTC (rev 104425)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/VFSClassLoaderDomainRegistry.java 2010-05-04 12:08:38 UTC (rev 104426)
@@ -26,13 +26,10 @@
import java.util.Map;
import java.util.WeakHashMap;
-import org.jboss.classloader.plugins.loader.ClassLoaderToLoaderAdapter;
import org.jboss.classloader.spi.ClassLoaderDomain;
import org.jboss.classloader.spi.ClassLoaderSystem;
import org.jboss.classloading.spi.dependency.ClassLoading;
import org.jboss.classloading.spi.dependency.Module;
-import org.jboss.deployers.plugins.classloading.AbstractDeploymentClassLoaderPolicyModule;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
/**
*
@@ -68,6 +65,8 @@
protected Map<ClassLoaderDomain, Integer> classLoaderDomainReferenceCounts = new WeakHashMap<ClassLoaderDomain, Integer>();
+ private volatile ClassLoader abstractDeploymentClassLoaderPolicyModuleLoader;
+
protected VFSClassLoaderDomainRegistry() {}
/**
@@ -234,17 +233,14 @@
private ClassLoader findParentUnitLoader(Module module)
{
- if (module instanceof AbstractDeploymentClassLoaderPolicyModule)
- {
- DeploymentUnit unit = AbstractDeploymentClassLoaderPolicyModule.class.cast(module).getDeploymentUnit();
- return unit.isTopLevel() ? null : unit.getParent().getClassLoader();
- }
- ClassLoaderDomain domain = ClassLoaderSystem.getInstance().getDomain(module.getDeterminedDomainName());
- if (domain.getParent() instanceof ClassLoaderToLoaderAdapter)
- {
- ClassLoaderToLoaderAdapter cp2la = (ClassLoaderToLoaderAdapter)domain.getParent();
- return SecurityActions.getClassLoader(cp2la);
- }
- return null;
+ return ParentUnitLoaderFinders.getInstance().findParentUnitLoader(module);
}
+
+ public void addCallback(Callback callback)
+ {
+ }
+
+ public void removeCallback(Callback callback)
+ {
+ }
}
\ No newline at end of file
Added: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ConfigClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ConfigClassPoolTestCase.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/ConfigClassPoolTestCase.java 2010-05-04 12:08:38 UTC (rev 104426)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.classpool.jbosscl.test;
+
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportArchives.JAR_B_URL;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_A;
+import static org.jboss.test.classpool.jbosscl.support.SupportClasses.CLASS_B;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Collection;
+import java.util.HashSet;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.beans.metadata.api.model.AutowireType;
+import org.jboss.beans.metadata.api.model.InjectOption;
+import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classpool.plugins.jbosscl.JBossClClassPoolConfig;
+import org.jboss.classpool.plugins.jbosscl.JBossClDelegatingClassPoolFactory;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.test.classpool.jbosscl.support.CLDeploymentBuilder;
+import org.jboss.test.classpool.support.ClassPoolTestScenario;
+import org.jboss.test.classpool.support.TestScenario;
+import org.jboss.util.NotImplementedException;
+
+/**
+ * Tests the JBossClClassPoolConfig as intended for use in AS
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Kabir Khan</a>
+ * @version $Revision: 101497 $
+ */
+public class ConfigClassPoolTestCase extends JBossClClassPoolTest<CtClass, ClassPool>
+{
+ private Collection<ClassLoader> createdURLClassLoaders = new HashSet<ClassLoader>();
+
+ public ConfigClassPoolTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static NoClassloadingTestDelegate getDelegate(Class<?> clazz) throws Exception
+ {
+ return new NoClassloadingTestDelegate(clazz);
+ }
+
+ @Override
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ super.tearDown();
+ }
+ finally
+ {
+ createdURLClassLoaders.clear();
+ }
+ }
+
+ protected NoClassloadingTestDelegate getDelegate()
+ {
+ return (NoClassloadingTestDelegate) super.getDelegate();
+ }
+
+ @Override
+ protected ClassLoaderSystem getClassLoaderSystemBean()
+ {
+ return null;
+ }
+
+ @Override
+ protected TestScenario<CtClass, ClassPool, CLDeploymentBuilder> getTestScenario()
+ {
+ return null;
+ }
+
+ /**
+ * Simulates the steps to be taken during AS bootstrap
+ */
+ public void testBootstrap() throws Exception
+ {
+ //Initialize the config. This wires together the parts of the system
+ JBossClClassPoolConfig config = JBossClClassPoolConfig.getInstance();
+ assertNotNull(config.getClassPoolFactory());
+ assertNotNull(config.getClassPoolRepository());
+ assertNotNull(config.getDomainRegistry());
+ assertNotNull(config.getRegisterModuleCallback());
+ assertNull(config.getClassLoading());
+
+ ClassLoader urlCl = createChildURLLoader(null, JAR_A_URL);
+ assertNotNull(urlCl);
+ ClassPool urlPool = config.getClassPoolRepository().registerClassLoader(urlCl);
+ assertNotNull(urlPool);
+ CtClass aUrl = urlPool.get(CLASS_A);
+ CtClass stringUrl = urlPool.get(String.class.getName());
+
+ //Install the bean to get notified when ClassLoading is installed
+ BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("JBossClClassPoolConfig", JBossClClassPoolConfig.class.getName());
+ builder.setFactoryClass(JBossClClassPoolConfig.class.getName());
+ builder.setFactoryMethod("getInstance");
+ ValueMetaData inject = builder.createContextualInject(null, null, AutowireType.BY_NAME, InjectOption.CALLBACK);
+ ((AbstractInjectionValueMetaData)inject).setValue("ClassLoading");
+ builder.addPropertyMetaData("classLoading", inject);
+ getDelegate().deploy(builder.getBeanMetaData());
+
+ //Deploy the ClassLoading. This causes the RegistryModuleCallback
+ //to get installed as a module registry in ClassLoading
+ getDelegate().deployCommon();
+ assertNotNull(config.getClassLoading());
+
+ testScenario = new ClassPoolTestScenario<CLDeploymentBuilder>(getClassLoaderFactory(), config.getClassPoolRepository());
+
+ ClassPool poolA = testScenario.createLoader(new CLDeploymentBuilder("A", JAR_A_URL));
+ CtClass aDomain = poolA.get(CLASS_A);
+ assertNotSame(aUrl, aDomain);
+ assertSame(stringUrl, poolA.get(String.class.getName()));
+
+ ClassPool poolB = testScenario.createLoader(new CLDeploymentBuilder("B", JAR_B_URL));
+ assertSame(aDomain, poolB.get(CLASS_A));
+ }
+
+ protected ClassLoader createChildURLLoader(ClassLoader parentClassLoader, URL url)
+ {
+ URLClassLoader classLoader = new URLClassLoader(new URL[] {url}, parentClassLoader);
+ return classLoader;
+ }
+
+ private static class NoClassloadingTestDelegate extends JBossClClassPoolTestDelegate
+ {
+ public NoClassloadingTestDelegate(Class<?> clazz) throws Exception
+ {
+ super(clazz);
+ }
+
+ protected void deploy() throws Exception
+ {
+
+ }
+
+ protected void deployCommon() throws Exception
+ {
+ super.deploy();
+ }
+
+ @Override
+ protected KernelControllerContext deploy(BeanMetaData beanMetaData) throws Exception
+ {
+ return super.deploy(beanMetaData);
+ }
+
+
+
+ }
+}
\ No newline at end of file
Modified: projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTest.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTest.java 2010-05-04 11:57:29 UTC (rev 104425)
+++ projects/jboss-classpool/trunk/jbosscl/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTest.java 2010-05-04 12:08:38 UTC (rev 104426)
@@ -106,10 +106,15 @@
// excluding class that knows how to load from system classloader
Set<Class<?>> excluded = AbstractJDKChecker.getExcluded();
excluded.add(TestScenario.class);
- system = (ClassLoaderSystem) getBean("ClassLoaderSystem");
+ system = getClassLoaderSystemBean();
this.testScenario = getTestScenario();
}
+ protected ClassLoaderSystem getClassLoaderSystemBean()
+ {
+ return (ClassLoaderSystem) getBean("ClassLoaderSystem");
+ }
+
protected void mountJars(URL... jarUrls) throws IOException, URISyntaxException
{
TempFileProvider tempFileProvider = TempFileProvider.create("test", Executors.newScheduledThreadPool(2));
@@ -126,7 +131,8 @@
VFSUtils.safeClose(mountHandles);
try
{
- this.testScenario.destroyLoaders();
+ if (testScenario != null)
+ this.testScenario.destroyLoaders();
}
finally
{
Property changes on: projects/jboss-classpool/trunk/jbosscl-as
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.classpath
.project
Added: projects/jboss-classpool/trunk/jbosscl-as/pom.xml
===================================================================
--- projects/jboss-classpool/trunk/jbosscl-as/pom.xml (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl-as/pom.xml 2010-05-04 12:08:38 UTC (rev 104426)
@@ -0,0 +1,28 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.classpool</groupId>
+ <artifactId>jboss-classpool-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-classpool-jbosscl-as</artifactId>
+ <packaging>jar</packaging>
+ <name>JBossCl ClassPool in AS Post-Bootstrap</name>
+ <url>http://www.jboss.org/jbossreflect</url>
+
+ <!-- Do not add version information here, use ../pom.xml instead -->
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.classpool</groupId>
+ <artifactId>jboss-classpool-jbosscl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.deployers</groupId>
+ <artifactId>jboss-deployers-impl</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Added: projects/jboss-classpool/trunk/jbosscl-as/src/main/java/org/jboss/classpool/plugins/jbosscl/as/AbstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl-as/src/main/java/org/jboss/classpool/plugins/jbosscl/as/AbstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder.java (rev 0)
+++ projects/jboss-classpool/trunk/jbosscl-as/src/main/java/org/jboss/classpool/plugins/jbosscl/as/AbstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder.java 2010-05-04 12:08:38 UTC (rev 104426)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, 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.classpool.plugins.jbosscl.as;
+
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classpool.plugins.jbosscl.ParentUnitLoaderFinder;
+import org.jboss.deployers.plugins.classloading.AbstractDeploymentClassLoaderPolicyModule;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+
+/**
+ * In AS AbstractDeploymentClassLoaderPolicyModule is only available after deploying deployers.xml
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractDeploymentClassLoaderPolicyModuleParentUnitLoaderFinder implements ParentUnitLoaderFinder
+{
+ public ClassLoader findParentUnitLoader(Module module)
+ {
+ if (module instanceof AbstractDeploymentClassLoaderPolicyModule == false)
+ throw new IllegalArgumentException(module + " is not an AbstractDeploymentClassLoaderPolicyModule");
+ {
+ DeploymentUnit unit = AbstractDeploymentClassLoaderPolicyModule.class.cast(module).getDeploymentUnit();
+ return unit.isTopLevel() ? null : unit.getParent().getClassLoader();
+ }
+ }
+
+ public boolean handle(Module module)
+ {
+ return module instanceof AbstractDeploymentClassLoaderPolicyModule;
+ }
+
+}
Modified: projects/jboss-classpool/trunk/pom.xml
===================================================================
--- projects/jboss-classpool/trunk/pom.xml 2010-05-04 11:57:29 UTC (rev 104425)
+++ projects/jboss-classpool/trunk/pom.xml 2010-05-04 12:08:38 UTC (rev 104426)
@@ -22,6 +22,7 @@
<module>scopedpool</module>
<module>classpool</module>
<module>jbosscl</module>
+ <module>jbosscl-as</module>
<module>ucl</module>
</modules>
@@ -228,7 +229,13 @@
<type>test-jar</type>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.classpool</groupId>
+ <artifactId>jboss-classpool-jbosscl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
More information about the jboss-cvs-commits
mailing list