|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.datastore.core.DatastoreUtils
public abstract class DatastoreUtils
Helper class for obtaining Datastore sessions. Based on similar work for Hibernate such as SessionFactoryUtils
Field Summary | |
---|---|
static org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
---|---|
DatastoreUtils()
|
Method Summary | |
---|---|
static void |
closeSession(Session session)
Perform actual closing of the Session, catching and logging any cleanup exceptions thrown. |
static void |
closeSessionOrRegisterDeferredClose(Session session,
Datastore datastore)
Close the given Session or register it for deferred close. |
static Session |
getSession(Datastore datastore,
boolean allowCreate)
Get a Datastore Session for the given Datastore. |
static void |
initDeferredClose(Datastore datastore)
Initialize deferred close for the current thread and the given Datastore. |
static boolean |
isSessionTransactional(Session session,
Datastore datastore)
Return whether the given Datastore Session is transactional, that is, bound to the current thread by Spring's transaction facilities. |
static void |
processDeferredClose(Datastore datastore)
Process all Datastore Sessions that have been registered for deferred close for the given SessionFactory. |
static void |
releaseSession(Session session,
Datastore datastore)
Close the given Session, created via the given factory, if it is not managed externally (i.e. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final org.apache.commons.logging.Log logger
Constructor Detail |
---|
public DatastoreUtils()
Method Detail |
---|
public static Session getSession(Datastore datastore, boolean allowCreate) throws org.springframework.dao.DataAccessResourceFailureException, IllegalStateException
DatastoreTransactionManager
. Will create a new
Session otherwise, if "allowCreate" is true
.
This is the getSession
method used by typical data access code,
in combination with releaseSession
called when done with
the Session.
datastore
- Datastore to create the session withallowCreate
- whether a non-transactional Session should be created
when no transactional Session can be found for the current thread
org.springframework.dao.DataAccessResourceFailureException
- if the Session couldn't be created
IllegalStateException
- if no thread-bound Session found and
"allowCreate" is false
public static boolean isSessionTransactional(Session session, Datastore datastore)
session
- the Datastore Session to checkdatastore
- Datastore that the Session was created with
(may be null
)
public static void closeSession(Session session)
session
- The Session instancepublic static void releaseSession(Session session, Datastore datastore)
session
- the Datastore Session to close (may be null
)datastore
- Datastore that the Session was created with
(may be null
)public static void processDeferredClose(Datastore datastore)
datastore
- the Datastore to process deferred close forinitDeferredClose(org.springframework.datastore.core.Datastore)
,
releaseSession(org.springframework.datastore.core.Session, org.springframework.datastore.core.Datastore)
public static void initDeferredClose(Datastore datastore)
processDeferredClose(org.springframework.datastore.core.Datastore)
call at a finishing point (like request completion).
datastore
- the Datastore to initialize deferred close forprocessDeferredClose(org.springframework.datastore.core.Datastore)
,
releaseSession(org.springframework.datastore.core.Session, org.springframework.datastore.core.Datastore)
public static void closeSessionOrRegisterDeferredClose(Session session, Datastore datastore)
session
- the Datastore Session to closedatastore
- Datastore that the Session was created with
(may be null
)initDeferredClose(org.springframework.datastore.core.Datastore)
,
processDeferredClose(org.springframework.datastore.core.Datastore)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |