[jboss-cvs] JBossAS SVN: r104671 - projects/jboss-cl/branches/tdi/jbosgi323/classloader/src/main/java/org/jboss/classloader/spi/base.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 11 07:05:54 EDT 2010
Author: thomas.diesler at jboss.com
Date: 2010-05-11 07:05:53 -0400 (Tue, 11 May 2010)
New Revision: 104671
Modified:
projects/jboss-cl/branches/tdi/jbosgi323/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java
Log:
Use ImportType to distinguish between static/dynamic imports
Modified: projects/jboss-cl/branches/tdi/jbosgi323/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java
===================================================================
--- projects/jboss-cl/branches/tdi/jbosgi323/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java 2010-05-11 11:01:10 UTC (rev 104670)
+++ projects/jboss-cl/branches/tdi/jbosgi323/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java 2010-05-11 11:05:53 UTC (rev 104671)
@@ -43,6 +43,7 @@
* package access to the protected methods.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author thomas.diesler at jboss.com
* @version $Revision: 1.1 $
*/
public abstract class BaseClassLoaderDomain implements Loader
@@ -74,6 +75,9 @@
/** Keep track of the added order */
private int order = 0;
+ /** The import type */
+ private enum ImportType { ALL, STATIC, DYNAMIC };
+
/**
* Flush the internal caches
*/
@@ -360,10 +364,10 @@
else if (trace)
log.trace(this + " not loading " + name + " from all exports");
- // Next we try the imports
+ // Next we try the static imports
if (info != null)
{
- loader = findLoaderInImports(info, name, trace);
+ loader = findLoaderInImports(info, name, ImportType.STATIC, trace);
if (loader != null)
return loader;
}
@@ -377,6 +381,14 @@
return classLoader.getLoader();
}
+ // Next we try the dynamic imports
+ if (info != null)
+ {
+ loader = findLoaderInImports(info, name, ImportType.DYNAMIC, trace);
+ if (loader != null)
+ return loader;
+ }
+
// Try the after attempt (e.g. from the parent)
if (findInParent)
return findAfterLoader(name);
@@ -442,7 +454,7 @@
// Next we try the imports
if (info != null)
{
- result = getResourceFromImports(info, name, trace);
+ result = getResourceFromImports(info, name, ImportType.ALL, trace);
if (result != null)
return result;
}
@@ -493,11 +505,13 @@
else if (trace)
log.trace(this + " not getting resource " + name + " from all exports");
- // Next we try the imports
+ // Next we try the static imports
if (info != null)
- getResourcesFromImports(info, name, urls, trace);
+ {
+ getResourcesFromImports(info, name, urls, ImportType.STATIC, trace);
+ }
- // Finally use any requesting classloader
+ // Next use any requesting classloader
if (classLoader != null)
{
if (trace)
@@ -505,6 +519,12 @@
classLoader.getResourcesLocally(name, urls);
}
+ // Next we try the dynamic imports
+ if (info != null)
+ {
+ getResourcesFromImports(info, name, urls, ImportType.DYNAMIC, trace);
+ }
+
// Try the after attempt
afterGetResources(name, urls);
}
@@ -550,15 +570,15 @@
else if (trace)
log.trace(this + " not getting package " + name + " from all exports");
- // Next we try the imports
+ // Next we try the static imports
if (info != null)
{
- result = getPackageFromImports(info, name, trace);
+ result = getPackageFromImports(info, name, ImportType.STATIC, trace);
if (result != null)
return result;
}
- // Finally use any requesting classloader
+ // Next use any requesting classloader
if (classLoader != null)
{
if (trace)
@@ -572,6 +592,14 @@
}
}
+ // Next we try the dynamic imports
+ if (info != null)
+ {
+ result = getPackageFromImports(info, name, ImportType.DYNAMIC, trace);
+ if (result != null)
+ return result;
+ }
+
// Try the after attempt
result = afterGetPackage(name);
if (result != null)
@@ -615,11 +643,13 @@
else if (trace)
log.trace(this + " not getting packages from all exports");
- // Next we try the imports
+ // Next we try the static imports
if (info != null)
- getPackagesFromImports(info, packages, trace);
+ {
+ getPackagesFromImports(info, packages, ImportType.STATIC, trace);
+ }
- // Finally use any requesting classloader
+ // Next use any requesting classloader
if (classLoader != null)
{
if (trace)
@@ -627,6 +657,12 @@
classLoader.getPackagesLocally(packages);
}
+ // Next we try the dynamic imports
+ if (info != null)
+ {
+ getPackagesFromImports(info, packages, ImportType.DYNAMIC, trace);
+ }
+
// Try the after attempt
afterGetPackages(packages);
}
@@ -832,10 +868,11 @@
*
* @param info the classloader information
* @param name the class resource name
+ * @param type the import type
* @param trace whether trace is enabled
* @return the loader
*/
- Loader findLoaderInImports(ClassLoaderInformation info, String name, boolean trace)
+ Loader findLoaderInImports(ClassLoaderInformation info, String name, ImportType type, boolean trace)
{
List<? extends DelegateLoader> delegates = info.getDelegates();
if (delegates == null || delegates.isEmpty())
@@ -879,10 +916,11 @@
*
* @param info the classloader information
* @param name the resource name
+ * @param type the import type
* @param trace whether trace is enabled
* @return the url
*/
- private URL getResourceFromImports(ClassLoaderInformation info, String name, boolean trace)
+ private URL getResourceFromImports(ClassLoaderInformation info, String name, ImportType type, boolean trace)
{
List<? extends DelegateLoader> delegates = info.getDelegates();
if (delegates == null || delegates.isEmpty())
@@ -929,11 +967,12 @@
* @param info the classloader info
* @param name the resource name
* @param urls the urls to add to
+ * @param type the import type
* @param trace whether trace is enabled
* @throws IOException for any error
*/
// FindBugs: The Set doesn't use equals/hashCode
- void getResourcesFromImports(ClassLoaderInformation info, String name, Set<URL> urls, boolean trace) throws IOException
+ void getResourcesFromImports(ClassLoaderInformation info, String name, Set<URL> urls, ImportType type, boolean trace) throws IOException
{
List<? extends DelegateLoader> delegates = info.getDelegates();
if (delegates == null || delegates.isEmpty())
@@ -953,10 +992,11 @@
*
* @param info the classloader information
* @param name the pacakge name
+ * @param type the import type
* @param trace whether trace is enabled
* @return the package
*/
- private Package getPackageFromImports(ClassLoaderInformation info, String name, boolean trace)
+ private Package getPackageFromImports(ClassLoaderInformation info, String name, ImportType type, boolean trace)
{
List<? extends DelegateLoader> delegates = info.getDelegates();
if (delegates == null || delegates.isEmpty())
@@ -983,9 +1023,10 @@
*
* @param info the classloader info
* @param packages the packages to add to
+ * @param type the import type
* @param trace whether trace is enabled
*/
- void getPackagesFromImports(ClassLoaderInformation info, Set<Package> packages, boolean trace)
+ void getPackagesFromImports(ClassLoaderInformation info, Set<Package> packages, ImportType type, boolean trace)
{
List<? extends DelegateLoader> delegates = info.getDelegates();
if (delegates == null || delegates.isEmpty())
More information about the jboss-cvs-commits
mailing list