felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1022936 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java
Date Fri, 15 Oct 2010 14:26:22 GMT
Author: rickhall
Date: Fri Oct 15 14:26:22 2010
New Revision: 1022936

URL: http://svn.apache.org/viewvc?rev=1022936&view=rev
Log:
Cannot override getResources() pre-Java 1.5 and some other minor cleanup.
(FELIX-2645)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java?rev=1022936&r1=1022935&r2=1022936&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java Fri Oct
15 14:26:22 2010
@@ -1653,44 +1653,6 @@ public class ModuleImpl implements Modul
         return (parent == null) ? m_bootClassLoader : parent;
     }
 
-    static Enumeration convertToLocalUrls(Enumeration urls) {
-        return new ToLocalUrlEnumeration(urls);
-    }
-
-    static URL convertToLocalUrl(URL url) {
-        if (url.getProtocol().equals("bundle"))
-        {
-            try
-            {
-                url = ((URLHandlersBundleURLConnection)
-                    url.openConnection()).getLocalURL();
-            }
-            catch (IOException ex)
-            {
-                // Ignore and add original url.
-            }
-        }
-        return url;
-    }
-
-    static class ToLocalUrlEnumeration implements Enumeration
-    {
-        final Enumeration enumeration;
-
-        ToLocalUrlEnumeration(Enumeration enumeration) {
-            this.enumeration = enumeration;
-        }
-
-        public boolean hasMoreElements() {
-            return enumeration.hasMoreElements();
-        }
-
-        public Object nextElement() {
-            URL url = (URL) enumeration.nextElement();
-            return convertToLocalUrl(url);
-        }
-    }
-
     private static final Constructor m_dexFileClassConstructor;
     private static final Method m_dexFileClassLoadDex;
     private static final Method m_dexFileClassLoadClass;
@@ -1749,7 +1711,7 @@ public class ModuleImpl implements Modul
             Enumeration urls = ModuleImpl.this.getResourcesByDelegation(name);
             if (m_useLocalURLs)
             {
-                urls = convertToLocalUrls(urls);
+                urls = new ToLocalUrlEnumeration(urls);
             }
             return urls;
         }
@@ -2060,16 +2022,6 @@ public class ModuleImpl implements Modul
             return url;
         }
 
-        public Enumeration getResources(String name) throws IOException
-        {
-            Enumeration urls = super.getResources(name);
-            if (m_useLocalURLs)
-            {
-                urls = convertToLocalUrls(urls);
-            }
-            return urls;
-        }
-
         protected URL findResource(String name)
         {
             return ModuleImpl.this.getResourceLocal(name);
@@ -2082,7 +2034,12 @@ public class ModuleImpl implements Modul
         // can't. As a workaround, we make findResources() delegate instead.
         protected Enumeration findResources(String name)
         {
-            return ModuleImpl.this.getResourcesByDelegation(name);
+            Enumeration urls = ModuleImpl.this.getResourcesByDelegation(name);
+            if (m_useLocalURLs)
+            {
+                urls = new ToLocalUrlEnumeration(urls);
+            }
+            return urls;
         }
 
         protected String findLibrary(String name)
@@ -2152,6 +2109,43 @@ public class ModuleImpl implements Modul
         }
     }
 
+    static URL convertToLocalUrl(URL url)
+    {
+        if (url.getProtocol().equals("bundle"))
+        {
+            try
+            {
+                url = ((URLHandlersBundleURLConnection)
+                    url.openConnection()).getLocalURL();
+            }
+            catch (IOException ex)
+            {
+                // Ignore and add original url.
+            }
+        }
+        return url;
+    }
+
+    static class ToLocalUrlEnumeration implements Enumeration
+    {
+        final Enumeration m_enumeration;
+
+        ToLocalUrlEnumeration(Enumeration enumeration)
+        {
+            m_enumeration = enumeration;
+        }
+
+        public boolean hasMoreElements()
+        {
+            return m_enumeration.hasMoreElements();
+        }
+
+        public Object nextElement()
+        {
+            return convertToLocalUrl((URL) m_enumeration.nextElement());
+        }
+    }
+
     private static String diagnoseClassLoadError(
         FelixResolver resolver, ModuleImpl module, String name)
     {



Mime
View raw message