commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1088094 - in /commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk: JDK11Hooks.java JDK12Hooks.java JDKHooks.java PsuedoSystemClassLoader.java
Date Sat, 02 Apr 2011 19:39:46 GMT
Author: simonetripodi
Date: Sat Apr  2 19:39:46 2011
New Revision: 1088094

URL: http://svn.apache.org/viewvc?rev=1088094&view=rev
Log:
added generics to JDKHooks and relative implementations

Modified:
    commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDK11Hooks.java
    commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDK12Hooks.java
    commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDKHooks.java
    commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/PsuedoSystemClassLoader.java

Modified: commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDK11Hooks.java
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDK11Hooks.java?rev=1088094&r1=1088093&r2=1088094&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDK11Hooks.java
(original)
+++ commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDK11Hooks.java
Sat Apr  2 19:39:46 2011
@@ -67,7 +67,7 @@ public class JDK11Hooks extends JDKHooks
      * using introspection and doing the lookup ourself, using the list
      * of URLs, via getURLs().
      */
-    public Enumeration getResources(ClassLoader loader,
+    public Enumeration<URL> getResources(ClassLoader loader,
                                     String resourceName)
         throws IOException
     {
@@ -96,13 +96,13 @@ public class JDK11Hooks extends JDKHooks
          */
         
         final URL first = (URL)loader.getResource(resourceName);
-        final Enumeration rest = loader.getResources(resourceName);
+        final Enumeration<URL> rest = loader.getResources(resourceName);
         
-        return new Enumeration() {
+        return new Enumeration<URL>() {
             private boolean firstDone = (first == null);
             private URL next = getNext();
             
-            public Object nextElement() {
+            public URL nextElement() {
                 URL o = next;
                 next = getNext();
                 return o;

Modified: commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDK12Hooks.java
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDK12Hooks.java?rev=1088094&r1=1088093&r2=1088094&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDK12Hooks.java
(original)
+++ commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDK12Hooks.java
Sat Apr  2 19:39:46 2011
@@ -20,6 +20,7 @@ import java.io.IOException;
 import java.net.URL;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.List;
 
 import org.apache.commons.discovery.log.DiscoveryLogFactory;
 import org.apache.commons.logging.Log;
@@ -53,9 +54,9 @@ public class JDK12Hooks extends JDKHooks
      * @return value of the property
      */
     public String getSystemProperty(final String propName) {
-        return (String)
-        java.security.AccessController.doPrivileged(new java.security.PrivilegedAction()
{
-            public Object run() {
+        return
+        java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<String>()
{
+            public String run() {
                 try {
                     return System.getProperty(propName);
                 } catch (SecurityException se){
@@ -110,7 +111,7 @@ public class JDK12Hooks extends JDKHooks
     /**
      * Implement ClassLoader.getResources for JDK 1.2
      */
-    public Enumeration getResources(ClassLoader loader,
+    public Enumeration<URL> getResources(ClassLoader loader,
                                     String resourceName)
         throws IOException
     {
@@ -142,11 +143,12 @@ public class JDK12Hooks extends JDKHooks
         
         // XXX: Trying to avoid JBoss UnifiedClassLoader problem
         
-        Enumeration resources;
+        Enumeration<URL> resources;
         
         if(first == null) {
             log.debug("Could not find resource: " + resourceName);
-            resources = Collections.enumeration(Collections.EMPTY_LIST);
+            List<URL> emptyURL = Collections.emptyList();
+            resources = Collections.enumeration(emptyURL);
             
         } else {
         
@@ -157,7 +159,8 @@ public class JDK12Hooks extends JDKHooks
             } catch (RuntimeException ex) {
                 log.error("Exception occured during attept to get " + resourceName 
                         + " from " + first, ex);
-                resources = Collections.enumeration(Collections.EMPTY_LIST);
+                List<URL> emptyURL = Collections.emptyList();
+                resources = Collections.enumeration(emptyURL);
             }
             
             resources = getResourcesFromUrl(first, resources);
@@ -166,12 +169,12 @@ public class JDK12Hooks extends JDKHooks
         return resources;
     }
     
-    private static Enumeration getResourcesFromUrl(final URL first, final Enumeration rest)
{
-        return new Enumeration() {
+    private static Enumeration<URL> getResourcesFromUrl(final URL first, final Enumeration<URL>
rest) {
+        return new Enumeration<URL>() {
             private boolean firstDone = (first == null);
             private URL next = getNext();
             
-            public Object nextElement() {
+            public URL nextElement() {
                 URL o = next;
                 next = getNext();
                 return o;

Modified: commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDKHooks.java
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDKHooks.java?rev=1088094&r1=1088093&r2=1088094&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDKHooks.java
(original)
+++ commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/JDKHooks.java
Sat Apr  2 19:39:46 2011
@@ -16,8 +16,9 @@
  */
 package org.apache.commons.discovery.jdk;
 
-import java.util.Enumeration;
 import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
 
 
 /**
@@ -67,7 +68,7 @@ public abstract class JDKHooks {
      */
     public abstract ClassLoader getSystemClassLoader();
     
-    public abstract Enumeration getResources(ClassLoader loader,
+    public abstract Enumeration<URL> getResources(ClassLoader loader,
                                              String resourceName)
         throws IOException;
 }

Modified: commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/PsuedoSystemClassLoader.java
URL: http://svn.apache.org/viewvc/commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/PsuedoSystemClassLoader.java?rev=1088094&r1=1088093&r2=1088094&view=diff
==============================================================================
--- commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/PsuedoSystemClassLoader.java
(original)
+++ commons/proper/discovery/trunk/src/java/org/apache/commons/discovery/jdk/PsuedoSystemClassLoader.java
Sat Apr  2 19:39:46 2011
@@ -26,7 +26,7 @@ import java.net.URL;
  * in 1.1.x, but this should be a good work around...
  */
 class PsuedoSystemClassLoader extends ClassLoader {
-    protected Class loadClass(String className, boolean resolve)
+    protected Class<?> loadClass(String className, boolean resolve)
         throws ClassNotFoundException
     {
         return findSystemClass(className);



Mime
View raw message