forked from apache/incubator-seata
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimize:refactor of auto proxying of datasource. (apache#2095)
- Loading branch information
1 parent
c796f8d
commit 734ee0c
Showing
16 changed files
with
242 additions
and
172 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,11 +16,11 @@ | |
package io.seata.spring.boot.autoconfigure; | ||
|
||
import io.seata.spring.annotation.GlobalTransactionScanner; | ||
import io.seata.spring.annotation.datasource.SeataDataSourceBeanPostProcessor; | ||
import io.seata.spring.boot.autoconfigure.properties.SeataProperties; | ||
import io.seata.spring.boot.autoconfigure.util.SpringUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
|
@@ -29,6 +29,8 @@ | |
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.DependsOn; | ||
|
||
import static io.seata.spring.annotation.datasource.AutoDataSourceProxyRegistrar.BEAN_NAME_SEATA_DATA_SOURCE_BEAN_POST_PROCESSOR; | ||
|
||
/** | ||
* @author [email protected] | ||
*/ | ||
|
@@ -38,8 +40,6 @@ | |
@EnableConfigurationProperties({SeataProperties.class}) | ||
public class SeataAutoConfiguration { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(SeataAutoConfiguration.class); | ||
@Autowired | ||
private SeataProperties seataProperties; | ||
|
||
@Bean | ||
public SpringUtils springUtils() { | ||
|
@@ -49,12 +49,17 @@ public SpringUtils springUtils() { | |
@Bean | ||
@DependsOn({"springUtils"}) | ||
@ConditionalOnMissingBean(GlobalTransactionScanner.class) | ||
public GlobalTransactionScanner globalTransactionScanner() { | ||
public GlobalTransactionScanner globalTransactionScanner(SeataProperties seataProperties) { | ||
if (LOGGER.isInfoEnabled()) { | ||
LOGGER.info("Automatically configure Seata"); | ||
} | ||
return new GlobalTransactionScanner(seataProperties.getApplicationId(), seataProperties.getTxServiceGroup()); | ||
} | ||
|
||
|
||
@Bean(BEAN_NAME_SEATA_DATA_SOURCE_BEAN_POST_PROCESSOR) | ||
@ConditionalOnProperty(prefix = StarterConstants.SEATA_PREFIX, name = "enableAutoDataSourceProxy", havingValue = "true", matchIfMissing = true) | ||
@ConditionalOnMissingBean(SeataDataSourceBeanPostProcessor.class) | ||
public SeataDataSourceBeanPostProcessor seataDataSourceBeanPostProcessor(SeataProperties seataProperties) { | ||
return new SeataDataSourceBeanPostProcessor(seataProperties.isUseJdkProxy()); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -15,13 +15,13 @@ | |
*/ | ||
package io.seata.spring.boot.autoconfigure; | ||
|
||
import java.util.HashMap; | ||
|
||
import io.seata.spring.boot.autoconfigure.properties.file.ClientProperties; | ||
import io.seata.spring.boot.autoconfigure.properties.file.LockProperties; | ||
import io.seata.spring.boot.autoconfigure.properties.file.LogProperties; | ||
import io.seata.spring.boot.autoconfigure.properties.file.ServiceProperties; | ||
import io.seata.spring.boot.autoconfigure.properties.file.ShutdownProperties; | ||
import io.seata.spring.boot.autoconfigure.properties.file.SpringProperties; | ||
import io.seata.spring.boot.autoconfigure.properties.file.SupportProperties; | ||
import io.seata.spring.boot.autoconfigure.properties.file.ThreadFactoryProperties; | ||
import io.seata.spring.boot.autoconfigure.properties.file.TransportProperties; | ||
import io.seata.spring.boot.autoconfigure.properties.file.UndoProperties; | ||
|
@@ -42,8 +42,6 @@ | |
import io.seata.spring.boot.autoconfigure.properties.registry.RegistrySofaProperties; | ||
import io.seata.spring.boot.autoconfigure.properties.registry.RegistryZooKeeperProperties; | ||
|
||
import java.util.HashMap; | ||
|
||
/** | ||
* @author [email protected] | ||
*/ | ||
|
@@ -60,8 +58,6 @@ public class StarterConstants { | |
public static final String LOCK_PREFIX = CLIENT_RM_PREFIX + ".lock"; | ||
public static final String UNDO_PREFIX = CLIENT_PREFIX + ".undo"; | ||
public static final String LOG_PREFIX = CLIENT_PREFIX + ".log"; | ||
public static final String SUPPORT_PREFIX = CLIENT_PREFIX + ".support"; | ||
public static final String SPRING_PREFIX = SUPPORT_PREFIX + ".spring"; | ||
|
||
public static final String REGISTRY_PREFIX = SEATA_PREFIX + ".registry"; | ||
public static final String REGISTRY_NACOS_PREFIX = REGISTRY_PREFIX + ".nacos"; | ||
|
@@ -89,8 +85,6 @@ public class StarterConstants { | |
put(LOCK_PREFIX, LockProperties.class); | ||
put(SERVICE_PREFIX, ServiceProperties.class); | ||
put(SHUTDOWN_PREFIX, ShutdownProperties.class); | ||
put(SPRING_PREFIX, SpringProperties.class); | ||
put(SUPPORT_PREFIX, SupportProperties.class); | ||
put(THREAD_FACTORY_PREFIX, ThreadFactoryProperties.class); | ||
put(UNDO_PREFIX, UndoProperties.class); | ||
put(LOG_PREFIX, LogProperties.class); | ||
|
@@ -125,8 +119,6 @@ public class StarterConstants { | |
public static String NORMALIZED_KEY_VGROUP_MAPPING = "vgroupMapping"; | ||
public static String SPECIAL_KEY_GROUPLIST = "grouplist"; | ||
public static String NORMALIZED_KEY_GROUPLIST = "grouplist"; | ||
public static String SPECIAL_KEY_DATASOURCE_AUTOPROXY = "datasource.autoproxy"; | ||
public static String NORMALIZED_KEY_DATASOURCE_AUTOPROXY = "datasourceAutoproxy"; | ||
public static String SPECIAL_KEY_UNDO = "client.undo."; | ||
public static String NORMALIZED_KEY_UNDO = "client.undo."; | ||
public static String SPECIAL_KEY_CLIENT = "client."; | ||
|
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 |
---|---|---|
|
@@ -18,14 +18,12 @@ | |
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
import static io.seata.spring.boot.autoconfigure.StarterConstants.SEATA_PREFIX; | ||
|
||
/** | ||
* @author [email protected] | ||
*/ | ||
@Component | ||
@ConfigurationProperties(prefix = SEATA_PREFIX) | ||
@EnableConfigurationProperties(SpringCloudAlibabaConfiguration.class) | ||
public class SeataProperties { | ||
|
@@ -41,6 +39,14 @@ public class SeataProperties { | |
* transaction service group | ||
*/ | ||
private String txServiceGroup; | ||
/** | ||
* Whether enable auto proxying of datasource bean | ||
*/ | ||
private boolean enableAutoDataSourceProxy = true; | ||
/** | ||
* Whether use JDK proxy instead of CGLIB proxy | ||
*/ | ||
private boolean useJdkProxy = false; | ||
|
||
@Autowired | ||
private SpringCloudAlibabaConfiguration springCloudAlibabaConfiguration; | ||
|
@@ -77,4 +83,22 @@ public SeataProperties setTxServiceGroup(String txServiceGroup) { | |
this.txServiceGroup = txServiceGroup; | ||
return this; | ||
} | ||
|
||
public boolean isEnableAutoDataSourceProxy() { | ||
return enableAutoDataSourceProxy; | ||
} | ||
|
||
public SeataProperties setEnableAutoDataSourceProxy(boolean enableAutoDataSourceProxy) { | ||
this.enableAutoDataSourceProxy = enableAutoDataSourceProxy; | ||
return this; | ||
} | ||
|
||
public boolean isUseJdkProxy() { | ||
return useJdkProxy; | ||
} | ||
|
||
public SeataProperties setUseJdkProxy(boolean useJdkProxy) { | ||
this.useJdkProxy = useJdkProxy; | ||
return this; | ||
} | ||
} |
42 changes: 0 additions & 42 deletions
42
...er/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SpringProperties.java
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
...r/src/main/java/io/seata/spring/boot/autoconfigure/properties/file/SupportProperties.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.