@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>Opaque object used to hold transaction information. | 
| Constructor and Description | 
|---|
| TransactionalInterceptor(io.micronaut.context.BeanLocator beanLocator)Default constructor. | 
| Modifier and Type | Method and Description | 
|---|---|
| protected void | cleanupTransactionInfo(TransactionalInterceptor.TransactionInfo txInfo)Reset the TransactionInfo ThreadLocal. | 
| protected void | commitTransactionAfterReturning(TransactionalInterceptor.TransactionInfo txInfo)Execute after successful completion of call, but not after an exception was handled. | 
| protected void | completeTransactionAfterThrowing(TransactionalInterceptor.TransactionInfo txInfo,
                                java.lang.Throwable ex)Handle a throwable, completing the transaction. | 
| protected TransactionalInterceptor.TransactionInfo | createTransactionIfNecessary(SynchronousTransactionManager<?> tm,
                            TransactionAttribute txAttr,
                            io.micronaut.inject.ExecutableMethod<java.lang.Object,java.lang.Object> executableMethod)Create a transaction if necessary based on the given TransactionAttribute. | 
| 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)Prepare a TransactionInfo for the given attribute and status object. | 
| protected TransactionAttribute | resolveTransactionDefinition(io.micronaut.inject.ExecutableMethod<java.lang.Object,java.lang.Object> executableMethod) | 
public TransactionalInterceptor(@NonNull
                                io.micronaut.context.BeanLocator beanLocator)
beanLocator - The bean locator.public int getOrder()
getOrder in interface io.micronaut.core.order.Orderedpublic 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 contextprotected 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.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 transactionprotected void commitTransactionAfterReturning(@NonNull
                                               TransactionalInterceptor.TransactionInfo txInfo)
txInfo - information about the current transactionprotected void completeTransactionAfterThrowing(@NonNull
                                                TransactionalInterceptor.TransactionInfo txInfo,
                                                java.lang.Throwable ex)
txInfo - information about the current transactionex - throwable encounteredprotected void cleanupTransactionInfo(@Nullable
                                      TransactionalInterceptor.TransactionInfo txInfo)
Call this in all cases: exception or normal return!
txInfo - information about the current transaction (may be null)protected TransactionAttribute resolveTransactionDefinition(io.micronaut.inject.ExecutableMethod<java.lang.Object,java.lang.Object> executableMethod)
executableMethod - The methodTransactionAttribute