Skip to content

Commit 842d68d

Browse files
authored
Merge pull request #237 from codingapi/5.0.0.RELEASE
5.0.0.release
2 parents 9b8dee3 + 961b5e2 commit 842d68d

19 files changed

Lines changed: 75 additions & 22 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# tx-lcn分布式事务框架 (5.0.0)
1+
# tx-lcn分布式事务框架 (5.0.0.RELEASE)
22

33
[![Gitter](https://badges.gitter.im/codingapi/tx-lcn.svg)](https://gitter.im/codingapi/tx-lcn?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
44
[![BBS](https://bbs.txlcn.org/style/Archlinux/txlcn-bbs.svg)](https://bbs.txlcn.org)

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.codingapi.txlcn</groupId>
88
<artifactId>tx-lcn</artifactId>
9-
<version>5.0.0</version>
9+
<version>5.0.0.RELEASE</version>
1010
<packaging>pom</packaging>
1111

1212

@@ -43,7 +43,7 @@
4343
<maven.javadoc.plugin>2.10.3</maven.javadoc.plugin>
4444
<maven.gpg.plugin>1.6</maven.gpg.plugin>
4545

46-
<codingapi.txlcn.version>5.0.0</codingapi.txlcn.version>
46+
<codingapi.txlcn.version>5.0.0.RELEASE</codingapi.txlcn.version>
4747

4848
<txlcn-org.projectlombok.version>1.18.0</txlcn-org.projectlombok.version>
4949
<txlcn-spring-cloud.version>Finchley.SR2</txlcn-spring-cloud.version>

run.txmanager.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
@echo off
22

3-
start java -jar -Xms256m -Xmx512m txlcn-tm/target/txlcn-tm-5.0.0.jar
3+
start java -jar -Xms256m -Xmx512m txlcn-tm/target/txlcn-tm-5.0.0.RELEASE.jar
44

txlcn-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>tx-lcn</artifactId>
77
<groupId>com.codingapi.txlcn</groupId>
8-
<version>5.0.0</version>
8+
<version>5.0.0.RELEASE</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

txlcn-common/src/main/java/com/codingapi/txlcn/common/util/Transactions.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ public class Transactions {
4343

4444
public static final String TAG_TASK = "Transaction Task";
4545

46+
47+
/**
48+
* 分布式事务类型 Properties传递参数key
49+
*/
50+
public static final String DTX_TYPE = "DTX_TYPE";
51+
52+
/**
53+
* 分布式事务传播类型 Properties传递参数key
54+
*/
55+
public static final String DTX_PROPAGATION = "DTX_PROPAGATION";
56+
4657
/////////// 工具方法 ////////////////////////////////////////////
4758

4859
/**

txlcn-logger/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>tx-lcn</artifactId>
77
<groupId>com.codingapi.txlcn</groupId>
8-
<version>5.0.0</version>
8+
<version>5.0.0.RELEASE</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

txlcn-tc/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.codingapi.txlcn</groupId>
77
<artifactId>tx-lcn</artifactId>
8-
<version>5.0.0</version>
8+
<version>5.0.0.RELEASE</version>
99
</parent>
1010

1111
<artifactId>txlcn-tc</artifactId>

txlcn-tc/src/main/java/com/codingapi/txlcn/tc/annotation/DTXPropagation.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,22 @@ public enum DTXPropagation {
3030
/**
3131
* 当前没有分布式事务,非分布式事务运行。当前有分布式事务,就加入
3232
*/
33-
SUPPORTS
33+
SUPPORTS;
34+
35+
36+
37+
public static DTXPropagation parser(String code){
38+
switch (code){
39+
case "REQUIRED":{
40+
return REQUIRED;
41+
}
42+
case "SUPPORTS":{
43+
return SUPPORTS;
44+
}
45+
default:{
46+
return REQUIRED;
47+
}
48+
}
49+
}
50+
3451
}

txlcn-tc/src/main/java/com/codingapi/txlcn/tc/aspect/interceptor/DTXInterceptor.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.aopalliance.intercept.MethodInvocation;
2020
import org.springframework.transaction.interceptor.TransactionInterceptor;
2121

22+
import java.util.Properties;
23+
2224
/**
2325
* Description:
2426
* Date: 1/12/19
@@ -30,13 +32,21 @@ public class DTXInterceptor extends TransactionInterceptor {
3032

3133
private final DTXLogicWeaver dtxLogicWeaver;
3234

35+
private Properties transactionAttributes;
36+
3337
public DTXInterceptor(DTXLogicWeaver dtxLogicWeaver) {
3438
this.dtxLogicWeaver = dtxLogicWeaver;
3539
}
3640

41+
@Override
42+
public void setTransactionAttributes(Properties transactionAttributes) {
43+
this.transactionAttributes = transactionAttributes;
44+
super.setTransactionAttributes(transactionAttributes);
45+
}
46+
3747
@Override
3848
public Object invoke(MethodInvocation invocation) throws Throwable {
39-
return dtxLogicWeaver.runTransaction(InterceptorInvocationUtils.load(invocation), () -> super.invoke(invocation));
49+
return dtxLogicWeaver.runTransaction(InterceptorInvocationUtils.load(invocation,transactionAttributes), () -> super.invoke(invocation));
4050
}
4151

4252
}

txlcn-tc/src/main/java/com/codingapi/txlcn/tc/aspect/interceptor/InterceptorInvocationUtils.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.aopalliance.intercept.MethodInvocation;
2222

2323
import java.util.Objects;
24+
import java.util.Properties;
2425

2526
/**
2627
* Description:
@@ -31,11 +32,17 @@
3132
*/
3233
class InterceptorInvocationUtils {
3334

34-
static DTXInfo load(MethodInvocation invocation) {
35-
TxTransaction txTransaction = invocation.getMethod().getAnnotation(TxTransaction.class);
35+
static DTXInfo load(MethodInvocation invocation, Properties transactionAttributes) {
36+
//默认值
3637
String transactionType = Transactions.LCN;
3738
DTXPropagation dtxPropagation = DTXPropagation.REQUIRED;
38-
39+
//优先获取配置的信息
40+
if(transactionAttributes!=null){
41+
transactionType = transactionAttributes.getProperty(Transactions.DTX_TYPE);
42+
dtxPropagation = DTXPropagation.parser(transactionAttributes.getProperty(Transactions.DTX_PROPAGATION));
43+
}
44+
//获取注解的信息
45+
TxTransaction txTransaction = invocation.getMethod().getAnnotation(TxTransaction.class);
3946
if (Objects.nonNull(txTransaction)) {
4047
transactionType = txTransaction.type();
4148
dtxPropagation = txTransaction.propagation();

0 commit comments

Comments
 (0)