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 eda2ecf  Fix example for spring-namespace (#12015)
eda2ecf is described below

commit eda2ecff87f105d437230fdecbff79a73778727e
Author: Haoran Meng <[email protected]>
AuthorDate: Thu Aug 26 14:16:35 2021 +0800

    Fix example for spring-namespace (#12015)
---
 .../zookeeper/cloud/application-encrypt.xml        | 10 +++++-----
 .../cloud/application-readwrite-splitting.xml      |  9 +++++----
 .../zookeeper/cloud/application-shadow.xml         |  9 +++++----
 .../application-sharding-databases-tables.xml      | 11 ++++++-----
 .../zookeeper/local/application-encrypt.xml        | 13 +++++++-----
 .../local/application-readwrite-splitting.xml      | 13 +++++++-----
 .../zookeeper/local/application-shadow.xml         | 13 +++++++-----
 .../application-sharding-databases-tables.xml      | 13 +++++++-----
 .../META-INF/zookeeper/registry-center.xml         | 10 ++++------
 .../parser/DataSourceBeanDefinitionParser.java     |  9 ++++++---
 .../resources/META-INF/namespace/datasource.xsd    |  4 ++--
 .../governance/ClusterEncryptNamespaceTest.java    | 14 ++++++-------
 .../registry/TestClusterPersistRepository.java     | 23 +++++++++++++++-------
 13 files changed, 88 insertions(+), 63 deletions(-)

diff --git 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-encrypt.xml
 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-encrypt.xml
index f553b2c..9d439f0 100644
--- 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-encrypt.xml
+++ 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-encrypt.xml
@@ -20,20 +20,20 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns:context="http://www.springframework.org/schema/context";
        xmlns:tx="http://www.springframework.org/schema/tx";
-       xmlns:governance="cluster-mode-repository.xsd"
+       
xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                         
http://www.springframework.org/schema/beans/spring-beans.xsd 
                         http://www.springframework.org/schema/context 
                         
http://www.springframework.org/schema/context/spring-context.xsd
                         http://www.springframework.org/schema/tx 
-                        http://www.springframework.org/schema/tx/spring-tx.xsd
-                        cluster-mode-repository.xsd
-                        cluster-mode-repository.xsd">
+                        http://www.springframework.org/schema/tx/spring-tx.xsd 
http://shardingsphere.apache.org/schema/shardingsphere/datasource 
http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd";>
     <import resource="classpath*:META-INF/zookeeper/registry-center.xml" />
     
     <context:component-scan 
base-package="org.apache.shardingsphere.example.core.mybatis" />
     
-    <governance:data-source id="encryptDataSource" reg-center-ref="regCenter" 
/>
+    <shardingsphere:data-source id="encryptDataSource">
+        <shardingsphere:mode type="Cluster" repository-ref="clusterRepository" 
/>
+    </shardingsphere:data-source>
     
     <bean id="transactionManager" 
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
         <property name="dataSource" ref="encryptDataSource" />
diff --git 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-readwrite-splitting.xml
 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-readwrite-splitting.xml
index 7ed45d8..817ae59 100644
--- 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-readwrite-splitting.xml
+++ 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-readwrite-splitting.xml
@@ -20,19 +20,20 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns:context="http://www.springframework.org/schema/context";
        xmlns:tx="http://www.springframework.org/schema/tx";
-       xmlns:governance="cluster-mode-repository.xsd"
+       
xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource";
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
                         
http://www.springframework.org/schema/beans/spring-beans.xsd 
                         http://www.springframework.org/schema/context 
                         
http://www.springframework.org/schema/context/spring-context.xsd
                         http://www.springframework.org/schema/tx 
                         http://www.springframework.org/schema/tx/spring-tx.xsd
-                        cluster-mode-repository.xsd
-                        cluster-mode-repository.xsd">
+                        
http://shardingsphere.apache.org/schema/shardingsphere/datasource 
http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd";>
     <context:component-scan 
base-package="org.apache.shardingsphere.example.core.mybatis" />
     <import resource="classpath*:META-INF/zookeeper/registry-center.xml" />
     
-    <governance:data-source id="readWriteSplittingDataSource" 
reg-center-ref="regCenter" />
+    <shardingsphere:data-source id="readWriteSplittingDataSource">
+        <shardingsphere:mode type="Cluster" repository-ref="clusterRepository" 
/>
+    </shardingsphere:data-source>
     
     <bean id="transactionManager" 
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
         <property name="dataSource" ref="readWriteSplittingDataSource" />
diff --git 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-shadow.xml
 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-shadow.xml
index cd5b30e..f31ab7c 100644
--- 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-shadow.xml
+++ 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-shadow.xml
@@ -20,20 +20,21 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns:context="http://www.springframework.org/schema/context";
        xmlns:tx="http://www.springframework.org/schema/tx";
-       xmlns:governance="cluster-mode-repository.xsd"
+       
xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                         
http://www.springframework.org/schema/beans/spring-beans.xsd 
                         http://www.springframework.org/schema/context 
                         
http://www.springframework.org/schema/context/spring-context.xsd
                         http://www.springframework.org/schema/tx 
                         http://www.springframework.org/schema/tx/spring-tx.xsd
-                        cluster-mode-repository.xsd
-                        cluster-mode-repository.xsd">
+                        
http://shardingsphere.apache.org/schema/shardingsphere/datasource 
http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd";>
     <import resource="classpath*:META-INF/zookeeper/registry-center.xml" />
     
     <context:component-scan 
base-package="org.apache.shardingsphere.example.core.mybatis" />
     
-    <governance:data-source id="shadowDataSource" reg-center-ref="regCenter" />
+    <shardingsphere:data-source id="shadowDataSource">
+        <shardingsphere:mode type="Cluster" repository-ref="clusterRepository" 
/>
+    </shardingsphere:data-source>
     
     <bean id="transactionManager" 
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
         <property name="dataSource" ref="shadowDataSource" />
diff --git 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-sharding-databases-tables.xml
 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-sharding-databases-tables.xml
index 558e654..725229c 100644
--- 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-sharding-databases-tables.xml
+++ 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/cloud/application-sharding-databases-tables.xml
@@ -20,19 +20,20 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns:context="http://www.springframework.org/schema/context";
        xmlns:tx="http://www.springframework.org/schema/tx";
-       xmlns:governance="cluster-mode-repository.xsd"
+       
xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                         
http://www.springframework.org/schema/beans/spring-beans.xsd
                         http://www.springframework.org/schema/context
                         
http://www.springframework.org/schema/context/spring-context.xsd
                         http://www.springframework.org/schema/tx
                         http://www.springframework.org/schema/tx/spring-tx.xsd
-                        cluster-mode-repository.xsd
-                        cluster-mode-repository.xsd">
+                        
http://shardingsphere.apache.org/schema/shardingsphere/datasource 
http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd";>
     <import resource="classpath*:META-INF/zookeeper/registry-center.xml" />
     <context:component-scan 
base-package="org.apache.shardingsphere.example.core.mybatis" />
-
-    <governance:data-source id="shardingDatabasesTablesDataSource" 
reg-center-ref="regCenter" />
+    
+    <shardingsphere:data-source id="shardingDatabasesTablesDataSource">
+        <shardingsphere:mode type="Cluster" repository-ref="clusterRepository" 
/>
+    </shardingsphere:data-source>
     
     <bean id="transactionManager" 
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
         <property name="dataSource" ref="shardingDatabasesTablesDataSource" />
diff --git 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-encrypt.xml
 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-encrypt.xml
index 81336bc..2972775 100644
--- 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-encrypt.xml
+++ 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-encrypt.xml
@@ -21,7 +21,7 @@
        xmlns:context="http://www.springframework.org/schema/context";
        xmlns:tx="http://www.springframework.org/schema/tx";
        
xmlns:encrypt="http://shardingsphere.apache.org/schema/shardingsphere/encrypt";
-       xmlns:governance="cluster-mode-repository.xsd"
+       
xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            
http://www.springframework.org/schema/beans/spring-beans.xsd 
                            http://www.springframework.org/schema/context 
@@ -30,9 +30,7 @@
                            
http://www.springframework.org/schema/tx/spring-tx.xsd
                            
http://shardingsphere.apache.org/schema/shardingsphere/encrypt
                            
http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd 
-                           cluster-mode-repository.xsd
-                           cluster-mode-repository.xsd
-                           ">
+                           
http://shardingsphere.apache.org/schema/shardingsphere/datasource 
http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd";>
     <import resource="classpath*:META-INF/zookeeper/registry-center.xml" />
     <context:component-scan 
base-package="org.apache.shardingsphere.example.core.mybatis" />
     
@@ -57,7 +55,12 @@
         </encrypt:table>
     </encrypt:rule>
     
-    <governance:data-source id="encryptDataSource" data-source-names="demo_ds" 
reg-center-ref="regCenter" rule-refs="encryptRule" />
+    <shardingsphere:data-source id="encryptDataSource" 
data-source-names="demo_ds" rule-refs="encryptRule">
+        <shardingsphere:mode type="Cluster" repository-ref="clusterRepository" 
/>
+        <props>
+            <prop key="sql-show">true</prop>
+        </props>
+    </shardingsphere:data-source>
     
     <bean id="transactionManager" 
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
         <property name="dataSource" ref="encryptDataSource" />
diff --git 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-readwrite-splitting.xml
 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-readwrite-splitting.xml
index ae53e31..9ad109b 100644
--- 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-readwrite-splitting.xml
+++ 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-readwrite-splitting.xml
@@ -21,7 +21,7 @@
        xmlns:context="http://www.springframework.org/schema/context";
        xmlns:tx="http://www.springframework.org/schema/tx";
        
xmlns:readwrite-splitting="http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting";
-       xmlns:governance="cluster-mode-repository.xsd"
+       
xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            
http://www.springframework.org/schema/beans/spring-beans.xsd 
                            http://www.springframework.org/schema/context 
@@ -30,9 +30,7 @@
                            
http://www.springframework.org/schema/tx/spring-tx.xsd
                            
http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting
                            
http://shardingsphere.apache.org/schema/shardingsphere/readwrite-splitting/readwrite-splitting.xsd
-                           cluster-mode-repository.xsd
-                           cluster-mode-repository.xsd
-                           ">
+                           
http://shardingsphere.apache.org/schema/shardingsphere/datasource 
http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd";>
     <import resource="classpath*:META-INF/zookeeper/registry-center.xml"/>
     <context:component-scan 
base-package="org.apache.shardingsphere.example.core.mybatis"/>
     
@@ -63,7 +61,12 @@
         <readwrite-splitting:data-source-rule id="demo_ds" 
write-data-source-name="demo_write_ds" read-data-source-names="demo_read_ds_0, 
demo_read_ds_1" load-balance-algorithm-ref="randomStrategy" />
     </readwrite-splitting:rule>
     
-    <governance:data-source id="readWriteSplittingDataSource" 
data-source-names="demo_write_ds, demo_read_ds_0, demo_read_ds_1" 
rule-refs="readWriteSplittingRule" reg-center-ref="regCenter" />
+    <shardingsphere:data-source id="readWriteSplittingDataSource" 
data-source-names="demo_write_ds, demo_read_ds_0, demo_read_ds_1" 
rule-refs="readWriteSplittingRule">
+        <shardingsphere:mode type="Cluster" repository-ref="clusterRepository" 
/>
+        <props>
+            <prop key="sql-show">true</prop>
+        </props>
+    </shardingsphere:data-source>
     
     <bean id="transactionManager" 
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
         <property name="dataSource" ref="readWriteSplittingDataSource" />
diff --git 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-shadow.xml
 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-shadow.xml
index e92821f..4db47d1 100644
--- 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-shadow.xml
+++ 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-shadow.xml
@@ -21,7 +21,7 @@
        xmlns:context="http://www.springframework.org/schema/context";
        xmlns:tx="http://www.springframework.org/schema/tx";
        
xmlns:shadow="http://shardingsphere.apache.org/schema/shardingsphere/shadow";
-       xmlns:governance="cluster-mode-repository.xsd"
+       
xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            
http://www.springframework.org/schema/beans/spring-beans.xsd 
                            http://www.springframework.org/schema/context 
@@ -30,9 +30,7 @@
                            
http://www.springframework.org/schema/tx/spring-tx.xsd
                            
http://shardingsphere.apache.org/schema/shardingsphere/shadow
                            
http://shardingsphere.apache.org/schema/shardingsphere/shadow/shadow.xsd
-                           cluster-mode-repository.xsd
-                           cluster-mode-repository.xsd
-                           ">
+                           
http://shardingsphere.apache.org/schema/shardingsphere/datasource 
http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd";>
     <import resource="classpath*:META-INF/zookeeper/registry-center.xml" />
     <context:component-scan 
base-package="org.apache.shardingsphere.example.core.mybatis" />
     
@@ -52,7 +50,12 @@
     
     <shadow:rule id="shadowRule" column="shadow" 
sourceDataSourceNames="demo_ds" shadowDataSourceNames="shadow_demo_ds"/>
     
-    <governance:data-source id="shadowDataSource" 
data-source-names="demo_ds,shadow_demo_ds" reg-center-ref="regCenter" 
rule-refs="shadowRule"/>
+    <shardingsphere:data-source id="shadowDataSource" 
data-source-names="demo_ds,shadow_demo_ds" rule-refs="shadowRule">
+        <shardingsphere:mode type="Cluster" repository-ref="clusterRepository" 
/>
+        <props>
+            <prop key="sql-show">true</prop>
+        </props>
+    </shardingsphere:data-source>
     
     <bean id="transactionManager" 
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
         <property name="dataSource" ref="shadowDataSource" />
diff --git 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-sharding-databases-tables.xml
 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-sharding-databases-tables.xml
index e127410..223d2d5 100644
--- 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-sharding-databases-tables.xml
+++ 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/local/application-sharding-databases-tables.xml
@@ -21,7 +21,7 @@
        xmlns:context="http://www.springframework.org/schema/context";
        xmlns:tx="http://www.springframework.org/schema/tx";
        
xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding";
-       xmlns:governance="cluster-mode-repository.xsd"
+       
xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            
http://www.springframework.org/schema/beans/spring-beans.xsd 
                            http://www.springframework.org/schema/tx 
@@ -30,9 +30,7 @@
                            
http://www.springframework.org/schema/context/spring-context.xsd
                            
http://shardingsphere.apache.org/schema/shardingsphere/sharding
                            
http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
-                           cluster-mode-repository.xsd
-                           cluster-mode-repository.xsd
-                           ">
+                           
http://shardingsphere.apache.org/schema/shardingsphere/datasource 
http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd";>
     <import resource="classpath*:META-INF/zookeeper/registry-center.xml" />
     <context:component-scan 
base-package="org.apache.shardingsphere.example.core.mybatis" />
     <bean id="demo_ds_0" class="com.zaxxer.hikari.HikariDataSource" 
destroy-method="close">
@@ -95,7 +93,12 @@
         </sharding:broadcast-table-rules>
     </sharding:rule>
     
-    <governance:data-source id="shardingDatabasesTablesDataSource" 
schema-name="sharding-databases-tables" data-source-names="demo_ds_0, 
demo_ds_1" reg-center-ref="regCenter" rule-refs="shardingRule" />
+    <shardingsphere:data-source id="shardingDatabasesTablesDataSource" 
schema-name="sharding-databases-tables" data-source-names="demo_ds_0, 
demo_ds_1" rule-refs="shardingRule">
+        <shardingsphere:mode type="Cluster" repository-ref="clusterRepository" 
/>
+        <props>
+            <prop key="sql-show">true</prop>
+        </props>
+    </shardingsphere:data-source>
     
     <bean id="transactionManager" 
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
         <property name="dataSource" ref="shardingDatabasesTablesDataSource" />
diff --git 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/registry-center.xml
 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/registry-center.xml
index 7495025..f60147b 100644
--- 
a/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/registry-center.xml
+++ 
b/examples/shardingsphere-jdbc-example/governance-example/governance-spring-namespace-mybatis-example/src/main/resources/META-INF/zookeeper/registry-center.xml
@@ -17,17 +17,15 @@
   -->
 
 <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-       xmlns:governance="cluster-mode-repository.xsd"
        xmlns="http://www.springframework.org/schema/beans";
+       
xmlns:cluster="http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster";
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            
http://www.springframework.org/schema/beans/spring-beans.xsd
-                           cluster-mode-repository.xsd
-                           cluster-mode-repository.xsd
-                           ">
-    <governance:reg-center id="regCenter" type="ZooKeeper" 
namespace="regCenter" server-lists="localhost:2181">
+                           
http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster 
http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster/repository.xsd";>
+    <cluster:repository id="clusterRepository" type="ZooKeeper" 
namespace="regCenter" server-lists="localhost:2181">
         <props>
             <prop key="max-retries">3</prop>
             <prop key="operation-timeout-milliseconds">3000</prop>
         </props>
-    </governance:reg-center>
+    </cluster:repository>
 </beans>
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/parser/DataSourceBeanDefinitionParser.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/parser/DataSourceBeanDefinitionParser.java
index 035f1ba..25e4c21 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/parser/DataSourceBeanDefinitionParser.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/java/org/apache/shardingsphere/spring/namespace/parser/DataSourceBeanDefinitionParser.java
@@ -30,6 +30,7 @@ import org.springframework.beans.factory.support.ManagedList;
 import org.springframework.beans.factory.support.ManagedMap;
 import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
 import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.StringUtils;
 import org.springframework.util.xml.DomUtils;
 import org.w3c.dom.Element;
 
@@ -48,9 +49,11 @@ public final class DataSourceBeanDefinitionParser extends 
AbstractBeanDefinition
         BeanDefinitionBuilder factory = 
BeanDefinitionBuilder.rootBeanDefinition(ShardingSphereDataSource.class);
         factory.addConstructorArgValue(parseSchemaName(element));
         factory.addConstructorArgValue(parseModeConfiguration(element));
-        factory.addConstructorArgValue(parseDataSources(element));
-        factory.addConstructorArgValue(parseRuleConfigurations(element));
-        factory.addConstructorArgValue(parseProperties(element, 
parserContext));
+        if 
(!StringUtils.isEmpty(element.getAttribute(DataSourceBeanDefinitionTag.DATA_SOURCE_NAMES_ATTRIBUTE)))
 {
+            factory.addConstructorArgValue(parseDataSources(element));
+            factory.addConstructorArgValue(parseRuleConfigurations(element));
+            factory.addConstructorArgValue(parseProperties(element, 
parserContext));
+        }
         factory.setDestroyMethodName("close");
         return factory.getBeanDefinition();
     }
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/resources/META-INF/namespace/datasource.xsd
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/resources/META-INF/namespace/datasource.xsd
index 58f0f87..8082280 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/resources/META-INF/namespace/datasource.xsd
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/main/resources/META-INF/namespace/datasource.xsd
@@ -31,8 +31,8 @@
             </xsd:all>
             <xsd:attribute name="id" type="xsd:string" use="required" />
             <xsd:attribute name="schema-name" type="xsd:string" 
default="logic_db" />
-            <xsd:attribute name="data-source-names" type="xsd:string" 
use="required" />
-            <xsd:attribute name="rule-refs" type="xsd:string" use="required" />
+            <xsd:attribute name="data-source-names" type="xsd:string"/>
+            <xsd:attribute name="rule-refs" type="xsd:string"/>
         </xsd:complexType>
     </xsd:element>
     
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/governance/ClusterEncryptNamespaceTest.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/governance/ClusterEncryptNamespaceTest.java
index dd0cfda..88ee73d 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/governance/ClusterEncryptNamespaceTest.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/governance/ClusterEncryptNamespaceTest.java
@@ -18,14 +18,14 @@
 package org.apache.shardingsphere.spring.namespace.governance;
 
 import 
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource;
-import 
org.apache.shardingsphere.encrypt.algorithm.config.AlgorithmProvidedEncryptRuleConfiguration;
+import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
 import 
org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
 import 
org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
-import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
+import 
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.config.properties.ConfigurationProperties;
 import 
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
-import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.infra.database.DefaultSchema;
+import org.apache.shardingsphere.mode.manager.ContextManager;
 import 
org.apache.shardingsphere.spring.namespace.governance.util.EmbedTestingServer;
 import 
org.apache.shardingsphere.spring.namespace.governance.util.FieldValueUtil;
 import org.junit.BeforeClass;
@@ -55,13 +55,13 @@ public final class ClusterEncryptNamespaceTest extends 
AbstractJUnit4SpringConte
         assertEncryptRule(getEncryptRuleConfiguration());
     }
     
-    private AlgorithmProvidedEncryptRuleConfiguration 
getEncryptRuleConfiguration() {
+    private EncryptRuleConfiguration getEncryptRuleConfiguration() {
         ShardingSphereDataSource governanceDataSource = 
(ShardingSphereDataSource) 
applicationContext.getBean("encryptDataSourceGovernance");
         ContextManager contextManager = (ContextManager) 
FieldValueUtil.getFieldValue(governanceDataSource, "contextManager");
-        return (AlgorithmProvidedEncryptRuleConfiguration) 
contextManager.getMetaDataContexts().getMetaData(DefaultSchema.LOGIC_NAME).getRuleMetaData().getConfigurations().iterator().next();
+        return (EncryptRuleConfiguration) 
contextManager.getMetaDataContexts().getMetaData(DefaultSchema.LOGIC_NAME).getRuleMetaData().getConfigurations().iterator().next();
     }
     
-    private void assertEncryptRule(final 
AlgorithmProvidedEncryptRuleConfiguration config) {
+    private void assertEncryptRule(final EncryptRuleConfiguration config) {
         assertThat(config.getEncryptors().size(), is(2));
         assertThat(config.getTables().size(), is(1));
         EncryptTableRuleConfiguration encryptTableRuleConfig = 
config.getTables().iterator().next();
@@ -70,7 +70,7 @@ public final class ClusterEncryptNamespaceTest extends 
AbstractJUnit4SpringConte
         EncryptColumnRuleConfiguration orderIdColumnRuleConfig = 
encryptColumnRuleConfigs.next();
         assertThat(userIdColumnRuleConfig.getCipherColumn(), 
is("user_encrypt"));
         assertThat(orderIdColumnRuleConfig.getPlainColumn(), 
is("order_decrypt"));
-        Map<String, EncryptAlgorithm> encryptAlgorithms = 
config.getEncryptors();
+        Map<String, ShardingSphereAlgorithmConfiguration> encryptAlgorithms = 
config.getEncryptors();
         assertThat(encryptAlgorithms.size(), is(2));
         assertThat(encryptAlgorithms.get("aes_encryptor").getType(), 
is("AES"));
         
assertThat(encryptAlgorithms.get("aes_encryptor").getProps().getProperty("aes-key-value"),
 is("123456"));
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/governance/registry/TestClusterPersistRepository.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/governance/registry/TestClusterPersistReposi
 [...]
index 21ea443..b8f8564 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/governance/registry/TestClusterPersistRepository.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-governance-spring/shardingsphere-jdbc-governance-spring-namespace/src/test/java/org/apache/shardingsphere/spring/namespace/governance/registry/TestClusterPersistRepository.java
@@ -17,57 +17,66 @@
 
 package org.apache.shardingsphere.spring.namespace.governance.registry;
 
+import org.apache.shardingsphere.infra.database.DefaultSchema;
 import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepository;
 import 
org.apache.shardingsphere.mode.repository.cluster.ClusterPersistRepositoryConfiguration;
 import 
org.apache.shardingsphere.mode.repository.cluster.listener.DataChangedEventListener;
 
 import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 public final class TestClusterPersistRepository implements 
ClusterPersistRepository {
     
+    private final Map<String, String> registryData = new LinkedHashMap<>();
+    
     @Override
     public void init(final ClusterPersistRepositoryConfiguration config) {
+        registryData.put("/metadata", DefaultSchema.LOGIC_NAME);
     }
     
     @Override
     public String get(final String key) {
-        return "";
+        return registryData.get(key);
     }
     
     @Override
     public List<String> getChildrenKeys(final String key) {
-        return Collections.emptyList();
+        return registryData.containsKey(key) ? 
Collections.singletonList(registryData.get(key)) : Collections.emptyList();
     }
     
     @Override
     public void persist(final String key, final String value) {
+        registryData.put(key, value);
     }
     
     @Override
     public void persistEphemeral(final String key, final String value) {
+        registryData.put(key, value);
     }
     
     @Override
-    public boolean tryLock(final String key, final long time, final TimeUnit 
unit) {
-        return false;
+    public void delete(final String key) {
     }
     
     @Override
-    public void releaseLock(final String key) {
+    public void watch(final String key, final DataChangedEventListener 
listener) {
     }
     
     @Override
-    public void delete(final String key) {
+    public boolean tryLock(final String key, final long time, final TimeUnit 
unit) {
+        return false;
     }
     
     @Override
-    public void watch(final String key, final DataChangedEventListener 
listener) {
+    public void releaseLock(final String key) {
     }
     
     @Override
     public void close() {
+        registryData.clear();
     }
     
     @Override

Reply via email to