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/11 14:37:59 UTC

[shardingsphere] branch master updated: Remove useless SingletonSPIRegistry (#16747)

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 b2ce9f84b9c Remove useless SingletonSPIRegistry (#16747)
b2ce9f84b9c is described below

commit b2ce9f84b9c3dbc4ba329cc33199ff13b5dbfafc
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Apr 11 22:37:50 2022 +0800

    Remove useless SingletonSPIRegistry (#16747)
---
 .../spi/type/singleton/SingletonSPIRegistry.java   | 48 ----------------------
 .../type/singleton/SingletonSPIRegistryTest.java   | 43 -------------------
 .../singleton/fixture/SingletonSPIFixture.java     | 24 -----------
 .../singleton/fixture/SingletonSPIFixtureImpl.java | 26 ------------
 ....spi.type.singleton.fixture.SingletonSPIFixture | 18 --------
 5 files changed, 159 deletions(-)

diff --git a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/singleton/SingletonSPIRegistry.java b/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/singleton/SingletonSPIRegistry.java
deleted file mode 100644
index 40999ad0388..00000000000
--- a/shardingsphere-spi/src/main/java/org/apache/shardingsphere/spi/type/singleton/SingletonSPIRegistry.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.spi.type.singleton;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
-/**
- * Singleton SPI registry.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class SingletonSPIRegistry {
-    
-    /**
-     * Get singleton instances map.
-     *
-     * @param spiClass singleton SPI class
-     * @param keyMapper key mapper
-     * @param <K> the output type of the key mapping function
-     * @param <T> the type of the input elements
-     * @return singleton instances map
-     */
-    public static <K, T extends SingletonSPI> Map<K, T> getSingletonInstancesMap(final Class<T> spiClass, final Function<? super T, ? extends K> keyMapper) {
-        Collection<T> instances = ShardingSphereServiceLoader.getSingletonServiceInstances(spiClass);
-        return instances.stream().collect(Collectors.toMap(keyMapper, Function.identity()));
-    }
-}
diff --git a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/singleton/SingletonSPIRegistryTest.java b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/singleton/SingletonSPIRegistryTest.java
deleted file mode 100644
index 85253f6a5ee..00000000000
--- a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/singleton/SingletonSPIRegistryTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.spi.type.singleton;
-
-import org.apache.shardingsphere.spi.ShardingSphereServiceLoader;
-import org.apache.shardingsphere.spi.type.singleton.fixture.SingletonSPIFixture;
-import org.junit.Test;
-
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-public final class SingletonSPIRegistryTest {
-    
-    static {
-        ShardingSphereServiceLoader.register(SingletonSPIFixture.class);
-    }
-    
-    @Test
-    public void assertGetSingletonInstancesMap() {
-        Map<String, SingletonSPIFixture> singletonSPIFixtureMap = SingletonSPIRegistry.getSingletonInstancesMap(
-                SingletonSPIFixture.class, SingletonSPIFixture::getType);
-        assertThat(singletonSPIFixtureMap.size(), is(1));
-        assertTrue(singletonSPIFixtureMap.containsKey("SINGLETON_FIXTURE"));
-    }
-}
diff --git a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/singleton/fixture/SingletonSPIFixture.java b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/singleton/fixture/SingletonSPIFixture.java
deleted file mode 100644
index de3df00c060..00000000000
--- a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/singleton/fixture/SingletonSPIFixture.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.spi.type.singleton.fixture;
-
-import org.apache.shardingsphere.spi.type.singleton.SingletonSPI;
-import org.apache.shardingsphere.spi.type.typed.TypedSPI;
-
-public interface SingletonSPIFixture extends SingletonSPI, TypedSPI {
-}
diff --git a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/singleton/fixture/SingletonSPIFixtureImpl.java b/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/singleton/fixture/SingletonSPIFixtureImpl.java
deleted file mode 100644
index cfa79cb35ad..00000000000
--- a/shardingsphere-spi/src/test/java/org/apache/shardingsphere/spi/type/singleton/fixture/SingletonSPIFixtureImpl.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.spi.type.singleton.fixture;
-
-public final class SingletonSPIFixtureImpl implements SingletonSPIFixture {
-    
-    @Override
-    public String getType() {
-        return "SINGLETON_FIXTURE";
-    }
-}
diff --git a/shardingsphere-spi/src/test/resources/META-INF/services/org.apache.shardingsphere.spi.type.singleton.fixture.SingletonSPIFixture b/shardingsphere-spi/src/test/resources/META-INF/services/org.apache.shardingsphere.spi.type.singleton.fixture.SingletonSPIFixture
deleted file mode 100644
index 044d5d70b07..00000000000
--- a/shardingsphere-spi/src/test/resources/META-INF/services/org.apache.shardingsphere.spi.type.singleton.fixture.SingletonSPIFixture
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.spi.type.singleton.fixture.SingletonSPIFixtureImpl