This is an automated email from the ASF dual-hosted git repository.

panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 56acbff  Add shadow switch and optimize API parameters. (#11785)
56acbff is described below

commit 56acbfff6b98149a5f397e00b454bd6da861d3ad
Author: gin <[email protected]>
AuthorDate: Thu Aug 12 19:36:08 2021 +0800

    Add shadow switch and optimize API parameters. (#11785)
---
 .../shadow/api/config/ShadowRuleConfiguration.java |  10 +-
 .../AlgorithmProvidedShadowRuleConfiguration.java  |   4 +-
 .../shadow/route/ShadowSQLRouter.java              |   7 +-
 .../shardingsphere/shadow/rule/ShadowRule.java     |  14 ++-
 .../yaml/config/YamlShadowRuleConfiguration.java   |   4 +-
 ...eAlgorithmProviderConfigurationYamlSwapper.java |   6 +-
 .../ShadowRuleConfigurationYamlSwapper.java        |   4 +-
 ...orithmProviderConfigurationYamlSwapperTest.java | 120 +++++++++++++--------
 .../ShadowRuleConfigurationYamlSwapperTest.java    |  42 ++++++--
 .../PropertiesShadowSpringBootStarterTest.java     |   3 +-
 .../boot/YmlShadowSpringBootStarterTest.java       |   3 +-
 .../application-shadow-properties.properties       |  10 +-
 .../src/test/resources/application-shadow-yml.yml  |   5 +-
 .../parser/ShadowRuleBeanDefinitionParser.java     |   7 +-
 .../namespace/tag/ShadowRuleBeanDefinitionTag.java |   4 +-
 .../main/resources/META-INF/namespace/shadow.xsd   |   5 +-
 .../ShadowAlgorithmSpringNamespaceTest.java        |   3 +-
 .../namespace/ShadowSpringNamespaceTest.java       |   3 +-
 .../shadow-algorithm-application-context.xml       |  10 +-
 19 files changed, 170 insertions(+), 94 deletions(-)

diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/api/config/ShadowRuleConfiguration.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/api/config/ShadowRuleConfiguration.java
index b2ca065..c441ded 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/api/config/ShadowRuleConfiguration.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-api/src/main/java/org/apache/shardingsphere/shadow/api/config/ShadowRuleConfiguration.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.shadow.api.config;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import lombok.Getter;
+import lombok.RequiredArgsConstructor;
 import lombok.Setter;
 import 
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.config.function.DistributedRuleConfiguration;
@@ -36,6 +37,7 @@ import java.util.Map;
  */
 @Getter
 @Setter
+@RequiredArgsConstructor
 public final class ShadowRuleConfiguration implements SchemaRuleConfiguration, 
DistributedRuleConfiguration {
     
     private final String column;
@@ -44,19 +46,19 @@ public final class ShadowRuleConfiguration implements 
SchemaRuleConfiguration, D
     
     private final List<String> shadowDataSourceNames;
     
+    private final boolean enable;
+    
     private Map<String, ShadowDataSourceConfiguration> dataSources = new 
LinkedHashMap<>();
     
-    private Map<String, ShadowTableConfiguration> shadowTables = new 
LinkedHashMap<>();
+    private Map<String, ShadowTableConfiguration> tables = new 
LinkedHashMap<>();
     
     private Map<String, ShardingSphereAlgorithmConfiguration> shadowAlgorithms 
= new LinkedHashMap<>();
     
     public ShadowRuleConfiguration(final String column, final List<String> 
sourceDataSourceNames, final List<String> shadowDataSourceNames) {
+        this(column, sourceDataSourceNames, shadowDataSourceNames, false);
         Preconditions.checkArgument(!Strings.isNullOrEmpty(column), "Column is 
required.");
         Preconditions.checkArgument(!sourceDataSourceNames.isEmpty(), 
"SourceDataSourceNames is required.");
         Preconditions.checkArgument(!shadowDataSourceNames.isEmpty(), 
"ShadowDataSourceNames is required.");
         Preconditions.checkArgument(sourceDataSourceNames.size() == 
shadowDataSourceNames.size(), "SourceDataSourceNames and ShadowDataSourceNames 
size must same.");
-        this.column = column;
-        this.sourceDataSourceNames = sourceDataSourceNames;
-        this.shadowDataSourceNames = shadowDataSourceNames;
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/config/AlgorithmProvidedShadowRuleConfiguration.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/config/AlgorithmProvidedShadowRuleConfiguration.java
index 2438536..d935a8b 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/config/AlgorithmProvidedShadowRuleConfiguration.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/algorithm/config/AlgorithmProvidedShadowRuleConfiguration.java
@@ -45,9 +45,11 @@ public final class AlgorithmProvidedShadowRuleConfiguration 
implements SchemaRul
     
     private final List<String> shadowDataSourceNames;
     
+    private boolean enable;
+    
     private Map<String, ShadowDataSourceConfiguration> dataSources = new 
LinkedHashMap<>();
     
-    private Map<String, ShadowTableConfiguration> shadowTables = new 
LinkedHashMap<>();
+    private Map<String, ShadowTableConfiguration> tables = new 
LinkedHashMap<>();
     
     private Map<String, ShadowAlgorithm> shadowAlgorithms = new 
LinkedHashMap<>();
 }
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java
index b5f156d..bbe512f 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/route/ShadowSQLRouter.java
@@ -84,7 +84,7 @@ public final class ShadowSQLRouter implements 
SQLRouter<ShadowRule> {
     @Override
     public void decorateRouteContext(final RouteContext routeContext,
                                      final LogicSQL logicSQL, final 
ShardingSphereMetaData metaData, final ShadowRule rule, final 
ConfigurationProperties props) {
-        if (isShadowEnable()) {
+        if (rule.isEnable()) {
             doShadowDecorateFuture(routeContext, logicSQL, metaData, rule, 
props);
         } else {
             doShadowDecorate(routeContext, logicSQL, rule);
@@ -117,11 +117,6 @@ public final class ShadowSQLRouter implements 
SQLRouter<ShadowRule> {
         ShadowRouteEngineFactory.newInstance(logicSQL).route(routeContext, 
logicSQL, metaData, rule, props);
     }
     
-    // fixme the shadow switch reconstruction is complete
-    private boolean isShadowEnable() {
-        return false;
-    }
-    
     @Override
     public int getOrder() {
         return ShadowOrder.ORDER;
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java
index b5a2e0f..5047c20 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java
@@ -49,37 +49,41 @@ public final class ShadowRule implements FeatureRule, 
SchemaRule, DataSourceCont
     
     private final String column;
     
+    private final boolean enable;
+    
     private final Map<String, ShadowDataSourceConfiguration> dataSources = new 
LinkedHashMap<>();
     
-    private final Map<String, ShadowTableConfiguration> shadowTables = new 
LinkedHashMap<>();
+    private final Map<String, ShadowTableConfiguration> tables = new 
LinkedHashMap<>();
     
     private final Map<String, ShadowAlgorithm> shadowAlgorithms = new 
LinkedHashMap<>();
     
     public ShadowRule(final ShadowRuleConfiguration shadowRuleConfig) {
         column = shadowRuleConfig.getColumn();
         shadowMappings = new 
HashMap<>(shadowRuleConfig.getShadowDataSourceNames().size());
+        enable = shadowRuleConfig.isEnable();
         for (int i = 0; i < 
shadowRuleConfig.getSourceDataSourceNames().size(); i++) {
             
shadowMappings.put(shadowRuleConfig.getSourceDataSourceNames().get(i), 
shadowRuleConfig.getShadowDataSourceNames().get(i));
         }
         if (!shadowRuleConfig.getDataSources().isEmpty()) {
             dataSources.putAll(shadowRuleConfig.getDataSources());
         }
-        if (!shadowRuleConfig.getShadowTables().isEmpty()) {
-            shadowTables.putAll(shadowRuleConfig.getShadowTables());
+        if (!shadowRuleConfig.getTables().isEmpty()) {
+            tables.putAll(shadowRuleConfig.getTables());
         }
     }
     
     public ShadowRule(final AlgorithmProvidedShadowRuleConfiguration 
shadowRuleConfig) {
         column = shadowRuleConfig.getColumn();
         shadowMappings = new 
HashMap<>(shadowRuleConfig.getShadowDataSourceNames().size());
+        enable = shadowRuleConfig.isEnable();
         for (int i = 0; i < 
shadowRuleConfig.getSourceDataSourceNames().size(); i++) {
             
shadowMappings.put(shadowRuleConfig.getSourceDataSourceNames().get(i), 
shadowRuleConfig.getShadowDataSourceNames().get(i));
         }
         if (!shadowRuleConfig.getDataSources().isEmpty()) {
             dataSources.putAll(shadowRuleConfig.getDataSources());
         }
-        if (!shadowRuleConfig.getShadowTables().isEmpty()) {
-            shadowTables.putAll(shadowRuleConfig.getShadowTables());
+        if (!shadowRuleConfig.getTables().isEmpty()) {
+            tables.putAll(shadowRuleConfig.getTables());
         }
         if (!shadowRuleConfig.getShadowAlgorithms().isEmpty()) {
             shadowAlgorithms.putAll(shadowRuleConfig.getShadowAlgorithms());
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/yaml/config/YamlShadowRuleConfiguration.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/yaml/config/YamlShadowRuleConfiguration.java
index 1ddd258..3827cc9 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/yaml/config/YamlShadowRuleConfiguration.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/yaml/config/YamlShadowRuleConfiguration.java
@@ -43,9 +43,11 @@ public final class YamlShadowRuleConfiguration implements 
YamlRuleConfiguration
     
     private List<String> shadowDataSourceNames;
     
+    private boolean enable;
+    
     private Map<String, YamlShadowDataSourceConfiguration> dataSources = new 
LinkedHashMap<>();
     
-    private Map<String, YamlShadowTableConfiguration> shadowTables = new 
LinkedHashMap<>();
+    private Map<String, YamlShadowTableConfiguration> tables = new 
LinkedHashMap<>();
     
     private Map<String, YamlShardingSphereAlgorithmConfiguration> 
shadowAlgorithms = new LinkedHashMap<>();
     
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleAlgorithmProviderConfigurationYamlSwapper.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleAlgorithmProviderConfigurationYamlSwapper.java
index 923d8f2..dba813b 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleAlgorithmProviderConfigurationYamlSwapper.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleAlgorithmProviderConfigurationYamlSwapper.java
@@ -37,6 +37,7 @@ public final class 
ShadowRuleAlgorithmProviderConfigurationYamlSwapper implement
     @Override
     public YamlShadowRuleConfiguration swapToYamlConfiguration(final 
AlgorithmProvidedShadowRuleConfiguration dataConfiguration) {
         YamlShadowRuleConfiguration result = new YamlShadowRuleConfiguration();
+        result.setEnable(dataConfiguration.isEnable());
         parseBasicShadowRule(dataConfiguration, result);
         parseDataSources(dataConfiguration, result);
         parseShadowTables(dataConfiguration, result);
@@ -50,7 +51,7 @@ public final class 
ShadowRuleAlgorithmProviderConfigurationYamlSwapper implement
     }
     
     private void parseShadowTables(final 
AlgorithmProvidedShadowRuleConfiguration dataConfiguration, final 
YamlShadowRuleConfiguration yamlConfiguration) {
-        dataConfiguration.getShadowTables().forEach((key, value) -> 
yamlConfiguration.getShadowTables().put(key, 
tableConfigurationYamlSwapper.swapToYamlConfiguration(value)));
+        dataConfiguration.getTables().forEach((key, value) -> 
yamlConfiguration.getTables().put(key, 
tableConfigurationYamlSwapper.swapToYamlConfiguration(value)));
     }
     
     private void parseDataSources(final 
AlgorithmProvidedShadowRuleConfiguration dataConfiguration, final 
YamlShadowRuleConfiguration yamlConfiguration) {
@@ -67,13 +68,14 @@ public final class 
ShadowRuleAlgorithmProviderConfigurationYamlSwapper implement
     @Override
     public AlgorithmProvidedShadowRuleConfiguration swapToObject(final 
YamlShadowRuleConfiguration yamlConfiguration) {
         AlgorithmProvidedShadowRuleConfiguration result = 
createBasicAlgorithmProvidedShadowRule(yamlConfiguration);
+        result.setEnable(yamlConfiguration.isEnable());
         parseYamlDataSources(yamlConfiguration, result);
         parseYamlShadowTables(yamlConfiguration, result);
         return result;
     }
     
     private void parseYamlShadowTables(final YamlShadowRuleConfiguration 
yamlConfiguration, final AlgorithmProvidedShadowRuleConfiguration 
dataConfiguration) {
-        yamlConfiguration.getShadowTables().forEach((key, value) -> 
dataConfiguration.getShadowTables().put(key, 
tableConfigurationYamlSwapper.swapToObject(value)));
+        yamlConfiguration.getTables().forEach((key, value) -> 
dataConfiguration.getTables().put(key, 
tableConfigurationYamlSwapper.swapToObject(value)));
     }
     
     private void parseYamlDataSources(final YamlShadowRuleConfiguration 
yamlConfiguration, final AlgorithmProvidedShadowRuleConfiguration 
dataConfiguration) {
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleConfigurationYamlSwapper.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleConfigurationYamlSwapper.java
index bf1b9e9..8a73ff8 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleConfigurationYamlSwapper.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/main/java/org/apache/shardingsphere/shadow/yaml/swapper/ShadowRuleConfigurationYamlSwapper.java
@@ -51,7 +51,7 @@ public final class ShadowRuleConfigurationYamlSwapper 
implements YamlRuleConfigu
     }
     
     private void parseShadowTables(final ShadowRuleConfiguration 
dataConfiguration, final YamlShadowRuleConfiguration yamlConfiguration) {
-        dataConfiguration.getShadowTables().forEach((key, value) -> 
yamlConfiguration.getShadowTables().put(key, 
tableConfigurationYamlSwapper.swapToYamlConfiguration(value)));
+        dataConfiguration.getTables().forEach((key, value) -> 
yamlConfiguration.getTables().put(key, 
tableConfigurationYamlSwapper.swapToYamlConfiguration(value)));
     }
     
     private void parseDataSources(final ShadowRuleConfiguration 
dataConfiguration, final YamlShadowRuleConfiguration yamlConfiguration) {
@@ -79,7 +79,7 @@ public final class ShadowRuleConfigurationYamlSwapper 
implements YamlRuleConfigu
     }
     
     private void parseYamlShadowTables(final YamlShadowRuleConfiguration 
yamlConfiguration, final ShadowRuleConfiguration dataConfiguration) {
-        yamlConfiguration.getShadowTables().forEach((key, value) -> 
dataConfiguration.getShadowTables().put(key, 
tableConfigurationYamlSwapper.swapToObject(value)));
+        yamlConfiguration.getTables().forEach((key, value) -> 
dataConfiguration.getTables().put(key, 
tableConfigurationYamlSwapper.swapToObject(value)));
     }
     
     private void parseYamlDataSources(final YamlShadowRuleConfiguration 
yamlConfiguration, final ShadowRuleConfiguration dataConfiguration) {
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/swapper/ShadowRuleAlgorithmProviderConfigurationYamlSwapperTest.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/swapper/ShadowRuleAlgorithmProviderConfigurationYamlSwapperTest.java
index c5443ce..4834439 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/swapper/ShadowRuleAlgorithmProviderConfigurationYamlSwapperTest.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/swapper/ShadowRuleAlgorithmProviderConfigurationYamlSwapperTest.java
@@ -27,6 +27,7 @@ import 
org.apache.shardingsphere.shadow.yaml.config.YamlShadowRuleConfiguration;
 import 
org.apache.shardingsphere.shadow.yaml.config.datasource.YamlShadowDataSourceConfiguration;
 import 
org.apache.shardingsphere.shadow.yaml.config.table.YamlShadowTableConfiguration;
 import 
org.apache.shardingsphere.shadow.yaml.swapper.ShadowRuleAlgorithmProviderConfigurationYamlSwapper;
+import org.junit.Before;
 import org.junit.Test;
 
 import java.util.Arrays;
@@ -36,84 +37,111 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
 
 public final class ShadowRuleAlgorithmProviderConfigurationYamlSwapperTest {
-
-    private AlgorithmProvidedShadowRuleConfiguration 
algorithmProvidedShadowRuleConfiguration;
-
-    private YamlShadowRuleConfiguration yamlShadowRuleConfiguration;
-
+    
+    private ShadowRuleAlgorithmProviderConfigurationYamlSwapper swapper;
+    
+    @Before
+    public void init() {
+        swapper = new ShadowRuleAlgorithmProviderConfigurationYamlSwapper();
+    }
+    
     @Test
     public void assertSwapToYamlConfiguration() {
-        buildAlgorithmProvidedShadowRuleConfiguration();
-        ShadowRuleAlgorithmProviderConfigurationYamlSwapper swapper = new 
ShadowRuleAlgorithmProviderConfigurationYamlSwapper();
-        YamlShadowRuleConfiguration yamlShadowRuleConfiguration = 
swapper.swapToYamlConfiguration(algorithmProvidedShadowRuleConfiguration);
-        assertThat(yamlShadowRuleConfiguration.getColumn(), 
is(algorithmProvidedShadowRuleConfiguration.getColumn()));
-        assertThat(yamlShadowRuleConfiguration.getShadowDataSourceNames(), 
is(algorithmProvidedShadowRuleConfiguration.getShadowDataSourceNames()));
-        assertThat(yamlShadowRuleConfiguration.getSourceDataSourceNames(), 
is(algorithmProvidedShadowRuleConfiguration.getSourceDataSourceNames()));
-        yamlShadowRuleConfiguration.getDataSources().entrySet().forEach(each 
-> {
-            ShadowDataSourceConfiguration dataSourceConfiguration = 
algorithmProvidedShadowRuleConfiguration.getDataSources().get(each.getKey());
+        AlgorithmProvidedShadowRuleConfiguration expectedConfiguration = 
buildAlgorithmProvidedShadowRuleConfiguration();
+        YamlShadowRuleConfiguration actualConfiguration = 
swapper.swapToYamlConfiguration(expectedConfiguration);
+        assertThat(actualConfiguration.isEnable(), 
is(expectedConfiguration.isEnable()));
+        assertBasicYamlShadowRule(actualConfiguration, expectedConfiguration);
+        actualConfiguration.getDataSources().entrySet().forEach(each -> {
+            ShadowDataSourceConfiguration dataSourceConfiguration = 
expectedConfiguration.getDataSources().get(each.getKey());
             assertNotNull(dataSourceConfiguration);
             assertThat(each.getValue().getShadowDataSourceName(), 
is(dataSourceConfiguration.getShadowDataSourceName()));
             assertThat(each.getValue().getSourceDataSourceName(), 
is(dataSourceConfiguration.getSourceDataSourceName()));
         });
-        yamlShadowRuleConfiguration.getShadowTables().entrySet().forEach(each 
-> {
-            ShadowTableConfiguration shadowTableConfiguration = 
algorithmProvidedShadowRuleConfiguration.getShadowTables().get(each.getKey());
+        actualConfiguration.getTables().entrySet().forEach(each -> {
+            ShadowTableConfiguration shadowTableConfiguration = 
expectedConfiguration.getTables().get(each.getKey());
             assertNotNull(shadowTableConfiguration);
             assertThat(each.getValue().getShadowAlgorithmNames(), 
is(shadowTableConfiguration.getShadowAlgorithmNames()));
         });
-        
yamlShadowRuleConfiguration.getShadowAlgorithms().entrySet().forEach(each -> {
-            ShadowAlgorithm shadowAlgorithm = 
algorithmProvidedShadowRuleConfiguration.getShadowAlgorithms().get(each.getKey());
+        actualConfiguration.getShadowAlgorithms().entrySet().forEach(each -> {
+            ShadowAlgorithm shadowAlgorithm = 
expectedConfiguration.getShadowAlgorithms().get(each.getKey());
             assertNotNull(shadowAlgorithm);
             assertThat(each.getValue().getType(), 
is(shadowAlgorithm.getType()));
         });
     }
-
+    
+    private AlgorithmProvidedShadowRuleConfiguration 
buildAlgorithmProvidedShadowRuleConfiguration() {
+        AlgorithmProvidedShadowRuleConfiguration result = 
createAlgorithmProvidedShadowRuleConfiguration();
+        result.setEnable(true);
+        result.getDataSources().put("shadow-data-source", new 
ShadowDataSourceConfiguration("ds", "ds-shadow"));
+        result.getTables().put("t_order", new 
ShadowTableConfiguration(Arrays.asList("user-id-match-algorithm", 
"note-algorithm")));
+        result.getShadowAlgorithms().put("user-id-match-algorithm", new 
ColumnRegularMatchShadowAlgorithm());
+        return result;
+    }
+    
+    // fixme remove method when the api refactoring is complete
+    private void assertBasicYamlShadowRule(final YamlShadowRuleConfiguration 
actualConfiguration, final AlgorithmProvidedShadowRuleConfiguration 
expectedConfiguration) {
+        assertThat(actualConfiguration.getColumn(), 
is(expectedConfiguration.getColumn()));
+        assertThat(actualConfiguration.getShadowDataSourceNames(), 
is(expectedConfiguration.getShadowDataSourceNames()));
+        assertThat(actualConfiguration.getSourceDataSourceNames(), 
is(expectedConfiguration.getSourceDataSourceNames()));
+    }
+    
+    // fixme remove method when the api refactoring is complete
+    private AlgorithmProvidedShadowRuleConfiguration 
createAlgorithmProvidedShadowRuleConfiguration() {
+        return new AlgorithmProvidedShadowRuleConfiguration("id", 
Arrays.asList("ds"), Arrays.asList("ds-shadow"));
+    }
+    
     @Test
     public void assertSwapToObject() {
-        buildYamlShadowRuleConfiguration();
-        ShadowRuleAlgorithmProviderConfigurationYamlSwapper swapper = new 
ShadowRuleAlgorithmProviderConfigurationYamlSwapper();
-        AlgorithmProvidedShadowRuleConfiguration targetConfiguration = 
swapper.swapToObject(yamlShadowRuleConfiguration);
-        assertThat(targetConfiguration.getColumn(), 
is(yamlShadowRuleConfiguration.getColumn()));
-        assertThat(targetConfiguration.getShadowDataSourceNames(), 
is(yamlShadowRuleConfiguration.getShadowDataSourceNames()));
-        assertThat(targetConfiguration.getSourceDataSourceNames(), 
is(yamlShadowRuleConfiguration.getSourceDataSourceNames()));
-        targetConfiguration.getDataSources().entrySet().forEach(each -> {
-            YamlShadowDataSourceConfiguration 
yamlShadowDataSourceConfiguration = 
yamlShadowRuleConfiguration.getDataSources().get(each.getKey());
+        YamlShadowRuleConfiguration expectedConfiguration = 
buildYamlShadowRuleConfiguration();
+        AlgorithmProvidedShadowRuleConfiguration actualConfiguration = 
swapper.swapToObject(expectedConfiguration);
+        assertBasicAlgorithmShadowRule(actualConfiguration, 
expectedConfiguration);
+        assertThat(actualConfiguration.isEnable(), 
is(expectedConfiguration.isEnable()));
+        actualConfiguration.getDataSources().entrySet().forEach(each -> {
+            YamlShadowDataSourceConfiguration 
yamlShadowDataSourceConfiguration = 
expectedConfiguration.getDataSources().get(each.getKey());
             assertNotNull(yamlShadowDataSourceConfiguration);
             assertThat(each.getValue().getShadowDataSourceName(), 
is(yamlShadowDataSourceConfiguration.getShadowDataSourceName()));
             assertThat(each.getValue().getSourceDataSourceName(), 
is(yamlShadowDataSourceConfiguration.getSourceDataSourceName()));
         });
-        targetConfiguration.getShadowTables().entrySet().forEach(each -> {
-            YamlShadowTableConfiguration yamlShadowTableConfiguration = 
yamlShadowRuleConfiguration.getShadowTables().get(each.getKey());
+        actualConfiguration.getTables().entrySet().forEach(each -> {
+            YamlShadowTableConfiguration yamlShadowTableConfiguration = 
expectedConfiguration.getTables().get(each.getKey());
             assertNotNull(yamlShadowTableConfiguration);
             assertThat(each.getValue().getShadowAlgorithmNames(), 
is(yamlShadowTableConfiguration.getShadowAlgorithmNames()));
         });
-        targetConfiguration.getShadowAlgorithms().entrySet().forEach(each -> {
-            YamlShardingSphereAlgorithmConfiguration 
yamlShardingSphereAlgorithmConfiguration = 
yamlShadowRuleConfiguration.getShadowAlgorithms().get(each.getKey());
+        actualConfiguration.getShadowAlgorithms().entrySet().forEach(each -> {
+            YamlShardingSphereAlgorithmConfiguration 
yamlShardingSphereAlgorithmConfiguration = 
expectedConfiguration.getShadowAlgorithms().get(each.getKey());
             assertNotNull(yamlShardingSphereAlgorithmConfiguration);
             assertThat(each.getValue().getType(), 
is(yamlShardingSphereAlgorithmConfiguration.getType()));
         });
     }
-
-    private void buildAlgorithmProvidedShadowRuleConfiguration() {
-        algorithmProvidedShadowRuleConfiguration = new 
AlgorithmProvidedShadowRuleConfiguration("id", Arrays.asList("ds"), 
Arrays.asList("ds-shadow"));
-        
algorithmProvidedShadowRuleConfiguration.getDataSources().put("shadow-data-source",
 new ShadowDataSourceConfiguration("ds", "ds-shadow"));
-        
algorithmProvidedShadowRuleConfiguration.getShadowTables().put("t_order", new 
ShadowTableConfiguration(Arrays.asList("user-id-match-algorithm", 
"note-algorithm")));
-        
algorithmProvidedShadowRuleConfiguration.getShadowAlgorithms().put("user-id-match-algorithm",
 new ColumnRegularMatchShadowAlgorithm());
-    }
-
-    private void buildYamlShadowRuleConfiguration() {
-        yamlShadowRuleConfiguration = new YamlShadowRuleConfiguration();
-        yamlShadowRuleConfiguration.setColumn("id");
-        
yamlShadowRuleConfiguration.setSourceDataSourceNames(Arrays.asList("ds"));
-        
yamlShadowRuleConfiguration.setShadowDataSourceNames(Arrays.asList("ds-shadow"));
+    
+    private YamlShadowRuleConfiguration buildYamlShadowRuleConfiguration() {
+        YamlShadowRuleConfiguration result = new YamlShadowRuleConfiguration();
+        buildBasicYamlShadowRule(result);
+        result.setEnable(true);
         YamlShadowDataSourceConfiguration yamlShadowDataSourceConfiguration = 
new YamlShadowDataSourceConfiguration();
         yamlShadowDataSourceConfiguration.setSourceDataSourceName("ds");
         yamlShadowDataSourceConfiguration.setShadowDataSourceName("ds-shadow");
-        yamlShadowRuleConfiguration.getDataSources().put("shadow-data-source", 
yamlShadowDataSourceConfiguration);
+        result.getDataSources().put("shadow-data-source", 
yamlShadowDataSourceConfiguration);
         YamlShadowTableConfiguration yamlShadowTableConfiguration = new 
YamlShadowTableConfiguration();
         
yamlShadowTableConfiguration.setShadowAlgorithmNames(Arrays.asList("user-id-match-algorithm",
 "note-algorithm"));
-        yamlShadowRuleConfiguration.getShadowTables().put("t_order", 
yamlShadowTableConfiguration);
+        result.getTables().put("t_order", yamlShadowTableConfiguration);
         YamlShardingSphereAlgorithmConfiguration 
yamlShardingSphereAlgorithmConfiguration = new 
YamlShardingSphereAlgorithmConfiguration();
         
yamlShardingSphereAlgorithmConfiguration.setType("COLUMN-REGULAR-MATCH");
-        
yamlShadowRuleConfiguration.getShadowAlgorithms().put("user-id-match-algorithm",
 yamlShardingSphereAlgorithmConfiguration);
+        result.getShadowAlgorithms().put("user-id-match-algorithm", 
yamlShardingSphereAlgorithmConfiguration);
+        return result;
+    }
+    
+    // fixme remove method when the api refactoring is complete
+    private void buildBasicYamlShadowRule(final YamlShadowRuleConfiguration 
yamlShadowRuleConfiguration) {
+        yamlShadowRuleConfiguration.setColumn("id");
+        
yamlShadowRuleConfiguration.setSourceDataSourceNames(Arrays.asList("ds"));
+        
yamlShadowRuleConfiguration.setShadowDataSourceNames(Arrays.asList("ds-shadow"));
+    }
+    
+    // fixme remove method when the api refactoring is complete
+    private void assertBasicAlgorithmShadowRule(final 
AlgorithmProvidedShadowRuleConfiguration actualConfiguration, final 
YamlShadowRuleConfiguration expectedConfiguration) {
+        assertThat(actualConfiguration.getColumn(), 
is(expectedConfiguration.getColumn()));
+        assertThat(actualConfiguration.getShadowDataSourceNames(), 
is(expectedConfiguration.getShadowDataSourceNames()));
+        assertThat(actualConfiguration.getSourceDataSourceNames(), 
is(expectedConfiguration.getSourceDataSourceNames()));
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/swapper/ShadowRuleConfigurationYamlSwapperTest.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/swapper/ShadowRuleConfigurationYamlSwapperTest.java
index e69664a..6c31f0f 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/swapper/ShadowRuleConfigurationYamlSwapperTest.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-core/src/test/java/org/apache/shardingsphere/shadow/swapper/ShadowRuleConfigurationYamlSwapperTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.shadow.swapper;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
 import 
org.apache.shardingsphere.shadow.yaml.config.YamlShadowRuleConfiguration;
 import 
org.apache.shardingsphere.shadow.yaml.swapper.ShadowRuleConfigurationYamlSwapper;
+import org.junit.Before;
 import org.junit.Test;
 
 import java.util.Arrays;
@@ -29,13 +30,42 @@ import static org.junit.Assert.assertThat;
 
 public final class ShadowRuleConfigurationYamlSwapperTest {
     
+    private ShadowRuleConfigurationYamlSwapper swapper;
+    
+    @Before
+    public void init() {
+        swapper = new ShadowRuleConfigurationYamlSwapper();
+    }
+    
     @Test
     public void assertSwapToYamlConfiguration() {
-        ShadowRuleConfiguration shadowRuleConfig = new 
ShadowRuleConfiguration("shadow", Arrays.asList("ds", "ds1"), 
Arrays.asList("shadow_ds", "shadow_ds1"));
-        YamlShadowRuleConfiguration actual = new 
ShadowRuleConfigurationYamlSwapper().swapToYamlConfiguration(shadowRuleConfig);
-        assertThat(actual.getColumn(), is("shadow"));
-        assertThat(actual.getSourceDataSourceNames().size(), 
is(actual.getShadowDataSourceNames().size()));
-        assertThat(actual.getSourceDataSourceNames(), is(Arrays.asList("ds", 
"ds1")));
-        assertThat(actual.getShadowDataSourceNames(), 
is(Arrays.asList("shadow_ds", "shadow_ds1")));
+        ShadowRuleConfiguration expectedConfiguration = 
createShadowRuleConfiguration();
+        YamlShadowRuleConfiguration actualConfiguration = 
swapper.swapToYamlConfiguration(expectedConfiguration);
+        assertThat(actualConfiguration.isEnable(), 
is(expectedConfiguration.isEnable()));
+        assertThat(actualConfiguration.getColumn(), 
is(expectedConfiguration.getColumn()));
+        assertThat(actualConfiguration.getSourceDataSourceNames(), 
is(expectedConfiguration.getSourceDataSourceNames()));
+        assertThat(actualConfiguration.getShadowDataSourceNames(), 
is(expectedConfiguration.getShadowDataSourceNames()));
+    }
+    
+    private ShadowRuleConfiguration createShadowRuleConfiguration() {
+        return new ShadowRuleConfiguration("shadow", Arrays.asList("ds", 
"ds1"), Arrays.asList("shadow_ds", "shadow_ds1"));
+    }
+    
+    @Test
+    public void assertSwapToObject() {
+        YamlShadowRuleConfiguration expectedConfiguration = 
createYamlShadowRuleConfiguration();
+        ShadowRuleConfiguration actualConfiguration = 
swapper.swapToObject(expectedConfiguration);
+        assertThat(actualConfiguration.isEnable(), 
is(expectedConfiguration.isEnable()));
+        assertThat(actualConfiguration.getColumn(), 
is(expectedConfiguration.getColumn()));
+        assertThat(actualConfiguration.getSourceDataSourceNames(), 
is(expectedConfiguration.getSourceDataSourceNames()));
+        assertThat(actualConfiguration.getShadowDataSourceNames(), 
is(expectedConfiguration.getShadowDataSourceNames()));
+    }
+    
+    private YamlShadowRuleConfiguration createYamlShadowRuleConfiguration() {
+        YamlShadowRuleConfiguration result = new YamlShadowRuleConfiguration();
+        result.setColumn("shadow");
+        result.setSourceDataSourceNames(Arrays.asList("ds", "ds1"));
+        result.setShadowDataSourceNames(Arrays.asList("shadow_ds", 
"shadow_ds1"));
+        return result;
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/PropertiesShadowSpringBootStarterTest.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/PropertiesShadowSpringBootStarterTest.java
index a4d1c35..4dfa1ba 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/PropertiesShadowSpringBootStarterTest.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/PropertiesShadowSpringBootStarterTest.java
@@ -49,9 +49,10 @@ public class PropertiesShadowSpringBootStarterTest {
     
     @Test
     public void assertShadowRuleConfiguration() {
+        assertThat(shadowRuleConfiguration.isEnable(), is(false));
         assertBasicShadowRule(shadowRuleConfiguration.getColumn(), 
shadowRuleConfiguration.getSourceDataSourceNames(), 
shadowRuleConfiguration.getShadowDataSourceNames());
         assertShadowDataSources(shadowRuleConfiguration.getDataSources());
-        assertShadowTables(shadowRuleConfiguration.getShadowTables());
+        assertShadowTables(shadowRuleConfiguration.getTables());
         assertShadowAlgorithms(shadowRuleConfiguration.getShadowAlgorithms());
     }
     
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowSpringBootStarterTest.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowSpringBootStarterTest.java
index d6b3d4b..aa07bed 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowSpringBootStarterTest.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/java/org/apache/shardingsphere/shadow/spring/boot/YmlShadowSpringBootStarterTest.java
@@ -49,9 +49,10 @@ public class YmlShadowSpringBootStarterTest {
     
     @Test
     public void assertShadowRuleConfiguration() {
+        assertThat(shadowRuleConfiguration.isEnable(), is(true));
         assertBasicShadowRule(shadowRuleConfiguration.getColumn(), 
shadowRuleConfiguration.getSourceDataSourceNames(), 
shadowRuleConfiguration.getShadowDataSourceNames());
         assertShadowDataSources(shadowRuleConfiguration.getDataSources());
-        assertShadowTables(shadowRuleConfiguration.getShadowTables());
+        assertShadowTables(shadowRuleConfiguration.getTables());
         assertShadowAlgorithms(shadowRuleConfiguration.getShadowAlgorithms());
     }
     
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/resources/application-shadow-properties.properties
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/resources/application-shadow-properties.properties
index cd6511f..c5d9dd9 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/resources/application-shadow-properties.properties
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/resources/application-shadow-properties.properties
@@ -22,12 +22,12 @@ 
spring.shardingsphere.rules.shadow.shadowDataSourceNames=shadow_ds,shadow_ds1
 
spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.source-data-source-name=ds0
 
spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.shadow-data-source-name=ds0-shadow
 
-spring.shardingsphere.rules.shadow.shadow-tables.t_order.shadow-algorithm-names[0]=t-order-user-id-algorithm
-spring.shardingsphere.rules.shadow.shadow-tables.t_order.shadow-algorithm-names[1]=t-order-note-algorithm
-spring.shardingsphere.rules.shadow.shadow-tables.t_order.shadow-algorithm-names[2]=t-order-note-algorithm
+spring.shardingsphere.rules.shadow.tables.t_order.shadow-algorithm-names[0]=t-order-user-id-algorithm
+spring.shardingsphere.rules.shadow.tables.t_order.shadow-algorithm-names[1]=t-order-note-algorithm
+spring.shardingsphere.rules.shadow.tables.t_order.shadow-algorithm-names[2]=t-order-note-algorithm
 
-spring.shardingsphere.rules.shadow.shadow-tables.t_user.shadow-algorithm-names[0]=t-order-user-id-algorithm
-spring.shardingsphere.rules.shadow.shadow-tables.t_user.shadow-algorithm-names[1]=t-order-note-algorithm
+spring.shardingsphere.rules.shadow.tables.t_user.shadow-algorithm-names[0]=t-order-user-id-algorithm
+spring.shardingsphere.rules.shadow.tables.t_user.shadow-algorithm-names[1]=t-order-note-algorithm
 
 
spring.shardingsphere.rules.shadow.shadow-algorithms.t-order-user-id-algorithm.type=COLUMN-REGULAR-MATCH
 
spring.shardingsphere.rules.shadow.shadow-algorithms.t-order-user-id-algorithm.props.column=user_id
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/resources/application-shadow-yml.yml
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/resources/application-shadow-yml.yml
index 000676e..411cb30 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/resources/application-shadow-yml.yml
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-boot-starter/src/test/resources/application-shadow-yml.yml
@@ -23,12 +23,12 @@ spring:
         source-data-source-names: ds,ds1
         shadow-data-source-names: shadow_ds,shadow_ds1
 
+        enable: true
         data-sources:
           shadow-data-source:
             source-data-source-name: ds-write-0
             shadow-data-source-name: ds-write-0-shadow
-
-        shadow-tables:
+        tables:
           t_order:
             shadow-algorithm-names:
               - t-order-user-id-algorithm
@@ -37,7 +37,6 @@ spring:
             shadow-algorithm-names:
               - t-order-user-id-algorithm
               - t-order-note-algorithm
-
         shadow-algorithms:
           t-order-user-id-algorithm:
             type: COLUMN-REGULAR-MATCH
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/parser/ShadowRuleBeanDefinitionParser.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/parser/ShadowRuleBeanDefinitionParser.java
index 02b58cb..006a628 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/parser/ShadowRuleBeanDefinitionParser.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/parser/ShadowRuleBeanDefinitionParser.java
@@ -52,12 +52,17 @@ public final class ShadowRuleBeanDefinitionParser extends 
AbstractBeanDefinition
     protected AbstractBeanDefinition parseInternal(final Element element, 
final ParserContext parserContext) {
         BeanDefinitionBuilder factory = 
BeanDefinitionBuilder.rootBeanDefinition(AlgorithmProvidedShadowRuleConfiguration.class);
         addConstructorArgValue(element, factory);
+        factory.addPropertyValue("enable", 
parseShadowEnableConfiguration(element));
         factory.addPropertyValue("dataSources", 
parseDataSourcesConfiguration(element));
-        factory.addPropertyValue("shadowTables", 
parseShadowTablesConfiguration(element));
+        factory.addPropertyValue("tables", 
parseShadowTablesConfiguration(element));
         factory.addPropertyValue("shadowAlgorithms", 
ShardingSphereAlgorithmBeanRegistry.getAlgorithmBeanReferences(parserContext, 
ShadowAlgorithmFactoryBean.class));
         return factory.getBeanDefinition();
     }
     
+    private boolean parseShadowEnableConfiguration(final Element element) {
+        return 
Boolean.parseBoolean(element.getAttribute(ShadowRuleBeanDefinitionTag.SHADOW_ENABLE_TAG));
+    }
+    
     private Map<String, BeanDefinition> parseShadowTablesConfiguration(final 
Element element) {
         List<Element> tableRuleElements = 
DomUtils.getChildElementsByTagName(element, 
ShadowRuleBeanDefinitionTag.SHADOW_TABLE_TAG);
         Map<String, BeanDefinition> result = new 
ManagedMap<>(tableRuleElements.size());
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/tag/ShadowRuleBeanDefinitionTag.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/tag/ShadowRuleBeanDefinitionTag.java
index aa1d916..3e08ddd 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/tag/ShadowRuleBeanDefinitionTag.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/tag/ShadowRuleBeanDefinitionTag.java
@@ -35,6 +35,8 @@ public final class ShadowRuleBeanDefinitionTag {
     
     public static final String SOURCE_DATASOURCE_NAMES_TAG = 
"sourceDataSourceNames";
     
+    public static final String SHADOW_ENABLE_TAG = "enable";
+    
     public static final String DATA_SOURCE_TAG = "data-source";
     
     public static final String DATA_SOURCE_ID_ATTRIBUTE = "id";
@@ -43,7 +45,7 @@ public final class ShadowRuleBeanDefinitionTag {
     
     public static final String SHADOW_DATA_SOURCE_NAME_ATTRIBUTE = 
"shadow-data-source-name";
     
-    public static final String SHADOW_TABLE_TAG = "shadow-table";
+    public static final String SHADOW_TABLE_TAG = "table";
     
     public static final String SHADOW_TABLE_NAME_ATTRIBUTE = "name";
     
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/resources/META-INF/namespace/shadow.xsd
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/resources/META-INF/namespace/shadow.xsd
index 9985365..14c07a3 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/resources/META-INF/namespace/shadow.xsd
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/resources/META-INF/namespace/shadow.xsd
@@ -28,9 +28,10 @@
         <xsd:complexType>
             <xsd:sequence>
                 <xsd:element ref="data-source" minOccurs="0" 
maxOccurs="unbounded" />
-                <xsd:element ref="shadow-table" minOccurs="0" 
maxOccurs="unbounded" />
+                <xsd:element ref="table" minOccurs="0" maxOccurs="unbounded" />
             </xsd:sequence>
             <xsd:attribute name="id" type="xsd:string" use="required"/>
+            <xsd:attribute name="enable" type="xsd:boolean"/>
             <!-- fixme remove when the api refactoring is complete start -->
             <xsd:attribute name="column" type="xsd:string" use="required"/>
             <xsd:attribute name="sourceDataSourceNames" type="list" 
use="required"/>
@@ -53,7 +54,7 @@
         </xsd:complexType>
     </xsd:element>
 
-    <xsd:element name="shadow-table">
+    <xsd:element name="table">
         <xsd:complexType>
             <xsd:sequence>
                 <xsd:element ref="table-algorithm" maxOccurs="unbounded" />
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowAlgorithmSpringNamespaceTest.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowAlgorithmSpringNamespaceTest.java
index b43c27e..440bc29 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowAlgorithmSpringNamespaceTest.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowAlgorithmSpringNamespaceTest.java
@@ -43,9 +43,10 @@ public final class ShadowAlgorithmSpringNamespaceTest 
extends AbstractJUnit4Spri
     
     @Test
     public void assertDataSource() {
+        assertThat(shadowRule.isEnable(), is(true));
         assertBasicShadowRule(shadowRule.getColumn(), 
shadowRule.getSourceDataSourceNames(), shadowRule.getShadowDataSourceNames());
         assertShadowDataSources(shadowRule.getDataSources());
-        assertShadowTables(shadowRule.getShadowTables());
+        assertShadowTables(shadowRule.getTables());
         assertShadowAlgorithms(shadowRule.getShadowAlgorithms());
     }
     
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowSpringNamespaceTest.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowSpringNamespaceTest.java
index acfec7e..000d505 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowSpringNamespaceTest.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/java/org/apache/shardingsphere/shadow/spring/namespace/ShadowSpringNamespaceTest.java
@@ -38,9 +38,10 @@ public final class ShadowSpringNamespaceTest extends 
AbstractJUnit4SpringContext
     
     @Test
     public void assertDataSource() {
+        assertThat(shadowRule.isEnable(), is(false));
         assertBasicShadowRule(shadowRule.getColumn(), 
shadowRule.getSourceDataSourceNames(), shadowRule.getShadowDataSourceNames());
         assertTrue(shadowRule.getDataSources().isEmpty());
-        assertTrue(shadowRule.getShadowTables().isEmpty());
+        assertTrue(shadowRule.getTables().isEmpty());
         assertTrue(shadowRule.getShadowAlgorithms().isEmpty());
     }
     
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/resources/META-INF/spring/shadow-algorithm-application-context.xml
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/resources/META-INF/spring/shadow-algorithm-application-context.xml
index c67cf83..5c9ec8a 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/resources/META-INF/spring/shadow-algorithm-application-context.xml
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/test/resources/META-INF/spring/shadow-algorithm-application-context.xml
@@ -38,15 +38,15 @@
         </props>
     </shadow:shadow-algorithm>
 
-    <shadow:rule id="shadowRule" column="shadow" 
sourceDataSourceNames="ds0,ds1" shadowDataSourceNames="shadow_ds0,shadow_ds1">
+    <shadow:rule id="shadowRule" enable="true" column="shadow" 
sourceDataSourceNames="ds0,ds1" shadowDataSourceNames="shadow_ds0,shadow_ds1">
         <shadow:data-source id="shadow-data-source" 
source-data-source-name="ds" shadow-data-source-name="ds-shadow"/>
-        <shadow:shadow-table name="t_order">
+        <shadow:table name="t_order">
             <shadow:table-algorithm shadow-algorithm-ref= 
"columnRegularMatchShadowAlgorithm" />
             <shadow:table-algorithm shadow-algorithm-ref= 
"noteShadowAlgorithm" />
-        </shadow:shadow-table>
-        <shadow:shadow-table name="t_user">
+        </shadow:table>
+        <shadow:table name="t_user">
             <shadow:table-algorithm shadow-algorithm-ref= 
"columnRegularMatchShadowAlgorithm" />
             <shadow:table-algorithm shadow-algorithm-ref= 
"noteShadowAlgorithm" />
-        </shadow:shadow-table>
+        </shadow:table>
     </shadow:rule>
 </beans>

Reply via email to