-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Craig,

Craig McClanahan wrote:
> Craig McClanahan wrote:
> Yep ... it's magic :-).
> 
> Actually, what happens is that the servlet container provides a
> mechanism to acquire the ClassLoader instance for the web application
> itself, from which you can load application classes no matter where
> the caller is located.  For instance, when Struts loads an action
> class, it does something like this (plus some exception catching, of
> course):
> 
>    String actionClassName = ...;
>    ClassLoader cl = Thread.currentThread().getContextClassLoader();
>    Class actionClass = cl.loadClass(actionClassName);

I thought that the server created and started those threads
independently of the webapp being used. I've never used
Thread.getContextClassLoader... is that something that the server sets
when it handles a request -- for purposes such as this?

> The container guarantees that the context class loader for a thread is
> set correctly, before it enters your servlet, filter, or listener.

I guess so... ;)

> There is indeed no way to search down the hierarchy, which is why the
> context class loader convention was created.  As you examine libraries
> for potentially putting them into a shared class loader, look for code
> that does this kind of thing.

Cool. Thanks for the explanation, Craig.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGJS4d9CaO5/Lv0PARAqzKAKC4t0HR31h8KaLX471socJ7rbNphQCfWpAM
IrvvDVTjDYBpzob6TtwoGl4=
=Qq2L
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to