[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Remaing classLoader changes
adrian@jboss.org
do-not-reply at jboss.com
Tue Jan 22 11:21:06 EST 2008
"scott.stark at jboss.org" wrote : One difference in behavior I'm seeing that we don't appear to have control over is duplicate resource ordering. The org.jboss.test.deployers.vfs.classloader.test.FilteredExportUnitTestCase.testEar1 test I just added shows a users.properties resource being loaded from the testear1/lib/jar1.jar rather than the testear1.ear/ejb1.jar as is the case for the ULR. In the ULR we give preference to exact matches on latter ordered classes loaders. If I turn off the import all flag, the ejb1.jar resource is found, but this is too restrictive a policy. We need a import-all-exact-match-first type of behavior it seems.
|
I don't see what you are describing in the UnifiedClassLoader, but I do see a difference
in the logic between the UnifiedLoaderRepository.getResource()
| public URL getResource(String name, ClassLoader cl)
| {
|
| ...
|
| // Not found in cache, ask the calling classloader
| resource = getResourceFromClassLoader(name, cl);
|
| ...
|
| // Not visible in global cache, iterate on all classloaders
| resource = getResourceFromRepository(name, cl);
|
and BaseClassLoaderDomain.getResource()
| URL getResource(BaseClassLoader classLoader, String name, boolean allExports)
| {
| boolean trace = log.isTraceEnabled();
|
| if (getClassLoaderSystem() == null)
| throw new IllegalStateException("Domain is not registered with a classloader system: " + toLongString());
|
| // Try the before attempt
| URL result = beforeGetResource(name);
| if (result != null)
| return result;
|
| // Work out the rules
| ClassLoaderInformation info = null;
| BaseClassLoaderPolicy policy;
| if (classLoader != null)
| {
| policy = classLoader.getPolicy();
| info = infos.get(classLoader);
| if (policy.isImportAll())
| allExports = true;
| }
|
| // Next we try the old "big ball of mud" model
| if (allExports)
| {
| result = getResourceFromExports(classLoader, name, trace);
| if (result != null)
| return result;
| }
| else if (trace)
| log.trace(this + " not getting resource " + name + " from all exports");
|
| // Next we try the imports
| if (info != null)
| {
| result = getResourceFromImports(info, name, trace);
| if (result != null)
| return result;
| }
|
| // Finally use any requesting classloader
| if (classLoader != null)
| {
| if (trace)
| log.trace(this + " trying to get resource " + name + " from requesting " + classLoader);
| result = classLoader.getResourceLocally(name);
| if (result != null)
| {
| if (trace)
| log.trace(this + " got resource from requesting " + classLoader + " " + result);
| return result;
| }
| }
|
| // Try the after attempt
| result = afterGetResource(name);
| if (result != null)
| return result;
|
| // Didn't find it
| return null;
| }
|
i..e. it doesn't do the look locally first before asking the parent or searching the
repository.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4122277#4122277
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4122277
More information about the jboss-dev-forums
mailing list