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

chengzhang 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 764f8d65944 Refactor SPI infra (#27619)
764f8d65944 is described below

commit 764f8d659443e14f8366c3a061438ebf3c794d52
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Aug 2 04:44:02 2023 +0800

    Refactor SPI infra (#27619)
    
    * Refactor TypedSPILoader
    
    * Refactor OrderedSPILoader
    
    * Rename ServiceProviderNotFoundException
    
    * Rename ShardingSphereServiceLoader
    
    * Rename ShardingSphereServiceLoader
    
    * Refactor MetaDataPersistService
    
    * Refactor NewMetaDataPersistService
    
    * Refactor NewRuleDefinitionBackendHandler
    
    * Refactor RuleDefinitionBackendHandler
---
 .../AlterEncryptRuleStatementUpdaterTest.java      |  4 +-
 .../CreateEncryptRuleStatementUpdaterTest.java     |  4 +-
 .../update/CreateMaskRuleStatementUpdaterTest.java |  4 +-
 ...ReadwriteSplittingRuleStatementUpdaterTest.java |  4 +-
 ...ReadwriteSplittingRuleStatementUpdaterTest.java |  4 +-
 ...DefaultShadowAlgorithmStatementUpdaterTest.java |  4 +-
 ...DefaultShadowAlgorithmStatementUpdaterTest.java |  4 +-
 .../CreateShadowRuleStatementUpdaterTest.java      |  4 +-
 .../checker/ShardingRuleStatementCheckerTest.java  |  6 +--
 .../database/core/spi/DatabaseTypedSPILoader.java  |  6 +--
 .../infra/spi/ShardingSphereServiceLoader.java     | 28 ++++++-----
 ....java => ServiceProviderNotFoundException.java} |  4 +-
 .../infra/spi/type/ordered/OrderedSPILoader.java   | 40 ++++++++--------
 .../infra/spi/type/typed/TypedSPILoader.java       | 54 +++++++++++-----------
 .../ServiceProviderNotFoundExceptionTest.java      |  2 +-
 .../infra/spi/type/typed/TypedSPILoaderTest.java   |  4 +-
 .../metadata/persist/MetaDataPersistService.java   | 10 ++--
 .../persist/NewMetaDataPersistService.java         | 10 ++--
 .../AlterTrafficRuleStatementUpdaterTest.java      |  4 +-
 .../rdl/rule/NewRuleDefinitionBackendHandler.java  |  9 ++--
 .../rdl/rule/RuleDefinitionBackendHandler.java     |  9 ++--
 .../ral/QueryableRALBackendHandlerTest.java        |  4 +-
 ...plittingRuleConfigurationImportCheckerTest.java |  4 +-
 ...ShardingRuleConfigurationImportCheckerTest.java |  6 +--
 .../ImportDatabaseConfigurationUpdaterTest.java    |  4 +-
 .../ral/updatable/LockClusterUpdaterTest.java      |  4 +-
 26 files changed, 114 insertions(+), 126 deletions(-)

diff --git 
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdaterTest.java
 
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdaterTest.java
index 4fa50b34c07..e8db40f3cee 100644
--- 
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdaterTest.java
+++ 
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/AlterEncryptRuleStatementUpdaterTest.java
@@ -30,7 +30,7 @@ import 
org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptRuleSegme
 import 
org.apache.shardingsphere.encrypt.distsql.parser.statement.AlterEncryptRuleStatement;
 import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Answers;
@@ -68,7 +68,7 @@ class AlterEncryptRuleStatementUpdaterTest {
     
     @Test
     void assertCheckSQLStatementWithoutToBeAlteredEncryptors() {
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> 
updater.checkSQLStatement(database, createSQLStatement("INVALID_TYPE"), 
createCurrentRuleConfiguration()));
+        assertThrows(ServiceProviderNotFoundException.class, () -> 
updater.checkSQLStatement(database, createSQLStatement("INVALID_TYPE"), 
createCurrentRuleConfiguration()));
     }
     
     @Test
diff --git 
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdaterTest.java
 
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdaterTest.java
index ca4a58b7479..761d152e424 100644
--- 
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdaterTest.java
+++ 
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/update/CreateEncryptRuleStatementUpdaterTest.java
@@ -28,7 +28,7 @@ import 
org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptRuleSegme
 import 
org.apache.shardingsphere.encrypt.distsql.parser.statement.CreateEncryptRuleStatement;
 import 
org.apache.shardingsphere.encrypt.exception.algorithm.EncryptAlgorithmInitializationException;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
 import org.junit.jupiter.api.Test;
@@ -63,7 +63,7 @@ class CreateEncryptRuleStatementUpdaterTest {
     
     @Test
     void assertCheckSQLStatementWithoutToBeCreatedEncryptors() {
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> 
updater.checkSQLStatement(database, createSQLStatement(false, "INVALID_TYPE"), 
null));
+        assertThrows(ServiceProviderNotFoundException.class, () -> 
updater.checkSQLStatement(database, createSQLStatement(false, "INVALID_TYPE"), 
null));
     }
     
     @Test
diff --git 
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleStatementUpdaterTest.java
 
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleStatementUpdaterTest.java
index 03cc2bacc09..553b9fe2a8a 100644
--- 
a/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleStatementUpdaterTest.java
+++ 
b/features/mask/distsql/handler/src/test/java/org/apache/shardingsphere/mask/distsql/handler/update/CreateMaskRuleStatementUpdaterTest.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.mask.distsql.handler.update;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.DuplicateRuleException;
 import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.mask.api.config.MaskRuleConfiguration;
 import 
org.apache.shardingsphere.mask.api.config.rule.MaskTableRuleConfiguration;
 import org.apache.shardingsphere.mask.distsql.parser.segment.MaskColumnSegment;
@@ -58,7 +58,7 @@ class CreateMaskRuleStatementUpdaterTest {
     
     @Test
     void assertCheckSQLStatementWithInvalidAlgorithm() {
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> 
updater.checkSQLStatement(database, createSQLStatement(false, "INVALID_TYPE"), 
null));
+        assertThrows(ServiceProviderNotFoundException.class, () -> 
updater.checkSQLStatement(database, createSQLStatement(false, "INVALID_TYPE"), 
null));
     }
     
     @Test
diff --git 
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java
 
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java
index 173b9e54d20..8dd1606f86b 100644
--- 
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java
+++ 
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/AlterReadwriteSplittingRuleStatementUpdaterTest.java
@@ -23,7 +23,7 @@ import 
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRe
 import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import 
org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
 import 
org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
 import 
org.apache.shardingsphere.readwritesplitting.distsql.parser.segment.ReadwriteSplittingRuleSegment;
@@ -83,7 +83,7 @@ class AlterReadwriteSplittingRuleStatementUpdaterTest {
     @Test
     void assertCheckSQLStatementWithoutToBeAlteredLoadBalancers() {
         
when(database.getRuleMetaData().findRules(any())).thenReturn(Collections.emptyList());
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> 
updater.checkSQLStatement(database, createSQLStatement("INVALID_TYPE"), 
createCurrentRuleConfiguration()));
+        assertThrows(ServiceProviderNotFoundException.class, () -> 
updater.checkSQLStatement(database, createSQLStatement("INVALID_TYPE"), 
createCurrentRuleConfiguration()));
     }
     
     @Test
diff --git 
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java
 
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java
index 1975ed74b3d..dfc16c8b8b5 100644
--- 
a/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java
+++ 
b/features/readwrite-splitting/distsql/handler/src/test/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/update/CreateReadwriteSplittingRuleStatementUpdaterTest.java
@@ -24,7 +24,7 @@ import 
org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
 import 
org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
 import 
org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
 import 
org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
@@ -104,7 +104,7 @@ class CreateReadwriteSplittingRuleStatementUpdaterTest {
     void assertCheckSQLStatementWithoutToBeCreatedLoadBalancers() {
         
when(database.getRuleMetaData().findRules(any())).thenReturn(Collections.emptyList());
         when(TypedSPILoader.checkService(any(), any(), 
any())).thenCallRealMethod();
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> 
updater.checkSQLStatement(database, createSQLStatement("INVALID_TYPE"), null));
+        assertThrows(ServiceProviderNotFoundException.class, () -> 
updater.checkSQLStatement(database, createSQLStatement("INVALID_TYPE"), null));
     }
     
     @Test
diff --git 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterDefaultShadowAlgorithmStatementUpdaterTest.java
 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterDefaultShadowAlgorithmStatementUpdaterTest.java
index e5846b282e2..6bdf6e592e8 100644
--- 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterDefaultShadowAlgorithmStatementUpdaterTest.java
+++ 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/AlterDefaultShadowAlgorithmStatementUpdaterTest.java
@@ -23,7 +23,7 @@ import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredR
 import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
 import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
 import 
org.apache.shardingsphere.shadow.distsql.handler.update.AlterDefaultShadowAlgorithmStatementUpdater;
 import 
org.apache.shardingsphere.shadow.distsql.parser.segment.ShadowAlgorithmSegment;
@@ -73,7 +73,7 @@ class AlterDefaultShadowAlgorithmStatementUpdaterTest {
     void assertExecuteInvalidAlgorithmType() {
         AlterDefaultShadowAlgorithmStatement sqlStatement = new 
AlterDefaultShadowAlgorithmStatement(
                 new ShadowAlgorithmSegment("default_shadow_algorithm", new 
AlgorithmSegment("NOT_EXIST_SQL_HINT", PropertiesBuilder.build(new 
Property("type", "value")))));
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> 
updater.checkSQLStatement(database, sqlStatement, currentConfig));
+        assertThrows(ServiceProviderNotFoundException.class, () -> 
updater.checkSQLStatement(database, sqlStatement, currentConfig));
     }
     
     @Test
diff --git 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateDefaultShadowAlgorithmStatementUpdaterTest.java
 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateDefaultShadowAlgorithmStatementUpdaterTest.java
index 2d9b5040e61..66d8a29edd5 100644
--- 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateDefaultShadowAlgorithmStatementUpdaterTest.java
+++ 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateDefaultShadowAlgorithmStatementUpdaterTest.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.shadow.distsql.update;
 
 import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
 import 
org.apache.shardingsphere.shadow.distsql.handler.update.CreateDefaultShadowAlgorithmStatementUpdater;
 import 
org.apache.shardingsphere.shadow.distsql.parser.segment.ShadowAlgorithmSegment;
@@ -51,7 +51,7 @@ class CreateDefaultShadowAlgorithmStatementUpdaterTest {
     void assertExecuteWithInvalidAlgorithm() {
         CreateDefaultShadowAlgorithmStatement statement = 
mock(CreateDefaultShadowAlgorithmStatement.class);
         when(statement.getShadowAlgorithmSegment()).thenReturn(new 
ShadowAlgorithmSegment("algorithmName", new AlgorithmSegment("name", 
PropertiesBuilder.build(new Property("type", "value")))));
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> 
updater.checkSQLStatement(database, statement, currentConfig));
+        assertThrows(ServiceProviderNotFoundException.class, () -> 
updater.checkSQLStatement(database, statement, currentConfig));
     }
     
     @Test
diff --git 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
index 8e72da4e408..3ec0c141030 100644
--- 
a/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
+++ 
b/features/shadow/distsql/handler/src/test/java/org/apache/shardingsphere/shadow/distsql/update/CreateShadowRuleStatementUpdaterTest.java
@@ -24,7 +24,7 @@ import 
org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
 import 
org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.shadow.api.config.ShadowRuleConfiguration;
 import 
org.apache.shardingsphere.shadow.api.config.datasource.ShadowDataSourceConfiguration;
 import 
org.apache.shardingsphere.shadow.distsql.handler.update.CreateShadowRuleStatementUpdater;
@@ -125,7 +125,7 @@ class CreateShadowRuleStatementUpdaterTest {
         ShadowAlgorithmSegment segment = new 
ShadowAlgorithmSegment("algorithmName", new AlgorithmSegment("type", 
PropertiesBuilder.build(new Property("type", "value"))));
         CreateShadowRuleStatement sqlStatement = new 
CreateShadowRuleStatement(false,
                 Collections.singleton(new ShadowRuleSegment("ruleName", "ds", 
null, Collections.singletonMap("t_order", Collections.singleton(segment)))));
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> 
updater.checkSQLStatement(database, sqlStatement, currentConfig));
+        assertThrows(ServiceProviderNotFoundException.class, () -> 
updater.checkSQLStatement(database, sqlStatement, currentConfig));
     }
     
     @Test
diff --git 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
index 8adbe205f3d..3c294139b85 100644
--- 
a/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
+++ 
b/features/sharding/distsql/handler/src/test/java/org/apache/shardingsphere/sharding/distsql/checker/ShardingRuleStatementCheckerTest.java
@@ -28,7 +28,7 @@ import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
 import 
org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
 import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.generic.UnsupportedSQLOperationException;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableReferenceRuleConfiguration;
@@ -147,7 +147,7 @@ class ShardingRuleStatementCheckerTest {
     void assertCheckCreationWithInvalidKeyGenerateAlgorithm() {
         AutoTableRuleSegment autoTableRuleSegment = new 
AutoTableRuleSegment("t_product", Arrays.asList("ds_0", "ds_1"));
         autoTableRuleSegment.setKeyGenerateStrategySegment(new 
KeyGenerateStrategySegment("product_id", new AlgorithmSegment("invalid", 
PropertiesBuilder.build(new Property("invalid", "invalid")))));
-        assertThrows(ServiceProviderNotFoundServerException.class,
+        assertThrows(ServiceProviderNotFoundException.class,
                 () -> 
ShardingTableRuleStatementChecker.checkCreation(database, 
Collections.singleton(autoTableRuleSegment), false, shardingRuleConfig));
     }
     
@@ -156,7 +156,7 @@ class ShardingRuleStatementCheckerTest {
         AutoTableRuleSegment autoTableRuleSegment = new 
AutoTableRuleSegment("t_product", Arrays.asList("ds_0", "ds_1"));
         autoTableRuleSegment.setAuditStrategySegment(new 
AuditStrategySegment(Collections.singletonList(new 
ShardingAuditorSegment("sharding_key_required_auditor",
                 new AlgorithmSegment("invalid", new Properties()))), true));
-        assertThrows(ServiceProviderNotFoundServerException.class,
+        assertThrows(ServiceProviderNotFoundException.class,
                 () -> 
ShardingTableRuleStatementChecker.checkCreation(database, 
Collections.singleton(autoTableRuleSegment), false, shardingRuleConfig));
     }
     
diff --git 
a/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/spi/DatabaseTypedSPILoader.java
 
b/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/spi/DatabaseTypedSPILoader.java
index f1adc40a555..2be6b7f781e 100644
--- 
a/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/spi/DatabaseTypedSPILoader.java
+++ 
b/infra/database/core/src/main/java/org/apache/shardingsphere/infra/database/core/spi/DatabaseTypedSPILoader.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.infra.database.core.spi;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
 
 import java.util.Optional;
@@ -80,7 +80,7 @@ public final class DatabaseTypedSPILoader {
      * @return found service
      */
     public static <T extends DatabaseTypedSPI> T getService(final Class<T> 
spiClass, final DatabaseType databaseType) {
-        return findService(spiClass, databaseType).orElseThrow(() -> new 
ServiceProviderNotFoundServerException(spiClass, databaseType.getType()));
+        return findService(spiClass, databaseType).orElseThrow(() -> new 
ServiceProviderNotFoundException(spiClass, databaseType.getType()));
     }
     
     /**
@@ -93,6 +93,6 @@ public final class DatabaseTypedSPILoader {
      * @return found service
      */
     public static <T extends DatabaseTypedSPI> T getService(final Class<T> 
spiClass, final DatabaseType databaseType, final Properties props) {
-        return findService(spiClass, databaseType, props).orElseThrow(() -> 
new ServiceProviderNotFoundServerException(spiClass, databaseType.getType()));
+        return findService(spiClass, databaseType, props).orElseThrow(() -> 
new ServiceProviderNotFoundException(spiClass, databaseType.getType()));
     }
 }
diff --git 
a/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/ShardingSphereServiceLoader.java
 
b/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/ShardingSphereServiceLoader.java
index aa175a13163..0e471deca5c 100644
--- 
a/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/ShardingSphereServiceLoader.java
+++ 
b/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/ShardingSphereServiceLoader.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.infra.spi;
 
 import com.google.common.base.Preconditions;
-import lombok.Getter;
 import lombok.SneakyThrows;
 import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
 
@@ -41,11 +40,10 @@ public final class ShardingSphereServiceLoader<T> {
     
     private static final Object[] LOAD_LOCKS = new Object[LOAD_LOCKS_COUNT];
     
-    private final Class<T> serviceInterface;
-    
-    @Getter
     private final Collection<T> services;
     
+    private final boolean isSingletonSPI;
+    
     static {
         for (int i = 0; i < LOAD_LOCKS_COUNT; i++) {
             LOAD_LOCKS[i] = new Object();
@@ -53,17 +51,17 @@ public final class ShardingSphereServiceLoader<T> {
     }
     
     private ShardingSphereServiceLoader(final Class<T> serviceInterface) {
-        this.serviceInterface = serviceInterface;
-        validate();
-        services = load();
+        validate(serviceInterface);
+        services = load(serviceInterface);
+        isSingletonSPI = null != 
serviceInterface.getAnnotation(SingletonSPI.class);
     }
     
-    private void validate() {
+    private void validate(final Class<T> serviceInterface) {
         Preconditions.checkNotNull(serviceInterface, "SPI interface is null.");
-        Preconditions.checkArgument(serviceInterface.isInterface(), "SPI 
interface `%s` is not interface.", serviceInterface);
+        Preconditions.checkArgument(serviceInterface.isInterface(), "SPI `%s` 
is not an interface.", serviceInterface);
     }
     
-    private Collection<T> load() {
+    private Collection<T> load(final Class<T> serviceInterface) {
         Collection<T> result = new LinkedList<>();
         for (T each : ServiceLoader.load(serviceInterface)) {
             result.add(each);
@@ -96,7 +94,11 @@ public final class ShardingSphereServiceLoader<T> {
     }
     
     private Collection<T> getServiceInstances() {
-        return null == serviceInterface.getAnnotation(SingletonSPI.class) ? 
createNewServiceInstances() : getSingletonServiceInstances();
+        return isSingletonSPI ? getSingletonServiceInstances() : 
createNewServiceInstances();
+    }
+    
+    private Collection<T> getSingletonServiceInstances() {
+        return services;
     }
     
     @SneakyThrows(ReflectiveOperationException.class)
@@ -108,8 +110,4 @@ public final class ShardingSphereServiceLoader<T> {
         }
         return result;
     }
-    
-    private Collection<T> getSingletonServiceInstances() {
-        return services;
-    }
 }
diff --git 
a/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/exception/ServiceProviderNotFoundServerException.java
 
b/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/exception/ServiceProviderNotFoundException.java
similarity index 87%
rename from 
infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/exception/ServiceProviderNotFoundServerException.java
rename to 
infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/exception/ServiceProviderNotFoundException.java
index 1bb2baccd6b..0377edddc15 100644
--- 
a/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/exception/ServiceProviderNotFoundServerException.java
+++ 
b/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/exception/ServiceProviderNotFoundException.java
@@ -22,7 +22,7 @@ import 
org.apache.shardingsphere.infra.exception.core.external.server.ShardingSp
 /**
  * Service provider not found exception.
  */
-public final class ServiceProviderNotFoundServerException extends 
ShardingSphereServerException {
+public final class ServiceProviderNotFoundException extends 
ShardingSphereServerException {
     
     private static final long serialVersionUID = -3730257541332863236L;
     
@@ -30,7 +30,7 @@ public final class ServiceProviderNotFoundServerException 
extends ShardingSphere
     
     private static final int ERROR_CODE = 1;
     
-    public ServiceProviderNotFoundServerException(final Class<?> clazz, final 
Object type) {
+    public ServiceProviderNotFoundException(final Class<?> clazz, final Object 
type) {
         super(ERROR_CATEGORY, ERROR_CODE, String.format("No implementation 
class load from SPI `%s` with type `%s`.", clazz.getName(), type));
     }
 }
diff --git 
a/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/type/ordered/OrderedSPILoader.java
 
b/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/type/ordered/OrderedSPILoader.java
index 5c71f1808cc..077a7005ce1 100644
--- 
a/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/type/ordered/OrderedSPILoader.java
+++ 
b/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/type/ordered/OrderedSPILoader.java
@@ -39,13 +39,13 @@ public final class OrderedSPILoader {
     /**
      * Get services by class type.
      *
-     * @param spiClass class of ordered SPI
+     * @param serviceInterface ordered SPI service interface
      * @param types types
      * @param <T> type of ordered SPI class
-     * @return services
+     * @return got services
      */
-    public static <T extends OrderedSPI<?>> Map<Class<?>, T> 
getServicesByClass(final Class<T> spiClass, final Collection<Class<?>> types) {
-        Collection<T> services = getServices(spiClass);
+    public static <T extends OrderedSPI<?>> Map<Class<?>, T> 
getServicesByClass(final Class<T> serviceInterface, final Collection<Class<?>> 
types) {
+        Collection<T> services = getServices(serviceInterface);
         Map<Class<?>, T> result = new LinkedHashMap<>(services.size(), 1F);
         for (T each : services) {
             types.stream().filter(type -> each.getTypeClass() == 
type).forEach(type -> result.put(type, each));
@@ -56,55 +56,55 @@ public final class OrderedSPILoader {
     /**
      * Get services.
      *
-     * @param spiClass class of ordered SPI
+     * @param serviceInterface ordered SPI service interface
      * @param types types
      * @param <K> type of key
      * @param <V> type of ordered SPI class
-     * @return services
+     * @return got services
      */
-    public static <K, V extends OrderedSPI<?>> Map<K, V> getServices(final 
Class<V> spiClass, final Collection<K> types) {
-        return getServices(spiClass, types, Comparator.naturalOrder());
+    public static <K, V extends OrderedSPI<?>> Map<K, V> getServices(final 
Class<V> serviceInterface, final Collection<K> types) {
+        return getServices(serviceInterface, types, Comparator.naturalOrder());
     }
     
     /**
      * Get services.
      *
-     * @param spiClass class of ordered SPI
+     * @param serviceInterface ordered SPI service interface
      * @param types types
      * @param <K> type of key
      * @param <V> type of ordered SPI class
      * @param orderComparator order comparator
-     * @return services
+     * @return got services
      */
     @SuppressWarnings("unchecked")
-    public static <K, V extends OrderedSPI<?>> Map<K, V> getServices(final 
Class<V> spiClass, final Collection<K> types, final Comparator<Integer> 
orderComparator) {
-        Optional<Map<K, V>> cachedServices = 
OrderedServicesCache.findCachedServices(spiClass, types).map(optional -> 
(Map<K, V>) optional);
+    public static <K, V extends OrderedSPI<?>> Map<K, V> getServices(final 
Class<V> serviceInterface, final Collection<K> types, final Comparator<Integer> 
orderComparator) {
+        Optional<Map<K, V>> cachedServices = 
OrderedServicesCache.findCachedServices(serviceInterface, types).map(optional 
-> (Map<K, V>) optional);
         if (cachedServices.isPresent()) {
             return cachedServices.get();
         }
-        Collection<V> services = getServices(spiClass, orderComparator);
+        Collection<V> services = getServices(serviceInterface, 
orderComparator);
         Map<K, V> result = new LinkedHashMap<>(services.size(), 1F);
         for (V each : services) {
             types.stream().filter(type -> each.getTypeClass() == 
type.getClass()).forEach(type -> result.put(type, each));
         }
-        OrderedServicesCache.cacheServices(spiClass, types, result);
+        OrderedServicesCache.cacheServices(serviceInterface, types, result);
         return result;
     }
     
     /**
      * Get services.
      *
-     * @param spiClass class of ordered SPI
+     * @param serviceInterface ordered SPI service interface
      * @param <T> type of ordered SPI class
-     * @return services
+     * @return got services
      */
-    public static <T extends OrderedSPI<?>> Collection<T> getServices(final 
Class<T> spiClass) {
-        return getServices(spiClass, Comparator.naturalOrder());
+    public static <T extends OrderedSPI<?>> Collection<T> getServices(final 
Class<T> serviceInterface) {
+        return getServices(serviceInterface, Comparator.naturalOrder());
     }
     
-    private static <T extends OrderedSPI<?>> Collection<T> getServices(final 
Class<T> spiClass, final Comparator<Integer> comparator) {
+    private static <T extends OrderedSPI<?>> Collection<T> getServices(final 
Class<T> serviceInterface, final Comparator<Integer> comparator) {
         Map<Integer, T> result = new TreeMap<>(comparator);
-        for (T each : 
ShardingSphereServiceLoader.getServiceInstances(spiClass)) {
+        for (T each : 
ShardingSphereServiceLoader.getServiceInstances(serviceInterface)) {
             Preconditions.checkArgument(!result.containsKey(each.getOrder()), 
"Found same order `%s` with `%s` and `%s`", each.getOrder(), 
result.get(each.getOrder()), each);
             result.put(each.getOrder(), each);
         }
diff --git 
a/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/type/typed/TypedSPILoader.java
 
b/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/type/typed/TypedSPILoader.java
index 78a2943dd64..875aa20b0f2 100644
--- 
a/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/type/typed/TypedSPILoader.java
+++ 
b/infra/spi/src/main/java/org/apache/shardingsphere/infra/spi/type/typed/TypedSPILoader.java
@@ -20,7 +20,7 @@ package org.apache.shardingsphere.infra.spi.type.typed;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 
 import java.util.Optional;
 import java.util.Properties;
@@ -34,51 +34,51 @@ public final class TypedSPILoader {
     /**
      * Judge whether contains service.
      * 
-     * @param spiClass typed SPI class
+     * @param serviceInterface typed SPI service interface to be judged
      * @param type type
      * @param <T> SPI class type
      * @return contains or not
      */
-    public static <T extends TypedSPI> boolean contains(final Class<T> 
spiClass, final Object type) {
-        return 
ShardingSphereServiceLoader.getServiceInstances(spiClass).stream().anyMatch(each
 -> matchesType(type, each));
+    public static <T extends TypedSPI> boolean contains(final Class<T> 
serviceInterface, final Object type) {
+        return 
ShardingSphereServiceLoader.getServiceInstances(serviceInterface).stream().anyMatch(each
 -> matchesType(type, each));
     }
     
     /**
      * Find service.
      * 
-     * @param spiClass typed SPI class
+     * @param serviceInterface typed SPI service interface
      * @param type type
      * @param <T> SPI class type
-     * @return service
+     * @return found service
      */
-    public static <T extends TypedSPI> Optional<T> findService(final Class<T> 
spiClass, final Object type) {
-        return findService(spiClass, type, new Properties());
+    public static <T extends TypedSPI> Optional<T> findService(final Class<T> 
serviceInterface, final Object type) {
+        return findService(serviceInterface, type, new Properties());
     }
     
     /**
      * Find service.
      * 
-     * @param spiClass typed SPI class
+     * @param serviceInterface typed SPI service interface
      * @param type type
      * @param props properties
      * @param <T> SPI class type
-     * @return service
+     * @return found service
      */
-    public static <T extends TypedSPI> Optional<T> findService(final Class<T> 
spiClass, final Object type, final Properties props) {
+    public static <T extends TypedSPI> Optional<T> findService(final Class<T> 
serviceInterface, final Object type, final Properties props) {
         if (null == type) {
-            return findDefaultService(spiClass);
+            return findDefaultService(serviceInterface);
         }
-        for (T each : 
ShardingSphereServiceLoader.getServiceInstances(spiClass)) {
+        for (T each : 
ShardingSphereServiceLoader.getServiceInstances(serviceInterface)) {
             if (matchesType(type, each)) {
                 each.init(null == props ? new Properties() : 
convertToStringTypedProperties(props));
                 return Optional.of(each);
             }
         }
-        return findDefaultService(spiClass);
+        return findDefaultService(serviceInterface);
     }
     
-    private static <T extends TypedSPI> Optional<T> findDefaultService(final 
Class<T> spiClass) {
-        for (T each : 
ShardingSphereServiceLoader.getServiceInstances(spiClass)) {
+    private static <T extends TypedSPI> Optional<T> findDefaultService(final 
Class<T> serviceInterface) {
+        for (T each : 
ShardingSphereServiceLoader.getServiceInstances(serviceInterface)) {
             if (!each.isDefault()) {
                 continue;
             }
@@ -100,46 +100,46 @@ public final class TypedSPILoader {
     /**
      * Get service.
      * 
-     * @param spiClass typed SPI class
+     * @param serviceInterface typed SPI service interface
      * @param type type
      * @param <T> SPI class type
      * @return service
      */
-    public static <T extends TypedSPI> T getService(final Class<T> spiClass, 
final Object type) {
-        return getService(spiClass, type, new Properties());
+    public static <T extends TypedSPI> T getService(final Class<T> 
serviceInterface, final Object type) {
+        return getService(serviceInterface, type, new Properties());
     }
     
     /**
      * Get service.
      * 
-     * @param spiClass typed SPI class
+     * @param serviceInterface typed SPI service interface
      * @param type type
      * @param props properties
      * @param <T> SPI class type
      * @return service
      */
-    public static <T extends TypedSPI> T getService(final Class<T> spiClass, 
final Object type, final Properties props) {
-        return findService(spiClass, type, props).orElseGet(() -> 
findDefaultService(spiClass).orElseThrow(() -> new 
ServiceProviderNotFoundServerException(spiClass, type)));
+    public static <T extends TypedSPI> T getService(final Class<T> 
serviceInterface, final Object type, final Properties props) {
+        return findService(serviceInterface, type, props).orElseGet(() -> 
findDefaultService(serviceInterface).orElseThrow(() -> new 
ServiceProviderNotFoundException(serviceInterface, type)));
     }
     
     /**
      * Check service.
      * 
-     * @param spiClass typed SPI class
+     * @param serviceInterface typed SPI service interface
      * @param type type
      * @param props properties
      * @param <T> SPI class type
      * @return is valid service or not
-     * @throws ServiceProviderNotFoundServerException service provider not 
found server exception
+     * @throws ServiceProviderNotFoundException service provider not found 
server exception
      */
-    public static <T extends TypedSPI> boolean checkService(final Class<T> 
spiClass, final Object type, final Properties props) {
-        for (T each : 
ShardingSphereServiceLoader.getServiceInstances(spiClass)) {
+    public static <T extends TypedSPI> boolean checkService(final Class<T> 
serviceInterface, final Object type, final Properties props) {
+        for (T each : 
ShardingSphereServiceLoader.getServiceInstances(serviceInterface)) {
             if (matchesType(type, each)) {
                 each.init(null == props ? new Properties() : 
convertToStringTypedProperties(props));
                 return true;
             }
         }
-        throw new ServiceProviderNotFoundServerException(spiClass, type);
+        throw new ServiceProviderNotFoundException(serviceInterface, type);
     }
     
     private static boolean matchesType(final Object type, final TypedSPI 
instance) {
diff --git 
a/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/exception/ServiceProviderNotFoundExceptionTest.java
 
b/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/exception/ServiceProviderNotFoundExceptionTest.java
index dd6523e0956..74d0983440e 100644
--- 
a/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/exception/ServiceProviderNotFoundExceptionTest.java
+++ 
b/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/exception/ServiceProviderNotFoundExceptionTest.java
@@ -26,6 +26,6 @@ class ServiceProviderNotFoundExceptionTest {
     
     @Test
     void assertGetMessageWithClassAndType() {
-        assertThat(new ServiceProviderNotFoundServerException(Object.class, 
"Foo").getMessage(), is("SPI-00001: No implementation class load from SPI 
`java.lang.Object` with type `Foo`."));
+        assertThat(new ServiceProviderNotFoundException(Object.class, 
"Foo").getMessage(), is("SPI-00001: No implementation class load from SPI 
`java.lang.Object` with type `Foo`."));
     }
 }
diff --git 
a/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/type/typed/TypedSPILoaderTest.java
 
b/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/type/typed/TypedSPILoaderTest.java
index 5b801b06964..65919295a71 100644
--- 
a/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/type/typed/TypedSPILoaderTest.java
+++ 
b/infra/spi/src/test/java/org/apache/shardingsphere/infra/spi/type/typed/TypedSPILoaderTest.java
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.infra.spi.type.typed;
 
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.infra.spi.type.typed.fixture.TypedSPIFixture;
 import 
org.apache.shardingsphere.infra.spi.type.typed.fixture.impl.TypedSPIFixtureImpl;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
@@ -69,6 +69,6 @@ class TypedSPILoaderTest {
     
     @Test
     void assertGetServiceWhenTypeIsNotExist() {
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> 
TypedSPILoader.getService(TypedSPIFixture.class, "NOT_EXISTED"));
+        assertThrows(ServiceProviderNotFoundException.class, () -> 
TypedSPILoader.getService(TypedSPIFixture.class, "NOT_EXISTED"));
     }
 }
diff --git 
a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/MetaDataPersistService.java
 
b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/MetaDataPersistService.java
index aa8d9e7564d..1b7e7e39a3c 100644
--- 
a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/MetaDataPersistService.java
+++ 
b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/MetaDataPersistService.java
@@ -43,6 +43,7 @@ import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Optional;
 import java.util.Properties;
 import java.util.stream.Collectors;
 
@@ -100,16 +101,13 @@ public final class MetaDataPersistService implements 
MetaDataBasedPersistService
         }
     }
     
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({"unchecked", "rawtypes"})
     private Collection<RuleConfiguration> decorateRuleConfigs(final String 
databaseName, final Map<String, DataSource> dataSources, final 
Collection<ShardingSphereRule> rules) {
         Collection<RuleConfiguration> result = new LinkedList<>();
         for (ShardingSphereRule each : rules) {
             RuleConfiguration ruleConfig = each.getConfiguration();
-            if (TypedSPILoader.contains(RuleConfigurationDecorator.class, 
ruleConfig.getClass().getName())) {
-                
result.add(TypedSPILoader.getService(RuleConfigurationDecorator.class, 
ruleConfig.getClass().getName()).decorate(databaseName, dataSources, rules, 
ruleConfig));
-            } else {
-                result.add(each.getConfiguration());
-            }
+            Optional<RuleConfigurationDecorator> decorator = 
TypedSPILoader.findService(RuleConfigurationDecorator.class, 
ruleConfig.getClass().getName());
+            result.add(decorator.map(optional -> 
optional.decorate(databaseName, dataSources, rules, 
ruleConfig)).orElse(ruleConfig));
         }
         return result;
     }
diff --git 
a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/NewMetaDataPersistService.java
 
b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/NewMetaDataPersistService.java
index 4bfd01a8950..fd93e42774a 100644
--- 
a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/NewMetaDataPersistService.java
+++ 
b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/NewMetaDataPersistService.java
@@ -43,6 +43,7 @@ import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Optional;
 import java.util.Properties;
 import java.util.stream.Collectors;
 
@@ -107,16 +108,13 @@ public final class NewMetaDataPersistService implements 
MetaDataBasedPersistServ
         }
     }
     
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({"unchecked", "rawtypes"})
     private Collection<RuleConfiguration> decorateRuleConfigs(final String 
databaseName, final Map<String, DataSource> dataSources, final 
Collection<ShardingSphereRule> rules) {
         Collection<RuleConfiguration> result = new LinkedList<>();
         for (ShardingSphereRule each : rules) {
             RuleConfiguration ruleConfig = each.getConfiguration();
-            if (TypedSPILoader.contains(RuleConfigurationDecorator.class, 
ruleConfig.getClass().getName())) {
-                
result.add(TypedSPILoader.getService(RuleConfigurationDecorator.class, 
ruleConfig.getClass().getName()).decorate(databaseName, dataSources, rules, 
ruleConfig));
-            } else {
-                result.add(each.getConfiguration());
-            }
+            Optional<RuleConfigurationDecorator> decorator = 
TypedSPILoader.findService(RuleConfigurationDecorator.class, 
ruleConfig.getClass().getName());
+            result.add(decorator.map(optional -> 
optional.decorate(databaseName, dataSources, rules, 
ruleConfig)).orElse(ruleConfig));
         }
         return result;
     }
diff --git 
a/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleStatementUpdaterTest.java
 
b/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleStatementUpdaterTest.java
index 9c49bb93734..1cf90004225 100644
--- 
a/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleStatementUpdaterTest.java
+++ 
b/kernel/traffic/distsql/handler/src/test/java/org/apache/shardingsphere/traffic/distsql/handler/update/AlterTrafficRuleStatementUpdaterTest.java
@@ -20,7 +20,7 @@ package 
org.apache.shardingsphere.traffic.distsql.handler.update;
 import 
org.apache.shardingsphere.distsql.handler.exception.rule.MissingRequiredRuleException;
 import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
 import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.test.util.PropertiesBuilder;
 import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
 import org.apache.shardingsphere.traffic.api.config.TrafficRuleConfiguration;
@@ -54,7 +54,7 @@ class AlterTrafficRuleStatementUpdaterTest {
         TrafficRuleSegment trafficRuleSegment = new TrafficRuleSegment(
                 "rule_name_1", Arrays.asList("olap", "order_by"), new 
AlgorithmSegment("invalid", new Properties()), new AlgorithmSegment("invalid", 
new Properties()));
         AlterTrafficRuleStatementUpdater updater = new 
AlterTrafficRuleStatementUpdater();
-        assertThrows(ServiceProviderNotFoundServerException.class,
+        assertThrows(ServiceProviderNotFoundException.class,
                 () -> 
updater.checkSQLStatement(createTrafficRuleConfiguration(), new 
AlterTrafficRuleStatement(Collections.singleton(trafficRuleSegment))));
     }
     
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/NewRuleDefinitionBackendHandler.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/NewRuleDefinitionBackendHandler.java
index ed050547b89..0247062bf6f 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/NewRuleDefinitionBackendHandler.java
+++ 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/NewRuleDefinitionBackendHandler.java
@@ -126,13 +126,10 @@ public final class NewRuleDefinitionBackendHandler<T 
extends RuleDefinitionState
         return 
ProxyContext.getInstance().getContextManager().getInstanceContext().getModeContextManager().alterRuleConfiguration(database.getName(),
 toBeAlteredRuleConfig);
     }
     
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({"unchecked", "rawtypes"})
     private RuleConfiguration decorateRuleConfiguration(final 
ShardingSphereDatabase database, final RuleConfiguration ruleConfig) {
-        if (TypedSPILoader.contains(RuleConfigurationDecorator.class, 
ruleConfig.getClass().getName())) {
-            return TypedSPILoader.getService(RuleConfigurationDecorator.class, 
ruleConfig.getClass().getName()).decorate(database.getName(),
-                    database.getResourceMetaData().getDataSources(), 
database.getRuleMetaData().getRules(), ruleConfig);
-        }
-        return ruleConfig;
+        Optional<RuleConfigurationDecorator> decorator = 
TypedSPILoader.findService(RuleConfigurationDecorator.class, 
ruleConfig.getClass().getName());
+        return decorator.map(optional -> optional.decorate(database.getName(), 
database.getResourceMetaData().getDataSources(), 
database.getRuleMetaData().getRules(), ruleConfig)).orElse(ruleConfig);
     }
     
     @SuppressWarnings({"rawtypes", "unchecked"})
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
index 9be92954602..8ed1a29f3e1 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
+++ 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rdl/rule/RuleDefinitionBackendHandler.java
@@ -98,13 +98,10 @@ public final class RuleDefinitionBackendHandler<T extends 
RuleDefinitionStatemen
         return result;
     }
     
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings({"unchecked", "rawtypes"})
     private RuleConfiguration decorateRuleConfiguration(final 
ShardingSphereDatabase database, final RuleConfiguration ruleConfig) {
-        if (TypedSPILoader.contains(RuleConfigurationDecorator.class, 
ruleConfig.getClass().getName())) {
-            return TypedSPILoader.getService(RuleConfigurationDecorator.class, 
ruleConfig.getClass().getName()).decorate(database.getName(),
-                    database.getResourceMetaData().getDataSources(), 
database.getRuleMetaData().getRules(), ruleConfig);
-        }
-        return ruleConfig;
+        Optional<RuleConfigurationDecorator> decorator = 
TypedSPILoader.findService(RuleConfigurationDecorator.class, 
ruleConfig.getClass().getName());
+        return decorator.map(optional -> optional.decorate(database.getName(), 
database.getResourceMetaData().getDataSources(), 
database.getRuleMetaData().getRules(), ruleConfig)).orElse(ruleConfig);
     }
     
     @SuppressWarnings({"rawtypes", "unchecked"})
diff --git 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandlerTest.java
 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandlerTest.java
index 5a8952ff579..846ea96a2f9 100644
--- 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandlerTest.java
+++ 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/QueryableRALBackendHandlerTest.java
@@ -30,7 +30,7 @@ import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSp
 import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereIndex;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
@@ -79,7 +79,7 @@ class QueryableRALBackendHandlerTest {
     
     @Test
     void assertExecuteWithAbstractStatement() {
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> new 
QueryableRALBackendHandler<>(mock(QueryableRALStatement.class), 
mock(ConnectionSession.class)).execute());
+        assertThrows(ServiceProviderNotFoundException.class, () -> new 
QueryableRALBackendHandler<>(mock(QueryableRALStatement.class), 
mock(ConnectionSession.class)).execute());
     }
     
     @Test
diff --git 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportCheckerTest.java
 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportCheckerTest.java
index 5e0b33ac179..bf4e9ae5dfe 100644
--- 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportCheckerTest.java
+++ 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ReadwriteSplittingRuleConfigurationImportCheckerTest.java
@@ -20,7 +20,7 @@ package 
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.common.check
 import 
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRequiredStorageUnitsException;
 import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import 
org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
 import 
org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
 import org.junit.jupiter.api.Test;
@@ -52,7 +52,7 @@ class ReadwriteSplittingRuleConfigurationImportCheckerTest {
     void assertCheckLoadBalancers() {
         ShardingSphereDatabase database = mockDatabase();
         ReadwriteSplittingRuleConfiguration currentRuleConfig = 
createInvalidLoadBalancerRuleConfig();
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> 
importChecker.check(database, currentRuleConfig));
+        assertThrows(ServiceProviderNotFoundException.class, () -> 
importChecker.check(database, currentRuleConfig));
     }
     
     private ShardingSphereDatabase mockDatabaseWithDataSource() {
diff --git 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportCheckerTest.java
 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportCheckerTest.java
index 6e851ebfc6d..7a011dd62cd 100644
--- 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportCheckerTest.java
+++ 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/common/checker/ShardingRuleConfigurationImportCheckerTest.java
@@ -22,7 +22,7 @@ import 
org.apache.shardingsphere.distsql.handler.exception.storageunit.MissingRe
 import org.apache.shardingsphere.infra.config.algorithm.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
 import org.junit.jupiter.api.Test;
@@ -53,12 +53,12 @@ class ShardingRuleConfigurationImportCheckerTest {
     
     @Test
     void assertCheckKeyGenerators() {
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> new 
ShardingRuleConfigurationImportChecker().check(mockDatabase(), 
createInvalidKeyGeneratorRuleConfiguration()));
+        assertThrows(ServiceProviderNotFoundException.class, () -> new 
ShardingRuleConfigurationImportChecker().check(mockDatabase(), 
createInvalidKeyGeneratorRuleConfiguration()));
     }
     
     @Test
     void assertCheckShardingAlgorithms() {
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> new 
ShardingRuleConfigurationImportChecker().check(mockDatabase(), 
createInvalidShardingAlgorithmRuleConfiguration()));
+        assertThrows(ServiceProviderNotFoundException.class, () -> new 
ShardingRuleConfigurationImportChecker().check(mockDatabase(), 
createInvalidShardingAlgorithmRuleConfiguration()));
     }
     
     private ShardingRuleConfiguration 
createDuplicatedTablesRuleConfiguration() {
diff --git 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java
 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java
index 262fcff069f..0cce0e07916 100644
--- 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java
+++ 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/ImportDatabaseConfigurationUpdaterTest.java
@@ -30,7 +30,7 @@ import 
org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphere
 import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import 
org.apache.shardingsphere.infra.rule.identifier.type.DataSourceContainedRule;
 import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.generic.UnsupportedSQLOperationException;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import 
org.apache.shardingsphere.proxy.backend.util.YamlDatabaseConfigurationImportExecutor;
@@ -104,7 +104,7 @@ class ImportDatabaseConfigurationUpdaterTest {
     
     @Test
     void assertImportInvalidAlgorithm() {
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> 
assertExecute("sharding_db", "/conf/import/config-invalid-algorithm.yaml"));
+        assertThrows(ServiceProviderNotFoundException.class, () -> 
assertExecute("sharding_db", "/conf/import/config-invalid-algorithm.yaml"));
     }
     
     private void assertExecute(final String databaseName, final String 
filePath) throws SQLException {
diff --git 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterUpdaterTest.java
 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterUpdaterTest.java
index 30fe76baf0d..104b484e47b 100644
--- 
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterUpdaterTest.java
+++ 
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/LockClusterUpdaterTest.java
@@ -21,7 +21,7 @@ import 
org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.updatable.LockClusterStatement;
 import org.apache.shardingsphere.infra.state.cluster.ClusterState;
 import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.generic.UnsupportedSQLOperationException;
-import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundServerException;
+import 
org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
 import org.apache.shardingsphere.mode.manager.ContextManager;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.test.mock.AutoMockExtension;
@@ -65,6 +65,6 @@ class LockClusterUpdaterTest {
         
when(contextManager.getClusterStateContext().getCurrentState()).thenReturn(ClusterState.OK);
         
when(ProxyContext.getInstance().getContextManager()).thenReturn(contextManager);
         LockClusterUpdater updater = new LockClusterUpdater();
-        assertThrows(ServiceProviderNotFoundServerException.class, () -> 
updater.executeUpdate("foo", new LockClusterStatement(new 
AlgorithmSegment("FOO", new Properties()))));
+        assertThrows(ServiceProviderNotFoundException.class, () -> 
updater.executeUpdate("foo", new LockClusterStatement(new 
AlgorithmSegment("FOO", new Properties()))));
     }
 }

Reply via email to