aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mnutt...@apache.org
Subject svn commit: r1516498 - in /aries/trunk/jndi/jndi-url: ./ src/main/java/org/apache/aries/jndi/services/ src/test/java/org/apache/aries/jndi/services/
Date Thu, 22 Aug 2013 16:09:43 GMT
Author: mnuttall
Date: Thu Aug 22 16:09:42 2013
New Revision: 1516498

URL: http://svn.apache.org/r1516498
Log:
Aries-1095: Cover a case when the interface being looked for is a parent of the one being
advertised. 

Added:
    aries/trunk/jndi/jndi-url/src/test/java/org/apache/aries/jndi/services/
    aries/trunk/jndi/jndi-url/src/test/java/org/apache/aries/jndi/services/ServiceHelperTest.java
Modified:
    aries/trunk/jndi/jndi-url/pom.xml
    aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java
    aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/packageinfo

Modified: aries/trunk/jndi/jndi-url/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/pom.xml?rev=1516498&r1=1516497&r2=1516498&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-url/pom.xml (original)
+++ aries/trunk/jndi/jndi-url/pom.xml Thu Aug 22 16:09:42 2013
@@ -29,7 +29,7 @@
     <artifactId>org.apache.aries.jndi.url</artifactId>
     <packaging>bundle</packaging>
     <name>Apache Aries JNDI URL Handler</name>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.1.0-SNAPSHOT</version>
     <description>
       This bundle contains the JNDI URL handler for OSGi
     </description>

Modified: aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java?rev=1516498&r1=1516497&r2=1516498&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java
(original)
+++ aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java
Thu Aug 22 16:09:42 2013
@@ -25,9 +25,11 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Comparator;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
@@ -349,10 +351,10 @@ public final class ServiceHelper
 			Class<?> ifacesOnService[] = ctx.getService(pair.ref).getClass().getInterfaces();
     	for (String interfaceName : classesNotFound) {
     		Class<?> thisClass = null;
-    		for (Class<?> c : ifacesOnService) { 
-    			inner: if (c.getName().equals(interfaceName)) { 
+    		for (Class<?> c : getAllInterfaces(ifacesOnService)) { 
+    			if (c.getName().equals(interfaceName)) { 
     				thisClass = c;
-    				break inner;
+    				break;
     			}
     		}
     		if (thisClass != null) { 
@@ -468,4 +470,18 @@ public final class ServiceHelper
     return result;
   }
  
+  static Collection<Class<?>> getAllInterfaces (Class<?>[] baseInterfaces)

+  {
+  	Set<Class<?>> result = new HashSet<Class<?>>();
+  	for (Class<?> c : baseInterfaces) {
+  		if (!c.equals(Object.class)) { 
+  			result.add (c);
+  			Class<?> ifaces[] = c.getInterfaces();
+  			if (ifaces.length != 0) { 
+  				result.addAll(getAllInterfaces(ifaces));
+  			}
+  		}
+  	}
+  	return result;
+  }
 }

Modified: aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/packageinfo
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/packageinfo?rev=1516498&r1=1516497&r2=1516498&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/packageinfo (original)
+++ aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/packageinfo Thu
Aug 22 16:09:42 2013
@@ -16,4 +16,4 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-version 1.0.0
+version 1.1.0

Added: aries/trunk/jndi/jndi-url/src/test/java/org/apache/aries/jndi/services/ServiceHelperTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/test/java/org/apache/aries/jndi/services/ServiceHelperTest.java?rev=1516498&view=auto
==============================================================================
--- aries/trunk/jndi/jndi-url/src/test/java/org/apache/aries/jndi/services/ServiceHelperTest.java
(added)
+++ aries/trunk/jndi/jndi-url/src/test/java/org/apache/aries/jndi/services/ServiceHelperTest.java
Thu Aug 22 16:09:42 2013
@@ -0,0 +1,30 @@
+package org.apache.aries.jndi.services;
+
+import java.util.Collection;
+
+import org.apache.aries.jndi.services.ServiceHelper;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class ServiceHelperTest {
+
+	interface A {};
+	interface B extends A{};
+	interface C {};
+	interface D extends A, C{};
+	
+	@Test
+	public void testGetAllInterfaces() throws Exception {
+		
+		Class<?>[] classes = { B.class, D.class };
+		Collection<Class<?>> cx = ServiceHelper.getAllInterfaces(classes);
+		
+		assertTrue (cx.contains(A.class));
+		assertTrue (cx.contains(B.class));
+		assertTrue (cx.contains(C.class));
+		assertTrue (cx.contains(D.class));
+		assertTrue (cx.size() == 4);
+		
+	}
+}



Mime
View raw message