On Oct 3, 2004, at 11:56 AM, Aaron Mulder wrote:
> On Sun, 3 Oct 2004, David Jencks wrote:
>> At the moment, the only way I see to implement this would be to supply
>> a separate WorkManager instance to each ResourceAdapter that could
>> associate the RA classloader with the work request.
>
> Couldn't the implementation go like this (in WorkerContext.run):
>
>
> ClassLoader before = Thread.currentThread().getContextClassLoader();
> try {
> Thread.currentThread().setContextClassLoader(adaptee.getClass().
> getClassLoader());
> ...
> adaptee.run();
> ...
> } finally {
> Thread.currentThread().setContextClassLoader(before);
> }
That won't work. The adaptee class may be loaded from a parent class
loader of the actual ra, which in my opinion would be actually worse
then having a null TCCL.
> The speed issue, well, I guess that's a more significant problem.
> If it's not slow to *read* the TCCL, we may want to do something like
> the
> above as a defensive measure -- reset the TCCL to the proper one if the
> Work changes it without changing it back. So we'd only record the
> existing (or desired) CL before invoking adaptee.run, and we'd put an
> "if(Thread.cT().getCCL() != before)" before resetting it in the finally
> clause.
Both operations are expensive. Of course dropping it from 3 operations
to 1 is better, but the general policy of geronimo is to only set the
TCCL is absolutely required by a specification (for example we set it
for EJBs).
-dain
|