Quest in sourcecode HttpContext.doStart()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Quest in sourcecode HttpContext.doStart()

Lebing Xie
Hi,all
The last part of the HttpContext.doStart(), seemed that the thread first
saved his own ClassLoader, and use _loader to start Servlethandlers,
after that obtain his own CL again. What is the idea behind it. Thanx
alot.

ur Lebing


        // Start the handlers
        Thread thread = Thread.currentThread();
        ClassLoader lastContextLoader=thread.getContextClassLoader();
        try
        {

            if (_loader!=null)
                thread.setContextClassLoader(_loader);

            if (_requestLog!=null)
                _requestLog.start();
           
            startHandlers();
        }
        finally
        {
            thread.setContextClassLoader(lastContextLoader);
            getHandlers();
        }



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Quest in sourcecode HttpContext.doStart()

Greg Wilkins-5
Lebing,

the context classloader should only be set while the thread is within
the "context" of jetty.

So a program that uses Jetty will have it's own classloading context,
that is replaced once it calls start.   This is so that any handlers,
listeners and servlets initialized during start have access to the jetty
class loader.

After the call the start completes, the thread that called start has
it's classloader restored.  But the Jetty classloader is still used by
all classes that jetty loaded and by any thread that jetty started itself.

cheers


Lebing Xie wrote:

> Hi,all
> The last part of the HttpContext.doStart(), seemed that the thread first
> saved his own ClassLoader, and use _loader to start Servlethandlers,
> after that obtain his own CL again. What is the idea behind it. Thanx
> alot.
>
> ur Lebing
>
>
>         // Start the handlers
>         Thread thread = Thread.currentThread();
>         ClassLoader lastContextLoader=thread.getContextClassLoader();
>         try
>         {
>
>             if (_loader!=null)
>                 thread.setContextClassLoader(_loader);
>
>             if (_requestLog!=null)
>                 _requestLog.start();
>            
>             startHandlers();
>         }
>         finally
>         {
>             thread.setContextClassLoader(lastContextLoader);
>             getHandlers();
>         }
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss