You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2021/04/19 02:17:08 UTC
[shardingsphere] branch master updated: Add KernelRule and
FeatureRule interface and make KernelRule has default configuration
(#10122)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 28d8ba1 Add KernelRule and FeatureRule interface and make KernelRule has default configuration (#10122)
28d8ba1 is described below
commit 28d8ba1031a61d84151ac1799311d6fb96851875
Author: Liang Zhang <te...@163.com>
AuthorDate: Mon Apr 19 10:16:26 2021 +0800
Add KernelRule and FeatureRule interface and make KernelRule has default configuration (#10122)
* Add KernelRule and FeatureRule
* Add DefaultKernelRuleConfigurationBuilder
* ignore load auth
---
.../authority/rule/AuthorityRule.java | 3 +-
.../rule/builder/AuthorityRuleBuilder.java | 5 +--
... DefaultAuthorityRuleConfigurationBuilder.java} | 21 +++++------
...der.level.DefaultKernelRuleConfigurationBuilder | 2 +-
...ere.infra.rule.builder.scope.GlobalRuleBuilder} | 0
.../common/rule/DatabaseDiscoveryRule.java | 3 +-
...orithmProvidedDatabaseDiscoveryRuleBuilder.java | 5 +--
.../rule/biulder/DatabaseDiscoveryRuleBuilder.java | 6 ++--
...ere.infra.rule.builder.scope.SchemaRuleBuilder} | 0
...hmProvidedDatabaseDiscoveryRuleBuilderTest.java | 2 +-
.../biulder/DatabaseDiscoveryRuleBuilderTest.java | 2 +-
.../shardingsphere/encrypt/rule/EncryptRule.java | 3 +-
.../AlgorithmProvidedEncryptRuleBuilder.java | 5 +--
.../encrypt/rule/builder/EncryptRuleBuilder.java | 5 +--
...ere.infra.rule.builder.scope.SchemaRuleBuilder} | 0
.../AlgorithmProvidedEncryptRuleBuilderTest.java | 2 +-
.../rule/builder/EncryptRuleBuilderTest.java | 2 +-
.../common/rule/ReadWriteSplittingRule.java | 3 +-
...rithmProvidedReadWriteSplittingRuleBuilder.java | 5 +--
.../biulder/ReadWriteSplittingRuleBuilder.java | 5 +--
...ere.infra.rule.builder.scope.SchemaRuleBuilder} | 0
...mProvidedReadWriteSplittingRuleBuilderTest.java | 2 +-
.../biulder/ReadWriteSplittingRuleBuilderTest.java | 2 +-
.../shardingsphere/shadow/rule/ShadowRule.java | 3 +-
.../shadow/rule/builder/ShadowRuleBuilder.java | 5 +--
...ere.infra.rule.builder.scope.SchemaRuleBuilder} | 0
.../shadow/rule/builder/ShadowRuleBuilderTest.java | 2 +-
.../shardingsphere/sharding/rule/ShardingRule.java | 3 +-
.../AlgorithmProvidedShardingRuleBuilder.java | 5 +--
.../sharding/rule/builder/ShardingRuleBuilder.java | 5 +--
...ere.infra.rule.builder.scope.SchemaRuleBuilder} | 0
.../AlgorithmProvidedShardingRuleBuilderTest.java | 2 +-
.../rule/builder/ShardingRuleBuilderTest.java | 2 +-
.../rule/builder/ShardingSphereRulesBuilder.java | 41 ++++++++++++++++++++++
.../DefaultKernelRuleConfigurationBuilder.java} | 24 +++++--------
.../rule/builder/level/FeatureRuleBuilder.java} | 28 +++------------
.../rule/builder/level/KernelRuleBuilder.java} | 28 +++------------
.../builder/{ => scope}/GlobalRuleBuilder.java | 5 ++-
.../RuleBuilder.java} | 24 ++-----------
.../builder/{ => scope}/SchemaRuleBuilder.java | 5 ++-
.../infra/rule/level/FeatureRule.java} | 28 ++++-----------
.../infra/rule/level/KernelRule.java} | 28 ++++-----------
.../fixture/TestShardingSphereRuleBuilder.java | 2 +-
...ere.infra.rule.builder.scope.SchemaRuleBuilder} | 0
.../infra/context/fixture/FixtureRuleBuilder.java | 2 +-
...ere.infra.rule.builder.scope.SchemaRuleBuilder} | 0
46 files changed, 141 insertions(+), 184 deletions(-)
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 b6e0901..84f3efc 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,6 +24,7 @@ import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmF
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.user.Grantee;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
+import org.apache.shardingsphere.infra.rule.level.KernelRule;
import org.apache.shardingsphere.infra.rule.scope.GlobalRule;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
@@ -34,7 +35,7 @@ import java.util.Optional;
/**
* Authority rule.
*/
-public final class AuthorityRule implements GlobalRule {
+public final class AuthorityRule implements KernelRule, GlobalRule {
static {
ShardingSphereServiceLoader.register(AuthorityProvideAlgorithm.class);
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 9a48265..2c19a8f 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
@@ -22,7 +22,8 @@ import org.apache.shardingsphere.authority.constant.AuthorityOrder;
import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
-import org.apache.shardingsphere.infra.rule.builder.GlobalRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.level.KernelRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.GlobalRuleBuilder;
import java.util.Collection;
import java.util.Map;
@@ -30,7 +31,7 @@ import java.util.Map;
/**
* Authority rule builder.
*/
-public final class AuthorityRuleBuilder implements GlobalRuleBuilder<AuthorityRule, AuthorityRuleConfiguration> {
+public final class AuthorityRuleBuilder implements KernelRuleBuilder, GlobalRuleBuilder<AuthorityRule, AuthorityRuleConfiguration> {
@Override
public AuthorityRule build(final AuthorityRuleConfiguration ruleConfig, final Map<String, ShardingSphereMetaData> mataDataMap, final Collection<ShardingSphereUser> users) {
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/DefaultAuthorityRuleConfigurationBuilder.java
similarity index 58%
copy from shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/AuthorityRuleBuilder.java
copy to shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/java/org/apache/shardingsphere/authority/rule/builder/DefaultAuthorityRuleConfigurationBuilder.java
index 9a48265..3e4d1d5 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/DefaultAuthorityRuleConfigurationBuilder.java
@@ -19,22 +19,19 @@ package org.apache.shardingsphere.authority.rule.builder;
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.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
-import org.apache.shardingsphere.infra.rule.builder.GlobalRuleBuilder;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.rule.builder.level.DefaultKernelRuleConfigurationBuilder;
-import java.util.Collection;
-import java.util.Map;
+import java.util.Properties;
/**
- * Authority rule builder.
+ * Default authority rule configuration builder.
*/
-public final class AuthorityRuleBuilder implements GlobalRuleBuilder<AuthorityRule, AuthorityRuleConfiguration> {
+public final class DefaultAuthorityRuleConfigurationBuilder implements DefaultKernelRuleConfigurationBuilder<AuthorityRuleConfiguration, AuthorityRuleBuilder> {
@Override
- public AuthorityRule build(final AuthorityRuleConfiguration ruleConfig, final Map<String, ShardingSphereMetaData> mataDataMap, final Collection<ShardingSphereUser> users) {
- return new AuthorityRule(ruleConfig, mataDataMap, users);
+ public AuthorityRuleConfiguration build() {
+ return new AuthorityRuleConfiguration(new ShardingSphereAlgorithmConfiguration("NATIVE", new Properties()));
}
@Override
@@ -43,7 +40,7 @@ public final class AuthorityRuleBuilder implements GlobalRuleBuilder<AuthorityRu
}
@Override
- public Class<AuthorityRuleConfiguration> getTypeClass() {
- return AuthorityRuleConfiguration.class;
+ public Class<AuthorityRuleBuilder> getTypeClass() {
+ return AuthorityRuleBuilder.class;
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.level.DefaultKernelRuleConfigurationBuilder
similarity index 89%
copy from shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder
copy to shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.level.DefaultKernelRuleConfigurationBuilder
index c067124..e46d73f 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder
+++ b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.level.DefaultKernelRuleConfigurationBuilder
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.infra.rule.fixture.TestShardingSphereRuleBuilder
+#org.apache.shardingsphere.authority.rule.builder.DefaultAuthorityRuleConfigurationBuilder
diff --git a/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.GlobalRuleBuilder b/shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.GlobalRuleBuilder
similarity index 100%
rename from shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.GlobalRuleBuilder
rename to shardingsphere-features/shardingsphere-authority/shardingsphere-authority-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.GlobalRuleBuilder
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/db/discovery/common/rule/DatabaseDiscoveryRule.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/db/discovery/common/rule/DatabaseDiscoveryRule.java
index 8e6ea48..1267ad4 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/db/discovery/common/rule/DatabaseDiscoveryRule.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/java/org/apache/shardingsphere/db/discovery/common/rule/DatabaseDiscoveryRule.java
@@ -32,6 +32,7 @@ import org.apache.shardingsphere.infra.exception.ShardingSphereException;
import org.apache.shardingsphere.infra.rule.event.RuleChangedEvent;
import org.apache.shardingsphere.infra.rule.event.impl.DataSourceNameDisabledEvent;
import org.apache.shardingsphere.infra.rule.event.impl.PrimaryDataSourceEvent;
+import org.apache.shardingsphere.infra.rule.level.FeatureRule;
import org.apache.shardingsphere.infra.rule.scope.SchemaRule;
import org.apache.shardingsphere.infra.rule.type.DataSourceContainedRule;
import org.apache.shardingsphere.infra.rule.type.StatusContainedRule;
@@ -50,7 +51,7 @@ import java.util.Optional;
/**
* Database discovery rule.
*/
-public final class DatabaseDiscoveryRule implements SchemaRule, DataSourceContainedRule, StatusContainedRule {
+public final class DatabaseDiscoveryRule implements FeatureRule, SchemaRule, DataSourceContainedRule, StatusContainedRule {
static {
ShardingSphereServiceLoader.register(DatabaseDiscoveryType.class);
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 0498962..5bba173 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,7 +21,8 @@ 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.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.level.FeatureRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import javax.sql.DataSource;
import java.util.Map;
@@ -29,7 +30,7 @@ import java.util.Map;
/**
* Algorithm provided data base discovery rule builder.
*/
-public final class AlgorithmProvidedDatabaseDiscoveryRuleBuilder implements SchemaRuleBuilder<DatabaseDiscoveryRule, AlgorithmProvidedDatabaseDiscoveryRuleConfiguration> {
+public final class AlgorithmProvidedDatabaseDiscoveryRuleBuilder implements FeatureRuleBuilder, SchemaRuleBuilder<DatabaseDiscoveryRule, AlgorithmProvidedDatabaseDiscoveryRuleConfiguration> {
@Override
public DatabaseDiscoveryRule build(final String schemaName, final Map<String, DataSource> dataSourceMap, final DatabaseType databaseType,
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 18ad7cc..66ef278 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,7 +22,8 @@ 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.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.level.FeatureRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import javax.sql.DataSource;
import java.util.HashMap;
@@ -31,7 +32,7 @@ import java.util.Map;
/**
* Database discovery rule builder.
*/
-public final class DatabaseDiscoveryRuleBuilder implements SchemaRuleBuilder<DatabaseDiscoveryRule, DatabaseDiscoveryRuleConfiguration> {
+public final class DatabaseDiscoveryRuleBuilder implements FeatureRuleBuilder, SchemaRuleBuilder<DatabaseDiscoveryRule, DatabaseDiscoveryRuleConfiguration> {
@Override
public DatabaseDiscoveryRule build(final String schemaName, final Map<String, DataSource> dataSourceMap, final DatabaseType databaseType, final DatabaseDiscoveryRuleConfiguration ruleConfig) {
@@ -53,5 +54,4 @@ public final class DatabaseDiscoveryRuleBuilder implements SchemaRuleBuilder<Dat
public Class<DatabaseDiscoveryRuleConfiguration> getTypeClass() {
return DatabaseDiscoveryRuleConfiguration.class;
}
-
}
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder
similarity index 100%
rename from shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder
rename to shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder
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 8bfd27e..d7d1a7f 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
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.db.discovery.common.rule.biulder;
import org.apache.shardingsphere.db.discovery.common.rule.DatabaseDiscoveryRule;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.ordered.OrderedSPIRegistry;
import org.apache.shardingsphere.db.discovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
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 3b21d28..381104c 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
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.db.discovery.api.config.DatabaseDiscoveryRuleCo
import org.apache.shardingsphere.db.discovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
import org.apache.shardingsphere.db.discovery.common.rule.DatabaseDiscoveryRule;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.ordered.OrderedSPIRegistry;
import org.junit.Test;
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
index ba75f9f..a402159 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/java/org/apache/shardingsphere/encrypt/rule/EncryptRule.java
@@ -26,6 +26,7 @@ import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfigu
import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
import org.apache.shardingsphere.encrypt.spi.QueryAssistedEncryptAlgorithm;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmFactory;
+import org.apache.shardingsphere.infra.rule.level.FeatureRule;
import org.apache.shardingsphere.infra.rule.scope.SchemaRule;
import org.apache.shardingsphere.infra.rule.type.TableContainedRule;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
@@ -41,7 +42,7 @@ import java.util.stream.Collectors;
/**
* Encrypt rule.
*/
-public final class EncryptRule implements SchemaRule, TableContainedRule {
+public final class EncryptRule implements FeatureRule, SchemaRule, TableContainedRule {
static {
ShardingSphereServiceLoader.register(EncryptAlgorithm.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 df12a89..306dde0 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,7 +21,8 @@ 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.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.level.FeatureRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import javax.sql.DataSource;
import java.util.Map;
@@ -29,7 +30,7 @@ import java.util.Map;
/**
* Algorithm provided encrypt rule builder.
*/
-public final class AlgorithmProvidedEncryptRuleBuilder implements SchemaRuleBuilder<EncryptRule, AlgorithmProvidedEncryptRuleConfiguration> {
+public final class AlgorithmProvidedEncryptRuleBuilder implements FeatureRuleBuilder, SchemaRuleBuilder<EncryptRule, AlgorithmProvidedEncryptRuleConfiguration> {
@Override
public EncryptRule build(final String schemaName, final Map<String, DataSource> dataSourceMap, final DatabaseType databaseType, final AlgorithmProvidedEncryptRuleConfiguration 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 7bb767c..da39276 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,7 +21,8 @@ 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.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.level.FeatureRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import javax.sql.DataSource;
import java.util.Map;
@@ -29,7 +30,7 @@ import java.util.Map;
/**
* Encrypt rule builder.
*/
-public final class EncryptRuleBuilder implements SchemaRuleBuilder<EncryptRule, EncryptRuleConfiguration> {
+public final class EncryptRuleBuilder implements FeatureRuleBuilder, SchemaRuleBuilder<EncryptRule, EncryptRuleConfiguration> {
@Override
public EncryptRule build(final String schemaName, final Map<String, DataSource> dataSourceMap, final DatabaseType databaseType, final EncryptRuleConfiguration ruleConfig) {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder
similarity index 100%
rename from shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder
rename to shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder
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 2fa4347..441a426 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
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.encrypt.rule.builder;
import org.apache.shardingsphere.encrypt.algorithm.config.AlgorithmProvidedEncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.ordered.OrderedSPIRegistry;
import org.junit.Test;
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 c7fe815..eff43e6 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
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.encrypt.rule.builder;
import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.rule.EncryptRule;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.ordered.OrderedSPIRegistry;
import org.junit.Test;
diff --git a/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/java/org/apache/shardingsphere/readwrite/splitting/common/rule/ReadWriteSplittingRule.java b/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/java/org/apache/shardingsphere/readwrite/splitting/common/rule/ReadWriteSplittingRule.java
index 92369f7..7df4a34 100644
--- a/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/java/org/apache/shardingsphere/readwrite/splitting/common/rule/ReadWriteSplittingRule.java
+++ b/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/java/org/apache/shardingsphere/readwrite/splitting/common/rule/ReadWriteSplittingRule.java
@@ -22,6 +22,7 @@ import com.google.common.base.Strings;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmFactory;
import org.apache.shardingsphere.infra.rule.event.RuleChangedEvent;
import org.apache.shardingsphere.infra.rule.event.impl.DataSourceNameDisabledEvent;
+import org.apache.shardingsphere.infra.rule.level.FeatureRule;
import org.apache.shardingsphere.infra.rule.scope.SchemaRule;
import org.apache.shardingsphere.infra.rule.type.DataSourceContainedRule;
import org.apache.shardingsphere.infra.rule.type.StatusContainedRule;
@@ -42,7 +43,7 @@ import java.util.Optional;
/**
* Read write splitting rule.
*/
-public final class ReadWriteSplittingRule implements SchemaRule, DataSourceContainedRule, StatusContainedRule {
+public final class ReadWriteSplittingRule implements FeatureRule, SchemaRule, DataSourceContainedRule, StatusContainedRule {
static {
ShardingSphereServiceLoader.register(ReplicaLoadBalanceAlgorithm.class);
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 e5877a6..3fb6d7f 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,7 +18,8 @@
package org.apache.shardingsphere.readwrite.splitting.common.rule.biulder;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.level.FeatureRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
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;
@@ -29,7 +30,7 @@ import java.util.Map;
/**
* Algorithm provided read write splitting rule builder.
*/
-public final class AlgorithmProvidedReadWriteSplittingRuleBuilder implements SchemaRuleBuilder<ReadWriteSplittingRule, AlgorithmProvidedReadWriteSplittingRuleConfiguration> {
+public final class AlgorithmProvidedReadWriteSplittingRuleBuilder implements FeatureRuleBuilder, SchemaRuleBuilder<ReadWriteSplittingRule, AlgorithmProvidedReadWriteSplittingRuleConfiguration> {
@Override
public ReadWriteSplittingRule build(final String schemaName, final Map<String, DataSource> dataSourceMap, final DatabaseType databaseType,
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 1e704e7..533f339 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,7 +18,8 @@
package org.apache.shardingsphere.readwrite.splitting.common.rule.biulder;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.level.FeatureRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
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;
@@ -29,7 +30,7 @@ import java.util.Map;
/**
* Read write splitting rule builder.
*/
-public final class ReadWriteSplittingRuleBuilder implements SchemaRuleBuilder<ReadWriteSplittingRule, ReadWriteSplittingRuleConfiguration> {
+public final class ReadWriteSplittingRuleBuilder implements FeatureRuleBuilder, SchemaRuleBuilder<ReadWriteSplittingRule, ReadWriteSplittingRuleConfiguration> {
@Override
public ReadWriteSplittingRule build(final String schemaName, final Map<String, DataSource> dataSourceMap, final DatabaseType databaseType, final ReadWriteSplittingRuleConfiguration ruleConfig) {
diff --git a/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder b/shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder
similarity index 100%
rename from shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder
rename to shardingsphere-features/shardingsphere-read-write-splitting/shardingsphere-read-write-splitting-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder
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 c2f921d..f7a5d9c 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
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.readwrite.splitting.common.rule.biulder;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.ordered.OrderedSPIRegistry;
import org.apache.shardingsphere.readwrite.splitting.api.rule.ReadWriteSplittingDataSourceRuleConfiguration;
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 533890e..b36c281 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
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.readwrite.splitting.common.rule.biulder;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.ordered.OrderedSPIRegistry;
import org.apache.shardingsphere.readwrite.splitting.api.ReadWriteSplittingRuleConfiguration;
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java
index 8a1dcbe..f955ace 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/main/java/org/apache/shardingsphere/shadow/rule/ShadowRule.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.shadow.rule;
import lombok.Getter;
+import org.apache.shardingsphere.infra.rule.level.FeatureRule;
import org.apache.shardingsphere.infra.rule.scope.SchemaRule;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
@@ -28,7 +29,7 @@ import java.util.Map;
* Databases shadow rule.
*/
@Getter
-public final class ShadowRule implements SchemaRule {
+public final class ShadowRule implements FeatureRule, SchemaRule {
private final Map<String, String> shadowMappings;
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 9e18d42..d4e73cc 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,7 +18,8 @@
package org.apache.shardingsphere.shadow.rule.builder;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.level.FeatureRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
import org.apache.shardingsphere.shadow.constant.ShadowOrder;
import org.apache.shardingsphere.shadow.rule.ShadowRule;
@@ -29,7 +30,7 @@ import java.util.Map;
/**
* Shadow rule builder.
*/
-public final class ShadowRuleBuilder implements SchemaRuleBuilder<ShadowRule, ShadowRuleConfiguration> {
+public final class ShadowRuleBuilder implements FeatureRuleBuilder, SchemaRuleBuilder<ShadowRule, ShadowRuleConfiguration> {
@Override
public ShadowRule build(final String schemaName, final Map<String, DataSource> dataSourceMap, final DatabaseType databaseType, final ShadowRuleConfiguration ruleConfig) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder
similarity index 100%
rename from shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder
rename to shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder
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 0ba34b4..05dd692 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
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.shadow.rule.builder;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.ordered.OrderedSPIRegistry;
import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
index dd86458..3a5414a 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/java/org/apache/shardingsphere/sharding/rule/ShardingRule.java
@@ -29,6 +29,7 @@ import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.eventbus.ShardingSphereEventBus;
import org.apache.shardingsphere.infra.metadata.schema.refresher.event.CreateTableEvent;
import org.apache.shardingsphere.infra.metadata.schema.refresher.event.DropTableEvent;
+import org.apache.shardingsphere.infra.rule.level.FeatureRule;
import org.apache.shardingsphere.infra.rule.scope.SchemaRule;
import org.apache.shardingsphere.infra.rule.type.DataNodeContainedRule;
import org.apache.shardingsphere.infra.rule.type.TableContainedRule;
@@ -67,7 +68,7 @@ import java.util.stream.Collectors;
* Sharding rule.
*/
@Getter
-public final class ShardingRule implements SchemaRule, DataNodeContainedRule, TableContainedRule {
+public final class ShardingRule implements FeatureRule, SchemaRule, DataNodeContainedRule, TableContainedRule {
static {
ShardingSphereServiceLoader.register(ShardingAlgorithm.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 b005717..0775bda 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,7 +18,8 @@
package org.apache.shardingsphere.sharding.rule.builder;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.level.FeatureRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import org.apache.shardingsphere.sharding.algorithm.config.AlgorithmProvidedShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.constant.ShardingOrder;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -29,7 +30,7 @@ import java.util.Map;
/**
* Algorithm provided sharding rule builder.
*/
-public final class AlgorithmProvidedShardingRuleBuilder implements SchemaRuleBuilder<ShardingRule, AlgorithmProvidedShardingRuleConfiguration> {
+public final class AlgorithmProvidedShardingRuleBuilder implements FeatureRuleBuilder, SchemaRuleBuilder<ShardingRule, AlgorithmProvidedShardingRuleConfiguration> {
@Override
public ShardingRule build(final String schemaName, final Map<String, DataSource> dataSourceMap, final DatabaseType databaseType, final AlgorithmProvidedShardingRuleConfiguration ruleConfig) {
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 ff3be23..2cf7743 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,7 +18,8 @@
package org.apache.shardingsphere.sharding.rule.builder;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.level.FeatureRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
import org.apache.shardingsphere.sharding.constant.ShardingOrder;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -29,7 +30,7 @@ import java.util.Map;
/**
* Sharding rule builder.
*/
-public final class ShardingRuleBuilder implements SchemaRuleBuilder<ShardingRule, ShardingRuleConfiguration> {
+public final class ShardingRuleBuilder implements FeatureRuleBuilder, SchemaRuleBuilder<ShardingRule, ShardingRuleConfiguration> {
@Override
public ShardingRule build(final String schemaName, final Map<String, DataSource> dataSourceMap, final DatabaseType databaseType, final ShardingRuleConfiguration ruleConfig) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder
similarity index 100%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder
rename to shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-common/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder
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 27d82f4..6cc1334 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
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.rule.builder;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.ordered.OrderedSPIRegistry;
import org.apache.shardingsphere.sharding.algorithm.config.AlgorithmProvidedShardingRuleConfiguration;
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 95fe704..735126d 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
@@ -18,7 +18,7 @@
package org.apache.shardingsphere.sharding.rule.builder;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.ordered.OrderedSPIRegistry;
import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
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 bead359..d6052dd 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
@@ -24,6 +24,10 @@ import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.apache.shardingsphere.infra.rule.builder.level.DefaultKernelRuleConfigurationBuilder;
+import org.apache.shardingsphere.infra.rule.builder.level.KernelRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.GlobalRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.spi.ordered.OrderedSPIRegistry;
@@ -43,6 +47,7 @@ public final class ShardingSphereRulesBuilder {
static {
ShardingSphereServiceLoader.register(SchemaRuleBuilder.class);
ShardingSphereServiceLoader.register(GlobalRuleBuilder.class);
+ ShardingSphereServiceLoader.register(DefaultKernelRuleConfigurationBuilder.class);
}
/**
@@ -58,9 +63,27 @@ public final class ShardingSphereRulesBuilder {
public static Collection<ShardingSphereRule> buildSchemaRules(final String schemaName, final Collection<RuleConfiguration> schemaRuleConfigurations,
final DatabaseType databaseType, final Map<String, DataSource> dataSourceMap) {
Map<RuleConfiguration, SchemaRuleBuilder> builders = OrderedSPIRegistry.getRegisteredServices(schemaRuleConfigurations, SchemaRuleBuilder.class);
+ appendDefaultKernelSchemaRuleConfigurationBuilder(builders);
return builders.entrySet().stream().map(entry -> entry.getValue().build(schemaName, dataSourceMap, databaseType, entry.getKey())).collect(Collectors.toList());
}
+ @SuppressWarnings("rawtypes")
+ private static void appendDefaultKernelSchemaRuleConfigurationBuilder(final Map<RuleConfiguration, SchemaRuleBuilder> builders) {
+ Map<SchemaRuleBuilder, DefaultKernelRuleConfigurationBuilder> defaultBuilders =
+ OrderedSPIRegistry.getRegisteredServices(getMissedKernelSchemaRuleBuilders(builders.values()), DefaultKernelRuleConfigurationBuilder.class);
+ // TODO consider about order for new put items
+ for (Entry<SchemaRuleBuilder, DefaultKernelRuleConfigurationBuilder> entry : defaultBuilders.entrySet()) {
+ builders.put(entry.getValue().build(), entry.getKey());
+ }
+ }
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ private static Collection<SchemaRuleBuilder> getMissedKernelSchemaRuleBuilders(final Collection<SchemaRuleBuilder> configuredBuilders) {
+ Collection<Class<SchemaRuleBuilder>> configuredBuilderClasses = configuredBuilders.stream().map(each -> (Class<SchemaRuleBuilder>) each.getClass()).collect(Collectors.toSet());
+ return OrderedSPIRegistry.getRegisteredServices(SchemaRuleBuilder.class).stream().filter(
+ each -> each instanceof KernelRuleBuilder && !configuredBuilderClasses.contains(each.getClass())).collect(Collectors.toList());
+ }
+
/**
* Build global rules.
*
@@ -73,10 +96,28 @@ public final class ShardingSphereRulesBuilder {
public static Collection<ShardingSphereRule> buildGlobalRules(final Collection<RuleConfiguration> globalRuleConfigurations,
final Map<String, ShardingSphereMetaData> mataDataMap, final Collection<ShardingSphereUser> users) {
Map<RuleConfiguration, GlobalRuleBuilder> builders = OrderedSPIRegistry.getRegisteredServices(globalRuleConfigurations, GlobalRuleBuilder.class);
+ appendDefaultKernelGlobalRuleConfigurationBuilder(builders);
Collection<ShardingSphereRule> result = new LinkedList<>();
for (Entry<RuleConfiguration, GlobalRuleBuilder> entry : builders.entrySet()) {
result.add(entry.getValue().build(entry.getKey(), mataDataMap, users));
}
return result;
}
+
+ @SuppressWarnings("rawtypes")
+ private static void appendDefaultKernelGlobalRuleConfigurationBuilder(final Map<RuleConfiguration, GlobalRuleBuilder> builders) {
+ Map<GlobalRuleBuilder, DefaultKernelRuleConfigurationBuilder> defaultBuilders =
+ OrderedSPIRegistry.getRegisteredServices(getMissedKernelGlobalRuleBuilders(builders.values()), DefaultKernelRuleConfigurationBuilder.class);
+ // TODO consider about order for new put items
+ for (Entry<GlobalRuleBuilder, DefaultKernelRuleConfigurationBuilder> entry : defaultBuilders.entrySet()) {
+ builders.put(entry.getValue().build(), entry.getKey());
+ }
+ }
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ private static Collection<GlobalRuleBuilder> getMissedKernelGlobalRuleBuilders(final Collection<GlobalRuleBuilder> configuredBuilders) {
+ Collection<Class<GlobalRuleBuilder>> configuredBuilderClasses = configuredBuilders.stream().map(each -> (Class<GlobalRuleBuilder>) each.getClass()).collect(Collectors.toSet());
+ return OrderedSPIRegistry.getRegisteredServices(GlobalRuleBuilder.class).stream().filter(
+ each -> each instanceof KernelRuleBuilder && !configuredBuilderClasses.contains(each.getClass())).collect(Collectors.toList());
+ }
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/SchemaRuleBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/level/DefaultKernelRuleConfigurationBuilder.java
similarity index 58%
copy from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/SchemaRuleBuilder.java
copy to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/level/DefaultKernelRuleConfigurationBuilder.java
index ab24f4e..4e6802c 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/SchemaRuleBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/level/DefaultKernelRuleConfigurationBuilder.java
@@ -15,32 +15,24 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.rule.builder;
+package org.apache.shardingsphere.infra.rule.builder.level;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.scope.SchemaRule;
+import org.apache.shardingsphere.infra.rule.builder.scope.RuleBuilder;
import org.apache.shardingsphere.infra.spi.ordered.OrderedSPI;
-import javax.sql.DataSource;
-import java.util.Map;
-
/**
- * Schema rule builder.
+ * Kernel rule builder.
*
- * @param <R> type of schema rule
* @param <T> type of rule configuration
+ * @param <B> type of rule builder
*/
-public interface SchemaRuleBuilder<R extends SchemaRule, T extends RuleConfiguration> extends OrderedSPI<T> {
+public interface DefaultKernelRuleConfigurationBuilder<T extends RuleConfiguration, B extends RuleBuilder> extends OrderedSPI<B> {
/**
- * Build Schema rule.
+ * Build default kernel rule configuration.
*
- * @param schemaName schema name
- * @param dataSourceMap dataSource map
- * @param databaseType database type
- * @param ruleConfig rule configuration
- * @return schema rule
+ * @return kernel rule configuration
*/
- R build(String schemaName, Map<String, DataSource> dataSourceMap, DatabaseType databaseType, T ruleConfig);
+ T build();
}
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/level/FeatureRuleBuilder.java
similarity index 50%
copy from shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java
copy to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/level/FeatureRuleBuilder.java
index 45e25b5..511a814 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/level/FeatureRuleBuilder.java
@@ -15,28 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.context.fixture;
+package org.apache.shardingsphere.infra.rule.builder.level;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
-
-import javax.sql.DataSource;
-import java.util.Map;
-
-public final class FixtureRuleBuilder implements SchemaRuleBuilder<FixtureRule, FixtureRuleConfiguration> {
-
- @Override
- public FixtureRule build(final String schemaName, final Map<String, DataSource> dataSourceMap, final DatabaseType databaseType, final FixtureRuleConfiguration ruleConfig) {
- return new FixtureRule();
- }
-
- @Override
- public int getOrder() {
- return 0;
- }
-
- @Override
- public Class<FixtureRuleConfiguration> getTypeClass() {
- return FixtureRuleConfiguration.class;
- }
+/**
+ * Feature rule builder.
+ */
+public interface FeatureRuleBuilder {
}
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/level/KernelRuleBuilder.java
similarity index 50%
copy from shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java
copy to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/level/KernelRuleBuilder.java
index 45e25b5..16b397f 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/level/KernelRuleBuilder.java
@@ -15,28 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.context.fixture;
+package org.apache.shardingsphere.infra.rule.builder.level;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
-
-import javax.sql.DataSource;
-import java.util.Map;
-
-public final class FixtureRuleBuilder implements SchemaRuleBuilder<FixtureRule, FixtureRuleConfiguration> {
-
- @Override
- public FixtureRule build(final String schemaName, final Map<String, DataSource> dataSourceMap, final DatabaseType databaseType, final FixtureRuleConfiguration ruleConfig) {
- return new FixtureRule();
- }
-
- @Override
- public int getOrder() {
- return 0;
- }
-
- @Override
- public Class<FixtureRuleConfiguration> getTypeClass() {
- return FixtureRuleConfiguration.class;
- }
+/**
+ * Kernel rule builder.
+ */
+public interface KernelRuleBuilder {
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/GlobalRuleBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/scope/GlobalRuleBuilder.java
similarity index 90%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/GlobalRuleBuilder.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/scope/GlobalRuleBuilder.java
index 205e1c8..2c94f92 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/GlobalRuleBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/scope/GlobalRuleBuilder.java
@@ -15,13 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.rule.builder;
+package org.apache.shardingsphere.infra.rule.builder.scope;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.rule.scope.GlobalRule;
-import org.apache.shardingsphere.infra.spi.ordered.OrderedSPI;
import java.util.Collection;
import java.util.Map;
@@ -32,7 +31,7 @@ import java.util.Map;
* @param <R> type of global rule
* @param <T> type of rule configuration
*/
-public interface GlobalRuleBuilder<R extends GlobalRule, T extends RuleConfiguration> extends OrderedSPI<T> {
+public interface GlobalRuleBuilder<R extends GlobalRule, T extends RuleConfiguration> extends RuleBuilder<T> {
/**
* Build global rule.
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/SchemaRuleBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/scope/RuleBuilder.java
similarity index 52%
copy from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/SchemaRuleBuilder.java
copy to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/scope/RuleBuilder.java
index ab24f4e..7e2698b 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/SchemaRuleBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/scope/RuleBuilder.java
@@ -15,32 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.rule.builder;
+package org.apache.shardingsphere.infra.rule.builder.scope;
-import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.scope.SchemaRule;
import org.apache.shardingsphere.infra.spi.ordered.OrderedSPI;
-import javax.sql.DataSource;
-import java.util.Map;
-
/**
- * Schema rule builder.
+ * Rule builder.
*
- * @param <R> type of schema rule
* @param <T> type of rule configuration
*/
-public interface SchemaRuleBuilder<R extends SchemaRule, T extends RuleConfiguration> extends OrderedSPI<T> {
-
- /**
- * Build Schema rule.
- *
- * @param schemaName schema name
- * @param dataSourceMap dataSource map
- * @param databaseType database type
- * @param ruleConfig rule configuration
- * @return schema rule
- */
- R build(String schemaName, Map<String, DataSource> dataSourceMap, DatabaseType databaseType, T ruleConfig);
+public interface RuleBuilder<T> extends OrderedSPI<T> {
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/SchemaRuleBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/scope/SchemaRuleBuilder.java
similarity index 90%
rename from shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/SchemaRuleBuilder.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/scope/SchemaRuleBuilder.java
index ab24f4e..216eee1 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/SchemaRuleBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/builder/scope/SchemaRuleBuilder.java
@@ -15,12 +15,11 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.rule.builder;
+package org.apache.shardingsphere.infra.rule.builder.scope;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.rule.scope.SchemaRule;
-import org.apache.shardingsphere.infra.spi.ordered.OrderedSPI;
import javax.sql.DataSource;
import java.util.Map;
@@ -31,7 +30,7 @@ import java.util.Map;
* @param <R> type of schema rule
* @param <T> type of rule configuration
*/
-public interface SchemaRuleBuilder<R extends SchemaRule, T extends RuleConfiguration> extends OrderedSPI<T> {
+public interface SchemaRuleBuilder<R extends SchemaRule, T extends RuleConfiguration> extends RuleBuilder<T> {
/**
* Build Schema rule.
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/level/FeatureRule.java
similarity index 50%
copy from shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java
copy to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/level/FeatureRule.java
index 45e25b5..905d17f 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/level/FeatureRule.java
@@ -15,28 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.context.fixture;
+package org.apache.shardingsphere.infra.rule.level;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import javax.sql.DataSource;
-import java.util.Map;
-
-public final class FixtureRuleBuilder implements SchemaRuleBuilder<FixtureRule, FixtureRuleConfiguration> {
-
- @Override
- public FixtureRule build(final String schemaName, final Map<String, DataSource> dataSourceMap, final DatabaseType databaseType, final FixtureRuleConfiguration ruleConfig) {
- return new FixtureRule();
- }
-
- @Override
- public int getOrder() {
- return 0;
- }
-
- @Override
- public Class<FixtureRuleConfiguration> getTypeClass() {
- return FixtureRuleConfiguration.class;
- }
+/**
+ * Feature rule which for level-2 of pluggable platform.
+ */
+public interface FeatureRule extends ShardingSphereRule {
}
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/level/KernelRule.java
similarity index 50%
copy from shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java
copy to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/level/KernelRule.java
index 45e25b5..a1cf72e 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/test/java/org/apache/shardingsphere/infra/context/fixture/FixtureRuleBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/rule/level/KernelRule.java
@@ -15,28 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.infra.context.fixture;
+package org.apache.shardingsphere.infra.rule.level;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import javax.sql.DataSource;
-import java.util.Map;
-
-public final class FixtureRuleBuilder implements SchemaRuleBuilder<FixtureRule, FixtureRuleConfiguration> {
-
- @Override
- public FixtureRule build(final String schemaName, final Map<String, DataSource> dataSourceMap, final DatabaseType databaseType, final FixtureRuleConfiguration ruleConfig) {
- return new FixtureRule();
- }
-
- @Override
- public int getOrder() {
- return 0;
- }
-
- @Override
- public Class<FixtureRuleConfiguration> getTypeClass() {
- return FixtureRuleConfiguration.class;
- }
+/**
+ * Kernel rule which for level-1 of pluggable platform..
+ */
+public interface KernelRule extends ShardingSphereRule {
}
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 38e7f77..9d63b5f 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
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.infra.rule.fixture;
import lombok.Getter;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import org.apache.shardingsphere.infra.rule.scope.SchemaRule;
import java.util.Map;
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder
similarity index 100%
rename from shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder
rename to shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder
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 45e25b5..9d935ef 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,7 +18,7 @@
package org.apache.shardingsphere.infra.context.fixture;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder;
+import org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder;
import javax.sql.DataSource;
import java.util.Map;
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder b/shardingsphere-infra/shardingsphere-infra-context/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder
similarity index 100%
rename from shardingsphere-infra/shardingsphere-infra-context/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.SchemaRuleBuilder
rename to shardingsphere-infra/shardingsphere-infra-context/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.rule.builder.scope.SchemaRuleBuilder