[jboss-cvs] JBossAS SVN: r104927 - in projects/jboss-cl/branches/Branch_2_0: classloader/src/main/java/org/jboss/classloader/spi and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 18 09:09:50 EDT 2010
Author: alesj
Date: 2010-05-18 09:09:49 -0400 (Tue, 18 May 2010)
New Revision: 104927
Added:
projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/CacheLoader.java
Modified:
projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/plugins/loader/ClassLoaderToLoaderAdapter.java
projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderDomain.java
projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/DelegateLoader.java
projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java
projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base/BaseDelegateLoader.java
projects/jboss-cl/branches/Branch_2_0/classloader/src/test/java/org/jboss/test/classloader/domain/test/CustomParentLoaderUnitTestCase.java
projects/jboss-cl/branches/Branch_2_0/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/ClassLoaderPolicyModule.java
Log:
[JBCL-159, JBCL-161]; port cache fix, dynamic package filtering.
Modified: projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/plugins/loader/ClassLoaderToLoaderAdapter.java
===================================================================
--- projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/plugins/loader/ClassLoaderToLoaderAdapter.java 2010-05-18 12:20:39 UTC (rev 104926)
+++ projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/plugins/loader/ClassLoaderToLoaderAdapter.java 2010-05-18 13:09:49 UTC (rev 104927)
@@ -29,10 +29,12 @@
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import java.util.Arrays;
import java.util.Enumeration;
import java.util.Set;
-import org.jboss.classloader.spi.Loader;
+import org.jboss.classloader.spi.CacheLoader;
+import org.jboss.classloader.spi.base.BaseClassLoader;
import org.jboss.classloader.spi.base.BaseClassLoaderSource;
import org.jboss.logging.Logger;
@@ -40,9 +42,10 @@
* ClassLoaderToLoaderAdapter.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
-public class ClassLoaderToLoaderAdapter extends BaseClassLoaderSource implements Loader
+public class ClassLoaderToLoaderAdapter extends BaseClassLoaderSource implements CacheLoader
{
/** The log */
private static final Logger log = Logger.getLogger(ClassLoaderToLoaderAdapter.class);
@@ -56,6 +59,9 @@
/** The get packages method */
private static Method getPackages;
+ /** The find class method */
+ private static Method findLoadedClass;
+
static
{
AccessController.doPrivileged(new PrivilegedAction<Object>()
@@ -80,6 +86,15 @@
{
log.warn("Unable to set accessible on ClassLoader.getPackages()", e);
}
+ try
+ {
+ findLoadedClass = ClassLoader.class.getDeclaredMethod("findLoadedClass", String.class);
+ findLoadedClass.setAccessible(true);
+ }
+ catch (Exception e)
+ {
+ log.warn("Unable to set accessible on ClassLoader.findLoadedClass()", e);
+ }
return null;
}
});
@@ -197,13 +212,15 @@
public void getPackages(Set<Package> packages)
{
- final ClassLoader classLoader = getClassLoader();
if (getPackages == null)
return;
+ final ClassLoader classLoader = getClassLoader();
try
{
- getPackages.invoke(classLoader);
+ Package[] pckgs = (Package[]) getPackages.invoke(classLoader);
+ if (pckgs != null)
+ packages.addAll(Arrays.asList(pckgs));
}
catch (Exception e)
{
@@ -211,6 +228,28 @@
}
}
+ public Class<?> checkClassCache(BaseClassLoader bcl, String name, String path, boolean allExports)
+ {
+ if (findLoadedClass == null)
+ return null;
+
+ final ClassLoader classLoader = getClassLoader();
+ try
+ {
+ Class<?> clazz = (Class<?>) findLoadedClass.invoke(classLoader, name);
+
+ if (clazz != null && log.isTraceEnabled())
+ log.trace("Found " + name + " in cache: " + this);
+
+ return clazz;
+ }
+ catch (Exception e)
+ {
+ log.warn("Unexpected error retrieving found class " + name + " from classloader " + classLoader, e);
+ return null;
+ }
+ }
+
@Override
public String toString()
{
Copied: projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/CacheLoader.java (from rev 104925, projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/Loader.java)
===================================================================
--- projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/CacheLoader.java (rev 0)
+++ projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/CacheLoader.java 2010-05-18 13:09:49 UTC (rev 104927)
@@ -0,0 +1,43 @@
+/*
+ * 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.classloader.spi;
+
+import org.jboss.classloader.spi.base.BaseClassLoader;
+
+/**
+ * Can load from cache.
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface CacheLoader extends Loader
+{
+ /**
+ * Check the class cache.
+ *
+ * @param classLoader the reference classloader (possibly null)
+ * @param name the name of the class
+ * @param path the path of the class resource
+ * @param allExports whether to look at all exports
+ * @return the class if cached
+ */
+ Class<?> checkClassCache(BaseClassLoader classLoader, String name, String path, boolean allExports);
+}
Modified: projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderDomain.java
===================================================================
--- projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderDomain.java 2010-05-18 12:20:39 UTC (rev 104926)
+++ projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderDomain.java 2010-05-18 13:09:49 UTC (rev 104927)
@@ -41,6 +41,7 @@
import org.jboss.classloader.plugins.ClassLoaderUtils;
import org.jboss.classloader.plugins.loader.ClassLoaderToLoaderAdapter;
+import org.jboss.classloader.spi.base.BaseClassLoader;
import org.jboss.classloader.spi.base.BaseClassLoaderDomain;
import org.jboss.classloader.spi.base.BaseClassLoaderSource;
import org.jboss.classloader.spi.filter.ClassFilter;
@@ -51,9 +52,10 @@
* ClassLoaderDomain.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
-public class ClassLoaderDomain extends BaseClassLoaderDomain implements Loader, ClassLoaderDomainMBean, MBeanRegistration, ClassNotFoundHandler, ClassFoundHandler
+public class ClassLoaderDomain extends BaseClassLoaderDomain implements ClassLoaderDomainMBean, MBeanRegistration, ClassNotFoundHandler, ClassFoundHandler
{
/** The log */
private static final Logger log = Logger.getLogger(ClassLoaderDomain.class);
@@ -1019,4 +1021,43 @@
}
}
}
+
+ @Override
+ protected Class<?> checkCacheBefore(BaseClassLoader classLoader, String name, String path, boolean allExports)
+ {
+ if (parent == null || parent instanceof CacheLoader == false)
+ return null;
+
+ ClassFilter filter = getParentPolicy().getBeforeFilter();
+ if (filter.matchesClassName(name))
+ {
+ CacheLoader loader = (CacheLoader) parent;
+ return loader.checkClassCache(classLoader, name, path, allExports);
+ }
+ return null;
+ }
+
+ /**
+ * Only check parent after if we already blacklisted this resource.
+ *
+ * @param classLoader the classloader (possibly null)
+ * @param name the name
+ * @param path the path of the class resource
+ * @param allExports whether to look at all exports
+ * @return cached result if found in parent
+ */
+ @Override
+ protected Class<?> checkCacheAfter(BaseClassLoader classLoader, String name, String path, boolean allExports)
+ {
+ if (parent == null || parent instanceof CacheLoader == false || isBlackListedClass(path) == false)
+ return null;
+
+ ClassFilter filter = getParentPolicy().getAfterFilter();
+ if (filter.matchesClassName(name))
+ {
+ CacheLoader loader = (CacheLoader) parent;
+ return loader.checkClassCache(classLoader, name, path, allExports);
+ }
+ return null;
+ }
}
Modified: projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/DelegateLoader.java
===================================================================
--- projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/DelegateLoader.java 2010-05-18 12:20:39 UTC (rev 104926)
+++ projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/DelegateLoader.java 2010-05-18 13:09:49 UTC (rev 104927)
@@ -29,7 +29,7 @@
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class DelegateLoader extends BaseDelegateLoader implements Loader
+public class DelegateLoader extends BaseDelegateLoader
{
/**
* Create a new DelegateLoader.
Modified: projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java
===================================================================
--- projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java 2010-05-18 12:20:39 UTC (rev 104926)
+++ projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java 2010-05-18 13:09:49 UTC (rev 104927)
@@ -36,10 +36,12 @@
import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.classloader.plugins.ClassLoaderUtils;
+import org.jboss.classloader.spi.CacheLoader;
import org.jboss.classloader.spi.ClassLoaderPolicy;
import org.jboss.classloader.spi.DelegateLoader;
import org.jboss.classloader.spi.Loader;
import org.jboss.logging.Logger;
+import org.jboss.util.collection.ConcurrentSet;
/**
* BaseClassLoaderDomain.<p>
@@ -48,9 +50,10 @@
* package access to the protected methods.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
-public abstract class BaseClassLoaderDomain implements Loader
+public abstract class BaseClassLoaderDomain implements CacheLoader
{
/** The log */
private static final Logger log = Logger.getLogger(BaseClassLoaderDomain.class);
@@ -71,13 +74,13 @@
private Map<String, ClassCacheItem> globalClassCache = new ConcurrentHashMap<String, ClassCacheItem>();
/** The global class black list */
- private Map<String, String> globalClassBlackList = new ConcurrentHashMap<String, String>();
+ private Set<String> globalClassBlackList = new ConcurrentSet<String>();
/** The global resource cache */
private Map<String, URL> globalResourceCache = new ConcurrentHashMap<String, URL>();
/** The global resource black list */
- private Map<String, String> globalResourceBlackList = new ConcurrentHashMap<String, String>();
+ private Set<String> globalResourceBlackList = new ConcurrentSet<String>();
/** Keep track of the added order */
private int order = 0;
@@ -108,17 +111,17 @@
public int getResourceBlackListSize()
{
- return globalClassBlackList.size();
+ return globalResourceBlackList.size();
}
public int getResourceCacheSize()
{
- return globalClassCache.size();
+ return globalResourceCache.size();
}
public Set<String> listClassBlackList()
{
- return Collections.unmodifiableSet(globalClassBlackList.keySet());
+ return Collections.unmodifiableSet(globalClassBlackList);
}
public Map<String, String> listClassCache()
@@ -131,7 +134,7 @@
public Set<String> listResourceBlackList()
{
- return Collections.unmodifiableSet(globalResourceBlackList.keySet());
+ return Collections.unmodifiableSet(globalResourceBlackList);
}
public Map<String, URL> listResourceCache()
@@ -197,8 +200,19 @@
{
return classLoaders.isEmpty() == false;
}
-
+
/**
+ * Check whether this is a black listed class
+ *
+ * @param name the class name
+ * @return true when black listed, false otherwise
+ */
+ protected boolean isBlackListedClass(String name)
+ {
+ return globalClassBlackList.contains(name);
+ }
+
+ /**
* Whether to use load class for parent
*
* @return true to load class on the parent loader
@@ -250,10 +264,7 @@
{
Class<?> clazz = loadClassBefore(name);
if (clazz != null)
- {
- globalClassCache.put(path, new ClassCacheItem(clazz));
return clazz;
- }
}
Loader loader = findLoader(classLoader, path, allExports, findInParent);
@@ -274,10 +285,7 @@
{
Class<?> clazz = loadClassAfter(name);
if (clazz != null)
- {
- globalClassCache.put(path, new ClassCacheItem(clazz));
return clazz;
- }
}
// Finally see whether this is the JDK assuming it can load its classes from any classloader
@@ -375,7 +383,13 @@
if (trace)
log.trace(this + " trying to load " + name + " from requesting " + classLoader);
if (classLoader.getResourceLocally(name) != null)
- return classLoader.getLoader();
+ {
+ loader = classLoader.getLoader();
+ policy = classLoader.getPolicy();
+ if (policy.isCacheable())
+ globalClassCache.put(name, new ClassCacheItem(loader));
+ return loader;
+ }
}
// Try the after attempt (e.g. from the parent)
@@ -654,7 +668,7 @@
}
}
- if (globalClassBlackList.containsKey(name))
+ if (isBlackListedClass(name))
{
if (trace)
log.trace(this + " class is black listed " + name);
@@ -690,7 +704,7 @@
}
// Here is not found in the exports so can we blacklist it?
if (canBlackList)
- globalClassBlackList.put(name, name);
+ globalClassBlackList.add(name);
return null;
}
@@ -712,7 +726,7 @@
log.trace(this + " got resource from cache " + name);
}
- if (globalResourceBlackList.containsKey(name))
+ if (globalResourceBlackList.contains(name))
{
if (trace)
log.trace(this + " resource is black listed, not looking at exports " + name);
@@ -749,7 +763,7 @@
}
// Here is not found in the exports so can we blacklist it?
if (canBlackList)
- globalResourceBlackList.put(name, name);
+ globalResourceBlackList.add(name);
return null;
}
@@ -1461,7 +1475,54 @@
return result;
}
+ public Class<?> checkClassCache(BaseClassLoader classLoader, String name, String path, boolean allExports)
+ {
+ Class<?> result = checkCacheBefore(classLoader, name, path, allExports);
+ if (result != null)
+ return result;
+
+ result = checkCacheAfter(classLoader, name, path, allExports);
+ if (result != null)
+ return result;
+
+ result = checkClassCacheLocally(classLoader, name, path, allExports);
+ if (result != null)
+ return result;
+
+ return null;
+ }
+
/**
+ * Check the cache before checking this domain.
+ * e.g. check parent's domain cache
+ *
+ * @param classLoader the classloader (possibly null)
+ * @param name the name
+ * @param path the path of the class resource
+ * @param allExports whether to look at all exports
+ * @return the class when found in the cache
+ */
+ protected Class<?> checkCacheBefore(BaseClassLoader classLoader, String name, String path, boolean allExports)
+ {
+ return null;
+ }
+
+ /**
+ * Check the cache after checking before domain.
+ * e.g. check parent's domain cache only if this one blacklisted the resource
+ *
+ * @param classLoader the classloader (possibly null)
+ * @param name the name
+ * @param path the path of the class resource
+ * @param allExports whether to look at all exports
+ * @return the class when found in the cache
+ */
+ protected Class<?> checkCacheAfter(BaseClassLoader classLoader, String name, String path, boolean allExports)
+ {
+ return null;
+ }
+
+ /**
* Check the class cache
*
* @param classLoader the reference classloader (possibly null)
@@ -1470,7 +1531,7 @@
* @param allExports whether to look at all exports
* @return the class if cached
*/
- Class<?> checkClassCache(BaseClassLoader classLoader, String name, String path, boolean allExports)
+ Class<?> checkClassCacheLocally(BaseClassLoader classLoader, String name, String path, boolean allExports)
{
if (allExports)
{
@@ -1501,7 +1562,7 @@
{
if (allExports)
{
- if (failIfBlackListed && globalClassBlackList.containsKey(path))
+ if (failIfBlackListed && isBlackListedClass(path))
{
if (log.isTraceEnabled())
log.trace("Found " + name + " in global blacklist");
Modified: projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base/BaseDelegateLoader.java
===================================================================
--- projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base/BaseDelegateLoader.java 2010-05-18 12:20:39 UTC (rev 104926)
+++ projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base/BaseDelegateLoader.java 2010-05-18 13:09:49 UTC (rev 104927)
@@ -25,18 +25,19 @@
import java.net.URL;
import java.util.Set;
+import org.jboss.classloader.spi.CacheLoader;
import org.jboss.classloader.spi.ClassLoaderPolicy;
import org.jboss.classloader.spi.ClassLoaderPolicyFactory;
-import org.jboss.classloader.spi.Loader;
import org.jboss.logging.Logger;
/**
* Base DelegateLoader.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
-public class BaseDelegateLoader implements Loader
+public class BaseDelegateLoader implements CacheLoader
{
/** The log */
private static final Logger log = Logger.getLogger(BaseDelegateLoader.class);
@@ -161,19 +162,26 @@
public void getPackages(Set<Package> packages)
{
- BaseClassLoader classLoader;
- try
+ if (delegate == null)
+ return;
+
+ BaseClassLoader classLoader = delegate.getClassLoaderUnchecked();
+ if (classLoader != null)
+ classLoader.getPackagesLocally(packages);
+ }
+
+ public Class<?> checkClassCache(BaseClassLoader classLoader, String name, String path, boolean allExports)
+ {
+ BaseClassLoaderPolicy policy = getPolicy();
+ if (policy != null)
{
- classLoader = delegate.getClassLoader();
+ BaseClassLoaderDomain domain = policy.getClassLoaderDomain();
+ if (domain != null)
+ return domain.checkClassCache(classLoader, name, path, allExports);
}
- catch (IllegalStateException e)
- {
- log.warn("Not getting packages from policy that has no classLoader: " + toLongString());
- return;
- }
- classLoader.getPackagesLocally(packages);
+ return null;
}
-
+
/**
* A long version of toString()
*
Modified: projects/jboss-cl/branches/Branch_2_0/classloader/src/test/java/org/jboss/test/classloader/domain/test/CustomParentLoaderUnitTestCase.java
===================================================================
--- projects/jboss-cl/branches/Branch_2_0/classloader/src/test/java/org/jboss/test/classloader/domain/test/CustomParentLoaderUnitTestCase.java 2010-05-18 12:20:39 UTC (rev 104926)
+++ projects/jboss-cl/branches/Branch_2_0/classloader/src/test/java/org/jboss/test/classloader/domain/test/CustomParentLoaderUnitTestCase.java 2010-05-18 13:09:49 UTC (rev 104927)
@@ -29,13 +29,7 @@
import junit.framework.Test;
import org.jboss.classloader.plugins.ClassLoaderUtils;
-import org.jboss.classloader.spi.ClassFoundHandler;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderDomainMBean;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloader.spi.ClassNotFoundHandler;
-import org.jboss.classloader.spi.Loader;
-import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloader.spi.*;
import org.jboss.classloader.spi.base.BaseClassLoaderDomain;
import org.jboss.classloader.spi.filter.ClassFilterUtils;
import org.jboss.classloader.test.support.MockClassLoaderPolicy;
@@ -161,7 +155,7 @@
ClassLoader classLoader = system.registerClassLoaderPolicy(domain, policy);
assertLoadClass(ClassLoaderDomain.class, classLoader);
- checkGetResource(loader, ClassLoaderDomain.class, BaseClassLoaderDomain.class, ClassLoaderDomainMBean.class, MBeanRegistration.class, Loader.class, ClassNotFoundHandler.class, ClassFoundHandler.class, Object.class);
+ checkGetResource(loader, ClassLoaderDomain.class, BaseClassLoaderDomain.class, ClassLoaderDomainMBean.class, MBeanRegistration.class, CacheLoader.class, Loader.class, ClassNotFoundHandler.class, ClassFoundHandler.class, Object.class);
checkLoadClass(loader);
}
Modified: projects/jboss-cl/branches/Branch_2_0/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/ClassLoaderPolicyModule.java
===================================================================
--- projects/jboss-cl/branches/Branch_2_0/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/ClassLoaderPolicyModule.java 2010-05-18 12:20:39 UTC (rev 104926)
+++ projects/jboss-cl/branches/Branch_2_0/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/ClassLoaderPolicyModule.java 2010-05-18 13:09:49 UTC (rev 104927)
@@ -33,7 +33,11 @@
import org.jboss.classloader.spi.Loader;
import org.jboss.classloader.spi.ParentPolicy;
import org.jboss.classloader.spi.base.BaseClassLoader;
+import org.jboss.classloader.spi.filter.ClassFilter;
+import org.jboss.classloader.spi.filter.FilteredDelegateLoader;
import org.jboss.classloader.spi.filter.LazyFilteredDelegateLoader;
+import org.jboss.classloader.spi.filter.PackageClassFilter;
+import org.jboss.classloading.plugins.metadata.PackageRequirement;
import org.jboss.classloading.spi.dependency.Domain;
import org.jboss.classloading.spi.dependency.Module;
import org.jboss.classloading.spi.dependency.RequirementDependencyItem;
@@ -254,7 +258,17 @@
Controller controller = context.getController();
DynamicClassLoaderPolicyFactory factory = new DynamicClassLoaderPolicyFactory(controller, domain, item);
- return new LazyFilteredDelegateLoader(factory);
+ Requirement requirement = item.getRequirement();
+ if (requirement instanceof PackageRequirement)
+ {
+ PackageRequirement pr = (PackageRequirement) requirement;
+ ClassFilter filter = PackageClassFilter.createPackageClassFilter(pr.getName());
+ return new FilteredDelegateLoader(factory, filter);
+ }
+ else
+ {
+ return new LazyFilteredDelegateLoader(factory);
+ }
}
@Override
More information about the jboss-cvs-commits
mailing list