You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2019/05/13 07:31:35 UTC
[aries-rsa] branch master updated: ARIES-1906 - Regression - export
of superclass interface fails
This is an automated email from the ASF dual-hosted git repository.
cschneider pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
The following commit(s) were added to refs/heads/master by this push:
new b4011a0 ARIES-1906 - Regression - export of superclass interface fails
new 12ef918 Merge pull request #19 from amichair/ARIES-1906
b4011a0 is described below
commit b4011a0b22855c26869476853bfcb5cc1e3d4720
Author: Amichai Rothman <am...@amichais.net>
AuthorDate: Thu Mar 28 14:49:36 2019 +0200
ARIES-1906 - Regression - export of superclass interface fails
---
.../aries/rsa/core/RemoteServiceAdminCore.java | 42 +++++++++++++++-------
1 file changed, 29 insertions(+), 13 deletions(-)
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
index 1586307..f5b6ef1 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
@@ -247,19 +247,35 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
return new ExportRegistrationImpl(e, closeHandler, eventProducer);
}
}
-
- private Class<?>[] getInterfaces(
- Object serviceO,
- List<String> interfaceNames
- ) throws ClassNotFoundException {
- List<Class<?>> interfaces = new ArrayList<>();
- Class<?>[] allInterfaces = serviceO.getClass().getInterfaces();
- for (Class<?> iface : allInterfaces) {
- if (interfaceNames.contains(iface.getName())) {
- interfaces.add(iface);
- }
- }
- return interfaces.toArray(new Class[]{});
+
+ /**
+ * Returns the interface classes corresponding to the given service's interface names.
+ * The classes are returned in the same order as the given names.
+ *
+ * @param service the service implementing the interfaces
+ * @param interfaceNames the interface names
+ * @return the interface classes corresponding to the interface names
+ * @throws ClassNotFoundException if the service does not implement any of the named interfaces
+ */
+ private Class<?>[] getInterfaces(Object service, List<String> interfaceNames) throws ClassNotFoundException {
+ // prepare a map of all of the service's implemented interface names and classes
+ Map<String, Class<?>> interfaces = new HashMap<>();
+ for (Class<?> cls = service.getClass(); cls != null; cls = cls.getSuperclass()) {
+ for (Class<?> interfaceClass : cls.getInterfaces()) {
+ interfaces.put(interfaceClass.getName(), interfaceClass);
+ }
+ }
+ // lookup the given names in order, ensuring all are found
+ List<Class<?>> interfaceClasses = new ArrayList<>();
+ for (String interfaceName : interfaceNames) {
+ Class<?> interfaceClass = interfaces.get(interfaceName);
+ if (interfaceClass == null) {
+ throw new ClassNotFoundException("Service class " + service.getClass()
+ + " does not implement interface " + interfaceName);
+ }
+ interfaceClasses.add(interfaceClass);
+ }
+ return interfaceClasses.toArray(new Class[0]);
}
/**