[jboss-cvs] JBossAS SVN: r87899 - projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Apr 27 17:12:34 EDT 2009
Author: alesj
Date: 2009-04-27 17:12:34 -0400 (Mon, 27 Apr 2009)
New Revision: 87899
Modified:
projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java
Log:
Remove double allExport check.
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 2009-04-27 21:11:02 UTC (rev 87898)
+++ projects/jboss-cl/branches/Branch_2_0/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java 2009-04-27 21:12:34 UTC (rev 87899)
@@ -43,7 +43,7 @@
/**
* BaseClassLoaderDomain.<p>
- *
+ *
* This class hides some of the implementation details and allows
* package access to the protected methods.
*
@@ -57,31 +57,31 @@
/** The classloader system to which we belong */
private BaseClassLoaderSystem system;
-
+
/** The classloaders in the order they were registered */
private List<ClassLoaderInformation> classLoaders = new CopyOnWriteArrayList<ClassLoaderInformation>();
/** The classloader information by classloader */
private Map<ClassLoader, ClassLoaderInformation> infos = new ConcurrentHashMap<ClassLoader, ClassLoaderInformation>();
-
+
/** The classloaders by package name */
private Map<String, List<ClassLoaderInformation>> classLoadersByPackageName = new ConcurrentHashMap<String, List<ClassLoaderInformation>>();
-
+
/** The global class cache */
private Map<String, ClassCacheItem> globalClassCache = new ConcurrentHashMap<String, ClassCacheItem>();
-
+
/** The global class black list */
private Map<String, String> globalClassBlackList = new ConcurrentHashMap<String, 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>();
-
+
/** Keep track of the added order */
private int order = 0;
-
+
/**
* Flush the internal caches
*/
@@ -115,7 +115,7 @@
{
return globalClassCache.size();
}
-
+
public Set<String> listClassBlackList()
{
return Collections.unmodifiableSet(globalClassBlackList.keySet());
@@ -141,17 +141,17 @@
/**
* Get the classloader system
- *
+ *
* @return the classloader system
*/
protected synchronized BaseClassLoaderSystem getClassLoaderSystem()
{
return system;
}
-
+
/**
* Get the classloader system
- *
+ *
* @param system the classloader system
*/
synchronized void setClassLoaderSystem(BaseClassLoaderSystem system)
@@ -163,7 +163,7 @@
/**
* Shutdown the domain<p>
- *
+ *
* The default implementation just unregisters all classloaders
*/
protected void shutdownDomain()
@@ -184,32 +184,32 @@
unregisterClassLoader(info.getClassLoader());
}
}
-
+
flushCaches();
}
-
+
/**
* Whether the domain has classloaders
- *
+ *
* @return true when the domain has classloaders
*/
public boolean hasClassLoaders()
{
return classLoaders.isEmpty() == false;
}
-
+
/**
* Whether to use load class for parent
- *
+ *
* @return true to load class on the parent loader
*/
public abstract boolean isUseLoadClassForParent();
-
+
/**
* Transform the byte code<p>
- *
+ *
* By default, this delegates to the classloader system
- *
+ *
* @param classLoader the classloader
* @param className the class name
* @param byteCode the byte code
@@ -227,7 +227,7 @@
/**
* Load a class from the domain
- *
+ *
* @param classLoader the classloader
* @param name the class name
* @param allExports whether we should look at all exports
@@ -237,14 +237,13 @@
protected Class<?> loadClass(BaseClassLoader classLoader, String name, boolean allExports) throws ClassNotFoundException
{
boolean trace = log.isTraceEnabled();
-
+
String path = ClassLoaderUtils.classNameToPath(name);
-
- if (allExports)
- checkClassBlackList(classLoader, name, path, allExports);
-
+
+ checkClassBlackList(classLoader, name, path, allExports);
+
boolean findInParent = (isUseLoadClassForParent() == false);
-
+
// Should we directly load from the parent?
if (findInParent == false)
{
@@ -255,7 +254,7 @@
return clazz;
}
}
-
+
Loader loader = findLoader(classLoader, path, allExports, findInParent);
if (loader != null)
{
@@ -268,7 +267,7 @@
item.clazz = result;
return result;
}
-
+
// Should we directly load from the parent?
if (findInParent == false)
{
@@ -299,14 +298,14 @@
}
}
}
-
+
// Didn't find it
return null;
}
/**
* Find a loader for a class
- *
+ *
* @param name the class resource name
* @return the loader
*/
@@ -317,7 +316,7 @@
/**
* Find a loader for a class
- *
+ *
* @param classLoader the classloader
* @param name the class resource name
* @param allExports whether we should look at all exports
@@ -329,10 +328,10 @@
boolean trace = log.isTraceEnabled();
if (trace)
log.trace(this + " findLoader " + name + " classLoader=" + classLoader + " allExports=" + allExports + " findInParent=" + findInParent);
-
+
if (getClassLoaderSystem() == null)
throw new IllegalStateException("Domain is not registered with a classloader system: " + toLongString());
-
+
// Try the before attempt (e.g. from the parent)
Loader loader = null;
if (findInParent)
@@ -351,7 +350,7 @@
allExports = true;
}
- // Next we try the old "big ball of mud" model
+ // Next we try the old "big ball of mud" model
if (allExports)
{
loader = findLoaderInExports(classLoader, name, trace);
@@ -360,7 +359,7 @@
}
else if (trace)
log.trace(this + " not loading " + name + " from all exports");
-
+
// Next we try the imports
if (info != null)
{
@@ -381,13 +380,13 @@
// Try the after attempt (e.g. from the parent)
if (findInParent)
return findAfterLoader(name);
-
+
return null;
}
-
+
/**
* Load a resource from the domain
- *
+ *
* @param classLoader the classloader
* @param name the resource name
* @param allExports whether we should look at all exports
@@ -430,7 +429,7 @@
allExports = true;
}
- // Next we try the old "big ball of mud" model
+ // Next we try the old "big ball of mud" model
if (allExports)
{
result = getResourceFromExports(classLoader, name, trace);
@@ -439,7 +438,7 @@
}
else if (trace)
log.trace(this + " not getting resource " + name + " from all exports");
-
+
// Next we try the imports
if (info != null)
{
@@ -452,14 +451,14 @@
result = afterGetResource(name);
if (result != null)
return result;
-
+
// Didn't find it
return null;
}
-
+
/**
* Load resources from the domain
- *
+ *
* @param classLoader the classloader
* @param name the resource name
* @param allExports whether we should look at all exports
@@ -487,12 +486,12 @@
allExports = true;
}
- // Next we try the old "big ball of mud" model
+ // Next we try the old "big ball of mud" model
if (allExports)
getResourcesFromExports(classLoader, name, urls, trace);
else if (trace)
log.trace(this + " not getting resource " + name + " from all exports");
-
+
// Next we try the imports
if (info != null)
getResourcesFromImports(info, name, urls, trace);
@@ -508,10 +507,10 @@
// Try the after attempt
afterGetResources(name, urls);
}
-
+
/**
* Load a package from the domain
- *
+ *
* @param classLoader the classloader
* @param name the resource name
* @param allExports whether we should look at all exports
@@ -540,7 +539,7 @@
allExports = true;
}
- // Next we try the old "big ball of mud" model
+ // Next we try the old "big ball of mud" model
if (allExports)
{
result = getPackageFromExports(classLoader, name, trace);
@@ -549,7 +548,7 @@
}
else if (trace)
log.trace(this + " not getting package " + name + " from all exports");
-
+
// Next we try the imports
if (info != null)
{
@@ -576,14 +575,14 @@
result = afterGetPackage(name);
if (result != null)
return result;
-
+
// Didn't find it
return null;
}
-
+
/**
* Load packages from the domain
- *
+ *
* @param classLoader the classloader
* @param packages the packages to add to
* @param allExports whether we should look at all exports
@@ -609,12 +608,12 @@
allExports = true;
}
- // Next we try the old "big ball of mud" model
+ // Next we try the old "big ball of mud" model
if (allExports)
getPackagesFromExports(classLoader, packages, trace);
else if (trace)
log.trace(this + " not getting packages from all exports");
-
+
// Next we try the imports
if (info != null)
getPackagesFromImports(info, packages, trace);
@@ -630,10 +629,10 @@
// Try the after attempt
afterGetPackages(packages);
}
-
+
/**
* Find a loader for class in exports
- *
+ *
* @param classLoader the classloader
* @param name the class resource name
* @param trace whether trace is enabled
@@ -661,7 +660,7 @@
}
boolean canCache = true;
boolean canBlackList = true;
-
+
String packageName = ClassLoaderUtils.getResourcePackageName(name);
List<ClassLoaderInformation> list = classLoadersByPackageName.get(packageName);
if (trace)
@@ -671,7 +670,7 @@
for (ClassLoaderInformation info : list)
{
BaseDelegateLoader exported = info.getExported();
-
+
// See whether the policies allow caching/blacklisting
BaseClassLoaderPolicy loaderPolicy = exported.getPolicy();
if (loaderPolicy == null || loaderPolicy.isCacheable() == false)
@@ -690,13 +689,13 @@
// Here is not found in the exports so can we blacklist it?
if (canBlackList)
globalClassBlackList.put(name, name);
-
+
return null;
}
-
+
/**
* Load a resource from the exports
- *
+ *
* @param classLoader the classloader
* @param name the resource name
* @param trace whether trace is enabled
@@ -710,7 +709,7 @@
if (trace)
log.trace(this + " got resource from cache " + name);
}
-
+
if (globalResourceBlackList.containsKey(name))
{
if (trace)
@@ -719,7 +718,7 @@
}
boolean canCache = true;
boolean canBlackList = true;
-
+
String packageName = ClassLoaderUtils.getResourcePackageName(name);
List<ClassLoaderInformation> list = classLoadersByPackageName.get(packageName);
if (trace)
@@ -729,7 +728,7 @@
for (ClassLoaderInformation info : list)
{
BaseDelegateLoader loader = info.getExported();
-
+
// See whether the policies allow caching/blacklisting
BaseClassLoaderPolicy loaderPolicy = loader.getPolicy();
if (loaderPolicy == null || loaderPolicy.isCacheable() == false)
@@ -751,10 +750,10 @@
globalResourceBlackList.put(name, name);
return null;
}
-
+
/**
* Load resources from the exports
- *
+ *
* @param classLoader the classloader
* @param name the resource name
* @param urls the urls to add to
@@ -776,10 +775,10 @@
}
}
}
-
+
/**
* Load a package from the exports
- *
+ *
* @param classLoader the classloader
* @param name the package name
* @param trace whether trace is enabled
@@ -803,10 +802,10 @@
}
return null;
}
-
+
/**
* Load packages from the exports
- *
+ *
* @param classLoader the classloader
* @param packages the packages to add to
* @param trace whether trace is enabled
@@ -828,7 +827,7 @@
/**
* Find a loader for a class in imports
- *
+ *
* @param info the classloader information
* @param name the class resource name
* @param trace whether trace is enabled
@@ -851,14 +850,14 @@
log.trace(this + " found in import cache " + name);
return loader;
}
-
+
if (info.isBlackListedClass(name))
{
if (trace)
log.trace(this + " class is black listed in imports " + name);
return null;
}
-
+
for (DelegateLoader delegate : delegates)
{
if (trace)
@@ -872,10 +871,10 @@
info.blackListClass(name);
return null;
}
-
+
/**
* Load a resource from the imports
- *
+ *
* @param info the classloader information
* @param name the resource name
* @param trace whether trace is enabled
@@ -898,7 +897,7 @@
log.trace(this + " found resource in import cache " + name);
return url;
}
-
+
if (info.isBlackListedResource(name))
{
if (trace)
@@ -921,10 +920,10 @@
info.blackListResource(name);
return null;
}
-
+
/**
* Load resources from the imports
- *
+ *
* @param info the classloader info
* @param name the resource name
* @param urls the urls to add to
@@ -945,10 +944,10 @@
for (DelegateLoader delegate : delegates)
delegate.getResources(name, urls);
}
-
+
/**
* Load a package from the imports
- *
+ *
* @param info the classloader information
* @param name the pacakge name
* @param trace whether trace is enabled
@@ -975,10 +974,10 @@
}
return null;
}
-
+
/**
* Load packages from the imports
- *
+ *
* @param info the classloader info
* @param packages the packages to add to
* @param trace whether trace is enabled
@@ -1000,15 +999,15 @@
/**
* Invoked before classloading is attempted to allow a preload attempt, e.g. from the parent
- *
+ *
* @param name the class name
* @return the loader if found or null otherwise
*/
protected abstract Class<?> loadClassBefore(String name);
-
+
/**
* Invoked after classloading is attempted to allow a postload attempt, e.g. from the parent
- *
+ *
* @param name the class name
* @return the loader if found or null otherwise
*/
@@ -1016,84 +1015,84 @@
/**
* Invoked before classloading is attempted to allow a preload attempt, e.g. from the parent
- *
+ *
* @param name the class resource name
* @return the loader if found or null otherwise
*/
protected abstract Loader findBeforeLoader(String name);
-
+
/**
* Invoked after classloading is attempted to allow a postload attempt, e.g. from the parent
- *
+ *
* @param name the class resource name
* @return the loader if found or null otherwise
*/
protected abstract Loader findAfterLoader(String name);
-
+
/**
* Invoked before getResources is attempted to allow a preload attempt, e.g. from the parent
- *
+ *
* @param name the resource name
* @param urls the urls to add to
* @throws IOException for any error
*/
protected abstract void beforeGetResources(String name, Set<URL> urls) throws IOException;
-
+
/**
* Invoked after getResources is attempted to allow a postload attempt, e.g. from the parent
- *
+ *
* @param name the resource name
* @param urls the urls to add to
* @throws IOException for any error
*/
protected abstract void afterGetResources(String name, Set<URL> urls) throws IOException;
-
+
/**
* Invoked before getResource is attempted to allow a preload attempt, e.g. from the parent
- *
+ *
* @param name the resource name
* @return the url if found or null otherwise
*/
protected abstract URL beforeGetResource(String name);
-
+
/**
* Invoked after getResource is attempted to allow a postload attempt, e.g. from the parent
- *
+ *
* @param name the resource name
* @return the url if found or null otherwise
*/
protected abstract URL afterGetResource(String name);
-
+
/**
* Invoked before getPackages is attempted to allow a preload attempt, e.g. from the parent
- *
+ *
* @param packages the packages to add to
*/
protected abstract void beforeGetPackages(Set<Package> packages);
-
+
/**
* Invoked after getPackages is attempted to allow a postload attempt, e.g. from the parent
- *
+ *
* @param packages the packages to add to
*/
protected abstract void afterGetPackages(Set<Package> packages);
-
+
/**
* Invoked before getPackage is attempted to allow a preload attempt, e.g. from the parent
- *
+ *
* @param name the package name
* @return the package if found or null otherwise
*/
protected abstract Package beforeGetPackage(String name);
-
+
/**
* Invoked after getPackage is attempted to allow a postload attempt, e.g. from the parent
- *
+ *
* @param name the package name
* @return the url if found or null otherwise
*/
protected abstract Package afterGetPackage(String name);
-
+
public Class<?> loadClass(String name)
{
try
@@ -1105,10 +1104,10 @@
return null;
}
}
-
+
/**
* Load a class from the domain
- *
+ *
* @param classLoader the classloader
* @param name the class name
* @return the class
@@ -1118,15 +1117,15 @@
{
return loadClass(classLoader, name, false);
}
-
+
public URL getResource(String name)
{
return getResource(null, name, true);
}
-
+
/**
* Get a resource from the domain
- *
+ *
* @param classLoader the classloader
* @param name the resource name
* @return the url
@@ -1135,15 +1134,15 @@
{
return getResource(classLoader, name, false);
}
-
+
public void getResources(String name, Set<URL> urls) throws IOException
{
getResources(null, name, urls, true);
}
-
+
/**
* Get a resource from the domain
- *
+ *
* @param classLoader the classloader
* @param name the resource name
* @param urls the urls to add to
@@ -1153,15 +1152,15 @@
{
getResources(classLoader, name, urls, false);
}
-
+
public Package getPackage(String name)
{
return getPackage(null, name, true);
}
-
+
/**
* Get a package from the specified classloader
- *
+ *
* @param classLoader the classloader
* @param name the package name
* @return the package
@@ -1170,15 +1169,15 @@
{
return getPackage(classLoader, name, false);
}
-
+
public void getPackages(Set<Package> packages)
{
getPackages(null, packages, true);
}
-
+
/**
- * Get the packages from a specified classloader
- *
+ * Get the packages from a specified classloader
+ *
* @param classLoader the classloader
* @param packages the packages
*/
@@ -1189,7 +1188,7 @@
/**
* A long version of toString()
- *
+ *
* @return the long string
*/
public String toLongString()
@@ -1202,19 +1201,19 @@
builder.append('}');
return builder.toString();
}
-
+
/**
* For subclasses to add information for toLongString()
- *
+ *
* @param builder the builder
*/
protected void toLongString(StringBuilder builder)
{
}
-
+
/**
- * Invoked before adding a classloader policy
- *
+ * Invoked before adding a classloader policy
+ *
* @param classLoader the classloader
* @param policy the classloader policy
*/
@@ -1224,8 +1223,8 @@
}
/**
- * Invoked after adding a classloader policy
- *
+ * Invoked after adding a classloader policy
+ *
* @param classLoader the classloader
* @param policy the classloader policy
*/
@@ -1233,10 +1232,10 @@
{
// nothing
}
-
+
/**
- * Invoked before adding a classloader policy
- *
+ * Invoked before adding a classloader policy
+ *
* @param classLoader the classloader
* @param policy the classloader policy
*/
@@ -1244,10 +1243,10 @@
{
// nothing
}
-
+
/**
- * Invoked after adding a classloader policy
- *
+ * Invoked after adding a classloader policy
+ *
* @param classLoader the classloader
* @param policy the classloader policy
*/
@@ -1258,7 +1257,7 @@
/**
* Get the parent classloader
- *
+ *
* @return the parent classloader
*/
protected ClassLoader getParentClassLoader()
@@ -1267,8 +1266,8 @@
}
/**
- * Register a classloader
- *
+ * Register a classloader
+ *
* @param classLoader the classloader
*/
void registerClassLoader(BaseClassLoader classLoader)
@@ -1277,12 +1276,12 @@
if (getClassLoaderSystem() == null)
throw new IllegalStateException("Domain is not registered with a classloader system: " + toLongString());
-
+
ClassLoaderPolicy policy = classLoader.getPolicy();
BaseDelegateLoader exported = policy.getExported();
if (exported != null && exported.getPolicy() == null)
throw new IllegalStateException("The exported delegate " + exported + " is too lazy for " + policy.toLongString());
-
+
try
{
beforeRegisterClassLoader(classLoader, policy);
@@ -1291,7 +1290,7 @@
{
log.warn("Error in beforeRegisterClassLoader: " + this + " classLoader=" + classLoader.toLongString(), t);
}
-
+
BaseClassLoaderPolicy basePolicy = classLoader.getPolicy();
basePolicy.setClassLoaderDomain(this);
@@ -1318,7 +1317,7 @@
log.trace("Registered " + policy + " as providing package=" + packageName);
}
}
-
+
flushCaches();
}
@@ -1331,10 +1330,10 @@
log.warn("Error in afterRegisterClassLoader: " + this + " classLoader=" + classLoader.toLongString(), t);
}
}
-
+
/**
- * Remove a classloader
- *
+ * Remove a classloader
+ *
* @param classLoader the classloader
*/
void unregisterClassLoader(BaseClassLoader classLoader)
@@ -1358,7 +1357,7 @@
// Remove the classloader
ClassLoaderInformation info = infos.remove(classLoader);
classLoaders.remove(info);
-
+
// Remove the package index
String[] packageNames = policy.getPackageNames();
if (packageNames != null && info.getExported() != null)
@@ -1391,7 +1390,7 @@
/**
* Get all the classloaders
- *
+ *
* @return the list of classloaders
*/
protected List<ClassLoader> getAllClassLoaders()
@@ -1404,7 +1403,7 @@
/**
* Get a map of packages to classloader
- *
+ *
* @return a map of packages to a list of classloaders for that package
*/
protected Map<String, List<ClassLoader>> getClassLoadersByPackage()
@@ -1424,7 +1423,7 @@
{
if (packageName == null)
throw new IllegalArgumentException("Null package name");
-
+
List<ClassLoader> result = new ArrayList<ClassLoader>();
List<ClassLoaderInformation> infos = classLoadersByPackageName.get(packageName);
if (infos != null)
@@ -1437,7 +1436,7 @@
/**
* 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
@@ -1461,7 +1460,7 @@
/**
* Check the class blacklist
- *
+ *
* @param classLoader the classloader (possibly null)
* @param name the name
* @param path the path of the class resource
@@ -1480,10 +1479,10 @@
}
}
}
-
+
/**
* Check the cache and blacklist
- *
+ *
* @param classLoader the classloader (possibly null)
* @param name the name
* @param path the path of the class resource
@@ -1495,11 +1494,11 @@
{
if (path == null)
path = ClassLoaderUtils.classNameToPath(name);
-
+
Class<?> result = checkClassCache(classLoader, name, path, allExports);
if (result != null)
return result;
-
+
checkClassBlackList(classLoader, name, path, allExports);
return null;
}
@@ -1525,7 +1524,7 @@
for (ClassLoaderInformation info : infos)
info.clearBlackList(name);
}
-
+
/**
* ClassCacheItem.
*/
@@ -1533,12 +1532,12 @@
{
Loader loader;
Class<?> clazz;
-
+
public ClassCacheItem(Loader loader)
{
this.loader = loader;
}
-
+
public ClassCacheItem(Class<?> clazz)
{
this.clazz = clazz;
More information about the jboss-cvs-commits
mailing list