-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: optimize TCC structure, supporting API access (#5165)
- Loading branch information
1 parent
4527a41
commit c7fba75
Showing
119 changed files
with
3,149 additions
and
1,396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright 1999-2019 Seata.io Group. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>io.seata</groupId> | ||
<artifactId>seata-parent</artifactId> | ||
<version>${revision}</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>seata-integration-tx-api</artifactId> | ||
<name>seata-integration-tx-api ${project.version}</name> | ||
<packaging>jar</packaging> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>seata-tm</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>seata-rm-datasource</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>seata-rm</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>seata-serializer-all</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>seata-common</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.bytebuddy</groupId> | ||
<artifactId>byte-buddy</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
.../main/java/io/seata/integration/tx/api/annotation/BusinessActionContextParameterDesc.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright 1999-2019 Seata.io Group. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.integration.tx.api.annotation; | ||
|
||
import io.seata.common.util.StringUtils; | ||
import io.seata.rm.tcc.api.BusinessActionContextParameter; | ||
|
||
import java.lang.annotation.Annotation; | ||
|
||
/** | ||
* @author leezongjie | ||
* @date 2022/12/23 | ||
*/ | ||
public class BusinessActionContextParameterDesc { | ||
private String paramName; | ||
private int index; | ||
private boolean isParamInProperty; | ||
|
||
private BusinessActionContextParameterDesc() { | ||
} | ||
|
||
public static BusinessActionContextParameterDesc createFromBusinessActionContextParameter(Annotation annotation) { | ||
if (annotation == null) { | ||
return null; | ||
} | ||
BusinessActionContextParameterDesc businessActionContextParameterDesc = null; | ||
if (annotation instanceof BusinessActionContextParameter) { | ||
businessActionContextParameterDesc = new BusinessActionContextParameterDesc(); | ||
BusinessActionContextParameter businessActionContextParameter = (BusinessActionContextParameter) annotation; | ||
businessActionContextParameterDesc.setIndex(businessActionContextParameter.index()); | ||
businessActionContextParameterDesc.setParamInProperty(businessActionContextParameter.isParamInProperty()); | ||
businessActionContextParameterDesc.setParamName(StringUtils.isNotBlank(businessActionContextParameter.paramName()) ? businessActionContextParameter.paramName() : businessActionContextParameter.value()); | ||
} | ||
return businessActionContextParameterDesc; | ||
} | ||
|
||
public String getParamName() { | ||
return paramName; | ||
} | ||
|
||
public void setParamName(String paramName) { | ||
this.paramName = paramName; | ||
} | ||
|
||
public int getIndex() { | ||
return index; | ||
} | ||
|
||
public void setIndex(int index) { | ||
this.index = index; | ||
} | ||
|
||
public boolean isParamInProperty() { | ||
return isParamInProperty; | ||
} | ||
|
||
public void setParamInProperty(boolean paramInProperty) { | ||
isParamInProperty = paramInProperty; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...ion-tx-api/src/main/java/io/seata/integration/tx/api/fence/DefaultCommonFenceHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright 1999-2019 Seata.io Group. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.integration.tx.api.fence; | ||
|
||
import io.seata.common.executor.Callback; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.Date; | ||
|
||
/** | ||
* @author leezongjie | ||
* @date 2022/12/17 | ||
*/ | ||
public class DefaultCommonFenceHandler implements FenceHandler { | ||
|
||
private FenceHandler fenceHandler; | ||
|
||
private static class SingletonHolder { | ||
private static final DefaultCommonFenceHandler INSTANCE = new DefaultCommonFenceHandler(); | ||
} | ||
|
||
public static DefaultCommonFenceHandler get() { | ||
return DefaultCommonFenceHandler.SingletonHolder.INSTANCE; | ||
} | ||
|
||
public void setFenceHandler(FenceHandler fenceHandler) { | ||
this.fenceHandler = fenceHandler; | ||
} | ||
|
||
private void check() { | ||
if (fenceHandler == null) { | ||
throw new RuntimeException("fenceHandler is null, need to set a fenceHandler implement"); | ||
} | ||
} | ||
|
||
@Override | ||
public Object prepareFence(String xid, Long branchId, String actionName, Callback<Object> targetCallback) { | ||
check(); | ||
return fenceHandler.prepareFence(xid, branchId, actionName, targetCallback); | ||
} | ||
|
||
@Override | ||
public boolean commitFence(Method commitMethod, Object targetTCCBean, String xid, Long branchId, Object[] args) { | ||
check(); | ||
return fenceHandler.commitFence(commitMethod, targetTCCBean, xid, branchId, args); | ||
} | ||
|
||
@Override | ||
public boolean rollbackFence(Method rollbackMethod, Object targetTCCBean, String xid, Long branchId, Object[] args, String actionName) { | ||
check(); | ||
return fenceHandler.rollbackFence(rollbackMethod, targetTCCBean, xid, branchId, args, actionName); | ||
} | ||
|
||
@Override | ||
public int deleteFenceByDate(Date datetime) { | ||
check(); | ||
return fenceHandler.deleteFenceByDate(datetime); | ||
} | ||
} |
Oops, something went wrong.