it.amattioli.dominate.sessions
Interface SessionManager

Show UML class diagram
All Known Implementing Classes:
CompositeSessionManager, HibernateSessionManager

public interface SessionManager

With a SessionManager instance you a repository is able to retrieve sessions to interact with an external repository system like a RDBMS.

A SessionManager can exist with two different SessionMode:

In thread local mode the manager will retain a session for the duration of a single thread. When the thred finishes the session is discarded.

In long running mode the session will be alive until the session manager is released using the release() or reset() method.

Author:
andrea

Method Summary
<S> S
getSession(Class<S> sessionClass)
          Retrieves a session associated with this SessionManager.
 SessionMode getSessionMode()
          Retrieves the SessionMode associated with this SessionManager
 boolean hasSessionMode(SessionMode sMode)
          Check if this SessionManager has a certain SessionMode
 boolean isReleased()
          Check if this SessionManager has been released.
 void release()
          Release this SessionManager and close all the associated sessions.
 void reset()
          Close all the associated sessions.
 void setSessionMode(SessionMode sessionMode)
           
 org.apache.commons.collections.Closure transactionalClosure(org.apache.commons.collections.Closure toBeDone)
          Decorate a closure so that it will be executed in a transactional context.
 

Method Detail

getSessionMode

SessionMode getSessionMode()
Retrieves the SessionMode associated with this SessionManager

Returns:
the SessionMode associated with this SessionManager

setSessionMode

void setSessionMode(SessionMode sessionMode)

hasSessionMode

boolean hasSessionMode(SessionMode sMode)
Check if this SessionManager has a certain SessionMode

Parameters:
sMode - the SessionMode to check
Returns:
true if this SessionManager has a certain SessionMode

getSession

<S> S getSession(Class<S> sessionClass)
Retrieves a session associated with this SessionManager. If this SessionManager has an associated session whose class is the same as the given class it will be returned, otherwise null will be returned.

Type Parameters:
S -
Parameters:
sessionClass - the class of the needed session
Returns:
the session associated with this SessionManager whose class is the same as the given class if it exists, null otherwise
Throws:
IllegalStateException - if this SessionManager has been released calling the release() method

release

void release()
Release this SessionManager and close all the associated sessions. After this, when the getSession(Class) method is called an IllegalStateException will be thrown


isReleased

boolean isReleased()
Check if this SessionManager has been released.

Returns:
true if this SessionManager has been released, false otherwise
See Also:
#release()}

reset

void reset()
Close all the associated sessions. After this, when the getSession(Class) method is called a new session will be opened.


transactionalClosure

org.apache.commons.collections.Closure transactionalClosure(org.apache.commons.collections.Closure toBeDone)
Decorate a closure so that it will be executed in a transactional context. A transaction will be open before the closure is executed and the same transaction will be committed after the execution.

Parameters:
toBeDone - the closure to be decorated
Returns:
the decorated closure


Copyright © 2011. All Rights Reserved.