Package io.micronaut.transaction.support
Class AbstractReactorTransactionOperations<C>
java.lang.Object
io.micronaut.transaction.support.AbstractReactorTransactionOperations<C>
- Type Parameters:
C
- The connection type
- All Implemented Interfaces:
ReactiveTransactionOperations<C>
,ReactorReactiveTransactionOperations<C>
@Internal
public abstract class AbstractReactorTransactionOperations<C>
extends Object
implements ReactorReactiveTransactionOperations<C>
Abstract Reactor transaction operations.
- Since:
- 4.0.0
- Author:
- Denis Stepanov
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static final class
Represents the current reactive transaction status.Nested classes/interfaces inherited from interface io.micronaut.transaction.reactive.ReactiveTransactionOperations
ReactiveTransactionOperations.TransactionalCallback<C,
T> -
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractReactorTransactionOperations
(ReactorConnectionOperations<C> connectionOperations) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract @NonNull org.reactivestreams.Publisher<Void>
beginTransaction
(@NonNull ConnectionStatus<C> connectionStatus, @NonNull TransactionDefinition transactionDefinition) protected abstract @NonNull org.reactivestreams.Publisher<Void>
commitTransaction
(@NonNull ConnectionStatus<C> connectionStatus, @NonNull TransactionDefinition transactionDefinition) protected @NonNull org.reactivestreams.Publisher<Void>
doCancel
(@NonNull AbstractReactorTransactionOperations.DefaultReactiveTransactionStatus<C> status) Cancels the TX operation.protected <R> @NonNull reactor.core.publisher.Flux<R>
executeCallbackFlux
(@NonNull ReactiveTransactionStatus<C> status, @NonNull ReactiveTransactionOperations.TransactionalCallback<C, R> handler) Execute the callback.protected <R> @NonNull reactor.core.publisher.Mono<R>
executeCallbackMono
(@NonNull ReactiveTransactionStatus<C> status, @NonNull Function<ReactiveTransactionStatus<C>, reactor.core.publisher.Mono<R>> handler) Execute the callback.protected <R> @NonNull reactor.core.publisher.Flux<R>
executeTransactionFlux
(@NonNull AbstractReactorTransactionOperations.DefaultReactiveTransactionStatus<C> txStatus, @NonNull ReactiveTransactionOperations.TransactionalCallback<C, R> handler) Execute the transaction.protected <R> @NonNull reactor.core.publisher.Mono<R>
executeTransactionMono
(@NonNull AbstractReactorTransactionOperations.DefaultReactiveTransactionStatus<C> txStatus, @NonNull Function<ReactiveTransactionStatus<C>, reactor.core.publisher.Mono<R>> handler) Execute the transaction.final Optional<ReactiveTransactionStatus<C>>
findTransactionStatus
(reactor.util.context.ContextView contextView) Retrieve the transaction status associated to the current transaction manager from the Reactor context.final TransactionDefinition
getTransactionDefinition
(reactor.util.context.ContextView contextView) Retrieve the transaction definition associated to the current transaction from the Reactor context.final ReactiveTransactionStatus<C>
getTransactionStatus
(reactor.util.context.ContextView contextView) Retrieve the transaction status associated to the current transaction manager from the Reactor context.protected abstract @NonNull org.reactivestreams.Publisher<Void>
rollbackTransaction
(@NonNull ConnectionStatus<C> connectionStatus, @NonNull TransactionDefinition transactionDefinition) final <T> @NonNull reactor.core.publisher.Flux<T>
withTransaction
(@NonNull TransactionDefinition definition, @NonNull ReactiveTransactionOperations.TransactionalCallback<C, T> handler) Execute the given handler with a new transaction.protected <T> reactor.core.publisher.Flux<T>
withTransactionFlux
(ReactiveTransactionStatus<C> transactionStatus, TransactionDefinition definition, ReactiveTransactionOperations.TransactionalCallback<C, T> handler) Execute the transaction with provided transaction status.<T> reactor.core.publisher.Mono<T>
withTransactionMono
(TransactionDefinition definition, Function<ReactiveTransactionStatus<C>, reactor.core.publisher.Mono<T>> handler) Execute the given handler with a new transaction.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.transaction.reactive.ReactorReactiveTransactionOperations
withTransaction, withTransactionFlux, withTransactionFlux, withTransactionMono
-
Constructor Details
-
AbstractReactorTransactionOperations
protected AbstractReactorTransactionOperations(@Parameter ReactorConnectionOperations<C> connectionOperations)
-
-
Method Details
-
beginTransaction
@NonNull protected abstract @NonNull org.reactivestreams.Publisher<Void> beginTransaction(@NonNull @NonNull ConnectionStatus<C> connectionStatus, @NonNull @NonNull TransactionDefinition transactionDefinition) -
commitTransaction
@NonNull protected abstract @NonNull org.reactivestreams.Publisher<Void> commitTransaction(@NonNull @NonNull ConnectionStatus<C> connectionStatus, @NonNull @NonNull TransactionDefinition transactionDefinition) -
rollbackTransaction
@NonNull protected abstract @NonNull org.reactivestreams.Publisher<Void> rollbackTransaction(@NonNull @NonNull ConnectionStatus<C> connectionStatus, @NonNull @NonNull TransactionDefinition transactionDefinition) -
findTransactionStatus
public final Optional<ReactiveTransactionStatus<C>> findTransactionStatus(reactor.util.context.ContextView contextView) Description copied from interface:ReactorReactiveTransactionOperations
Retrieve the transaction status associated to the current transaction manager from the Reactor context.- Specified by:
findTransactionStatus
in interfaceReactorReactiveTransactionOperations<C>
- Parameters:
contextView
- The context view- Returns:
- the key
-
getTransactionStatus
public final ReactiveTransactionStatus<C> getTransactionStatus(reactor.util.context.ContextView contextView) Description copied from interface:ReactorReactiveTransactionOperations
Retrieve the transaction status associated to the current transaction manager from the Reactor context.- Specified by:
getTransactionStatus
in interfaceReactorReactiveTransactionOperations<C>
- Parameters:
contextView
- The context view- Returns:
- the key
-
getTransactionDefinition
public final TransactionDefinition getTransactionDefinition(reactor.util.context.ContextView contextView) Description copied from interface:ReactorReactiveTransactionOperations
Retrieve the transaction definition associated to the current transaction from the Reactor context.- Specified by:
getTransactionDefinition
in interfaceReactorReactiveTransactionOperations<C>
- Parameters:
contextView
- The context view- Returns:
- the key
-
withTransaction
@NonNull public final <T> @NonNull reactor.core.publisher.Flux<T> withTransaction(@NonNull @NonNull TransactionDefinition definition, @NonNull @NonNull ReactiveTransactionOperations.TransactionalCallback<C, T> handler) Description copied from interface:ReactiveTransactionOperations
Execute the given handler with a new transaction.- Specified by:
withTransaction
in interfaceReactiveTransactionOperations<C>
- Specified by:
withTransaction
in interfaceReactorReactiveTransactionOperations<C>
- Type Parameters:
T
- The emitted type- Parameters:
definition
- The definitionhandler
- The handler- Returns:
- A publisher that emits the result type
-
withTransactionFlux
protected <T> reactor.core.publisher.Flux<T> withTransactionFlux(ReactiveTransactionStatus<C> transactionStatus, TransactionDefinition definition, ReactiveTransactionOperations.TransactionalCallback<C, T> handler) Execute the transaction with provided transaction status.- Type Parameters:
T
- The transaction type- Parameters:
transactionStatus
- The transaction statusdefinition
- The definitionhandler
- The handler- Returns:
- The published result
-
withTransactionMono
public <T> reactor.core.publisher.Mono<T> withTransactionMono(TransactionDefinition definition, Function<ReactiveTransactionStatus<C>, reactor.core.publisher.Mono<T>> handler) Description copied from interface:ReactorReactiveTransactionOperations
Execute the given handler with a new transaction.- Specified by:
withTransactionMono
in interfaceReactorReactiveTransactionOperations<C>
- Type Parameters:
T
- The emitted type- Parameters:
definition
- The definitionhandler
- The handler- Returns:
- A publisher that emits the result type
-
executeTransactionFlux
@NonNull protected <R> @NonNull reactor.core.publisher.Flux<R> executeTransactionFlux(@NonNull @NonNull AbstractReactorTransactionOperations.DefaultReactiveTransactionStatus<C> txStatus, @NonNull @NonNull ReactiveTransactionOperations.TransactionalCallback<C, R> handler) Execute the transaction.- Type Parameters:
R
- The callback result type- Parameters:
txStatus
- The transaction statushandler
- The callback- Returns:
- The callback result
-
executeTransactionMono
@NonNull protected <R> @NonNull reactor.core.publisher.Mono<R> executeTransactionMono(@NonNull @NonNull AbstractReactorTransactionOperations.DefaultReactiveTransactionStatus<C> txStatus, @NonNull @NonNull Function<ReactiveTransactionStatus<C>, reactor.core.publisher.Mono<R>> handler) Execute the transaction.- Type Parameters:
R
- The callback result type- Parameters:
txStatus
- The transaction statushandler
- The callback- Returns:
- The callback result
-
executeCallbackFlux
@NonNull protected <R> @NonNull reactor.core.publisher.Flux<R> executeCallbackFlux(@NonNull @NonNull ReactiveTransactionStatus<C> status, @NonNull @NonNull ReactiveTransactionOperations.TransactionalCallback<C, R> handler) Execute the callback.- Type Parameters:
R
- The callback result type- Parameters:
status
- The transaction statushandler
- The callback- Returns:
- The callback result
-
executeCallbackMono
@NonNull protected <R> @NonNull reactor.core.publisher.Mono<R> executeCallbackMono(@NonNull @NonNull ReactiveTransactionStatus<C> status, @NonNull @NonNull Function<ReactiveTransactionStatus<C>, reactor.core.publisher.Mono<R>> handler) Execute the callback.- Type Parameters:
R
- The callback result type- Parameters:
status
- The transaction statushandler
- The callback- Returns:
- The callback result
-
doCancel
@NonNull protected @NonNull org.reactivestreams.Publisher<Void> doCancel(@NonNull @NonNull AbstractReactorTransactionOperations.DefaultReactiveTransactionStatus<C> status) Cancels the TX operation.- Parameters:
status
- The TX status- Returns:
- the canceling publisher
-