commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1090705 - in /commons/proper/discovery/trunk: pom.xml src/java/org/apache/commons/discovery/tools/Service.java src/test/org/apache/commons/discovery/test/TestAll.java
Date Sat, 09 Apr 2011 23:14:22 GMT
Author: simonetripodi
Date: Sat Apr  9 23:14:21 2011
New Revision: 1090705

URL: http://svn.apache.org/viewvc?rev=1090705&view=rev
Log:
rollback for DISCOVERY-17, issue is invalid

Modified:
    commons/proper/discovery/trunk/pom.xml
    commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/Service.java
    commons/proper/discovery/trunk/src/test/org/apache/commons/discovery/test/TestAll.java

Modified: commons/proper/discovery/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/pom.xml?rev=1090705&r1=1090704&r2=1090705&view=diff
==============================================================================
--- commons/proper/discovery/trunk/pom.xml (original)
+++ commons/proper/discovery/trunk/pom.xml Sat Apr  9 23:14:21 2011
@@ -108,12 +108,6 @@
       <version>4.8.2</version>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>avalon-logkit</groupId>
-      <artifactId>avalon-logkit</artifactId>
-      <version>2.1</version>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
 
   <properties>

Modified: commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/Service.java
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/Service.java?rev=1090705&r1=1090704&r2=1090705&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/Service.java
(original)
+++ commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/tools/Service.java
Sat Apr  9 23:14:21 2011
@@ -92,23 +92,32 @@ public class Service {
 
         return new Enumeration<S>() {
 
+            private S object = getNextClassInstance();
+
             public boolean hasMoreElements() {
-                return services.hasNext();
+                return object != null;
             }
 
             public S nextElement() {
-                ResourceClass<S> info = services.nextResourceClass();
-
-                if (info == null) {
+                if (object == null) {
                     throw new NoSuchElementException();
                 }
 
-                try {
-                    return spi.newInstance(info.loadClass());
-                } catch (Exception e) {
-                    // ignore
-                } catch (LinkageError le) {
-                    // ignore
+                S obj = object;
+                object = getNextClassInstance();
+                return obj;
+            }
+
+            private S getNextClassInstance() {
+                while (services.hasNext()) {
+                    ResourceClass<S> info = services.nextResourceClass();
+                    try {
+                        return spi.newInstance(info.loadClass());
+                    } catch (Exception e) {
+                        // ignore
+                    } catch (LinkageError le) {
+                        // ignore
+                    }
                 }
                 return null;
             }

Modified: commons/proper/discovery/trunk/src/test/org/apache/commons/discovery/test/TestAll.java
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/test/org/apache/commons/discovery/test/TestAll.java?rev=1090705&r1=1090704&r2=1090705&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/test/org/apache/commons/discovery/test/TestAll.java
(original)
+++ commons/proper/discovery/trunk/src/test/org/apache/commons/discovery/test/TestAll.java
Sat Apr  9 23:14:21 2011
@@ -294,7 +294,7 @@ public class TestAll {
 
     @Test
     public void findImplementationsViaService() {
-        final int expectedLogImplementations = 3;
+        final int expectedLogImplementations = 2;
         int actualLogImplementations = 0;
 
         Enumeration<? extends Log> logImplementations = providers(newSPInterface(Log.class,



Mime
View raw message