[
https://issues.apache.org/jira/browse/SCB-942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16641384#comment-16641384
]
ASF GitHub Bot commented on SCB-942:
------------------------------------
laijianbin closed pull request #935: [SCB-942]Choose the highest priority from
all implementation classes
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/935
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/SPIServiceUtils.java
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/SPIServiceUtils.java
index ea8a0bc12..b8b74adcb 100644
---
a/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/SPIServiceUtils.java
+++
b/foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/utils/SPIServiceUtils.java
@@ -149,7 +149,7 @@ private SPIServiceUtils() {
List<T> services = getOrLoadSortedService(serviceType);
return (IMPL) services
.stream()
- .filter(service -> service.getClass().equals(implType))
+ .filter(service -> implType.isAssignableFrom(service.getClass()))
.findFirst()
.orElse(null);
}
diff --git
a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestPriority.java
b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestPriority.java
new file mode 100644
index 000000000..0c0103daf
--- /dev/null
+++
b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestPriority.java
@@ -0,0 +1,23 @@
+/*
+ * 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.servicecomb.foundation.common.utils;
+
+public interface TestPriority {
+ public int getOrder();
+}
diff --git
a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestPriotiryImpl.java
b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestPriotiryImpl.java
new file mode 100644
index 000000000..1236a61ca
--- /dev/null
+++
b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestPriotiryImpl.java
@@ -0,0 +1,28 @@
+/*
+ * 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.servicecomb.foundation.common.utils;
+
+public class TestPriotiryImpl implements TestPriority{
+
+ @Override
+ public int getOrder() {
+ return 0;
+ }
+
+}
diff --git
a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestSPIServiceUtils.java
b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestSPIServiceUtils.java
index 6b26ff9e8..f55057313 100644
---
a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestSPIServiceUtils.java
+++
b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestSPIServiceUtils.java
@@ -154,4 +154,9 @@ public void getPriorityHighestServices() {
Map<Class<?>, List<Object>> cache =
Deencapsulation.getField(SPIServiceUtils.class, "cache");
cache.clear();
}
+
+ @Test
+ public void testGetTargetService() {
+ Assert.assertEquals(-1,
SPIServiceUtils.getTargetService(TestPriority.class,
TestSubPriotiryImpl.class).getOrder());
+ }
}
diff --git
a/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestSubPriotiryImpl.java
b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestSubPriotiryImpl.java
new file mode 100644
index 000000000..22f67093f
--- /dev/null
+++
b/foundations/foundation-common/src/test/java/org/apache/servicecomb/foundation/common/utils/TestSubPriotiryImpl.java
@@ -0,0 +1,27 @@
+/*
+ * 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.servicecomb.foundation.common.utils;
+
+public class TestSubPriotiryImpl extends TestPriotiryImpl {
+
+ @Override
+ public int getOrder() {
+ return -1;
+ }
+}
diff --git
a/foundations/foundation-common/src/test/resources/META-INF/services/org.apache.servicecomb.foundation.common.utils.TestPriority
b/foundations/foundation-common/src/test/resources/META-INF/services/org.apache.servicecomb.foundation.common.utils.TestPriority
new file mode 100644
index 000000000..0047c3b1f
--- /dev/null
+++
b/foundations/foundation-common/src/test/resources/META-INF/services/org.apache.servicecomb.foundation.common.utils.TestPriority
@@ -0,0 +1,19 @@
+#
+# 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.servicecomb.foundation.common.utils.TestPriotiryImpl
+org.apache.servicecomb.foundation.common.utils.TestSubPriotiryImpl
\ No newline at end of file
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> choose the highest priority from all implementation classes
> -----------------------------------------------------------
>
> Key: SCB-942
> URL: https://issues.apache.org/jira/browse/SCB-942
> Project: Apache ServiceComb
> Issue Type: Task
> Reporter: laijianbin
> Assignee: laijianbin
> Priority: Major
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)