You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Ojares Rami EINT <Ra...@elisa.fi> on 2003/09/11 16:26:17 UTC

commons-logging & classloading

Why does LogFactoryImpl in commons-logging
try to load the Log implementation class first
from thread classloader and then loader that loaded this class?

Is there some kind of design pattern behind this?


- Rami Ojares / Elisa Internet

----------------------------------
Man Plans, God Laughs
    --European Proverb

Re: commons-logging & classloading

Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Thu, 11 Sep 2003, Ojares Rami EINT wrote:

> Date: Thu, 11 Sep 2003 17:26:17 +0300
> From: Ojares Rami EINT <Ra...@elisa.fi>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> To: commons-dev@jakarta.apache.org
> Subject: commons-logging & classloading
>
> Why does LogFactoryImpl in commons-logging
> try to load the Log implementation class first
> from thread classloader and then loader that loaded this class?
>
> Is there some kind of design pattern behind this?
>

One very common :-) use case for commons-logging is inside web
applications, where the servlet container provides a class loader per
webapp (pointing at the classes in /WEB-INF/classes and /WEB-INF/lib),
plus normally a parent class loader for shared classes and resources.  The
container is required to set the Thead context class loader for the
current webapp prior to handing the request off to the servlet.

The lookup design pattern in LogFactoryImpl allows webapps to use their
own version of the log implementation classes.

>
> - Rami Ojares / Elisa Internet

Craig