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);
}
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.
Aaron
> Aside from the extreme slowness Dain mentioned, I don't see how to
> implement this proposal without a major rewriting of the WorkManager.
> Nothing else in connector-land executes with the TCCL set to the
> connector's classloader, so I'm not really seeing why the Work
> submissions should.