@groovy.transform.CompileStatic interface SessionResolver
Resolver for the current session bound to a datastore in the current context (thread). Implementations compose over SessionHolder/ org.springframework.transaction.support.TransactionSynchronizationManager rather than maintaining independent state, so this never disagrees with Spring's own transactional session bookkeeping.
| Type Params | Return Type | Name and description |
|---|---|---|
|
abstract void |
bind(Session session)Binds a session owned by this resolver's datastore to the current context, making it the session resolve() returns. |
|
abstract boolean |
hasResolvedSession()Non-mutating check for whether a connected session is currently bound - the same determination resolve() makes, but without evicting any stale, disconnected session it finds along the way or unbinding a holder left empty by that eviction. |
|
abstract Session |
resolve()Resolves the current valid session bound in the current context (thread), or null
if none is bound. |
|
abstract void |
unbind()Unbinds and closes the current session, restoring the previously-bound session (if any) as current. |
Binds a session owned by this resolver's datastore to the current context, making it the session resolve() returns. Nested bindings stack: binding a second session pushes it on top of the first.
Non-mutating check for whether a connected session is currently bound - the same determination resolve() makes, but without evicting any stale, disconnected session it finds along the way or unbinding a holder left empty by that eviction. Safe to call from routing/discovery code that scans multiple datastores and must not have side effects on bindings unrelated to the one it ultimately selects.
Resolves the current valid session bound in the current context (thread), or null
if none is bound. Implementations must return only sessions that
Session.isConnected - stale, disconnected sessions are evicted rather than
returned (and a binding left empty by eviction is cleaned up), matching
DatastoreUtils.doGetSession's validation semantics.
Unbinds and closes the current session, restoring the previously-bound session (if
any) as current. Equivalent to DatastoreUtils.unbindSession(resolve()): the popped
session is closed (or registered for deferred close), so callers must not continue using a
session after unbinding it. When no valid session is bound, no session is closed (though
the same stale-binding housekeeping as resolve() may still occur).