zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.codingapi.tx.motan.interceptor;
 
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
 
/**
 * LCN 事务拦截器
 * create by lorne on 2018/1/5
 */
 
@Aspect
@Component
public class TransactionAspect implements Ordered {
 
    private Logger logger = LoggerFactory.getLogger(TransactionAspect.class);
 
    @Autowired
    private TxManagerInterceptor txManagerInterceptor;
 
 
    @Around("@annotation(com.codingapi.tx.annotation.TxTransaction)")
    public Object transactionRunning(ProceedingJoinPoint point)throws Throwable{
        logger.debug("annotation-TransactionRunning-start---->");
        Object obj = txManagerInterceptor.around(point);
        logger.debug("annotation-TransactionRunning-end---->");
        return obj;
    }
 
    @Around("this(com.codingapi.tx.annotation.ITxTransaction) && execution( * *(..))")
    public Object around(ProceedingJoinPoint point)throws Throwable{
        logger.debug("interface-ITransactionRunning-start---->");
        Object obj =  txManagerInterceptor.around(point);
        logger.debug("interface-ITransactionRunning-end---->");
        return obj;
    }
 
 
    @Override
    public int getOrder() {
        return HIGHEST_PRECEDENCE;
    }
 
 
}