geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r468499 - in /geronimo/xbean/trunk/xbean-finder/src: main/java/org/apache/xbean/finder/ClassFinder.java test/java/org/apache/xbean/finder/ClassFinderTest.java
Date Fri, 27 Oct 2006 18:57:45 GMT
Author: dblevins
Date: Fri Oct 27 11:57:44 2006
New Revision: 468499

URL: http://svn.apache.org/viewvc?view=rev&rev=468499
Log:
new method findImplementingClasses and corresponding test

Modified:
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFinder.java
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderTest.java

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFinder.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFinder.java?view=diff&rev=468499&r1=468498&r2=468499
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFinder.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFinder.java
Fri Oct 27 11:57:44 2006
@@ -111,6 +111,17 @@
         return mappedClasses;
     }
 
+    public List<Class> findImplementingClasses(Class interfce){
+        List<Class> allClasses = getClasses();
+        List<Class> classes = new ArrayList<Class>();
+        for (Class clazz : allClasses) {
+            if (interfce.isAssignableFrom(clazz) && !interfce.getName().equals(clazz.getName()))
{
+                classes.add(clazz);
+            }
+        }
+        return classes;
+    }
+
     public List<Class> getClasses() {
         return this.classes;
     }

Modified: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderTest.java?view=diff&rev=468499&r1=468498&r2=468499
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderTest.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderTest.java
Fri Oct 27 11:57:44 2006
@@ -24,6 +24,7 @@
 
 import org.acme.foo.Holiday;
 import org.acme.foo.Color;
+import org.acme.foo.Primary;
 
 /**
  * @version $Rev$ $Date$
@@ -48,4 +49,12 @@
         assertNotNull("classes", classes);
         assertEquals("classes.size", 8, classes.size());
     }
+
+    public void testFindImplementingClasses() throws Exception {
+        ClassFinder classFinder = new ClassFinder(Thread.currentThread().getContextClassLoader());
+        List<Class> classes = classFinder.findImplementingClasses(Primary.class);
+        assertNotNull("classes", classes);
+        assertEquals("classes.size", 4, classes.size());
+    }
+
 }



Mime
View raw message