Interface SessionScoped
public interface SessionScoped
Gateway interface to execute
The very same bound
ClientSession
bound operations against MongoDB via a SessionCallback
.
The very same bound
ClientSession
is used for all invocations of execute
on the instance.- Since:
- 2.1
- Author:
- Christoph Strobl, Mark Paluch
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> T
execute
(SessionCallback<T> action) Executes the givenSessionCallback
within theClientSession
.<T> T
execute
(SessionCallback<T> action, Consumer<com.mongodb.client.ClientSession> doFinally) Executes the givenSessionCallback
within theClientSession
.
-
Method Details
-
execute
Executes the givenSessionCallback
within theClientSession
.
It is up to the caller to make sure theClientSession
isclosed
when done.- Type Parameters:
T
- return type.- Parameters:
action
- callback object that specifies the MongoDB action the callback action. Must not be null.- Returns:
- a result object returned by the action. Can be null.
-
execute
@Nullable <T> T execute(SessionCallback<T> action, Consumer<com.mongodb.client.ClientSession> doFinally) Executes the givenSessionCallback
within theClientSession
.
It is up to the caller to make sure theClientSession
isclosed
when done.- Type Parameters:
T
- return type.- Parameters:
action
- callback object that specifies the MongoDB action the callback action. Must not be null.doFinally
- callback object that acceptsClientSession
after invokingSessionCallback
. ThisConsumer
is guaranteed to be notified in any case (successful and exceptional outcome ofSessionCallback
).- Returns:
- a result object returned by the action. Can be null.
-