I committed a first attempt at a listener interface. I had to split
the functionality setThreadContext method so I can tell the
difference between a context entering and leaving. The new standard
template for ThreadContext is:
ThreadContext callContext = new ThreadContext(deployInfo,
primKey, securityIdentity);
ThreadContext oldCallContext = ThreadContext.enter(callContext);
try {
doSomething();
} finally {
ThreadContext.exit(oldCallContext);
}
A few items to take note of:
* The ThreadContext code automatically manages the thread context
class loader. I have removed code from the CMP and MDB containers
that was also managing the TCCL.
* You can listen for contextEntered and contextExited events by
adding a ThreadContextListener to the ThreadContext.
* The deploymentInfo and securityIdentity are now final fields.
* When constructing a ThreadContext the deploymentInfo must not be null.
* The primaryKey is mutable because ejbCreate for Stateful and Entity
beans changes it (we should consider just pushing a new context).
WDYT?
-dain