Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.hibernate.context
Class ManagedSessionContext  view ManagedSessionContext download ManagedSessionContext.java

java.lang.Object
  extended byorg.hibernate.context.ManagedSessionContext
All Implemented Interfaces:
CurrentSessionContext, java.io.Serializable

public class ManagedSessionContext
extends java.lang.Object
implements CurrentSessionContext

Represents a CurrentSessionContext the notion of a contextual session is managed by some external entity (generally some form of interceptor, etc). This external manager is responsible for scoping these contextual sessions appropriately binding/unbinding them here for exposure to the application through SessionFactory.getCurrentSession()>SessionFactory.getCurrentSession() 55 calls.

Basically exposes two interfaces.

The underlying storage of the current sessions here is a static java.lang.ThreadLocal-based map where the sessions are keyed by the the owning session factory.


Field Summary
private static java.lang.ThreadLocal context
           
private  org.hibernate.engine.SessionFactoryImplementor factory
           
 
Constructor Summary
ManagedSessionContext(org.hibernate.engine.SessionFactoryImplementor factory)
           
 
Method Summary
static org.hibernate.classic.Session bind(org.hibernate.classic.Session session)
          Binds the given session to the current context for its session factory.
 org.hibernate.classic.Session currentSession()
          Retrieve the current session according to the scoping defined by this implementation.
private static void doCleanup()
           
private static org.hibernate.classic.Session existingSession(org.hibernate.SessionFactory factory)
           
static boolean hasBind(org.hibernate.SessionFactory factory)
          Check to see if there is already a session associated with the current thread for the given session factory.
protected static java.util.Map sessionMap()
           
private static java.util.Map sessionMap(boolean createMap)
           
static org.hibernate.classic.Session unbind(org.hibernate.SessionFactory factory)
          Unbinds the session (if one) current associated with the context for the given session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

private static final java.lang.ThreadLocal context

factory

private final org.hibernate.engine.SessionFactoryImplementor factory
Constructor Detail

ManagedSessionContext

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

currentSession

public org.hibernate.classic.Session currentSession()
Description copied from interface: CurrentSessionContext
Retrieve the current session according to the scoping defined by this implementation.

Specified by:
currentSession in interface CurrentSessionContext

hasBind

public static boolean hasBind(org.hibernate.SessionFactory factory)
Check to see if there is already a session associated with the current thread for the given session factory.


bind

public static org.hibernate.classic.Session bind(org.hibernate.classic.Session session)
Binds the given session to the current context for its session factory.


unbind

public static org.hibernate.classic.Session unbind(org.hibernate.SessionFactory factory)
Unbinds the session (if one) current associated with the context for the given session.


existingSession

private static org.hibernate.classic.Session existingSession(org.hibernate.SessionFactory factory)

sessionMap

protected static java.util.Map sessionMap()

sessionMap

private static java.util.Map sessionMap(boolean createMap)

doCleanup

private static void doCleanup()