You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/05/03 14:11:04 UTC
[shardingsphere] branch master updated: Remove useless TypedSPIRegistry.getRegisteredServiceMetaDataMap() (#17303)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new b6eea0cb907 Remove useless TypedSPIRegistry.getRegisteredServiceMetaDataMap() (#17303)
b6eea0cb907 is described below
commit b6eea0cb90791e79d6c1699054fcdceb8cb049ba
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue May 3 22:10:57 2022 +0800
Remove useless TypedSPIRegistry.getRegisteredServiceMetaDataMap() (#17303)
* Remove useless TypedSPIRegistry.getRegisteredServiceMetaDataMap()
* Fix compile example error
---
.../spi/ShardingSphereServiceLoader.java | 24 +++++++++++-----------
.../spi/type/typed/TypedSPIRegistry.java | 14 -------------
2 files changed, 12 insertions(+), 26 deletions(-)
diff --git a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/ShardingSphereServiceLoader.java b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/ShardingSphereServiceLoader.java
index c653f4f7285..fca5d266a08 100644
--- a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/ShardingSphereServiceLoader.java
+++ b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/ShardingSphereServiceLoader.java
@@ -67,18 +67,6 @@ public final class ShardingSphereServiceLoader {
return null == serviceInterface.getAnnotation(SingletonSPI.class) ? newServiceInstances(serviceInterface) : getSingletonServiceInstances(serviceInterface);
}
- /**
- * Get singleton service instances.
- *
- * @param serviceInterface service interface
- * @param <T> type of service
- * @return service instances
- */
- @SuppressWarnings("unchecked")
- public static <T> Collection<T> getSingletonServiceInstances(final Class<T> serviceInterface) {
- return (Collection<T>) SERVICES.getOrDefault(serviceInterface, Collections.emptyList());
- }
-
/**
* New service instances.
*
@@ -109,4 +97,16 @@ public final class ShardingSphereServiceLoader {
throw new ServiceLoaderInstantiationException(clazz, ex);
}
}
+
+ /**
+ * Get singleton service instances.
+ *
+ * @param serviceInterface service interface
+ * @param <T> type of service
+ * @return service instances
+ */
+ @SuppressWarnings("unchecked")
+ public static <T> Collection<T> getSingletonServiceInstances(final Class<T> serviceInterface) {
+ return (Collection<T>) SERVICES.getOrDefault(serviceInterface, Collections.emptyList());
+ }
}
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 37cb8cf51a9..5616c730388 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
@@ -22,11 +22,8 @@ import lombok.NoArgsConstructor;
import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.spi.exception.ServiceProviderNotFoundException;
-import java.util.Map;
import java.util.Optional;
import java.util.Properties;
-import java.util.function.Function;
-import java.util.stream.Collectors;
/**
* Typed SPI registry.
@@ -115,15 +112,4 @@ public final class TypedSPIRegistry {
}
throw new ServiceProviderNotFoundException(spiClass, type);
}
-
- /**
- * Get registered service meta data map.
- *
- * @param spiClass stateless typed SPI class
- * @param <T> SPI class type
- * @return registered service meta data map, key is type name, value is meta data it self
- */
- public static <T extends TypedSPIMetadataAware & TypedSPI> Map<String, T> getRegisteredServiceMetaDataMap(final Class<T> spiClass) {
- return ShardingSphereServiceLoader.getSingletonServiceInstances(spiClass).stream().collect(Collectors.toMap(TypedSPI::getType, Function.identity()));
- }
}