Class TransactionalInterceptor
- java.lang.Object
-
- io.micronaut.transaction.interceptor.TransactionalInterceptor
-
- All Implemented Interfaces:
io.micronaut.aop.Interceptor<java.lang.Object,java.lang.Object>
,io.micronaut.aop.MethodInterceptor<java.lang.Object,java.lang.Object>
,io.micronaut.core.order.Ordered
@Singleton @Internal public final class TransactionalInterceptor extends java.lang.Object implements io.micronaut.aop.MethodInterceptor<java.lang.Object,java.lang.Object>
Default implementation ofTransactionalAdvice
. Forked from the reflection based code in Spring.- Since:
- 1.0
- Author:
- graemerocher, Denis stepanov
-
-
Constructor Summary
Constructors Constructor Description TransactionalInterceptor(TransactionOperationsRegistry transactionOperationsRegistry, TransactionDataSourceTenantResolver tenantResolver)
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> TransactionStatus<T>
currentTransactionStatus()
Return the transaction status of the current method invocation.int
getOrder()
java.lang.Object
intercept(io.micronaut.aop.MethodInvocationContext<java.lang.Object,java.lang.Object> context)
-
-
-
Constructor Detail
-
TransactionalInterceptor
public TransactionalInterceptor(@NonNull TransactionOperationsRegistry transactionOperationsRegistry, @Nullable TransactionDataSourceTenantResolver tenantResolver)
Default constructor.- Parameters:
transactionOperationsRegistry
- TheTransactionOperationsRegistry
tenantResolver
-
-
-
Method Detail
-
getOrder
public int getOrder()
- Specified by:
getOrder
in interfaceio.micronaut.core.order.Ordered
-
intercept
public java.lang.Object intercept(io.micronaut.aop.MethodInvocationContext<java.lang.Object,java.lang.Object> context)
- Specified by:
intercept
in interfaceio.micronaut.aop.MethodInterceptor<java.lang.Object,java.lang.Object>
-
currentTransactionStatus
public static <T> TransactionStatus<T> currentTransactionStatus() throws NoTransactionException
Return the transaction status of the current method invocation. Mainly intended for code that wants to set the current transaction rollback-only but not throw an application exception.- Type Parameters:
T
- The connection type- Returns:
- The current status
- Throws:
NoTransactionException
- if the transaction info cannot be found, because the method was invoked outside an AOP invocation context
-
-