[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] TCCL and Servlet bridge

Hi Saminda,

The servletbridge tries very hard to isolate itself from the web container it's running inside to provide a consistent and modiular base for the OSGi framework it runs. Normally for an incoming servlet request the container will set the TCCL to the webapp's class loader.The Servletbridge switches the TCCL over to use the frameworks TCCL to avoid leaking resources from the webapp class loader into the OSGi environment.

If you're interested Equinox's implementation of the TCCL is called ContextFinder which has some fairly specialized logic to determine the real context of the caller of thread.getContextClassLoader().

HTH
-Simon

Inactive hide details for "Saminda Abeyruwan" ---08/21/2008 06:11:37 PM---Hi Devs,"Saminda Abeyruwan" ---08/21/2008 06:11:37 PM---Hi Devs,


From:

"Saminda Abeyruwan" <samindaa@xxxxxxxxx>

To:

"Equinox development mailing list" <equinox-dev@xxxxxxxxxxx>

Date:

08/21/2008 06:11 PM

Subject:

[equinox-dev] TCCL and Servlet bridge




Hi Devs,

In the service method of ServletBridge class, the line of codes related TCCL setting is very peculiar .

=====================
ClassLoader original = Thread.currentThread().getContextClassLoader();
HttpServlet servletReference = acquireDelegateReference();
if (servletReference == null) {
resp.sendError(HttpServletResponse.SC_NOT_FOUND, "BridgeServlet: " + req.getRequestURI()); //$NON-NLS-1$
return;
}
try {
Thread.currentThread().setContextClassLoader(framework.getFrameworkContextClassLoader());
servletReference.service(req, resp);
} finally {
releaseDelegateReference();
Thread.currentThread().setContextClassLoader(original);
}
=====================

Why would it need to do so. ServletBridge itself is part of fragment host that extends the framework classpath.

I would really appreciate if someone could elaborate the semantics behind here.

Thank you!

Saminda
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev


GIF image

GIF image