return;
}
// Implementation note: the work listener is notified prior to release
// the start lock. This behavior is intentional and seems to be the
// more conservative.
workListener.workStarted(new WorkEvent(this, WorkEvent.WORK_STARTED, worker, null));
startLatch.countDown();
// Implementation note: we assume this is being called without an
// interesting TransactionContext,
// and ignore/replace whatever is associated with the current thread.
try
{
final ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
try
{
// execute with the application or domain specific classloader in the context
Thread.currentThread().setContextClassLoader(executionClassLoader);
worker.run();
}
finally
{
Thread.currentThread().setContextClassLoader(originalCl);
}
workListener.workCompleted(new WorkEvent(this, WorkEvent.WORK_COMPLETED, worker, null));
}
catch (Throwable e)
{
workException = (WorkException)(e instanceof WorkCompletedException
? e : new WorkCompletedException("Unknown error",
WorkCompletedException.UNDEFINED).initCause(e));
workListener.workCompleted(new WorkEvent(this, WorkEvent.WORK_REJECTED, worker, workException));
}
finally
{
RequestContext.clear();
TransactionCoordination.getInstance().clear();