[jboss-user] [JBoss Microcontainer Development] - Classloading and caching changes
Ales Justin
do-not-reply at jboss.com
Fri May 14 10:20:06 EDT 2010
Ales Justin [http://community.jboss.org/people/alesj] replied to the discussion
"Classloading and caching changes"
To view the discussion, visit: http://community.jboss.org/message/543107#543107
--------------------------------------------------------------
First a few questions.
> What's the idea behind "useLoadClassForParent" flag?
> * So, instead of going into that magic synch code, we try the parent before?
The loadClassForParent is a backwards compatibility thing to work around
a few issues that the more efficient resource check causes in some edge cases when it delegates to the java classpath.
It shouldn't be using it when a Domain delegates to another Domain.
That was something we spotted and fixed in 2.2.x, see around line old/new 689/920
http://fisheye.jboss.org/browse/JBossAS/projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderDomain.java?r1=95108&r2=96496 http://fisheye.jboss.org/browse/JBossAS/projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/ClassLoaderDomain.java?r1=95108&r2=96496
> Why doesn't this code write into global cache?
> * I guess only certain Loaders are valid for caching? e.g. depending on the policy or "OSGi" rules
>
> (from BaseClassLoaderDomain)
>
> Loader loader = findLoader(classLoader, path, allExports, findInParent);
> if (loader != null)
> {
> Thread thread = Thread.currentThread();
> ClassLoadingTask task = new ClassLoadingTask(name, classLoader, thread);
> ClassLoaderManager.scheduleTask(task, loader, false);
> Class<?> result = ClassLoaderManager.process(thread, task);
> ClassCacheItem item = globalClassCache.get(path);
> if (item != null)
> item.clazz = result;
> return result;
> }
Whether it caches things is decided elsewhere, based on the ClassLoaderPolicy rules.
This code is just a safety check in the event that the class changes
(somebody redeployed a classloader) and the global cache hasn't been flushed properly.
As I said on the other response, it can't cache the load in that "globalClassCache", because
the classloader used is in the parent domain. It would need some complicated
flushing rules to cache it in the child domain as well - not my preferred solution.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/543107#543107]
Start a new discussion in JBoss Microcontainer Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2115]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100514/195a6b8c/attachment-0001.html
More information about the jboss-user
mailing list