You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2022/04/25 16:19:20 UTC

[shardingsphere] branch master updated: Use RuleConfigurationCheckerFactory in test cases (#17105)

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

jianglongtao 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 1d2bcfc98ec Use RuleConfigurationCheckerFactory in test cases (#17105)
1d2bcfc98ec is described below

commit 1d2bcfc98ec091da9ddd1a0fb3e88cb18638b815
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue Apr 26 00:19:14 2022 +0800

    Use RuleConfigurationCheckerFactory in test cases (#17105)
    
    * Refactor ShardingSphereAlgorithmFactoryBean
    
    * Refactor ShardingSphereAlgorithmFactoryBean
    
    * Use RuleConfigurationCheckerFactory in test cases
---
 ...abaseDiscoveryRuleConfigurationCheckerTest.java | 27 +++++++-------
 .../DatabaseDiscoveryAlgorithmFactoryBean.java     | 12 +++---
 ...rovidedEncryptRuleConfigurationCheckerTest.java | 23 ++++++------
 .../EncryptRuleConfigurationCheckerTest.java       | 23 ++++++------
 .../factorybean/EncryptAlgorithmFactoryBean.java   | 13 ++++---
 ...writeSplittingRuleConfigurationCheckerTest.java | 23 ++++++------
 ...writeSplittingRuleConfigurationCheckerTest.java | 23 ++++++------
 .../ReplicaLoadBalanceAlgorithmFactoryBean.java    | 12 +++---
 .../factorybean/ShadowAlgorithmFactoryBean.java    | 12 +++---
 ...ovidedShardingRuleConfigurationCheckerTest.java | 43 +++++++++-------------
 .../KeyGenerateAlgorithmFactoryBean.java           | 12 +++---
 .../factorybean/ShardingAlgorithmFactoryBean.java  | 12 +++---
 .../rule/ShardingRuleBeanDefinitionParser.java     |  2 +-
 .../ShardingSphereAlgorithmFactoryBean.java        | 15 +-------
 ...hardingSphereAlgorithmBeanDefinitionParser.java |  4 +-
 .../ShardingSphereAlgorithmFixtureFactoryBean.java |  9 ++++-
 16 files changed, 131 insertions(+), 134 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/checker/DatabaseDiscoveryRuleConfigurationCheckerTest.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/checker/DatabaseDiscoveryRuleConfigurationCheckerTest.java
index 426d01c72b9..533408ed86d 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/checker/DatabaseDiscoveryRuleConfigurationCheckerTest.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-core/src/test/java/org/apache/shardingsphere/dbdiscovery/checker/DatabaseDiscoveryRuleConfigurationCheckerTest.java
@@ -20,37 +20,35 @@ package org.apache.shardingsphere.dbdiscovery.checker;
 import org.apache.shardingsphere.dbdiscovery.api.config.DatabaseDiscoveryRuleConfiguration;
 import org.apache.shardingsphere.dbdiscovery.api.config.rule.DatabaseDiscoveryDataSourceRuleConfiguration;
 import org.apache.shardingsphere.infra.config.checker.RuleConfigurationChecker;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.type.ordered.OrderedSPIRegistry;
+import org.apache.shardingsphere.infra.config.checker.RuleConfigurationCheckerFactory;
 import org.junit.Test;
 
 import java.util.Collections;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 public final class DatabaseDiscoveryRuleConfigurationCheckerTest {
     
-    static {
-        ShardingSphereServiceLoader.register(RuleConfigurationChecker.class);
-    }
-    
     @SuppressWarnings({"rawtypes", "unchecked"})
     @Test
     public void assertValidCheck() {
         DatabaseDiscoveryRuleConfiguration config = getValidConfiguration();
-        RuleConfigurationChecker checker = OrderedSPIRegistry.getRegisteredServices(RuleConfigurationChecker.class, Collections.singletonList(config)).get(config);
-        assertThat(checker, instanceOf(DatabaseDiscoveryRuleConfigurationChecker.class));
-        checker.check("test", config);
+        Optional<RuleConfigurationChecker> checker = RuleConfigurationCheckerFactory.newInstance(config);
+        assertTrue(checker.isPresent());
+        assertThat(checker.get(), instanceOf(DatabaseDiscoveryRuleConfigurationChecker.class));
+        checker.get().check("test", config);
     }
     
     private DatabaseDiscoveryRuleConfiguration getValidConfiguration() {
         DatabaseDiscoveryRuleConfiguration result = mock(DatabaseDiscoveryRuleConfiguration.class);
         DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = mock(DatabaseDiscoveryDataSourceRuleConfiguration.class);
         when(dataSourceRuleConfig.getDiscoveryTypeName()).thenReturn("jdbc");
-        when(result.getDataSources()).thenReturn(Collections.singletonList(dataSourceRuleConfig));
+        when(result.getDataSources()).thenReturn(Collections.singleton(dataSourceRuleConfig));
         return result;
     }
     
@@ -58,16 +56,17 @@ public final class DatabaseDiscoveryRuleConfigurationCheckerTest {
     @Test(expected = IllegalStateException.class)
     public void assertInvalidCheck() {
         DatabaseDiscoveryRuleConfiguration config = getInvalidConfiguration();
-        RuleConfigurationChecker checker = OrderedSPIRegistry.getRegisteredServices(RuleConfigurationChecker.class, Collections.singletonList(config)).get(config);
-        assertThat(checker, instanceOf(DatabaseDiscoveryRuleConfigurationChecker.class));
-        checker.check("test", config);
+        Optional<RuleConfigurationChecker> checker = RuleConfigurationCheckerFactory.newInstance(config);
+        assertTrue(checker.isPresent());
+        assertThat(checker.get(), instanceOf(DatabaseDiscoveryRuleConfigurationChecker.class));
+        checker.get().check("test", config);
     }
     
     private DatabaseDiscoveryRuleConfiguration getInvalidConfiguration() {
         DatabaseDiscoveryRuleConfiguration result = mock(DatabaseDiscoveryRuleConfiguration.class);
         DatabaseDiscoveryDataSourceRuleConfiguration dataSourceRuleConfig = mock(DatabaseDiscoveryDataSourceRuleConfiguration.class);
         when(dataSourceRuleConfig.getDiscoveryTypeName()).thenReturn("");
-        when(result.getDataSources()).thenReturn(Collections.singletonList(dataSourceRuleConfig));
+        when(result.getDataSources()).thenReturn(Collections.singleton(dataSourceRuleConfig));
         return result;
     }
 }
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-namespace/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/namespace/factorybean/DatabaseDiscoveryAlgorithmFactoryBean.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-namespace/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/namespace/factorybean/DatabaseD [...]
index 0ce4ec845d6..0cbab1bd307 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-namespace/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/namespace/factorybean/DatabaseDiscoveryAlgorithmFactoryBean.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-spring/shardingsphere-db-discovery-spring-namespace/src/main/java/org/apache/shardingsphere/dbdiscovery/spring/namespace/factorybean/DatabaseDiscoveryAlgorithmFactoryBean.java
@@ -17,8 +17,9 @@
 
 package org.apache.shardingsphere.dbdiscovery.spring.namespace.factorybean;
 
+import org.apache.shardingsphere.dbdiscovery.factory.DatabaseDiscoveryProviderAlgorithmFactory;
 import org.apache.shardingsphere.dbdiscovery.spi.DatabaseDiscoveryProviderAlgorithm;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
 import org.apache.shardingsphere.spring.namespace.factorybean.ShardingSphereAlgorithmFactoryBean;
 
 import java.util.Properties;
@@ -28,11 +29,12 @@ import java.util.Properties;
  */
 public final class DatabaseDiscoveryAlgorithmFactoryBean extends ShardingSphereAlgorithmFactoryBean<DatabaseDiscoveryProviderAlgorithm> {
     
-    static {
-        ShardingSphereServiceLoader.register(DatabaseDiscoveryProviderAlgorithm.class);
+    public DatabaseDiscoveryAlgorithmFactoryBean(final String type, final Properties props) {
+        super(type, props, DatabaseDiscoveryProviderAlgorithm.class);
     }
     
-    public DatabaseDiscoveryAlgorithmFactoryBean(final String type, final Properties props) {
-        super(DatabaseDiscoveryProviderAlgorithm.class, type, props);
+    @Override
+    public DatabaseDiscoveryProviderAlgorithm getObject() {
+        return DatabaseDiscoveryProviderAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration(getType(), getProps()));
     }
 }
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/checker/AlgorithmProvidedEncryptRuleConfigurationCheckerTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/checker/AlgorithmProvidedEncryptRuleConfigurationCheckerTest.java
index ece6855a68d..07996b89d1f 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/checker/AlgorithmProvidedEncryptRuleConfigurationCheckerTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/checker/AlgorithmProvidedEncryptRuleConfigurationCheckerTest.java
@@ -20,30 +20,28 @@ package org.apache.shardingsphere.encrypt.checker;
 import org.apache.shardingsphere.encrypt.algorithm.config.AlgorithmProvidedEncryptRuleConfiguration;
 import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
 import org.apache.shardingsphere.infra.config.checker.RuleConfigurationChecker;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.type.ordered.OrderedSPIRegistry;
+import org.apache.shardingsphere.infra.config.checker.RuleConfigurationCheckerFactory;
 import org.junit.Test;
 
 import java.util.Collections;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 public final class AlgorithmProvidedEncryptRuleConfigurationCheckerTest {
     
-    static {
-        ShardingSphereServiceLoader.register(RuleConfigurationChecker.class);
-    }
-    
     @SuppressWarnings({"rawtypes", "unchecked"})
     @Test
     public void assertValidCheck() {
         AlgorithmProvidedEncryptRuleConfiguration config = createValidConfiguration();
-        RuleConfigurationChecker checker = OrderedSPIRegistry.getRegisteredServices(RuleConfigurationChecker.class, Collections.singleton(config)).get(config);
-        assertThat(checker, instanceOf(AlgorithmProvidedEncryptRuleConfigurationChecker.class));
-        checker.check("test", config);
+        Optional<RuleConfigurationChecker> checker = RuleConfigurationCheckerFactory.newInstance(config);
+        assertTrue(checker.isPresent());
+        assertThat(checker.get(), instanceOf(AlgorithmProvidedEncryptRuleConfigurationChecker.class));
+        checker.get().check("test", config);
     }
     
     private AlgorithmProvidedEncryptRuleConfiguration createValidConfiguration() {
@@ -57,9 +55,10 @@ public final class AlgorithmProvidedEncryptRuleConfigurationCheckerTest {
     @Test(expected = IllegalStateException.class)
     public void assertInvalidCheck() {
         AlgorithmProvidedEncryptRuleConfiguration config = createInvalidConfiguration();
-        RuleConfigurationChecker checker = OrderedSPIRegistry.getRegisteredServices(RuleConfigurationChecker.class, Collections.singleton(config)).get(config);
-        assertThat(checker, instanceOf(AlgorithmProvidedEncryptRuleConfigurationChecker.class));
-        checker.check("test", config);
+        Optional<RuleConfigurationChecker> checker = RuleConfigurationCheckerFactory.newInstance(config);
+        assertTrue(checker.isPresent());
+        assertThat(checker.get(), instanceOf(AlgorithmProvidedEncryptRuleConfigurationChecker.class));
+        checker.get().check("test", config);
     }
     
     private AlgorithmProvidedEncryptRuleConfiguration createInvalidConfiguration() {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationCheckerTest.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationCheckerTest.java
index 41b5123cc28..d4b4baf2eab 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationCheckerTest.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/test/java/org/apache/shardingsphere/encrypt/checker/EncryptRuleConfigurationCheckerTest.java
@@ -20,30 +20,28 @@ package org.apache.shardingsphere.encrypt.checker;
 import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
 import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
 import org.apache.shardingsphere.infra.config.checker.RuleConfigurationChecker;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.type.ordered.OrderedSPIRegistry;
+import org.apache.shardingsphere.infra.config.checker.RuleConfigurationCheckerFactory;
 import org.junit.Test;
 
 import java.util.Collections;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 public final class EncryptRuleConfigurationCheckerTest {
     
-    static {
-        ShardingSphereServiceLoader.register(RuleConfigurationChecker.class);
-    }
-    
     @SuppressWarnings({"rawtypes", "unchecked"})
     @Test
     public void assertValidCheck() {
         EncryptRuleConfiguration config = createValidConfiguration();
-        RuleConfigurationChecker checker = OrderedSPIRegistry.getRegisteredServices(RuleConfigurationChecker.class, Collections.singleton(config)).get(config);
-        assertThat(checker, instanceOf(EncryptRuleConfigurationChecker.class));
-        checker.check("test", config);
+        Optional<RuleConfigurationChecker> checker = RuleConfigurationCheckerFactory.newInstance(config);
+        assertTrue(checker.isPresent());
+        assertThat(checker.get(), instanceOf(EncryptRuleConfigurationChecker.class));
+        checker.get().check("test", config);
     }
     
     private EncryptRuleConfiguration createValidConfiguration() {
@@ -57,9 +55,10 @@ public final class EncryptRuleConfigurationCheckerTest {
     @Test(expected = IllegalStateException.class)
     public void assertInvalidCheck() {
         EncryptRuleConfiguration config = createInvalidConfiguration();
-        RuleConfigurationChecker checker = OrderedSPIRegistry.getRegisteredServices(RuleConfigurationChecker.class, Collections.singleton(config)).get(config);
-        assertThat(checker, instanceOf(EncryptRuleConfigurationChecker.class));
-        checker.check("test", config);
+        Optional<RuleConfigurationChecker> checker = RuleConfigurationCheckerFactory.newInstance(config);
+        assertTrue(checker.isPresent());
+        assertThat(checker.get(), instanceOf(EncryptRuleConfigurationChecker.class));
+        checker.get().check("test", config);
     }
     
     private EncryptRuleConfiguration createInvalidConfiguration() {
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/main/java/org/apache/shardingsphere/encrypt/spring/namespace/factorybean/EncryptAlgorithmFactoryBean.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/main/java/org/apache/shardingsphere/encrypt/spring/namespace/factorybean/EncryptAlgorithmFactoryBean.java
index 36973568987..b3f5c95748a 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/main/java/org/apache/shardingsphere/encrypt/spring/namespace/factorybean/EncryptAlgorithmFactoryBean.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-spring/shardingsphere-encrypt-spring-namespace/src/main/java/org/apache/shardingsphere/encrypt/spring/namespace/factorybean/EncryptAlgorithmFactoryBean.java
@@ -17,8 +17,9 @@
 
 package org.apache.shardingsphere.encrypt.spring.namespace.factorybean;
 
+import org.apache.shardingsphere.encrypt.factory.EncryptAlgorithmFactory;
 import org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
 import org.apache.shardingsphere.spring.namespace.factorybean.ShardingSphereAlgorithmFactoryBean;
 
 import java.util.Properties;
@@ -26,13 +27,15 @@ import java.util.Properties;
 /**
  * Encrypt algorithm factory bean.
  */
+@SuppressWarnings("rawtypes")
 public final class EncryptAlgorithmFactoryBean extends ShardingSphereAlgorithmFactoryBean<EncryptAlgorithm> {
     
-    static {
-        ShardingSphereServiceLoader.register(EncryptAlgorithm.class);
+    public EncryptAlgorithmFactoryBean(final String type, final Properties props) {
+        super(type, props, EncryptAlgorithm.class);
     }
     
-    public EncryptAlgorithmFactoryBean(final String type, final Properties props) {
-        super(EncryptAlgorithm.class, type, props);
+    @Override
+    public EncryptAlgorithm<?, ?> getObject() {
+        return EncryptAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration(getType(), getProps()));
     }
 }
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/AlgorithmProvidedReadwriteSplittingRuleConfigurationCheckerTest.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/AlgorithmProvidedReadwriteSplittingRuleConfigurationCheckerTest.java
index 2dfc8427611..3b9edc265ae 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/AlgorithmProvidedReadwriteSplittingRuleConfigurationCheckerTest.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/AlgorithmProvidedReadwriteSplittingRuleConfigurationCheckerTest.java
@@ -18,33 +18,31 @@
 package org.apache.shardingsphere.readwritesplitting.checker;
 
 import org.apache.shardingsphere.infra.config.checker.RuleConfigurationChecker;
+import org.apache.shardingsphere.infra.config.checker.RuleConfigurationCheckerFactory;
 import org.apache.shardingsphere.readwritesplitting.algorithm.config.AlgorithmProvidedReadwriteSplittingRuleConfiguration;
 import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.type.ordered.OrderedSPIRegistry;
 import org.junit.Test;
 
 import java.util.Collections;
+import java.util.Optional;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 public final class AlgorithmProvidedReadwriteSplittingRuleConfigurationCheckerTest {
     
-    static {
-        ShardingSphereServiceLoader.register(RuleConfigurationChecker.class);
-    }
-    
     @SuppressWarnings({"rawtypes", "unchecked"})
     @Test
     public void assertValidCheck() {
         AlgorithmProvidedReadwriteSplittingRuleConfiguration config = createValidConfiguration();
-        RuleConfigurationChecker checker = OrderedSPIRegistry.getRegisteredServices(RuleConfigurationChecker.class, Collections.singleton(config)).get(config);
-        assertThat(checker, instanceOf(AlgorithmProvidedReadwriteSplittingRuleConfigurationChecker.class));
-        checker.check("test", config);
+        Optional<RuleConfigurationChecker> checker = RuleConfigurationCheckerFactory.newInstance(config);
+        assertTrue(checker.isPresent());
+        assertThat(checker.get(), instanceOf(AlgorithmProvidedReadwriteSplittingRuleConfigurationChecker.class));
+        checker.get().check("test", config);
     }
     
     private AlgorithmProvidedReadwriteSplittingRuleConfiguration createValidConfiguration() {
@@ -66,9 +64,10 @@ public final class AlgorithmProvidedReadwriteSplittingRuleConfigurationCheckerTe
     @Test(expected = IllegalStateException.class)
     public void assertInValidCheck() {
         AlgorithmProvidedReadwriteSplittingRuleConfiguration config = createInvalidConfiguration();
-        RuleConfigurationChecker checker = OrderedSPIRegistry.getRegisteredServices(RuleConfigurationChecker.class, Collections.singleton(config)).get(config);
-        assertThat(checker, instanceOf(AlgorithmProvidedReadwriteSplittingRuleConfigurationChecker.class));
-        checker.check("test", config);
+        Optional<RuleConfigurationChecker> checker = RuleConfigurationCheckerFactory.newInstance(config);
+        assertTrue(checker.isPresent());
+        assertThat(checker.get(), instanceOf(AlgorithmProvidedReadwriteSplittingRuleConfigurationChecker.class));
+        checker.get().check("test", config);
     }
     
     private AlgorithmProvidedReadwriteSplittingRuleConfiguration createInvalidConfiguration() {
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java
index 9ed20d7a8bb..3588cef34c0 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/test/java/org/apache/shardingsphere/readwritesplitting/checker/ReadwriteSplittingRuleConfigurationCheckerTest.java
@@ -18,33 +18,31 @@
 package org.apache.shardingsphere.readwritesplitting.checker;
 
 import org.apache.shardingsphere.infra.config.checker.RuleConfigurationChecker;
+import org.apache.shardingsphere.infra.config.checker.RuleConfigurationCheckerFactory;
 import org.apache.shardingsphere.readwritesplitting.api.ReadwriteSplittingRuleConfiguration;
 import org.apache.shardingsphere.readwritesplitting.api.rule.ReadwriteSplittingDataSourceRuleConfiguration;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.type.ordered.OrderedSPIRegistry;
 import org.junit.Test;
 
 import java.util.Collections;
+import java.util.Optional;
 import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 public final class ReadwriteSplittingRuleConfigurationCheckerTest {
     
-    static {
-        ShardingSphereServiceLoader.register(RuleConfigurationChecker.class);
-    }
-    
     @SuppressWarnings({"rawtypes", "unchecked"})
     @Test
     public void assertValidCheck() {
         ReadwriteSplittingRuleConfiguration config = createValidConfiguration();
-        RuleConfigurationChecker checker = OrderedSPIRegistry.getRegisteredServices(RuleConfigurationChecker.class, Collections.singleton(config)).get(config);
-        assertThat(checker, instanceOf(ReadwriteSplittingRuleConfigurationChecker.class));
-        checker.check("test", config);
+        Optional<RuleConfigurationChecker> checker = RuleConfigurationCheckerFactory.newInstance(config);
+        assertTrue(checker.isPresent());
+        assertThat(checker.get(), instanceOf(ReadwriteSplittingRuleConfigurationChecker.class));
+        checker.get().check("test", config);
     }
     
     private ReadwriteSplittingRuleConfiguration createValidConfiguration() {
@@ -66,9 +64,10 @@ public final class ReadwriteSplittingRuleConfigurationCheckerTest {
     @Test(expected = IllegalStateException.class)
     public void assertInvalidCheck() {
         ReadwriteSplittingRuleConfiguration config = createInvalidConfiguration();
-        RuleConfigurationChecker checker = OrderedSPIRegistry.getRegisteredServices(RuleConfigurationChecker.class, Collections.singleton(config)).get(config);
-        assertThat(checker, instanceOf(ReadwriteSplittingRuleConfigurationChecker.class));
-        checker.check("test", config);
+        Optional<RuleConfigurationChecker> checker = RuleConfigurationCheckerFactory.newInstance(config);
+        assertTrue(checker.isPresent());
+        assertThat(checker.get(), instanceOf(ReadwriteSplittingRuleConfigurationChecker.class));
+        checker.get().check("test", config);
     }
     
     private ReadwriteSplittingRuleConfiguration createInvalidConfiguration() {
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-spring/shardingsphere-readwrite-splitting-spring-namespace/src/main/java/org/apache/shardingsphere/readwritesplitting/spring/namespace/factorybean/ReplicaLoadBalanceAlgorithmFactoryBean.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-spring/shardingsphere-readwrite-splitting-spring-namespace/src/main/java/org/apache/shardingsphere/ [...]
index a6be8cfdad7..95a29e054dc 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-spring/shardingsphere-readwrite-splitting-spring-namespace/src/main/java/org/apache/shardingsphere/readwritesplitting/spring/namespace/factorybean/ReplicaLoadBalanceAlgorithmFactoryBean.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-spring/shardingsphere-readwrite-splitting-spring-namespace/src/main/java/org/apache/shardingsphere/readwritesplitting/spring/namespace/factorybean/ReplicaLoadBalanceAlgorithmFactoryBean.java
@@ -17,8 +17,9 @@
 
 package org.apache.shardingsphere.readwritesplitting.spring.namespace.factorybean;
 
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.readwritesplitting.factory.ReplicaLoadBalanceAlgorithmFactory;
 import org.apache.shardingsphere.readwritesplitting.spi.ReplicaLoadBalanceAlgorithm;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.spring.namespace.factorybean.ShardingSphereAlgorithmFactoryBean;
 
 import java.util.Properties;
@@ -28,11 +29,12 @@ import java.util.Properties;
  */
 public final class ReplicaLoadBalanceAlgorithmFactoryBean extends ShardingSphereAlgorithmFactoryBean<ReplicaLoadBalanceAlgorithm> {
     
-    static {
-        ShardingSphereServiceLoader.register(ReplicaLoadBalanceAlgorithm.class);
+    public ReplicaLoadBalanceAlgorithmFactoryBean(final String type, final Properties props) {
+        super(type, props, ReplicaLoadBalanceAlgorithm.class);
     }
     
-    public ReplicaLoadBalanceAlgorithmFactoryBean(final String type, final Properties props) {
-        super(ReplicaLoadBalanceAlgorithm.class, type, props);
+    @Override
+    public ReplicaLoadBalanceAlgorithm getObject() {
+        return ReplicaLoadBalanceAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration(getType(), getProps()));
     }
 }
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/factorybean/ShadowAlgorithmFactoryBean.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/factorybean/ShadowAlgorithmFactoryBean.java
index 2ee57cb112e..5072db2f14a 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/factorybean/ShadowAlgorithmFactoryBean.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/factorybean/ShadowAlgorithmFactoryBean.java
@@ -17,8 +17,9 @@
 
 package org.apache.shardingsphere.shadow.spring.namespace.factorybean;
 
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.shadow.factory.ShadowAlgorithmFactory;
 import org.apache.shardingsphere.shadow.spi.ShadowAlgorithm;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.spring.namespace.factorybean.ShardingSphereAlgorithmFactoryBean;
 
 import java.util.Properties;
@@ -28,11 +29,12 @@ import java.util.Properties;
  */
 public final class ShadowAlgorithmFactoryBean extends ShardingSphereAlgorithmFactoryBean<ShadowAlgorithm> {
     
-    static {
-        ShardingSphereServiceLoader.register(ShadowAlgorithm.class);
+    public ShadowAlgorithmFactoryBean(final String type, final Properties props) {
+        super(type, props, ShadowAlgorithm.class);
     }
     
-    public ShadowAlgorithmFactoryBean(final String type, final Properties props) {
-        super(ShadowAlgorithm.class, type, props);
+    @Override
+    public ShadowAlgorithm getObject() {
+        return ShadowAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration(getType(), getProps()));
     }
 }
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/checker/AlgorithmProvidedShardingRuleConfigurationCheckerTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/checker/AlgorithmProvidedShardingRuleConfigurationCheckerTest.java
index 67ceef95e01..5fa3905ff65 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/checker/AlgorithmProvidedShardingRuleConfigurationCheckerTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/checker/AlgorithmProvidedShardingRuleConfigurationCheckerTest.java
@@ -18,53 +18,46 @@
 package org.apache.shardingsphere.sharding.checker;
 
 import org.apache.shardingsphere.infra.config.checker.RuleConfigurationChecker;
+import org.apache.shardingsphere.infra.config.checker.RuleConfigurationCheckerFactory;
 import org.apache.shardingsphere.sharding.algorithm.config.AlgorithmProvidedShardingRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.type.ordered.OrderedSPIRegistry;
 import org.junit.Test;
 
 import java.util.Collections;
+import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 public final class AlgorithmProvidedShardingRuleConfigurationCheckerTest {
     
-    static {
-        ShardingSphereServiceLoader.register(RuleConfigurationChecker.class);
-    }
-    
     @SuppressWarnings({"rawtypes", "unchecked"})
     @Test
     public void assertCheckPass() {
-        ShardingStrategyConfiguration strategyConfiguration = mock(ShardingStrategyConfiguration.class);
-        ShardingTableRuleConfiguration ruleConfiguration = mock(ShardingTableRuleConfiguration.class);
-        ShardingAutoTableRuleConfiguration autoTableRuleConfiguration = mock(ShardingAutoTableRuleConfiguration.class);
-        AlgorithmProvidedShardingRuleConfiguration ruleConfig = mock(AlgorithmProvidedShardingRuleConfiguration.class);
-        when(ruleConfig.getTables()).thenReturn(Collections.singleton(ruleConfiguration));
-        when(ruleConfig.getAutoTables()).thenReturn(Collections.singleton(autoTableRuleConfiguration));
-        when(ruleConfig.getDefaultTableShardingStrategy()).thenReturn(strategyConfiguration);
-        RuleConfigurationChecker checker = OrderedSPIRegistry.getRegisteredServices(RuleConfigurationChecker.class, Collections.singleton(ruleConfig)).get(ruleConfig);
-        assertNotNull(checker);
-        assertThat(checker, instanceOf(AlgorithmProvidedShardingRuleConfigurationChecker.class));
-        checker.check("test", ruleConfig);
+        AlgorithmProvidedShardingRuleConfiguration config = mock(AlgorithmProvidedShardingRuleConfiguration.class);
+        when(config.getTables()).thenReturn(Collections.singleton(mock(ShardingTableRuleConfiguration.class)));
+        when(config.getAutoTables()).thenReturn(Collections.singleton(mock(ShardingAutoTableRuleConfiguration.class)));
+        when(config.getDefaultTableShardingStrategy()).thenReturn(mock(ShardingStrategyConfiguration.class));
+        Optional<RuleConfigurationChecker> checker = RuleConfigurationCheckerFactory.newInstance(config);
+        assertTrue(checker.isPresent());
+        assertThat(checker.get(), instanceOf(AlgorithmProvidedShardingRuleConfigurationChecker.class));
+        checker.get().check("test", config);
     }
     
     @SuppressWarnings({"rawtypes", "unchecked"})
     @Test(expected = IllegalStateException.class)
     public void assertCheckNoPass() {
-        AlgorithmProvidedShardingRuleConfiguration ruleConfig = mock(AlgorithmProvidedShardingRuleConfiguration.class);
-        when(ruleConfig.getTables()).thenReturn(Collections.emptyList());
-        when(ruleConfig.getAutoTables()).thenReturn(Collections.emptyList());
-        RuleConfigurationChecker checker = OrderedSPIRegistry.getRegisteredServices(RuleConfigurationChecker.class, Collections.singleton(ruleConfig)).get(ruleConfig);
-        assertNotNull(checker);
-        assertThat(checker, instanceOf(AlgorithmProvidedShardingRuleConfigurationChecker.class));
-        checker.check("test", ruleConfig);
+        AlgorithmProvidedShardingRuleConfiguration config = mock(AlgorithmProvidedShardingRuleConfiguration.class);
+        when(config.getTables()).thenReturn(Collections.emptyList());
+        when(config.getAutoTables()).thenReturn(Collections.emptyList());
+        Optional<RuleConfigurationChecker> checker = RuleConfigurationCheckerFactory.newInstance(config);
+        assertTrue(checker.isPresent());
+        assertThat(checker.get(), instanceOf(AlgorithmProvidedShardingRuleConfigurationChecker.class));
+        checker.get().check("test", config);
     }
 }
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/factorybean/KeyGenerateAlgorithmFactoryBean.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/factorybean/KeyGenerateAlgorithmFactoryBean.java
index 31712d2f064..d1dace1a65d 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/factorybean/KeyGenerateAlgorithmFactoryBean.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/factorybean/KeyGenerateAlgorithmFactoryBean.java
@@ -17,8 +17,9 @@
 
 package org.apache.shardingsphere.sharding.spring.namespace.factorybean;
 
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.sharding.factory.KeyGenerateAlgorithmFactory;
 import org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.spring.namespace.factorybean.ShardingSphereAlgorithmFactoryBean;
 
 import java.util.Properties;
@@ -28,11 +29,12 @@ import java.util.Properties;
  */
 public final class KeyGenerateAlgorithmFactoryBean extends ShardingSphereAlgorithmFactoryBean<KeyGenerateAlgorithm> {
     
-    static {
-        ShardingSphereServiceLoader.register(KeyGenerateAlgorithm.class);
+    public KeyGenerateAlgorithmFactoryBean(final String type, final Properties props) {
+        super(type, props, KeyGenerateAlgorithm.class);
     }
     
-    public KeyGenerateAlgorithmFactoryBean(final String type, final Properties props) {
-        super(KeyGenerateAlgorithm.class, type, props);
+    @Override
+    public KeyGenerateAlgorithm getObject() {
+        return KeyGenerateAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration(getType(), getProps()));
     }
 }
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/factorybean/ShardingAlgorithmFactoryBean.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/factorybean/ShardingAlgorithmFactoryBean.java
index a106ae18c55..0f480fa2f9c 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/factorybean/ShardingAlgorithmFactoryBean.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/factorybean/ShardingAlgorithmFactoryBean.java
@@ -17,8 +17,9 @@
 
 package org.apache.shardingsphere.sharding.spring.namespace.factorybean;
 
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.sharding.factory.ShardingAlgorithmFactory;
 import org.apache.shardingsphere.sharding.spi.ShardingAlgorithm;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.spring.namespace.factorybean.ShardingSphereAlgorithmFactoryBean;
 
 import java.util.Properties;
@@ -28,11 +29,12 @@ import java.util.Properties;
  */
 public final class ShardingAlgorithmFactoryBean extends ShardingSphereAlgorithmFactoryBean<ShardingAlgorithm> {
     
-    static {
-        ShardingSphereServiceLoader.register(ShardingAlgorithm.class);
+    public ShardingAlgorithmFactoryBean(final String type, final Properties props) {
+        super(type, props, ShardingAlgorithm.class);
     }
     
-    public ShardingAlgorithmFactoryBean(final String type, final Properties props) {
-        super(ShardingAlgorithm.class, type, props);
+    @Override
+    public ShardingAlgorithm getObject() {
+        return ShardingAlgorithmFactory.newInstance(new ShardingSphereAlgorithmConfiguration(getType(), getProps()));
     }
 }
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/parser/rule/ShardingRuleBeanDefinitionParser.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/parser/rule/ShardingRuleBeanDefinitionParser.java
index 77193ec43ed..63f08ea20b0 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/parser/rule/ShardingRuleBeanDefinitionParser.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-spring/shardingsphere-sharding-spring-namespace/src/main/java/org/apache/shardingsphere/sharding/spring/namespace/parser/rule/ShardingRuleBeanDefinitionParser.java
@@ -18,12 +18,12 @@
 package org.apache.shardingsphere.sharding.spring.namespace.parser.rule;
 
 import com.google.common.base.Strings;
+import org.apache.shardingsphere.sharding.algorithm.config.AlgorithmProvidedShardingRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
 import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
 import org.apache.shardingsphere.sharding.spring.namespace.factorybean.KeyGenerateAlgorithmFactoryBean;
 import org.apache.shardingsphere.sharding.spring.namespace.factorybean.ShardingAlgorithmFactoryBean;
 import org.apache.shardingsphere.sharding.spring.namespace.tag.rule.ShardingRuleBeanDefinitionTag;
-import org.apache.shardingsphere.sharding.algorithm.config.AlgorithmProvidedShardingRuleConfiguration;
 import org.apache.shardingsphere.spring.namespace.registry.ShardingSphereAlgorithmBeanRegistry;
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/factorybean/ShardingSphereAlgorithmFactoryBean.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/factorybean/ShardingSphereAlgorithmFactoryBean.java
index 22c3b60160d..1072e0209d5 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/factorybean/ShardingSphereAlgorithmFactoryBean.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/factorybean/ShardingSphereAlgorithmFactoryBean.java
@@ -20,8 +20,6 @@ package org.apache.shardingsphere.spring.namespace.factorybean;
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithm;
-import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmPostProcessor;
-import org.apache.shardingsphere.spi.type.typed.TypedSPIRegistry;
 import org.springframework.beans.factory.FactoryBean;
 
 import java.util.Properties;
@@ -30,23 +28,14 @@ import java.util.Properties;
  * ShardingSphere algorithm factory bean.
  */
 @RequiredArgsConstructor
+@Getter
 public abstract class ShardingSphereAlgorithmFactoryBean<T extends ShardingSphereAlgorithm> implements FactoryBean<T> {
     
-    @Getter
-    private final Class<T> objectType;
-    
     private final String type;
     
     private final Properties props;
     
-    @Override
-    public T getObject() {
-        T result = TypedSPIRegistry.getRegisteredService(objectType, type, props);
-        if (result instanceof ShardingSphereAlgorithmPostProcessor) {
-            ((ShardingSphereAlgorithmPostProcessor) result).init();
-        }
-        return result;
-    }
+    private final Class<T> objectType;
     
     @Override
     public final boolean isSingleton() {
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/parser/ShardingSphereAlgorithmBeanDefinitionParser.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/parser/ShardingSphereAlgorithmBeanDefinitionParser.java
index 87cd7a3b52b..c5f417ed331 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/parser/ShardingSphereAlgorithmBeanDefinitionParser.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/main/java/org/apache/shardingsphere/spring/namespace/parser/ShardingSphereAlgorithmBeanDefinitionParser.java
@@ -24,10 +24,10 @@ import org.apache.shardingsphere.infra.config.scope.SchemaRuleConfiguration;
 import org.apache.shardingsphere.readwritesplitting.algorithm.config.AlgorithmProvidedReadwriteSplittingRuleConfiguration;
 import org.apache.shardingsphere.shadow.algorithm.config.AlgorithmProvidedShadowRuleConfiguration;
 import org.apache.shardingsphere.sharding.algorithm.config.AlgorithmProvidedShardingRuleConfiguration;
-import org.apache.shardingsphere.spring.namespace.factorybean.ShardingSphereAlgorithmFactoryBean;
 import org.apache.shardingsphere.spring.namespace.tag.ShardingSphereAlgorithmBeanDefinitionTag;
 import org.springframework.beans.MutablePropertyValues;
 import org.springframework.beans.PropertyValue;
+import org.springframework.beans.factory.FactoryBean;
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.config.RuntimeBeanReference;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
@@ -46,7 +46,7 @@ import java.util.Properties;
 @RequiredArgsConstructor
 public final class ShardingSphereAlgorithmBeanDefinitionParser extends AbstractBeanDefinitionParser {
     
-    private final Class<? extends ShardingSphereAlgorithmFactoryBean<?>> beanClass;
+    private final Class<? extends FactoryBean<?>> beanClass;
     
     @Override
     protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/test/java/org/apache/shardingsphere/spring/namespace/fixture/factorybean/ShardingSphereAlgorithmFixtureFactoryBean.java b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/test/java/org/apache/shardingsphere/spring/namespace/fixture/factorybean/ShardingSphereAlgorithmFixtureF [...]
index 44c20b8cf9c..d11e67b84c1 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/test/java/org/apache/shardingsphere/spring/namespace/fixture/factorybean/ShardingSphereAlgorithmFixtureFactoryBean.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-spring-infra/shardingsphere-jdbc-spring-namespace-infra/src/test/java/org/apache/shardingsphere/spring/namespace/fixture/factorybean/ShardingSphereAlgorithmFixtureFactoryBean.java
@@ -17,6 +17,8 @@
 
 package org.apache.shardingsphere.spring.namespace.fixture.factorybean;
 
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;
+import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmFactory;
 import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.spring.namespace.factorybean.ShardingSphereAlgorithmFactoryBean;
 import org.apache.shardingsphere.spring.namespace.fixture.ShardingSphereFixtureAlgorithm;
@@ -30,6 +32,11 @@ public final class ShardingSphereAlgorithmFixtureFactoryBean extends ShardingSph
     }
     
     public ShardingSphereAlgorithmFixtureFactoryBean(final String type, final Properties props) {
-        super(ShardingSphereFixtureAlgorithm.class, type, props);
+        super(type, props, ShardingSphereFixtureAlgorithm.class);
+    }
+    
+    @Override
+    public ShardingSphereFixtureAlgorithm getObject() {
+        return ShardingSphereAlgorithmFactory.createAlgorithm(new ShardingSphereAlgorithmConfiguration(getType(), getProps()), ShardingSphereFixtureAlgorithm.class);
     }
 }