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> Texecute(SessionCallback<T> action) Executes the givenSessionCallbackwithin theClientSession.<T> Texecute(SessionCallback<T> action, Consumer<com.mongodb.client.ClientSession> doFinally) Executes the givenSessionCallbackwithin theClientSession.
-
Method Details
-
execute
Executes the givenSessionCallbackwithin theClientSession.
It is up to the caller to make sure theClientSessionisclosedwhen 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 givenSessionCallbackwithin theClientSession.
It is up to the caller to make sure theClientSessionisclosedwhen 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 acceptsClientSessionafter invokingSessionCallback. ThisConsumeris guaranteed to be notified in any case (successful and exceptional outcome ofSessionCallback).- Returns:
- a result object returned by the action. Can be null.
-