Skip to content

optimize: add support for configuring exposeProxy in GlobalTransactionScanner #6566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6540](https://github.com/apache/incubator-seata/pull/6540)] exclude com.google.guava:listenablefuture
- [[#6549](https://github.com/apache/incubator-seata/pull/6549)] macos workflow support arm testing
- [[#6558](https://github.com/apache/incubator-seata/pull/6558)] remove mysql-connector-java from pom.xml
- [[#6562](https://github.com/apache/incubator-seata/pull/6562)] Add support for configuring exposeProxy in GlobalTransactionScanner

### security:
- [[#6069](https://github.com/apache/incubator-seata/pull/6069)] Upgrade Guava dependencies to fix security vulnerabilities
Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
- [[#6540](https://github.com/apache/incubator-seata/pull/6540)] 排除 com.google.guava:listenablefuture 依赖
- [[#6549](https://github.com/apache/incubator-seata/pull/6549)] 支持macos arm架构单测
- [[#6558](https://github.com/apache/incubator-seata/pull/6558)] y移除 mysql-connector-java 依赖
- [[#6562](https://github.com/apache/incubator-seata/pull/6562)] 支持GlobalTransactionScanner类中exposeProxy属性的配置

### security:
- [[#6069](https://github.com/apache/incubator-seata/pull/6069)] 升级Guava依赖版本,修复安全漏洞
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public class SeataProperties {
* Whether use JDK proxy instead of CGLIB proxy
*/
private boolean useJdkProxy = false;
/**
* Whether to expose the proxy object through AopContext.
* Setting this to true allows AopContext.currentProxy() to be used to obtain the current proxy,
* which can be useful for invoking methods annotated with @GlobalTransactional within the same class.
*/
private boolean exposeProxy = false;
/**
* The scan packages. If empty, will scan all beans.
*/
Expand Down Expand Up @@ -136,6 +142,14 @@ public SeataProperties setUseJdkProxy(boolean useJdkProxy) {
return this;
}

public boolean isExposeProxy() {
return exposeProxy;
}

public void setExposeProxy(boolean exposeProxy) {
this.exposeProxy = exposeProxy;
}

public String[] getExcludesForAutoProxying() {
return excludesForAutoProxying;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public static GlobalTransactionScanner globalTransactionScanner(SeataProperties
GlobalTransactionScanner.setAccessKey(seataProperties.getAccessKey());
GlobalTransactionScanner.setSecretKey(seataProperties.getSecretKey());
// create global transaction scanner
return new GlobalTransactionScanner(seataProperties.getApplicationId(), seataProperties.getTxServiceGroup(), failureHandler);
return new GlobalTransactionScanner(seataProperties.getApplicationId(), seataProperties.getTxServiceGroup(),
seataProperties.isExposeProxy(), failureHandler);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public GlobalTransactionScanner(String applicationId, String txServiceGroup) {
* @param mode the mode
*/
public GlobalTransactionScanner(String applicationId, String txServiceGroup, int mode) {
this(applicationId, txServiceGroup, mode, null);
this(applicationId, txServiceGroup, mode, false, null);
}

/**
Expand All @@ -171,7 +171,20 @@ public GlobalTransactionScanner(String applicationId, String txServiceGroup, int
* @param failureHandlerHook the failure handler hook
*/
public GlobalTransactionScanner(String applicationId, String txServiceGroup, FailureHandler failureHandlerHook) {
this(applicationId, txServiceGroup, DEFAULT_MODE, failureHandlerHook);
this(applicationId, txServiceGroup, DEFAULT_MODE, false, failureHandlerHook);
}

/**
* Instantiates a new Global transaction scanner.
*
* @param applicationId the application id
* @param txServiceGroup the tx service group
* @param exposeProxy the exposeProxy
* @param failureHandlerHook the failure handler hook
*/
public GlobalTransactionScanner(String applicationId, String txServiceGroup, boolean exposeProxy,
FailureHandler failureHandlerHook) {
this(applicationId, txServiceGroup, DEFAULT_MODE, exposeProxy, failureHandlerHook);
}

/**
Expand All @@ -180,12 +193,14 @@ public GlobalTransactionScanner(String applicationId, String txServiceGroup, Fai
* @param applicationId the application id
* @param txServiceGroup the tx service group
* @param mode the mode
* @param exposeProxy the exposeProxy
* @param failureHandlerHook the failure handler hook
*/
public GlobalTransactionScanner(String applicationId, String txServiceGroup, int mode,
public GlobalTransactionScanner(String applicationId, String txServiceGroup, int mode, boolean exposeProxy,
FailureHandler failureHandlerHook) {
setOrder(ORDER_NUM);
setProxyTargetClass(true);
setExposeProxy(exposeProxy);
this.applicationId = applicationId;
this.txServiceGroup = txServiceGroup;
this.failureHandlerHook = failureHandlerHook;
Expand Down
Loading