You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/05/07 09:03:23 UTC
[shardingsphere] branch master updated: Use @SingletonSPI to replace StatelessTypedSPI (#17420)
This is an automated email from the ASF dual-hosted git repository.
panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 7456b3cdf73 Use @SingletonSPI to replace StatelessTypedSPI (#17420)
7456b3cdf73 is described below
commit 7456b3cdf73c7ee04da4fde2e22ea4ef8398f091
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat May 7 17:03:17 2022 +0800
Use @SingletonSPI to replace StatelessTypedSPI (#17420)
* Rename AlgorithmFixture
* Rename AlgorithmFixture
* Use @SingletonSPI to replace StatelessTypedSPI
---
.../destroyer/detector/DataSourcePoolActiveDetector.java | 6 ++++--
.../datasource/pool/metadata/DataSourcePoolMetaData.java | 6 ++++--
.../distsql/preprocess/RuleDefinitionAlterPreprocessor.java | 6 ++++--
.../shardingsphere/infra/distsql/update/RALUpdater.java | 6 ++++--
.../infra/distsql/update/RuleDefinitionUpdater.java | 6 ++++--
.../schema/loader/spi/DialectSchemaMetaDataLoader.java | 6 ++++--
.../mode/PersistRepositoryConfigurationYamlSwapper.java | 6 ++++--
.../infra/context/refresher/MetaDataRefresher.java | 6 ++++--
.../database/provider/DatetimeLoadingSQLProvider.java | 6 ++++--
.../engine/driver/jdbc/sane/SaneQueryResultEngine.java | 6 ++++--
.../executor/sql/prepare/driver/SQLExecutionUnitBuilder.java | 6 ++++--
.../context/parser/dialect/OptimizerSQLDialectBuilder.java | 6 ++++--
.../org/apache/shardingsphere/driver/state/DriverState.java | 6 ++++--
.../provider/natived/builder/StoragePrivilegeHandler.java | 6 ++++--
.../pipeline/spi/check/datasource/DataSourceChecker.java | 6 ++++--
.../data/pipeline/spi/ddlgenerator/DialectDDLGenerator.java | 6 ++++--
.../pipeline/spi/ingest/position/PositionInitializer.java | 6 ++++--
.../core/datasource/creator/PipelineDataSourceCreator.java | 6 ++++--
.../apache/shardingsphere/scaling/core/spi/ScalingEntry.java | 6 ++++--
.../mysql/ingest/column/value/MySQLDataTypeHandler.java | 6 ++++--
.../spi/TransactionConfigurationFileGenerator.java | 6 ++++--
.../transaction/xa/jta/connection/XAConnectionWrapper.java | 6 ++++--
.../xa/jta/datasource/properties/XADataSourceDefinition.java | 6 ++++--
.../shardingsphere/mode/manager/ContextManagerBuilder.java | 6 ++++--
.../statement/StatementMemoryStrictlyFetchSizeSetter.java | 6 ++++--
.../backend/response/header/query/QueryHeaderBuilder.java | 6 ++++--
.../text/admin/executor/DatabaseAdminExecutorFactory.java | 6 ++++--
.../proxy/frontend/state/impl/OKProxyState.java | 6 ++++--
.../shardingsphere/spi/type/typed/StatelessTypedSPI.java | 3 +++
.../shardingsphere/spi/type/typed/TypedSPIRegistry.java | 12 ++++++------
.../typed/fixture/stateless/StatelessTypedSPIFixture.java | 6 ++++--
31 files changed, 125 insertions(+), 64 deletions(-)
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/pool/destroyer/detector/DataSourcePoolActiveDetector.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/pool/destroyer/detector/DataSourcePoolActiveDetector.java
index 40826cc01b4..85ee8abe44d 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/pool/destroyer/detector/DataSourcePoolActiveDetector.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/pool/destroyer/detector/DataSourcePoolActiveDetector.java
@@ -17,15 +17,17 @@
package org.apache.shardingsphere.infra.datasource.pool.destroyer.detector;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.spi.type.required.RequiredSPI;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import javax.sql.DataSource;
/**
* Data source pool active detector.
*/
-public interface DataSourcePoolActiveDetector extends StatelessTypedSPI, RequiredSPI {
+@SingletonSPI
+public interface DataSourcePoolActiveDetector extends TypedSPI, RequiredSPI {
/**
* Whether contains active connection.
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/pool/metadata/DataSourcePoolMetaData.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/pool/metadata/DataSourcePoolMetaData.java
index b400f59925c..5c867eed5af 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/pool/metadata/DataSourcePoolMetaData.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/datasource/pool/metadata/DataSourcePoolMetaData.java
@@ -17,7 +17,8 @@
package org.apache.shardingsphere.infra.datasource.pool.metadata;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import java.util.Collection;
import java.util.Map;
@@ -25,7 +26,8 @@ import java.util.Map;
/**
* Data source pool meta data.
*/
-public interface DataSourcePoolMetaData extends StatelessTypedSPI {
+@SingletonSPI
+public interface DataSourcePoolMetaData extends TypedSPI {
/**
* Get default properties.
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessor.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessor.java
index b569df2008b..f5eb2b44c89 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessor.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/preprocess/RuleDefinitionAlterPreprocessor.java
@@ -18,7 +18,8 @@
package org.apache.shardingsphere.infra.distsql.preprocess;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
/**
@@ -27,7 +28,8 @@ import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
* @param <T> type of SQL statement
* @param <R> type of rule configuration
*/
-public interface RuleDefinitionAlterPreprocessor<T extends SQLStatement, R extends RuleConfiguration> extends StatelessTypedSPI {
+@SingletonSPI
+public interface RuleDefinitionAlterPreprocessor<T extends SQLStatement, R extends RuleConfiguration> extends TypedSPI {
/**
* Preprocess current rule configuration.
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RALUpdater.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RALUpdater.java
index 3f2d7c50677..a767bf92479 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RALUpdater.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RALUpdater.java
@@ -17,7 +17,8 @@
package org.apache.shardingsphere.infra.distsql.update;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
/**
@@ -25,7 +26,8 @@ import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
*
* @param <T> type of updatable RAL statement
*/
-public interface RALUpdater<T extends SQLStatement> extends StatelessTypedSPI {
+@SingletonSPI
+public interface RALUpdater<T extends SQLStatement> extends TypedSPI {
/**
* Execute update.
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RuleDefinitionUpdater.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RuleDefinitionUpdater.java
index c582be1e127..8a6f6e4a77f 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RuleDefinitionUpdater.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/distsql/update/RuleDefinitionUpdater.java
@@ -20,7 +20,8 @@ package org.apache.shardingsphere.infra.distsql.update;
import org.apache.shardingsphere.infra.config.RuleConfiguration;
import org.apache.shardingsphere.infra.distsql.exception.DistSQLException;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
/**
@@ -29,7 +30,8 @@ import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
* @param <T> type of SQL statement
* @param <R> type of rule configuration
*/
-public interface RuleDefinitionUpdater<T extends SQLStatement, R extends RuleConfiguration> extends StatelessTypedSPI {
+@SingletonSPI
+public interface RuleDefinitionUpdater<T extends SQLStatement, R extends RuleConfiguration> extends TypedSPI {
/**
* Check SQL statement.
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/spi/DialectSchemaMetaDataLoader.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/spi/DialectSchemaMetaDataLoader.java
index 4a8f3879a73..74b5b74e80f 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/spi/DialectSchemaMetaDataLoader.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/schema/loader/spi/DialectSchemaMetaDataLoader.java
@@ -19,7 +19,8 @@ package org.apache.shardingsphere.infra.metadata.schema.loader.spi;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.schema.model.SchemaMetaData;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import javax.sql.DataSource;
import java.sql.Connection;
@@ -31,7 +32,8 @@ import java.util.LinkedList;
/**
* Dialect schema meta data loader.
*/
-public interface DialectSchemaMetaDataLoader extends StatelessTypedSPI {
+@SingletonSPI
+public interface DialectSchemaMetaDataLoader extends TypedSPI {
/**
* Load schema meta data.
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapper.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapper.java
index d38b5daf855..978ceb2c816 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapper.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapper.java
@@ -20,12 +20,14 @@ package org.apache.shardingsphere.infra.yaml.config.swapper.mode;
import org.apache.shardingsphere.infra.config.mode.PersistRepositoryConfiguration;
import org.apache.shardingsphere.infra.yaml.config.pojo.mode.YamlPersistRepositoryConfiguration;
import org.apache.shardingsphere.infra.yaml.config.swapper.YamlConfigurationSwapper;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
/**
* Persist repository configuration YAML swapper.
*
* @param <T> type of persist repository configuration
*/
-public interface PersistRepositoryConfigurationYamlSwapper<T extends PersistRepositoryConfiguration> extends YamlConfigurationSwapper<YamlPersistRepositoryConfiguration, T>, StatelessTypedSPI {
+@SingletonSPI
+public interface PersistRepositoryConfigurationYamlSwapper<T extends PersistRepositoryConfiguration> extends YamlConfigurationSwapper<YamlPersistRepositoryConfiguration, T>, TypedSPI {
}
diff --git a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefresher.java b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefresher.java
index b03535babd1..274c66dcb93 100644
--- a/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefresher.java
+++ b/shardingsphere-infra/shardingsphere-infra-context/src/main/java/org/apache/shardingsphere/infra/context/refresher/MetaDataRefresher.java
@@ -21,7 +21,8 @@ import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.federation.optimizer.context.planner.OptimizerPlannerContext;
import org.apache.shardingsphere.infra.federation.optimizer.metadata.FederationDatabaseMetaData;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import java.sql.SQLException;
@@ -33,7 +34,8 @@ import java.util.Map;
*
* @param <T> type of SQL statement
*/
-public interface MetaDataRefresher<T extends SQLStatement> extends StatelessTypedSPI {
+@SingletonSPI
+public interface MetaDataRefresher<T extends SQLStatement> extends TypedSPI {
/**
* Refresh schema.
diff --git a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/provider/DatetimeLoadingSQLProvider.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/provider/DatetimeLoadingSQLProvider.java
index 62a85c6c59e..8de27ba4ab7 100644
--- a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/provider/DatetimeLoadingSQLProvider.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/provider/DatetimeLoadingSQLProvider.java
@@ -17,12 +17,14 @@
package org.apache.shardingsphere.datetime.database.provider;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
/**
* Datetime loading SQL provider.
*/
-public interface DatetimeLoadingSQLProvider extends StatelessTypedSPI {
+@SingletonSPI
+public interface DatetimeLoadingSQLProvider extends TypedSPI {
/**
* Get SQL for datetime loading.
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/jdbc/sane/SaneQueryResultEngine.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/jdbc/sane/SaneQueryResultEngine.java
index 67a579e6e7c..50b72842533 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/jdbc/sane/SaneQueryResultEngine.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/execute/engine/driver/jdbc/sane/SaneQueryResultEngine.java
@@ -18,7 +18,8 @@
package org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.sane;
import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import java.util.Optional;
@@ -26,7 +27,8 @@ import java.util.Optional;
/**
* Sane query result engine.
*/
-public interface SaneQueryResultEngine extends StatelessTypedSPI {
+@SingletonSPI
+public interface SaneQueryResultEngine extends TypedSPI {
/**
* Get sane query result.
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/SQLExecutionUnitBuilder.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/SQLExecutionUnitBuilder.java
index 5f9f387c138..aa0a62abc71 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/SQLExecutionUnitBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/sql/prepare/driver/SQLExecutionUnitBuilder.java
@@ -20,7 +20,8 @@ package org.apache.shardingsphere.infra.executor.sql.prepare.driver;
import org.apache.shardingsphere.infra.executor.sql.context.ExecutionUnit;
import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.DriverExecutionUnit;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import java.sql.SQLException;
@@ -32,7 +33,8 @@ import java.sql.SQLException;
* @param <C> type of resource connection
* @param <O> type of storage resource option
*/
-public interface SQLExecutionUnitBuilder<T extends DriverExecutionUnit<?>, M extends ExecutorStatementManager<C, ?, O>, C, O extends StorageResourceOption> extends StatelessTypedSPI {
+@SingletonSPI
+public interface SQLExecutionUnitBuilder<T extends DriverExecutionUnit<?>, M extends ExecutorStatementManager<C, ?, O>, C, O extends StorageResourceOption> extends TypedSPI {
/**
* Build SQL execution unit.
diff --git a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/context/parser/dialect/OptimizerSQLDialectBuilder.java b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/context/parser/dialect/OptimizerSQLDialectBuilder.java
index 58dac6f4e83..6ec48b137c3 100644
--- a/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/context/parser/dialect/OptimizerSQLDialectBuilder.java
+++ b/shardingsphere-infra/shardingsphere-infra-federation/shardingsphere-infra-federation-optimizer/src/main/java/org/apache/shardingsphere/infra/federation/optimizer/context/parser/dialect/OptimizerSQLDialectBuilder.java
@@ -17,15 +17,17 @@
package org.apache.shardingsphere.infra.federation.optimizer.context.parser.dialect;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.spi.type.required.RequiredSPI;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import java.util.Properties;
/**
* Optimizer SQL dialect properties builder.
*/
-public interface OptimizerSQLDialectBuilder extends StatelessTypedSPI, RequiredSPI {
+@SingletonSPI
+public interface OptimizerSQLDialectBuilder extends TypedSPI, RequiredSPI {
/**
* Build optimizer SQL dialect properties.
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/state/DriverState.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/state/DriverState.java
index 2bc5c9fedc8..14737e43d62 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/state/DriverState.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/state/DriverState.java
@@ -18,14 +18,16 @@
package org.apache.shardingsphere.driver.state;
import org.apache.shardingsphere.mode.manager.ContextManager;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import java.sql.Connection;
/**
* Driver state.
*/
-public interface DriverState extends StatelessTypedSPI {
+@SingletonSPI
+public interface DriverState extends TypedSPI {
/**
* Get connection.
diff --git a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeHandler.java b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeHandler.java
index bbb51be1abd..4b431a0ec57 100644
--- a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeHandler.java
+++ b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/StoragePrivilegeHandler.java
@@ -19,7 +19,8 @@ package org.apache.shardingsphere.authority.provider.natived.builder;
import org.apache.shardingsphere.authority.provider.natived.model.privilege.NativePrivileges;
import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import javax.sql.DataSource;
import java.sql.SQLException;
@@ -29,7 +30,8 @@ import java.util.Map;
/**
* Storage privilege handler.
*/
-public interface StoragePrivilegeHandler extends StatelessTypedSPI {
+@SingletonSPI
+public interface StoragePrivilegeHandler extends TypedSPI {
/**
* Differentiate users between storage and exterior.
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/check/datasource/DataSourceChecker.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/check/datasource/DataSourceChecker.java
index 337b4c4ca8a..49f570e07b3 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/check/datasource/DataSourceChecker.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/check/datasource/DataSourceChecker.java
@@ -18,7 +18,8 @@
package org.apache.shardingsphere.data.pipeline.spi.check.datasource;
import org.apache.shardingsphere.data.pipeline.api.config.TableNameSchemaNameMapping;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import javax.sql.DataSource;
import java.util.Collection;
@@ -26,7 +27,8 @@ import java.util.Collection;
/**
* Data source checker.
*/
-public interface DataSourceChecker extends StatelessTypedSPI {
+@SingletonSPI
+public interface DataSourceChecker extends TypedSPI {
/**
* Check data source connections.
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ddlgenerator/DialectDDLGenerator.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ddlgenerator/DialectDDLGenerator.java
index c8f4bb38c30..336cebadc4f 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ddlgenerator/DialectDDLGenerator.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ddlgenerator/DialectDDLGenerator.java
@@ -17,7 +17,8 @@
package org.apache.shardingsphere.data.pipeline.spi.ddlgenerator;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import javax.sql.DataSource;
import java.sql.SQLException;
@@ -25,7 +26,8 @@ import java.sql.SQLException;
/**
* Dialect DDL SQL generator.
*/
-public interface DialectDDLGenerator extends StatelessTypedSPI {
+@SingletonSPI
+public interface DialectDDLGenerator extends TypedSPI {
/**
* Generate DDL SQL.
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/position/PositionInitializer.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/position/PositionInitializer.java
index 81f40d722e4..2fc2154bfdf 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/position/PositionInitializer.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/spi/ingest/position/PositionInitializer.java
@@ -18,7 +18,8 @@
package org.apache.shardingsphere.data.pipeline.spi.ingest.position;
import org.apache.shardingsphere.data.pipeline.api.ingest.position.IngestPosition;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import javax.sql.DataSource;
import java.sql.SQLException;
@@ -26,7 +27,8 @@ import java.sql.SQLException;
/**
* Position initializer.
*/
-public interface PositionInitializer extends StatelessTypedSPI {
+@SingletonSPI
+public interface PositionInitializer extends TypedSPI {
/**
* Init position by data source.
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/PipelineDataSourceCreator.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/PipelineDataSourceCreator.java
index f1667550178..a4631b61938 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/PipelineDataSourceCreator.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/PipelineDataSourceCreator.java
@@ -17,7 +17,8 @@
package org.apache.shardingsphere.data.pipeline.core.datasource.creator;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import javax.sql.DataSource;
import java.sql.SQLException;
@@ -25,7 +26,8 @@ import java.sql.SQLException;
/**
* Pipeline data source creator.
*/
-public interface PipelineDataSourceCreator extends StatelessTypedSPI {
+@SingletonSPI
+public interface PipelineDataSourceCreator extends TypedSPI {
/**
* Create pipeline data source.
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/scaling/core/spi/ScalingEntry.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/scaling/core/spi/ScalingEntry.java
index 56ee3c26ed4..d00a3168ddf 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/scaling/core/spi/ScalingEntry.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/scaling/core/spi/ScalingEntry.java
@@ -21,12 +21,14 @@ import org.apache.shardingsphere.data.pipeline.spi.importer.Importer;
import org.apache.shardingsphere.data.pipeline.spi.ingest.dumper.IncrementalDumper;
import org.apache.shardingsphere.data.pipeline.spi.ingest.dumper.InventoryDumper;
import org.apache.shardingsphere.scaling.core.job.check.EnvironmentChecker;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
/**
* Scaling entry.
*/
-public interface ScalingEntry extends StatelessTypedSPI {
+@SingletonSPI
+public interface ScalingEntry extends TypedSPI {
/**
* Get inventory dumper type.
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLDataTypeHandler.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLDataTypeHandler.java
index 6d317f18266..5212a4352ad 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLDataTypeHandler.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/column/value/MySQLDataTypeHandler.java
@@ -17,14 +17,16 @@
package org.apache.shardingsphere.data.pipeline.mysql.ingest.column.value;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import java.io.Serializable;
/**
* MySQL data type handler.
*/
-public interface MySQLDataTypeHandler extends StatelessTypedSPI {
+@SingletonSPI
+public interface MySQLDataTypeHandler extends TypedSPI {
/**
* Handle column value.
diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/spi/TransactionConfigurationFileGenerator.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/spi/TransactionConfigurationFileGenerator.java
index 4a1ba03c2d7..25a30eddf25 100644
--- a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/spi/TransactionConfigurationFileGenerator.java
+++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/spi/TransactionConfigurationFileGenerator.java
@@ -19,14 +19,16 @@ package org.apache.shardingsphere.transaction.spi;
import org.apache.shardingsphere.infra.config.database.DatabaseConfiguration;
import org.apache.shardingsphere.infra.instance.InstanceContext;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import java.util.Properties;
/**
* Transaction configuration file generator.
*/
-public interface TransactionConfigurationFileGenerator extends StatelessTypedSPI {
+@SingletonSPI
+public interface TransactionConfigurationFileGenerator extends TypedSPI {
/**
* Generate transaction configuration file.
diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/XAConnectionWrapper.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/XAConnectionWrapper.java
index e9adc905593..25b20dcdd05 100644
--- a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/XAConnectionWrapper.java
+++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/connection/XAConnectionWrapper.java
@@ -17,7 +17,8 @@
package org.apache.shardingsphere.transaction.xa.jta.connection;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import javax.sql.XAConnection;
import javax.sql.XADataSource;
@@ -27,7 +28,8 @@ import java.sql.SQLException;
/**
* XA connection wrapper.
*/
-public interface XAConnectionWrapper extends StatelessTypedSPI {
+@SingletonSPI
+public interface XAConnectionWrapper extends TypedSPI {
/**
* Wrap a normal connection to XA connection.
diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/XADataSourceDefinition.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/propert [...]
index cc917824d74..f1d8beff6b6 100644
--- a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/XADataSourceDefinition.java
+++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/properties/XADataSourceDefinition.java
@@ -17,14 +17,16 @@
package org.apache.shardingsphere.transaction.xa.jta.datasource.properties;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import java.util.Collection;
/**
* XA data source definition.
*/
-public interface XADataSourceDefinition extends StatelessTypedSPI {
+@SingletonSPI
+public interface XADataSourceDefinition extends TypedSPI {
/**
* Get XA driver class names.
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilder.java b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilder.java
index b52fe96a84a..9ff26d79cba 100644
--- a/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilder.java
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/main/java/org/apache/shardingsphere/mode/manager/ContextManagerBuilder.java
@@ -17,15 +17,17 @@
package org.apache.shardingsphere.mode.manager;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.spi.type.required.RequiredSPI;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import java.sql.SQLException;
/**
* Context manager builder.
*/
-public interface ContextManagerBuilder extends StatelessTypedSPI, RequiredSPI {
+@SingletonSPI
+public interface ContextManagerBuilder extends TypedSPI, RequiredSPI {
/**
* Build context manager.
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/StatementMemoryStrictlyFetchSizeSetter.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/StatementMemoryStrictlyFetchSizeSetter.java
index 5c3202e6aa2..9509df9efe8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/StatementMemoryStrictlyFetchSizeSetter.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/jdbc/statement/StatementMemoryStrictlyFetchSizeSetter.java
@@ -17,7 +17,8 @@
package org.apache.shardingsphere.proxy.backend.communication.jdbc.statement;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import java.sql.SQLException;
import java.sql.Statement;
@@ -25,7 +26,8 @@ import java.sql.Statement;
/**
* Statement memory strictly fetch size setter.
*/
-public interface StatementMemoryStrictlyFetchSizeSetter extends StatelessTypedSPI {
+@SingletonSPI
+public interface StatementMemoryStrictlyFetchSizeSetter extends TypedSPI {
/**
* Set fetch size.
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/header/query/QueryHeaderBuilder.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/header/query/QueryHeaderBuilder.java
index 63006573527..af88a1c95bd 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/header/query/QueryHeaderBuilder.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/response/header/query/QueryHeaderBuilder.java
@@ -21,15 +21,17 @@ import org.apache.commons.lang3.concurrent.LazyInitializer;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResultMetaData;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.rule.identifier.type.DataNodeContainedRule;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
import org.apache.shardingsphere.spi.type.required.RequiredSPI;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import java.sql.SQLException;
/**
* Query header builder.
*/
-public interface QueryHeaderBuilder extends StatelessTypedSPI, RequiredSPI {
+@SingletonSPI
+public interface QueryHeaderBuilder extends TypedSPI, RequiredSPI {
/**
* Build query header.
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/DatabaseAdminExecutorFactory.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/DatabaseAdminExecutorFactory.java
index d74997b374f..c74b522b4f7 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/DatabaseAdminExecutorFactory.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/executor/DatabaseAdminExecutorFactory.java
@@ -18,14 +18,16 @@
package org.apache.shardingsphere.proxy.backend.text.admin.executor;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
import java.util.Optional;
/**
* Database admin executor factory.
*/
-public interface DatabaseAdminExecutorFactory extends StatelessTypedSPI {
+@SingletonSPI
+public interface DatabaseAdminExecutorFactory extends TypedSPI {
/**
* Create an instance of database admin executor,
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
index c41808554c2..59836668ea4 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/state/impl/OKProxyState.java
@@ -18,10 +18,12 @@
package org.apache.shardingsphere.proxy.frontend.state.impl;
import org.apache.shardingsphere.proxy.frontend.state.ProxyState;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
/**
* OK proxy state.
*/
-public interface OKProxyState extends ProxyState, StatelessTypedSPI {
+@SingletonSPI
+public interface OKProxyState extends ProxyState, TypedSPI {
}
diff --git a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/StatelessTypedSPI.java b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/StatelessTypedSPI.java
index c630bb05c0c..c247beda08e 100644
--- a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/StatelessTypedSPI.java
+++ b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/StatelessTypedSPI.java
@@ -17,8 +17,11 @@
package org.apache.shardingsphere.spi.type.typed;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+
/**
* Stateless typed SPI.
*/
+@SingletonSPI
public interface StatelessTypedSPI extends TypedSPI {
}
diff --git a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java
index b0fba8f1360..d48a57c11cd 100644
--- a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java
+++ b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/typed/TypedSPIRegistry.java
@@ -34,13 +34,13 @@ public final class TypedSPIRegistry {
/**
* Find registered service.
*
- * @param spiClass stateless typed SPI class
+ * @param spiClass typed SPI class
* @param type type
* @param <T> SPI class type
* @return registered service
*/
- public static <T extends StatelessTypedSPI> Optional<T> findRegisteredService(final Class<T> spiClass, final String type) {
- for (T each : ShardingSphereServiceLoader.getSingletonServiceInstances(spiClass)) {
+ public static <T extends TypedSPI> Optional<T> findRegisteredService(final Class<T> spiClass, final String type) {
+ for (T each : ShardingSphereServiceLoader.getServiceInstances(spiClass)) {
if (matchesType(type, each)) {
return Optional.of(each);
}
@@ -58,7 +58,7 @@ public final class TypedSPIRegistry {
* @return registered service
*/
public static <T extends StatefulTypedSPI> Optional<T> findRegisteredService(final Class<T> spiClass, final String type, final Properties props) {
- for (T each : ShardingSphereServiceLoader.newServiceInstances(spiClass)) {
+ for (T each : ShardingSphereServiceLoader.getServiceInstances(spiClass)) {
if (matchesType(type, each)) {
// TODO for contains judge only, should fix here
if (null != props && !props.isEmpty()) {
@@ -86,12 +86,12 @@ public final class TypedSPIRegistry {
/**
* Get registered service.
*
- * @param spiClass stateless typed SPI class
+ * @param spiClass typed SPI class
* @param type type
* @param <T> SPI class type
* @return registered service
*/
- public static <T extends StatelessTypedSPI> T getRegisteredService(final Class<T> spiClass, final String type) {
+ public static <T extends TypedSPI> T getRegisteredService(final Class<T> spiClass, final String type) {
Optional<T> result = findRegisteredService(spiClass, type);
if (result.isPresent()) {
return result.get();
diff --git a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/typed/fixture/stateless/StatelessTypedSPIFixture.java b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/typed/fixture/stateless/StatelessTypedSPIFixture.java
index 20d52745501..053a8d5df4f 100644
--- a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/typed/fixture/stateless/StatelessTypedSPIFixture.java
+++ b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/typed/fixture/stateless/StatelessTypedSPIFixture.java
@@ -17,7 +17,9 @@
package org.apache.shardingsphere.spi.type.typed.fixture.stateless;
-import org.apache.shardingsphere.spi.type.typed.StatelessTypedSPI;
+import org.apache.shardingsphere.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.spi.type.typed.TypedSPI;
-public interface StatelessTypedSPIFixture extends StatelessTypedSPI {
+@SingletonSPI
+public interface StatelessTypedSPIFixture extends TypedSPI {
}