99import com .codingapi .tx .model .TransactionInvocation ;
1010import org .aspectj .lang .ProceedingJoinPoint ;
1111import org .aspectj .lang .reflect .MethodSignature ;
12+ import org .slf4j .Logger ;
13+ import org .slf4j .LoggerFactory ;
1214import org .springframework .beans .factory .annotation .Autowired ;
1315import org .springframework .stereotype .Service ;
14- import org .springframework .transaction .annotation .Transactional ;
1516
1617import java .lang .reflect .Method ;
1718
@@ -25,6 +26,9 @@ public class AspectBeforeServiceImpl implements AspectBeforeService {
2526 private TransactionServerFactoryService transactionServerFactoryService ;
2627
2728
29+ private Logger logger = LoggerFactory .getLogger (AspectBeforeServiceImpl .class );
30+
31+
2832 public Object around (String groupId ,int maxTimeOut , ProceedingJoinPoint point ) throws Throwable {
2933
3034 MethodSignature signature = (MethodSignature ) point .getSignature ();
@@ -35,16 +39,19 @@ public Object around(String groupId,int maxTimeOut, ProceedingJoinPoint point) t
3539
3640 TxTransaction transaction = thisMethod .getAnnotation (TxTransaction .class );
3741
38- Transactional transactional = thisMethod .getAnnotation (Transactional .class );
39- if (transactional == null ) {
40- transactional = clazz .getAnnotation (Transactional .class );
42+ TxTransactionLocal txTransactionLocal = TxTransactionLocal .current ();
43+
44+
45+ if (txTransactionLocal !=null ){
46+ //在同一次事务下,调用多个业务模块。
47+ txTransactionLocal .setHasMoreService (true );
4148 }
4249
43- TxTransactionLocal txTransactionLocal = TxTransactionLocal . current ( );
50+ logger . info ( "around--> groupId-> " + groupId + ",txTransactionLocal->" + txTransactionLocal );
4451
4552 TransactionInvocation invocation = new TransactionInvocation (clazz , thisMethod .getName (), thisMethod .toString (), args , method .getParameterTypes ());
4653
47- TxTransactionInfo info = new TxTransactionInfo (transaction ,transactional , txTransactionLocal ,invocation ,groupId ,maxTimeOut );
54+ TxTransactionInfo info = new TxTransactionInfo (transaction ,txTransactionLocal ,invocation ,groupId ,maxTimeOut );
4855
4956 TransactionServer server = transactionServerFactoryService .createTransactionServer (info );
5057
0 commit comments