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 8658e71  Add users and built rules into ShardingSphereRulesBuilder 
(#9932)
8658e71 is described below

commit 8658e7102b951b88b00b6e1a6a346600c259c55a
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Apr 4 21:42:16 2021 +0800

    Add users and built rules into ShardingSphereRulesBuilder (#9932)
    
    * Adjust authority order
    
    * Add built rules into ShardingSphereRulesBuilder
    
    * Add users into ShardingSphereRulesBuilder
    
    * Fix checkstyle
---
 .../authority/constant/AuthorityOrder.java            |  4 ++--
 .../shardingsphere/authority/rule/AuthorityRule.java  |  7 +++++--
 .../authority/rule/builder/AuthorityRuleBuilder.java  |  8 ++++++--
 ...AlgorithmProvidedDatabaseDiscoveryRuleBuilder.java |  8 ++++++--
 .../rule/biulder/DatabaseDiscoveryRuleBuilder.java    |  7 +++++--
 ...rithmProvidedDatabaseDiscoveryRuleBuilderTest.java |  3 ++-
 .../biulder/DatabaseDiscoveryRuleBuilderTest.java     |  2 +-
 .../builder/AlgorithmProvidedEncryptRuleBuilder.java  |  7 +++++--
 .../encrypt/rule/builder/EncryptRuleBuilder.java      |  6 +++++-
 .../AlgorithmProvidedEncryptRuleBuilderTest.java      |  2 +-
 .../encrypt/rule/builder/EncryptRuleBuilderTest.java  |  2 +-
 .../EncryptSQLRewriterParameterizedTest.java          |  4 ++--
 ...lgorithmProvidedReadWriteSplittingRuleBuilder.java |  8 ++++++--
 .../rule/biulder/ReadWriteSplittingRuleBuilder.java   |  7 +++++--
 ...ithmProvidedReadWriteSplittingRuleBuilderTest.java |  3 ++-
 .../biulder/ReadWriteSplittingRuleBuilderTest.java    |  2 +-
 .../shadow/rule/builder/ShadowRuleBuilder.java        |  7 +++++--
 .../shadow/rule/builder/ShadowRuleBuilderTest.java    |  2 +-
 .../builder/AlgorithmProvidedShardingRuleBuilder.java |  7 +++++--
 .../sharding/rule/builder/ShardingRuleBuilder.java    |  7 +++++--
 .../AlgorithmProvidedShardingRuleBuilderTest.java     |  4 +++-
 .../rule/builder/ShardingRuleBuilderTest.java         |  4 +++-
 .../MixSQLRewriterParameterizedTest.java              |  4 ++--
 .../ShardingSQLRewriterParameterizedTest.java         |  4 ++--
 .../infra/rule/builder/ShardingSphereRuleBuilder.java |  6 +++++-
 .../rule/builder/ShardingSphereRulesBuilder.java      | 19 +++++++++++++------
 .../infra/rule/ShardingSphereRulesBuilderTest.java    |  5 +++--
 .../rule/fixture/TestShardingSphereRuleBuilder.java   |  8 +++++---
 .../context/metadata/MetaDataContextsBuilder.java     |  2 +-
 .../infra/context/fixture/FixtureRuleBuilder.java     |  7 +++++--
 30 files changed, 113 insertions(+), 53 deletions(-)

diff --git 
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/constant/AuthorityOrder.java
 
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/constant/AuthorityOrder.java
index a84c10d..bf378cf 100644
--- 
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/constant/AuthorityOrder.java
+++ 
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/constant/AuthorityOrder.java
@@ -29,10 +29,10 @@ public final class AuthorityOrder {
     /**
      * Authority order.
      */
-    public static final int ORDER = -100;
+    public static final int ORDER = 500;
     
     /**
      * Algorithm provider authority order.
      */
-    public static final int ALGORITHM_PROVIDER_AUTHORITY_ORDER = -99;
+    public static final int ALGORITHM_PROVIDER_AUTHORITY_ORDER = 501;
 }
diff --git 
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
 
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
index 1343353..ad7b428 100644
--- 
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
+++ 
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/AuthorityRule.java
@@ -24,9 +24,12 @@ import 
org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmF
 import org.apache.shardingsphere.infra.metadata.auth.Authentication;
 import org.apache.shardingsphere.infra.metadata.auth.AuthenticationContext;
 import 
org.apache.shardingsphere.infra.metadata.auth.builtin.DefaultAuthentication;
+import 
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
 
+import java.util.Collection;
+
 /**
  * Authority rule.
  */
@@ -38,12 +41,12 @@ public final class AuthorityRule implements 
ShardingSphereRule {
     
     private final PrivilegeLoadAlgorithm privilegeLoader;
     
-    public AuthorityRule(final AuthorityRuleConfiguration config) {
+    public AuthorityRule(final AuthorityRuleConfiguration config, final 
Collection<ShardingSphereUser> users, final Collection<ShardingSphereRule> 
builtRules) {
         Preconditions.checkState(1 == config.getPrivilegeLoaders().size(), 
"Only support one privilege loader.");
         privilegeLoader = 
ShardingSphereAlgorithmFactory.createAlgorithm(config.getPrivilegeLoaders().values().iterator().next(),
 PrivilegeLoadAlgorithm.class);
         Authentication authentication = new DefaultAuthentication();
         // TODO pass correct parameters
-        authentication.init(privilegeLoader.load(null, null));
+        authentication.init(privilegeLoader.load(null, users));
         AuthenticationContext.getInstance().init(authentication);
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
 
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
index cd86683..8e78e63 100644
--- 
a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
+++ 
b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
@@ -21,9 +21,12 @@ import 
org.apache.shardingsphere.authority.api.config.AuthorityRuleConfiguration
 import org.apache.shardingsphere.authority.constant.AuthorityOrder;
 import org.apache.shardingsphere.authority.rule.AuthorityRule;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.builder.ShardingSphereRuleBuilder;
 
 import javax.sql.DataSource;
+import java.util.Collection;
 import java.util.Map;
 
 /**
@@ -32,8 +35,9 @@ import java.util.Map;
 public final class AuthorityRuleBuilder implements 
ShardingSphereRuleBuilder<AuthorityRule, AuthorityRuleConfiguration> {
     
     @Override
-    public AuthorityRule build(final String schemaName, final Map<String, 
DataSource> dataSourceMap, final DatabaseType databaseType, final 
AuthorityRuleConfiguration ruleConfig) {
-        return new AuthorityRule(ruleConfig);
+    public AuthorityRule build(final String schemaName, final Map<String, 
DataSource> dataSourceMap, final DatabaseType databaseType, 
+                               final AuthorityRuleConfiguration ruleConfig, 
final Collection<ShardingSphereUser> users, final 
Collection<ShardingSphereRule> builtRules) {
+        return new AuthorityRule(ruleConfig, users, builtRules);
     }
     
     @Override
diff --git 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/AlgorithmProvidedDatabaseDiscoveryRuleBuilder.java
 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/AlgorithmProvidedDatabaseDiscoveryRuleBuilder.java
index f008f21..8e65a7a 100644
--- 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/AlgorithmProvidedDatabaseDiscoveryRuleBuilder.java
+++ 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/AlgorithmProvidedDatabaseDiscoveryRuleBuilder.java
@@ -21,9 +21,12 @@ import 
org.apache.shardingsphere.db.discovery.common.algorithm.config.AlgorithmP
 import 
org.apache.shardingsphere.db.discovery.common.constant.DatabaseDiscoveryOrder;
 import 
org.apache.shardingsphere.db.discovery.common.rule.DatabaseDiscoveryRule;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.builder.ShardingSphereRuleBuilder;
 
 import javax.sql.DataSource;
+import java.util.Collection;
 import java.util.Map;
 
 /**
@@ -32,8 +35,9 @@ import java.util.Map;
 public final class AlgorithmProvidedDatabaseDiscoveryRuleBuilder implements 
ShardingSphereRuleBuilder<DatabaseDiscoveryRule, 
AlgorithmProvidedDatabaseDiscoveryRuleConfiguration> {
     
     @Override
-    public DatabaseDiscoveryRule build(final String schemaName, 
-                                       final Map<String, DataSource> 
dataSourceMap, final DatabaseType databaseType, final 
AlgorithmProvidedDatabaseDiscoveryRuleConfiguration ruleConfig) {
+    public DatabaseDiscoveryRule build(final String schemaName, final 
Map<String, DataSource> dataSourceMap, final DatabaseType databaseType, 
+                                       final 
AlgorithmProvidedDatabaseDiscoveryRuleConfiguration ruleConfig, 
+                                       final Collection<ShardingSphereUser> 
users, final Collection<ShardingSphereRule> builtRules) {
         return new DatabaseDiscoveryRule(ruleConfig, databaseType, 
dataSourceMap, schemaName);
     }
     
diff --git 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/DatabaseDiscoveryRuleBuilder.java
 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/DatabaseDiscoveryRuleBuilder.java
index 8086189..e1bda8d 100644
--- 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/DatabaseDiscoveryRuleBuilder.java
+++ 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/DatabaseDiscoveryRuleBuilder.java
@@ -22,9 +22,12 @@ import 
org.apache.shardingsphere.db.discovery.api.config.rule.DatabaseDiscoveryD
 import 
org.apache.shardingsphere.db.discovery.common.constant.DatabaseDiscoveryOrder;
 import 
org.apache.shardingsphere.db.discovery.common.rule.DatabaseDiscoveryRule;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.builder.ShardingSphereRuleBuilder;
 
 import javax.sql.DataSource;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -34,8 +37,8 @@ import java.util.Map;
 public final class DatabaseDiscoveryRuleBuilder implements 
ShardingSphereRuleBuilder<DatabaseDiscoveryRule, 
DatabaseDiscoveryRuleConfiguration> {
     
     @Override
-    public DatabaseDiscoveryRule build(final String schemaName,
-                                       final Map<String, DataSource> 
dataSourceMap, final DatabaseType databaseType, final 
DatabaseDiscoveryRuleConfiguration ruleConfig) {
+    public DatabaseDiscoveryRule build(final String schemaName, final 
Map<String, DataSource> dataSourceMap, final DatabaseType databaseType, 
+                                       final 
DatabaseDiscoveryRuleConfiguration ruleConfig, final 
Collection<ShardingSphereUser> users, final Collection<ShardingSphereRule> 
builtRules) {
         Map<String, DataSource> realDataSourceMap = new HashMap<>();
         for (DatabaseDiscoveryDataSourceRuleConfiguration each : 
ruleConfig.getDataSources()) {
             for (String datasourceName : each.getDataSourceNames()) {
diff --git 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/AlgorithmProvidedDatabaseDiscoveryRuleBuilderTest.java
 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/AlgorithmProvidedDatabaseDiscoveryRuleBuilderTest.java
index d40b08b..a50e335 100644
--- 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/AlgorithmProvidedDatabaseDiscoveryRuleBuilderTest.java
+++ 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/AlgorithmProvidedDatabaseDiscoveryRuleBuilderTest.java
@@ -48,6 +48,7 @@ public final class 
AlgorithmProvidedDatabaseDiscoveryRuleBuilderTest {
         
when(algorithmProvidedRuleConfig.getDataSources()).thenReturn(Collections.singletonList(ruleConfig));
         ShardingSphereRuleBuilder builder = 
OrderedSPIRegistry.getRegisteredServices(
                 Collections.singletonList(algorithmProvidedRuleConfig), 
ShardingSphereRuleBuilder.class).get(algorithmProvidedRuleConfig);
-        assertThat(builder.build("", Collections.emptyMap(), 
mock(DatabaseType.class), algorithmProvidedRuleConfig), 
instanceOf(DatabaseDiscoveryRule.class));
+        assertThat(builder.build("", Collections.emptyMap(), 
mock(DatabaseType.class), algorithmProvidedRuleConfig, Collections.emptyList(), 
Collections.emptyList()), 
+                instanceOf(DatabaseDiscoveryRule.class));
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/DatabaseDiscoveryRuleBuilderTest.java
 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/DatabaseDiscoveryRuleBuilderTest.java
index e5bdaf0..fd066af 100644
--- 
a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/DatabaseDiscoveryRuleBuilderTest.java
+++ 
b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/test/java/org/apache/shardingsphere/db/discovery/common/rule/biulder/DatabaseDiscoveryRuleBuilderTest.java
@@ -51,6 +51,6 @@ public final class DatabaseDiscoveryRuleBuilderTest {
         ShardingSphereRuleBuilder builder = 
OrderedSPIRegistry.getRegisteredServices(Collections.singletonList(ruleConfig), 
ShardingSphereRuleBuilder.class).get(ruleConfig);
         Map<String, DataSource> dataSourceMap = new HashMap<>(1, 1);
         dataSourceMap.put("primaryDataSourceName", mock(DataSource.class));
-        assertThat(builder.build("test_schema", dataSourceMap, 
mock(DatabaseType.class), ruleConfig), instanceOf(DatabaseDiscoveryRule.class));
+        assertThat(builder.build("test_schema", dataSourceMap, 
mock(DatabaseType.class), ruleConfig, Collections.emptyList(), 
Collections.emptyList()), instanceOf(DatabaseDiscoveryRule.class));
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/rule/builder/AlgorithmProvidedEncryptRuleBuilder.java
 
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/rule/builder/AlgorithmProvidedEncryptRuleBuilder.java
index 8514509..dbeab80 100644
--- 
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/rule/builder/AlgorithmProvidedEncryptRuleBuilder.java
+++ 
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/rule/builder/AlgorithmProvidedEncryptRuleBuilder.java
@@ -21,9 +21,12 @@ import 
org.apache.shardingsphere.encrypt.algorithm.config.AlgorithmProvidedEncry
 import org.apache.shardingsphere.encrypt.constant.EncryptOrder;
 import org.apache.shardingsphere.encrypt.rule.EncryptRule;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.builder.ShardingSphereRuleBuilder;
 
 import javax.sql.DataSource;
+import java.util.Collection;
 import java.util.Map;
 
 /**
@@ -32,8 +35,8 @@ import java.util.Map;
 public final class AlgorithmProvidedEncryptRuleBuilder implements 
ShardingSphereRuleBuilder<EncryptRule, 
AlgorithmProvidedEncryptRuleConfiguration> {
     
     @Override
-    public EncryptRule build(final String schemaName,
-                             final Map<String, DataSource> dataSourceMap, 
final DatabaseType databaseType, final 
AlgorithmProvidedEncryptRuleConfiguration ruleConfig) {
+    public EncryptRule build(final String schemaName, final Map<String, 
DataSource> dataSourceMap, final DatabaseType databaseType, 
+                             final AlgorithmProvidedEncryptRuleConfiguration 
ruleConfig, final Collection<ShardingSphereUser> users, final 
Collection<ShardingSphereRule> builtRules) {
         return new EncryptRule(ruleConfig);
     }
     
diff --git 
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilder.java
 
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilder.java
index f63e6fa..31fbccd 100644
--- 
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilder.java
+++ 
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilder.java
@@ -21,9 +21,12 @@ import 
org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
 import org.apache.shardingsphere.encrypt.constant.EncryptOrder;
 import org.apache.shardingsphere.encrypt.rule.EncryptRule;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.builder.ShardingSphereRuleBuilder;
 
 import javax.sql.DataSource;
+import java.util.Collection;
 import java.util.Map;
 
 /**
@@ -32,7 +35,8 @@ import java.util.Map;
 public final class EncryptRuleBuilder implements 
ShardingSphereRuleBuilder<EncryptRule, EncryptRuleConfiguration> {
     
     @Override
-    public EncryptRule build(final String schemaName, final Map<String, 
DataSource> dataSourceMap, final DatabaseType databaseType, final 
EncryptRuleConfiguration ruleConfig) {
+    public EncryptRule build(final String schemaName, final Map<String, 
DataSource> dataSourceMap, final DatabaseType databaseType, 
+                             final EncryptRuleConfiguration ruleConfig, final 
Collection<ShardingSphereUser> users, final Collection<ShardingSphereRule> 
builtRules) {
         return new EncryptRule(ruleConfig);
     }
     
diff --git 
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/AlgorithmProvidedEncryptRuleBuilderTest.java
 
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/AlgorithmProvidedEncryptRuleBuilderTest.java
index 029d416..a899345 100644
--- 
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/AlgorithmProvidedEncryptRuleBuilderTest.java
+++ 
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/AlgorithmProvidedEncryptRuleBuilderTest.java
@@ -42,6 +42,6 @@ public final class AlgorithmProvidedEncryptRuleBuilderTest {
     public void assertBuild() {
         AlgorithmProvidedEncryptRuleConfiguration ruleConfig = 
mock(AlgorithmProvidedEncryptRuleConfiguration.class);
         ShardingSphereRuleBuilder builder = 
OrderedSPIRegistry.getRegisteredServices(Collections.singletonList(ruleConfig), 
ShardingSphereRuleBuilder.class).get(ruleConfig);
-        assertThat(builder.build("", Collections.emptyMap(), 
mock(DatabaseType.class), ruleConfig), instanceOf(EncryptRule.class));
+        assertThat(builder.build("", Collections.emptyMap(), 
mock(DatabaseType.class), ruleConfig, Collections.emptyList(), 
Collections.emptyList()), instanceOf(EncryptRule.class));
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilderTest.java
 
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilderTest.java
index d0c1d45..755623b 100644
--- 
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilderTest.java
+++ 
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/test/java/org/apache/shardingsphere/encrypt/rule/builder/EncryptRuleBuilderTest.java
@@ -42,6 +42,6 @@ public final class EncryptRuleBuilderTest {
     public void assertBuild() {
         EncryptRuleConfiguration ruleConfig = 
mock(EncryptRuleConfiguration.class);
         ShardingSphereRuleBuilder builder = 
OrderedSPIRegistry.getRegisteredServices(Collections.singletonList(ruleConfig), 
ShardingSphereRuleBuilder.class).get(ruleConfig);
-        assertThat(builder.build("", Collections.emptyMap(), 
mock(DatabaseType.class), ruleConfig), instanceOf(EncryptRule.class));
+        assertThat(builder.build("", Collections.emptyMap(), 
mock(DatabaseType.class), ruleConfig, Collections.emptyList(), 
Collections.emptyList()), instanceOf(EncryptRule.class));
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-rewrite/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameterized/EncryptSQLRewriterParameterizedTest.java
 
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-rewrite/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameterized/EncryptSQLRewriterParameterizedTest.java
index 70038a1..663271d 100644
--- 
a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-rewrite/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameterized/EncryptSQLRewriterParameterizedTest.java
+++ 
b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-rewrite/src/test/java/org/apache/shardingsphere/encrypt/rewrite/parameterized/EncryptSQLRewriterParameterizedTest.java
@@ -73,9 +73,9 @@ public final class EncryptSQLRewriterParameterizedTest 
extends AbstractSQLRewrit
     protected Collection<SQLRewriteUnit> createSQLRewriteUnits() throws 
IOException {
         YamlRootRuleConfigurations ruleConfigurations = 
createRuleConfigurations();
         String databaseType = null == getTestParameters().getDatabaseType() ? 
"MySQL" : getTestParameters().getDatabaseType();
-        Collection<ShardingSphereRule> rules = 
ShardingSphereRulesBuilder.build(new 
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(
+        Collection<ShardingSphereRule> rules = 
ShardingSphereRulesBuilder.build("schema_name", new 
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(
                 ruleConfigurations.getRules()), 
DatabaseTypeRegistry.getTrunkDatabaseType(databaseType),
-                new 
YamlDataSourceConfigurationSwapper().swapToDataSources(ruleConfigurations.getDataSources()),
 "schema_name");
+                new 
YamlDataSourceConfigurationSwapper().swapToDataSources(ruleConfigurations.getDataSources()),
 Collections.emptyList());
         SQLStatementParserEngine sqlStatementParserEngine = new 
SQLStatementParserEngine(databaseType);
         ShardingSphereSchema schema = mockSchema();
         ConfigurationProperties props = new 
ConfigurationProperties(ruleConfigurations.getProps());
diff --git 
a/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/AlgorithmProvidedReadWriteSplittingRuleBuilder.java
 
b/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/AlgorithmProvidedReadWriteSplittingRuleBuilder.java
index 7a8a54e..8c680ed 100644
--- 
a/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/AlgorithmProvidedReadWriteSplittingRuleBuilder.java
+++ 
b/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/AlgorithmProvidedReadWriteSplittingRuleBuilder.java
@@ -18,12 +18,15 @@
 package org.apache.shardingsphere.readwrite.splitting.common.rule.biulder;
 
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.builder.ShardingSphereRuleBuilder;
 import 
org.apache.shardingsphere.readwrite.splitting.common.algorithm.config.AlgorithmProvidedReadWriteSplittingRuleConfiguration;
 import 
org.apache.shardingsphere.readwrite.splitting.common.constant.ReadWriteSplittingOrder;
 import 
org.apache.shardingsphere.readwrite.splitting.common.rule.ReadWriteSplittingRule;
 
 import javax.sql.DataSource;
+import java.util.Collection;
 import java.util.Map;
 
 /**
@@ -32,8 +35,9 @@ import java.util.Map;
 public final class AlgorithmProvidedReadWriteSplittingRuleBuilder implements 
ShardingSphereRuleBuilder<ReadWriteSplittingRule, 
AlgorithmProvidedReadWriteSplittingRuleConfiguration> {
     
     @Override
-    public ReadWriteSplittingRule build(final String schemaName,
-                                        final Map<String, DataSource> 
dataSourceMap, final DatabaseType databaseType, final 
AlgorithmProvidedReadWriteSplittingRuleConfiguration ruleConfig) {
+    public ReadWriteSplittingRule build(final String schemaName, final 
Map<String, DataSource> dataSourceMap, final DatabaseType databaseType,
+                                        final 
AlgorithmProvidedReadWriteSplittingRuleConfiguration ruleConfig, 
+                                        final Collection<ShardingSphereUser> 
users, final Collection<ShardingSphereRule> builtRules) {
         return new ReadWriteSplittingRule(ruleConfig);
     }
     
diff --git 
a/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/ReadWriteSplittingRuleBuilder.java
 
b/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/ReadWriteSplittingRuleBuilder.java
index 1e7ccb9..1c7e78b 100644
--- 
a/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/ReadWriteSplittingRuleBuilder.java
+++ 
b/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/ReadWriteSplittingRuleBuilder.java
@@ -18,12 +18,15 @@
 package org.apache.shardingsphere.readwrite.splitting.common.rule.biulder;
 
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.builder.ShardingSphereRuleBuilder;
 import 
org.apache.shardingsphere.readwrite.splitting.api.ReadWriteSplittingRuleConfiguration;
 import 
org.apache.shardingsphere.readwrite.splitting.common.constant.ReadWriteSplittingOrder;
 import 
org.apache.shardingsphere.readwrite.splitting.common.rule.ReadWriteSplittingRule;
 
 import javax.sql.DataSource;
+import java.util.Collection;
 import java.util.Map;
 
 /**
@@ -32,8 +35,8 @@ import java.util.Map;
 public final class ReadWriteSplittingRuleBuilder implements 
ShardingSphereRuleBuilder<ReadWriteSplittingRule, 
ReadWriteSplittingRuleConfiguration> {
     
     @Override
-    public ReadWriteSplittingRule build(final String schemaName,
-                                        final Map<String, DataSource> 
dataSourceMap, final DatabaseType databaseType, final 
ReadWriteSplittingRuleConfiguration ruleConfig) {
+    public ReadWriteSplittingRule build(final String schemaName, final 
Map<String, DataSource> dataSourceMap, final DatabaseType databaseType, 
+                                        final 
ReadWriteSplittingRuleConfiguration ruleConfig, final 
Collection<ShardingSphereUser> users, final Collection<ShardingSphereRule> 
builtRules) {
         return new ReadWriteSplittingRule(ruleConfig);
     }
     
diff --git 
a/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/test/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/AlgorithmProvidedReadWriteSplittingRuleBuilderTest.java
 
b/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/test/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/AlgorithmProvidedReadWriteSplittingRuleBuilderTest.java
index aa906c9..41938bf 100644
--- 
a/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/test/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/AlgorithmProvidedReadWriteSplittingRuleBuilderTest.java
+++ 
b/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/test/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/AlgorithmProvidedReadWriteSplittingRuleBuilderTest.java
@@ -48,6 +48,7 @@ public final class 
AlgorithmProvidedReadWriteSplittingRuleBuilderTest {
         
when(algorithmProvidedRuleConfig.getDataSources()).thenReturn(Collections.singletonList(ruleConfig));
         ShardingSphereRuleBuilder builder = 
OrderedSPIRegistry.getRegisteredServices(
                 Collections.singletonList(algorithmProvidedRuleConfig), 
ShardingSphereRuleBuilder.class).get(algorithmProvidedRuleConfig);
-        assertThat(builder.build("", Collections.emptyMap(), 
mock(DatabaseType.class), algorithmProvidedRuleConfig), 
instanceOf(ReadWriteSplittingRule.class));
+        assertThat(builder.build("", Collections.emptyMap(), 
mock(DatabaseType.class), algorithmProvidedRuleConfig, Collections.emptyList(), 
Collections.emptyList()), 
+                instanceOf(ReadWriteSplittingRule.class));
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/test/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/ReadWriteSplittingRuleBuilderTest.java
 
b/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/test/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/ReadWriteSplittingRuleBuilderTest.java
index ab56cea..cb62063 100644
--- 
a/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/test/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/ReadWriteSplittingRuleBuilderTest.java
+++ 
b/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/test/java/org/apache/shardingsphere/readwrite/splitting/common/rule/biulder/ReadWriteSplittingRuleBuilderTest.java
@@ -47,6 +47,6 @@ public final class ReadWriteSplittingRuleBuilderTest {
                 "name", "pr_ds", "writeDataSourceName", 
Collections.singletonList("name"), "loadBalancerName");
         
when(ruleConfig.getDataSources()).thenReturn(Collections.singletonList(dataSourceRuleConfig));
         ShardingSphereRuleBuilder builder = 
OrderedSPIRegistry.getRegisteredServices(Collections.singletonList(ruleConfig), 
ShardingSphereRuleBuilder.class).get(ruleConfig);
-        assertThat(builder.build("", Collections.emptyMap(), 
mock(DatabaseType.class), ruleConfig), 
instanceOf(ReadWriteSplittingRule.class));
+        assertThat(builder.build("", Collections.emptyMap(), 
mock(DatabaseType.class), ruleConfig, Collections.emptyList(), 
Collections.emptyList()), instanceOf(ReadWriteSplittingRule.class));
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/main/java/org/apache/shardingsphere/shadow/rule/builder/ShadowRuleBuilder.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/main/java/org/apache/shardingsphere/shadow/rule/builder/ShadowRuleBuilder.java
index 9fe7d65..4791056 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/main/java/org/apache/shardingsphere/shadow/rule/builder/ShadowRuleBuilder.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/main/java/org/apache/shardingsphere/shadow/rule/builder/ShadowRuleBuilder.java
@@ -18,12 +18,15 @@
 package org.apache.shardingsphere.shadow.rule.builder;
 
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.builder.ShardingSphereRuleBuilder;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
 import org.apache.shardingsphere.shadow.constant.ShadowOrder;
 import org.apache.shardingsphere.shadow.rule.ShadowRule;
 
 import javax.sql.DataSource;
+import java.util.Collection;
 import java.util.Map;
 
 /**
@@ -32,8 +35,8 @@ import java.util.Map;
 public final class ShadowRuleBuilder implements 
ShardingSphereRuleBuilder<ShadowRule, ShadowRuleConfiguration> {
     
     @Override
-    public ShadowRule build(final String schemaName,
-                            final Map<String, DataSource> dataSourceMap, final 
DatabaseType databaseType, final ShadowRuleConfiguration ruleConfig) {
+    public ShadowRule build(final String schemaName, final Map<String, 
DataSource> dataSourceMap, final DatabaseType databaseType, 
+                            final ShadowRuleConfiguration ruleConfig, final 
Collection<ShardingSphereUser> users, final Collection<ShardingSphereRule> 
builtRules) {
         return new ShadowRule(ruleConfig);
     }
     
diff --git 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/test/java/org/apache/shardingsphere/shadow/rule/builder/ShadowRuleBuilderTest.java
 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/test/java/org/apache/shardingsphere/shadow/rule/builder/ShadowRuleBuilderTest.java
index da0c6de..1ce9702 100644
--- 
a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/test/java/org/apache/shardingsphere/shadow/rule/builder/ShadowRuleBuilderTest.java
+++ 
b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/test/java/org/apache/shardingsphere/shadow/rule/builder/ShadowRuleBuilderTest.java
@@ -42,6 +42,6 @@ public final class ShadowRuleBuilderTest {
     public void assertBuild() {
         ShadowRuleConfiguration ruleConfig = 
mock(ShadowRuleConfiguration.class);
         ShardingSphereRuleBuilder builder = 
OrderedSPIRegistry.getRegisteredServices(Collections.singletonList(ruleConfig), 
ShardingSphereRuleBuilder.class).get(ruleConfig);
-        assertThat(builder.build("", Collections.emptyMap(), 
mock(DatabaseType.class), ruleConfig), instanceOf(ShadowRule.class));
+        assertThat(builder.build("", Collections.emptyMap(), 
mock(DatabaseType.class), ruleConfig, Collections.emptyList(), 
Collections.emptyList()), instanceOf(ShadowRule.class));
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/builder/AlgorithmProvidedShardingRuleBuilder.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/builder/AlgorithmProvidedShardingRuleBuilder.java
index 313bfd0..068815d 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/builder/AlgorithmProvidedShardingRuleBuilder.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/builder/AlgorithmProvidedShardingRuleBuilder.java
@@ -18,12 +18,15 @@
 package org.apache.shardingsphere.sharding.rule.builder;
 
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.builder.ShardingSphereRuleBuilder;
 import 
org.apache.shardingsphere.sharding.algorithm.config.AlgorithmProvidedShardingRuleConfiguration;
 import org.apache.shardingsphere.sharding.constant.ShardingOrder;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 
 import javax.sql.DataSource;
+import java.util.Collection;
 import java.util.Map;
 
 /**
@@ -32,8 +35,8 @@ import java.util.Map;
 public final class AlgorithmProvidedShardingRuleBuilder implements 
ShardingSphereRuleBuilder<ShardingRule, 
AlgorithmProvidedShardingRuleConfiguration> {
     
     @Override
-    public ShardingRule build(final String schemaName,
-                              final Map<String, DataSource> dataSourceMap, 
final DatabaseType databaseType, final 
AlgorithmProvidedShardingRuleConfiguration ruleConfig) {
+    public ShardingRule build(final String schemaName, final Map<String, 
DataSource> dataSourceMap, final DatabaseType databaseType, 
+                              final AlgorithmProvidedShardingRuleConfiguration 
ruleConfig, final Collection<ShardingSphereUser> users, final 
Collection<ShardingSphereRule> builtRules) {
         return new ShardingRule(ruleConfig, databaseType, dataSourceMap);
     }
     
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/builder/ShardingRuleBuilder.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/builder/ShardingRuleBuilder.java
index e62d426..fe096d0 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/builder/ShardingRuleBuilder.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/builder/ShardingRuleBuilder.java
@@ -18,12 +18,15 @@
 package org.apache.shardingsphere.sharding.rule.builder;
 
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.builder.ShardingSphereRuleBuilder;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import org.apache.shardingsphere.sharding.constant.ShardingOrder;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 
 import javax.sql.DataSource;
+import java.util.Collection;
 import java.util.Map;
 
 /**
@@ -32,8 +35,8 @@ import java.util.Map;
 public final class ShardingRuleBuilder implements 
ShardingSphereRuleBuilder<ShardingRule, ShardingRuleConfiguration> {
     
     @Override
-    public ShardingRule build(final String schemaName,
-                              final Map<String, DataSource> dataSourceMap, 
final DatabaseType databaseType, final ShardingRuleConfiguration ruleConfig) {
+    public ShardingRule build(final String schemaName, final Map<String, 
DataSource> dataSourceMap, final DatabaseType databaseType, 
+                              final ShardingRuleConfiguration ruleConfig, 
final Collection<ShardingSphereUser> users, final 
Collection<ShardingSphereRule> builtRules) {
         return new ShardingRule(ruleConfig, databaseType, dataSourceMap);
     }
     
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/rule/builder/AlgorithmProvidedShardingRuleBuilderTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/rule/builder/AlgorithmProvidedShardingRuleBuilderTest.java
index b8c547b..3bb7b85 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/rule/builder/AlgorithmProvidedShardingRuleBuilderTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/rule/builder/AlgorithmProvidedShardingRuleBuilderTest.java
@@ -44,6 +44,8 @@ public final class AlgorithmProvidedShardingRuleBuilderTest {
     public void assertBuild() {
         AlgorithmProvidedShardingRuleConfiguration ruleConfig = 
mock(AlgorithmProvidedShardingRuleConfiguration.class);
         ShardingSphereRuleBuilder builder = 
OrderedSPIRegistry.getRegisteredServices(Collections.singletonList(ruleConfig), 
ShardingSphereRuleBuilder.class).get(ruleConfig);
-        assertThat(builder.build("test_schema", 
Collections.singletonMap("name", mock(DataSource.class, RETURNS_DEEP_STUBS)), 
mock(DatabaseType.class), ruleConfig), instanceOf(ShardingRule.class));
+        assertThat(builder.build("test_schema", 
+                Collections.singletonMap("name", mock(DataSource.class, 
RETURNS_DEEP_STUBS)), mock(DatabaseType.class), ruleConfig, 
Collections.emptyList(), Collections.emptyList()), 
+                instanceOf(ShardingRule.class));
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/rule/builder/ShardingRuleBuilderTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/rule/builder/ShardingRuleBuilderTest.java
index 2cdc801..cbdd48d 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/rule/builder/ShardingRuleBuilderTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/test/java/org/apache/shardingsphere/sharding/rule/builder/ShardingRuleBuilderTest.java
@@ -44,6 +44,8 @@ public final class ShardingRuleBuilderTest {
     public void assertBuild() {
         ShardingRuleConfiguration ruleConfig = 
mock(ShardingRuleConfiguration.class);
         ShardingSphereRuleBuilder builder = 
OrderedSPIRegistry.getRegisteredServices(Collections.singletonList(ruleConfig), 
ShardingSphereRuleBuilder.class).get(ruleConfig);
-        assertThat(builder.build("test_schema", 
Collections.singletonMap("name", mock(DataSource.class, RETURNS_DEEP_STUBS)), 
mock(DatabaseType.class), ruleConfig), instanceOf(ShardingRule.class));
+        assertThat(builder.build("test_schema", 
+                Collections.singletonMap("name", mock(DataSource.class, 
RETURNS_DEEP_STUBS)), mock(DatabaseType.class), ruleConfig, 
Collections.emptyList(), Collections.emptyList()), 
+                instanceOf(ShardingRule.class));
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/MixSQLRewriterParameterizedTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/MixSQLRewriterParameterizedTest.java
index 206c1e1..1478eb9 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/MixSQLRewriterParameterizedTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/MixSQLRewriterParameterizedTest.java
@@ -80,9 +80,9 @@ public final class MixSQLRewriterParameterizedTest extends 
AbstractSQLRewriterPa
     protected Collection<SQLRewriteUnit> createSQLRewriteUnits() throws 
IOException {
         YamlRootRuleConfigurations ruleConfigurations = 
createRuleConfigurations();
         String databaseType = null == getTestParameters().getDatabaseType() ? 
"MySQL" : getTestParameters().getDatabaseType();
-        Collection<ShardingSphereRule> rules = 
ShardingSphereRulesBuilder.build(new 
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(
+        Collection<ShardingSphereRule> rules = 
ShardingSphereRulesBuilder.build("schema_name", new 
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(
                 ruleConfigurations.getRules()), 
DatabaseTypeRegistry.getTrunkDatabaseType(databaseType),
-                new 
YamlDataSourceConfigurationSwapper().swapToDataSources(ruleConfigurations.getDataSources()),
 "schema_name");
+                new 
YamlDataSourceConfigurationSwapper().swapToDataSources(ruleConfigurations.getDataSources()),
 Collections.emptyList());
         SQLStatementParserEngine sqlStatementParserEngine = new 
SQLStatementParserEngine(databaseType);
         ShardingSphereSchema schema = mockSchema();
         ConfigurationProperties props = new 
ConfigurationProperties(ruleConfigurations.getProps());
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/ShardingSQLRewriterParameterizedTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/ShardingSQLRewriterParameterizedTest.java
index e071233..efad92c 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/ShardingSQLRewriterParameterizedTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/ShardingSQLRewriterParameterizedTest.java
@@ -80,9 +80,9 @@ public final class ShardingSQLRewriterParameterizedTest 
extends AbstractSQLRewri
     protected Collection<SQLRewriteUnit> createSQLRewriteUnits() throws 
IOException {
         YamlRootRuleConfigurations yamlRootRuleConfigs = 
createYamlRootRuleConfigurations();
         String databaseType = null == getTestParameters().getDatabaseType() ? 
"SQL92" : getTestParameters().getDatabaseType();
-        Collection<ShardingSphereRule> rules = 
ShardingSphereRulesBuilder.build(new 
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(
+        Collection<ShardingSphereRule> rules = 
ShardingSphereRulesBuilder.build("schema_name", new 
YamlRuleConfigurationSwapperEngine().swapToRuleConfigurations(
                 yamlRootRuleConfigs.getRules()), 
DatabaseTypeRegistry.getTrunkDatabaseType(databaseType),
-                new 
YamlDataSourceConfigurationSwapper().swapToDataSources(yamlRootRuleConfigs.getDataSources()),
 "schema_name");
+                new 
YamlDataSourceConfigurationSwapper().swapToDataSources(yamlRootRuleConfigs.getDataSources()),
 Collections.emptyList());
         SQLStatementParserEngine sqlStatementParserEngine = new 
SQLStatementParserEngine(databaseType);
         ShardingSphereSchema schema = mockSchema();
         ConfigurationProperties props = new 
ConfigurationProperties(yamlRootRuleConfigs.getProps());
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/ShardingSphereRuleBuilder.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/ShardingSphereRuleBuilder.java
index 8b33b9d..9f362ab 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/ShardingSphereRuleBuilder.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/ShardingSphereRuleBuilder.java
@@ -19,10 +19,12 @@ package org.apache.shardingsphere.infra.rule.builder;
 
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.spi.ordered.OrderedSPI;
 
 import javax.sql.DataSource;
+import java.util.Collection;
 import java.util.Map;
 
 /**
@@ -40,7 +42,9 @@ public interface ShardingSphereRuleBuilder<R extends 
ShardingSphereRule, T exten
      * @param dataSourceMap dataSource map
      * @param databaseType database type
      * @param ruleConfig rule configuration
+     * @param users users
+     * @param builtRules built rules
      * @return ShardingSphere rule
      */
-    R build(String schemaName, Map<String, DataSource> dataSourceMap, 
DatabaseType databaseType, T ruleConfig);
+    R build(String schemaName, Map<String, DataSource> dataSourceMap, 
DatabaseType databaseType, T ruleConfig, Collection<ShardingSphereUser> users, 
Collection<ShardingSphereRule> builtRules);
 }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/ShardingSphereRulesBuilder.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/ShardingSphereRulesBuilder.java
index 10a6859..113c4da 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/ShardingSphereRulesBuilder.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/ShardingSphereRulesBuilder.java
@@ -21,14 +21,16 @@ import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.infra.config.RuleConfiguration;
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.infra.spi.ordered.OrderedSPIRegistry;
 
 import javax.sql.DataSource;
 import java.util.Collection;
+import java.util.LinkedList;
 import java.util.Map;
-import java.util.stream.Collectors;
+import java.util.Map.Entry;
 
 /**
  * ShardingSphere rule builder.
@@ -43,16 +45,21 @@ public final class ShardingSphereRulesBuilder {
     /**
      * Build rules.
      *
+     * @param schemaName schema name
      * @param ruleConfigurations rule configurations
      * @param databaseType database type
      * @param dataSourceMap data source map
-     * @param schemaName schema name
-     * @return rules
+     * @param users users
+     * @return built rules
      */
     @SuppressWarnings({"unchecked", "rawtypes"})
-    public static Collection<ShardingSphereRule> build(final 
Collection<RuleConfiguration> ruleConfigurations, final DatabaseType 
databaseType,
-                                                       final Map<String, 
DataSource> dataSourceMap, final String schemaName) {
+    public static Collection<ShardingSphereRule> build(final String 
schemaName, final Collection<RuleConfiguration> ruleConfigurations, 
+                                                       final DatabaseType 
databaseType, final Map<String, DataSource> dataSourceMap, final 
Collection<ShardingSphereUser> users) {
         Map<RuleConfiguration, ShardingSphereRuleBuilder> builders = 
OrderedSPIRegistry.getRegisteredServices(ruleConfigurations, 
ShardingSphereRuleBuilder.class);
-        return builders.entrySet().stream().map(entry -> 
entry.getValue().build(schemaName, dataSourceMap, databaseType, 
entry.getKey())).collect(Collectors.toList());
+        Collection<ShardingSphereRule> result = new LinkedList<>();
+        for (Entry<RuleConfiguration, ShardingSphereRuleBuilder> entry : 
builders.entrySet()) {
+            result.add(entry.getValue().build(schemaName, dataSourceMap, 
databaseType, entry.getKey(), users, result));
+        }
+        return result;
     }
 }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/ShardingSphereRulesBuilderTest.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/ShardingSphereRulesBuilderTest.java
index 12a5723..c355b90 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/ShardingSphereRulesBuilderTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/ShardingSphereRulesBuilderTest.java
@@ -36,7 +36,8 @@ public final class ShardingSphereRulesBuilderTest {
     @Test
     public void assertBuild() {
         RuleConfiguration ruleConfig = new TestRuleConfiguration();
-        Collection<ShardingSphereRule> shardingSphereRules = 
ShardingSphereRulesBuilder.build(Collections.singletonList(ruleConfig), 
mock(DatabaseType.class), Collections.emptyMap(), "schema_name");
-        assertThat(shardingSphereRules, 
is(Collections.singletonList(TestShardingSphereRuleBuilder.getRule())));
+        Collection<ShardingSphereRule> shardingSphereRules = 
ShardingSphereRulesBuilder.build(
+                "schema_name", Collections.singletonList(ruleConfig), 
mock(DatabaseType.class), Collections.emptyMap(), Collections.emptyList());
+        assertThat(shardingSphereRules, 
is(Collections.singletonList(TestShardingSphereRuleBuilder.getRULE())));
     }
 }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/TestShardingSphereRuleBuilder.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/TestShardingSphereRuleBuilder.java
index c0fda21..f7bfdf9 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/TestShardingSphereRuleBuilder.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/rule/fixture/TestShardingSphereRuleBuilder.java
@@ -23,16 +23,18 @@ import 
org.apache.shardingsphere.infra.database.type.DatabaseType;
 import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.builder.ShardingSphereRuleBuilder;
 
+import java.util.Collection;
 import java.util.Map;
 
 public final class TestShardingSphereRuleBuilder implements 
ShardingSphereRuleBuilder {
     
     @Getter
-    private static ShardingSphereRule rule = new TestShardingSphereRule();
+    private static final ShardingSphereRule RULE = new 
TestShardingSphereRule();
     
     @Override
-    public ShardingSphereRule build(final String schemaName, final Map 
dataSourceMap, final DatabaseType databaseType, final RuleConfiguration 
ruleConfig) {
-        return rule;
+    public ShardingSphereRule build(final String schemaName, final Map 
dataSourceMap,
+                                    final DatabaseType databaseType, final 
RuleConfiguration ruleConfig, final Collection users, final Collection 
builtRules) {
+        return RULE;
     }
     
     @Override
diff --git 
a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilder.java
 
b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilder.java
index 24f9db2..5159b7d 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilder.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/metadata/MetaDataContextsBuilder.java
@@ -103,7 +103,7 @@ public final class MetaDataContextsBuilder {
         Map<String, DataSource> dataSourceMap = dataSources.get(schemaName);
         Collection<RuleConfiguration> ruleConfigs = 
this.ruleConfigs.get(schemaName);
         DatabaseType databaseType = getDatabaseType(dataSourceMap);
-        Collection<ShardingSphereRule> rules = 
ShardingSphereRulesBuilder.build(ruleConfigs, databaseType, dataSourceMap, 
schemaName);
+        Collection<ShardingSphereRule> rules = 
ShardingSphereRulesBuilder.build(schemaName, ruleConfigs, databaseType, 
dataSourceMap, users);
         ShardingSphereRuleMetaData ruleMetaData = new 
ShardingSphereRuleMetaData(ruleConfigs, rules);
         return new ShardingSphereMetaData(schemaName, 
buildResource(databaseType, dataSourceMap), ruleMetaData, 
buildSchema(databaseType, dataSourceMap, rules));
     }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java
 
b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java
index 80e8f7e..9eae20c5 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java
@@ -18,16 +18,19 @@
 package org.apache.shardingsphere.infra.context.fixture;
 
 import org.apache.shardingsphere.infra.database.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.metadata.auth.model.user.ShardingSphereUser;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
 import org.apache.shardingsphere.infra.rule.builder.ShardingSphereRuleBuilder;
 
 import javax.sql.DataSource;
+import java.util.Collection;
 import java.util.Map;
 
 public final class FixtureRuleBuilder implements 
ShardingSphereRuleBuilder<FixtureRule, FixtureRuleConfiguration> {
     
     @Override
-    public FixtureRule build(final String schemaName,
-                             final Map<String, DataSource> dataSourceMap, 
final DatabaseType databaseType, final FixtureRuleConfiguration ruleConfig) {
+    public FixtureRule build(final String schemaName, final Map<String, 
DataSource> dataSourceMap, final DatabaseType databaseType, 
+                             final FixtureRuleConfiguration ruleConfig, final 
Collection<ShardingSphereUser> users, final Collection<ShardingSphereRule> 
builtRules) {
         return new FixtureRule();
     }
     

Reply via email to