org.mycore.backend.hibernate
Class MCRSessionContext

java.lang.Object
  extended by org.hibernate.context.ThreadLocalSessionContext
      extended by org.mycore.backend.hibernate.MCRSessionContext
All Implemented Interfaces:
Serializable, org.hibernate.context.CurrentSessionContext, MCRSessionListener

public class MCRSessionContext
extends org.hibernate.context.ThreadLocalSessionContext
implements MCRSessionListener

A CurrentSessionContext implementation which scopes the notion of current session by the current MCRSession. As the MCRSession can be used by more than one Thread at a time and Session is not threadsafe. This implementation allows the first thread of a MCRSession to keep the Session open for a long conversation.

Since:
2.0
Version:
$Revision: 13745 $ $Date: 2008-07-14 15:07:17 +0200 (Mo, 14 Jul 2008) $
Author:
Thomas Scheffler (yagee)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.hibernate.context.ThreadLocalSessionContext
org.hibernate.context.ThreadLocalSessionContext.CleanupSynch
 
Field Summary
(package private)  ThreadLocal<Boolean> firstThread
           
 
Fields inherited from class org.hibernate.context.ThreadLocalSessionContext
factory
 
Constructor Summary
MCRSessionContext(org.hibernate.engine.SessionFactoryImplementor factory)
           
 
Method Summary
protected  org.hibernate.context.ThreadLocalSessionContext.CleanupSynch buildCleanupSynch()
           
protected  org.hibernate.classic.Session buildOrObtainSession()
           
protected  boolean isAutoCloseEnabled()
           
protected  boolean isAutoFlushEnabled()
           
 void sessionEvent(MCRSessionEvent event)
           
 
Methods inherited from class org.hibernate.context.ThreadLocalSessionContext
bind, currentSession, getConnectionReleaseMode, getFactory, sessionMap, unbind, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

firstThread

ThreadLocal<Boolean> firstThread
Constructor Detail

MCRSessionContext

public MCRSessionContext(org.hibernate.engine.SessionFactoryImplementor factory)
Method Detail

sessionEvent

public void sessionEvent(MCRSessionEvent event)
Specified by:
sessionEvent in interface MCRSessionListener

buildOrObtainSession

protected org.hibernate.classic.Session buildOrObtainSession()
Overrides:
buildOrObtainSession in class org.hibernate.context.ThreadLocalSessionContext

isAutoCloseEnabled

protected boolean isAutoCloseEnabled()
Overrides:
isAutoCloseEnabled in class org.hibernate.context.ThreadLocalSessionContext

isAutoFlushEnabled

protected boolean isAutoFlushEnabled()
Overrides:
isAutoFlushEnabled in class org.hibernate.context.ThreadLocalSessionContext

buildCleanupSynch

protected org.hibernate.context.ThreadLocalSessionContext.CleanupSynch buildCleanupSynch()
Overrides:
buildCleanupSynch in class org.hibernate.context.ThreadLocalSessionContext