cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@localbar.com>
Subject Classloading in Cocoon 2
Date Mon, 27 Mar 2000 08:46:05 GMT

Pier,
You have a comment
        // This is better than Class.forName() because components should
be
        // loaded by the same classloader that loaded Cocoon (they
should
        // be in the same jar file, or directory.
regarding

return(this.getClass().getClassLoader().loadClass(className));

And afaik, this is a direct subsitution for Class.forName() in JVM 1.2.
The same delegation model will occur, it wouldn't surprise me if
Class.forName() does the above, but needs to fondle with the stack to
get the class of the calling object.

Your statement "they should be in the same jar..." is also incorrect,
since we can expect many add-ons to Cocoon in the future that will be in
their own Jars/directories.

I would recommend to use the Context Classloader instead, which is the
Classloader used for the executing thread, and typically is the initial
classloader.

            return
Thread.currentThread().getContextClassLoader().loadClass(className);

Note; This is a 1.2 feature...

Niclas


Mime
View raw message