commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1088177 - /commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/DiscoverClass.java
Date Sat, 02 Apr 2011 23:20:11 GMT
Author: simonetripodi
Date: Sat Apr  2 23:20:11 2011
New Revision: 1088177

URL: http://svn.apache.org/viewvc?rev=1088177&view=rev
Log:
DISCOVERY-12: DiscoverClass improvements
patch submitted by Neeme Praks

Modified:
    commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/DiscoverClass.java

Modified: commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/DiscoverClass.java
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/DiscoverClass.java?rev=1088177&r1=1088176&r2=1088177&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/DiscoverClass.java
(original)
+++ commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/DiscoverClass.java
Sat Apr  2 23:20:11 2011
@@ -313,20 +313,23 @@ public class DiscoverClass {
                            : properties.getProperties(spi, loaders);
 
         String[] classNames = discoverClassNames(spi, props);
+        Exception error = null;
 
         if (classNames.length > 0) {
             DiscoverClasses<T> classDiscovery = new DiscoverClasses<T>(loaders);
 
-            ResourceClassIterator<T> classes =
-                classDiscovery.findResourceClasses(classNames[0]);
-
-            // If it's set as a property.. it had better be there!
-            if (classes.hasNext()) {
-                ResourceClass<T> info = classes.nextResourceClass();
-                try {
-                    return info.loadClass();
-                } catch (Exception e) {
-                    // ignore
+            for (int i = 0; i < classNames.length; i++) {
+                 ResourceClassIterator<T> classes =
+                     classDiscovery.findResourceClasses(classNames[i]);
+
+                 // If it's set as a property.. it had better be there!
+                 if (classes.hasNext()) {
+                     ResourceClass<T> info = classes.nextResourceClass();
+                     try {
+                         return info.loadClass();
+                     } catch (Exception e) {
+                         error = e;
+                     }
                 }
             }
         } else {
@@ -347,12 +350,12 @@ public class DiscoverClass {
                 try {
                     return info.loadClass();
                 } catch (Exception e) {
-                    // ignore
+                    error = e;
                 }
             }
         }
 
-        throw new DiscoveryException("No implementation defined for " + spi.getSPName());
+        throw new DiscoveryException("No implementation defined for " + spi.getSPName(),
error);
         // return null;
     }
 



Mime
View raw message