|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.e2etrace.trace.AbstractTraceSessionManager org.e2etrace.trace.ThreadedTraceSessionManager
public class ThreadedTraceSessionManager
Thread-Aware implementation of a trace session manager.
This session manager is targeted for a multi-threaded environment (e.g.
application servers). It maintains a ITraceSession
for
every running thread.
Note: The implementation uses a synchronized
WeakHashMap
to cache the sessions (using the threads as keys).
Hence, as soon as a thread terminates, the GC will remove the respective
cache entry automatically. This design works for multi-threaded applications
and for application servers using thread pools. An alternative design would
have been to use ThreadLocal
instead. However, there are
discussions going on that ThreadLocal
may cause memory leaks
on application servers if applications are hot-deployed (just google for
threadlocal+leak). Personally, I would prefer ThreadLocal
instead of the custom cache that is currently implemented, because the
ThreadLocal
approache doesn´t require a synchronized map that
stores the trace sessions. I´ll monitor the memory-leak discussion and decide
later, if a re-design is appropriate.
This class implements the singleton pattern.
Method Summary | |
---|---|
protected void |
assignCurrentSession(ITraceSession session)
CALL-BACK: Forward a newly assigned current trace session to sub-classes. |
static ThreadedTraceSessionManager |
getInstance()
Returns the singleton instance of the session manager. |
void |
releaseCurrentSession()
Release current session. |
protected ITraceSession |
requestCurrentSession()
CALL-BACK: Request the current trace session from sub-classes. |
Methods inherited from class org.e2etrace.trace.AbstractTraceSessionManager |
---|
getConfig, getCurrentSession, setConfig, setCurrentSession |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ThreadedTraceSessionManager getInstance()
protected ITraceSession requestCurrentSession()
This call-back is triggered for every invokation of
getCurrentSession
.
requestCurrentSession
in class AbstractTraceSessionManager
protected void assignCurrentSession(ITraceSession session)
This call-back is triggered for every invokation of
setCurrentSession
.
assignCurrentSession
in class AbstractTraceSessionManager
session
- new current (active) trace sessionpublic void releaseCurrentSession()
This call releases the reference to the current trace session. It should be called in when all trace data for the current trace session has been collected and the session is no longer needed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |