commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1088080 - in /commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes: DiscoverClasses.java ResourceClassDiscoverImpl.java
Date Sat, 02 Apr 2011 18:44:26 GMT
Author: simonetripodi
Date: Sat Apr  2 18:44:26 2011
New Revision: 1088080

URL: http://svn.apache.org/viewvc?rev=1088080&view=rev
Log:
switched to generics

Modified:
    commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/DiscoverClasses.java
    commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/ResourceClassDiscoverImpl.java

Modified: commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/DiscoverClasses.java
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/DiscoverClasses.java?rev=1088080&r1=1088079&r2=1088080&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/DiscoverClasses.java
(original)
+++ commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/DiscoverClasses.java
Sat Apr  2 18:44:26 2011
@@ -17,7 +17,8 @@
 package org.apache.commons.discovery.resource.classes;
 
 import java.net.URL;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.commons.discovery.ResourceClass;
 import org.apache.commons.discovery.ResourceClassDiscover;
@@ -35,9 +36,9 @@ import org.apache.commons.logging.Log;
  * @author Costin Manolache
  * @author James Strachan
  */
-public class DiscoverClasses
-    extends ResourceClassDiscoverImpl
-    implements ResourceClassDiscover
+public class DiscoverClasses<T>
+    extends ResourceClassDiscoverImpl<T>
+    implements ResourceClassDiscover<T>
 {
     private static Log log = DiscoveryLogFactory.newLog(DiscoverClasses.class);
     public static void setLog(Log _log) {
@@ -56,16 +57,16 @@ public class DiscoverClasses
         super(classLoaders);
     }
     
-    public ResourceClassIterator findResourceClasses(final String className) {
+    public ResourceClassIterator<T> findResourceClasses(final String className) {
         final String resourceName = className.replace('.','/') + ".class";
         
         if (log.isDebugEnabled())
             log.debug("find: className='" + className + "'");
 
-        return new ResourceClassIterator() {
-            private Vector history = new Vector();
+        return new ResourceClassIterator<T>() {
+            private List<URL> history = new ArrayList<URL>();
             private int idx = 0;
-            private ResourceClass resource = null;
+            private ResourceClass<T> resource = null;
             
             public boolean hasNext() {
                 if (resource == null) {
@@ -74,24 +75,24 @@ public class DiscoverClasses
                 return resource != null;
             }
             
-            public ResourceClass nextResourceClass() {
-                ResourceClass element = resource;
+            public ResourceClass<T> nextResourceClass() {
+                ResourceClass<T> element = resource;
                 resource = null;
                 return element;
             }
             
-            private ResourceClass getNextClass() {
+            private ResourceClass<T> getNextClass() {
                 while (idx < getClassLoaders().size()) {
                     ClassLoader loader = getClassLoaders().get(idx++);
                     URL url = loader.getResource(resourceName);
                     if (url != null) {
                         if (!history.contains(url)) {
-                            history.addElement(url);
+                            history.add(url);
     
                             if (log.isDebugEnabled())
                                 log.debug("getNextClass: next URL='" + url + "'");
     
-                            return new ResourceClass(className, url, loader);
+                            return new ResourceClass<T>(className, url, loader);
                         }
                         if (log.isDebugEnabled())
                             log.debug("getNextClass: duplicate URL='" + url + "'");

Modified: commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/ResourceClassDiscoverImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/ResourceClassDiscoverImpl.java?rev=1088080&r1=1088079&r2=1088080&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/ResourceClassDiscoverImpl.java
(original)
+++ commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/resource/classes/ResourceClassDiscoverImpl.java
Sat Apr  2 18:44:26 2011
@@ -28,9 +28,9 @@ import org.apache.commons.discovery.reso
 /**
  * @author Richard A. Sitze
  */
-public abstract class ResourceClassDiscoverImpl
+public abstract class ResourceClassDiscoverImpl<T>
     extends ResourceDiscoverImpl
-    implements ResourceClassDiscover
+    implements ResourceClassDiscover<T>
 {
     /**
      * Construct a new resource discoverer
@@ -89,17 +89,17 @@ public abstract class ResourceClassDisco
      * 
      * @return ResourceClassIterator
      */
-    public abstract ResourceClassIterator findResourceClasses(String className);
+    public abstract ResourceClassIterator<T> findResourceClasses(String className);
 
     /**
      * Locate class resources that are bound to <code>resourceNames</code>.
      * 
      * @return ResourceIterator
      */
-    public ResourceClassIterator findResourceClasses(final ResourceNameIterator inputNames)
{
-        return new ResourceClassIterator() {
-            private ResourceClassIterator classes = null;
-            private ResourceClass resource = null;
+    public ResourceClassIterator<T> findResourceClasses(final ResourceNameIterator
inputNames) {
+        return new ResourceClassIterator<T>() {
+            private ResourceClassIterator<T> classes = null;
+            private ResourceClass<T> resource = null;
             
             public boolean hasNext() {
                 if (resource == null) {
@@ -108,13 +108,13 @@ public abstract class ResourceClassDisco
                 return resource != null;
             }
             
-            public ResourceClass nextResourceClass() {
-                ResourceClass rsrc = resource;
+            public ResourceClass<T> nextResourceClass() {
+                ResourceClass<T> rsrc = resource;
                 resource = null;
                 return rsrc;
             }
             
-            private ResourceClass getNextResource() {
+            private ResourceClass<T> getNextResource() {
                 while (inputNames.hasNext() &&
                        (classes == null  ||  !classes.hasNext())) {
                     classes =



Mime
View raw message