@Singleton
public class TransactionalInterceptor
extends java.lang.Object
implements io.micronaut.aop.MethodInterceptor<java.lang.Object,java.lang.Object>
TransactionalAdvice
. Forked from the reflection based code in Spring.Modifier and Type | Class and Description |
---|---|
protected static class |
TransactionalInterceptor.TransactionInfo<T>
Deprecated.
The class will be final with private methods in the next major version
|
Constructor and Description |
---|
TransactionalInterceptor(io.micronaut.context.BeanLocator beanLocator)
Default constructor.
|
TransactionalInterceptor(io.micronaut.context.BeanLocator beanLocator,
CoroutineTxHelper coroutineTxHelper)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
cleanupTransactionInfo(TransactionalInterceptor.TransactionInfo txInfo)
Deprecated.
The class will be final with private methods in the next major version
|
protected void |
commitTransactionAfterReturning(TransactionalInterceptor.TransactionInfo txInfo)
Deprecated.
The class will be final with private methods in the next major version
|
protected void |
completeTransactionAfterThrowing(TransactionalInterceptor.TransactionInfo txInfo,
java.lang.Throwable ex)
Deprecated.
The class will be final with private methods in the next major version
|
protected TransactionalInterceptor.TransactionInfo |
createTransactionIfNecessary(SynchronousTransactionManager<?> tm,
TransactionAttribute txAttr,
io.micronaut.inject.ExecutableMethod<java.lang.Object,java.lang.Object> executableMethod)
Deprecated.
The class will be final with private methods in the next major version
|
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) |
protected TransactionalInterceptor.TransactionInfo |
prepareTransactionInfo(SynchronousTransactionManager tm,
TransactionAttribute txAttr,
io.micronaut.inject.ExecutableMethod<java.lang.Object,java.lang.Object> executableMethod,
TransactionStatus status)
Deprecated.
The class will be final with private methods in the next major version
|
protected TransactionAttribute |
resolveTransactionDefinition(io.micronaut.inject.ExecutableMethod<java.lang.Object,java.lang.Object> executableMethod)
Deprecated.
The class will be final with private methods in the next major version
|
public TransactionalInterceptor(@NonNull io.micronaut.context.BeanLocator beanLocator)
beanLocator
- The bean locator.@Inject public TransactionalInterceptor(@NonNull io.micronaut.context.BeanLocator beanLocator, @Nullable CoroutineTxHelper coroutineTxHelper)
beanLocator
- The bean locator.coroutineTxHelper
- The coroutine helperpublic int getOrder()
getOrder
in interface io.micronaut.core.order.Ordered
public java.lang.Object intercept(io.micronaut.aop.MethodInvocationContext<java.lang.Object,java.lang.Object> context)
intercept
in interface io.micronaut.aop.MethodInterceptor<java.lang.Object,java.lang.Object>
public static <T> TransactionStatus<T> currentTransactionStatus() throws NoTransactionException
T
- The connection typeNoTransactionException
- if the transaction info cannot be found,
because the method was invoked outside an AOP invocation context@Deprecated protected TransactionalInterceptor.TransactionInfo createTransactionIfNecessary(@NonNull SynchronousTransactionManager<?> tm, @NonNull TransactionAttribute txAttr, io.micronaut.inject.ExecutableMethod<java.lang.Object,java.lang.Object> executableMethod)
Allows callers to perform custom TransactionAttribute lookups through the TransactionAttributeSource.
tm
- The transaction managertxAttr
- the TransactionAttribute (may be null
)executableMethod
- the method that is being executed
(used for monitoring and logging purposes)hasTransaction()
method on TransactionInfo can be used to
tell if there was a transaction created.@Deprecated protected TransactionalInterceptor.TransactionInfo prepareTransactionInfo(@NonNull SynchronousTransactionManager tm, @NonNull TransactionAttribute txAttr, io.micronaut.inject.ExecutableMethod<java.lang.Object,java.lang.Object> executableMethod, @NonNull TransactionStatus status)
tm
- The transaction managertxAttr
- the TransactionAttribute (may be null
)executableMethod
- the fully qualified method name
(used for monitoring and logging purposes)status
- the TransactionStatus for the current transaction@Deprecated protected void commitTransactionAfterReturning(@NonNull TransactionalInterceptor.TransactionInfo txInfo)
txInfo
- information about the current transaction@Deprecated protected void completeTransactionAfterThrowing(@NonNull TransactionalInterceptor.TransactionInfo txInfo, java.lang.Throwable ex)
txInfo
- information about the current transactionex
- throwable encountered@Deprecated protected void cleanupTransactionInfo(@Nullable TransactionalInterceptor.TransactionInfo txInfo)
Call this in all cases: exception or normal return!
txInfo
- information about the current transaction (may be null
)@Deprecated protected TransactionAttribute resolveTransactionDefinition(io.micronaut.inject.ExecutableMethod<java.lang.Object,java.lang.Object> executableMethod)
executableMethod
- The methodTransactionAttribute