You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2009/06/19 18:30:15 UTC

svn commit: r786573 - in /felix/trunk/framework/src/main/java/org/apache/felix/framework: ExtensionManager.java FindEntriesEnumeration.java ModuleImpl.java

Author: rickhall
Date: Fri Jun 19 16:30:15 2009
New Revision: 786573

URL: http://svn.apache.org/viewvc?rev=786573&view=rev
Log:
Applied patch FELIX-1254, which effectively rolls back FELIX-1249. The
original approach was not sufficient; the new patch actually implements
searching of fragments in Bundle.findEntries().

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

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java?rev=786573&r1=786572&r2=786573&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java Fri Jun 19 16:30:15 2009
@@ -703,11 +703,6 @@
             return ExtensionManager.this;
         }
 
-        public Enumeration getEntries()
-        {
-            return ExtensionManager.this.getEntries();
-        }
-
         public URL getEntry(String name)
         {
             // There is no content for the system bundle, so return null.

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/FindEntriesEnumeration.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/FindEntriesEnumeration.java?rev=786573&r1=786572&r2=786573&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/FindEntriesEnumeration.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/FindEntriesEnumeration.java Fri Jun 19 16:30:15 2009
@@ -20,10 +20,14 @@
 
 import java.util.*;
 
+import org.apache.felix.moduleloader.IModule;
+
 class FindEntriesEnumeration implements Enumeration
 {
     private BundleImpl m_bundle = null;
-    private Enumeration m_enumeration = null;
+    private Enumeration[] m_enumerations = null;
+    private IModule[] m_modules = null;
+    private int m_moduleIndex = 0;
     private String m_path = null;
     private String[] m_filePattern = null;
     private boolean m_recurse = false;
@@ -34,8 +38,24 @@
     {
         m_bundle = bundle;
         m_path = path;
-        m_enumeration = (m_bundle.getCurrentModule().getContent() == null)
-            ? null : ((ModuleImpl) m_bundle.getCurrentModule()).getEntries();
+        IModule bundleModule = m_bundle.getCurrentModule();
+        IModule[] fragmentModules = ((ModuleImpl) bundleModule).getFragments();
+        if (fragmentModules == null)
+        {
+            fragmentModules = new IModule[0];
+        }
+        m_modules = new IModule[fragmentModules.length + 1];
+        m_modules[0] = bundleModule;
+        for (int i = 0; i < fragmentModules.length; i++)
+        {
+            m_modules[i + 1] = fragmentModules[i];
+        }
+        m_enumerations = new Enumeration[m_modules.length];
+        for (int i = 0; i < m_modules.length; i++)
+        {
+            m_enumerations[i] = m_modules[i].getContent() != null ?
+                m_modules[i].getContent().getEntries() : null;
+        }
         m_recurse = recurse;
 
         // Sanity check the parameters.
@@ -84,39 +104,48 @@
         // it only displays the contents of the directory specified by
         // the path argument either recursively or not; much like using
         // "ls -R" or "ls" to list the contents of a directory, respectively.
-        while ((m_enumeration != null) && m_enumeration.hasMoreElements())
+        if (m_enumerations == null)
+        {
+            return null;
+        }
+        while (m_moduleIndex < m_enumerations.length)
         {
-            // Get the next entry name.
-            String entryName = (String) m_enumeration.nextElement();
-            // Check to see if it is a descendent of the specified path.
-            if (!entryName.equals(m_path) && entryName.startsWith(m_path))
-            {
-                // If this is recursive search, then try to match any
-                // entry path that starts with the specified path;
-                // otherwise, only try to match children of the specified
-                // path and not any grandchild. This code uses the knowledge
-                // that content entries corresponding to directories end in '/'.
-                int idx = entryName.indexOf('/', m_path.length());
-                if (m_recurse || (idx < 0) || (idx == (entryName.length() - 1)))
-                {
-                    // Get the last element of the entry path, not including
-                    // the '/' if it is a directory.
-                    int endIdx = (entryName.charAt(entryName.length() - 1) == '/')
-                        ? entryName.length() - 1
-                        : entryName.length();
-                    int startIdx = (entryName.charAt(entryName.length() - 1) == '/')
-                        ? entryName.lastIndexOf('/', endIdx - 1) + 1
-                        : entryName.lastIndexOf('/', endIdx) + 1;
-                    String lastElement = entryName.substring(startIdx, endIdx);
-                    
-                    // See if the file pattern matches the last element of the path.
-                    if (checkSubstring(m_filePattern, lastElement))
+            while (m_enumerations[m_moduleIndex] != null
+                &&  m_enumerations[m_moduleIndex].hasMoreElements())
+            {
+                // Get the next entry name.
+                String entryName = (String) m_enumerations[m_moduleIndex].nextElement();
+                // Check to see if it is a descendent of the specified path.
+                if (!entryName.equals(m_path) && entryName.startsWith(m_path))
+                {
+                    // If this is recursive search, then try to match any
+                    // entry path that starts with the specified path;
+                    // otherwise, only try to match children of the specified
+                    // path and not any grandchild. This code uses the knowledge
+                    // that content entries corresponding to directories end in '/'.
+                    int idx = entryName.indexOf('/', m_path.length());
+                    if (m_recurse || (idx < 0) || (idx == (entryName.length() - 1)))
                     {
-                        // Convert entry name into an entry URL.
-                        return m_bundle.getCurrentModule().getEntry(entryName);
+                        // Get the last element of the entry path, not including
+                        // the '/' if it is a directory.
+                        int endIdx = (entryName.charAt(entryName.length() - 1) == '/')
+                            ? entryName.length() - 1
+                            : entryName.length();
+                        int startIdx = (entryName.charAt(entryName.length() - 1) == '/')
+                            ? entryName.lastIndexOf('/', endIdx - 1) + 1
+                            : entryName.lastIndexOf('/', endIdx) + 1;
+                        String lastElement = entryName.substring(startIdx, endIdx);
+                        
+                        // See if the file pattern matches the last element of the path.
+                        if (checkSubstring(m_filePattern, lastElement))
+                        {
+                            // Convert entry name into an entry URL.
+                            return m_modules[m_moduleIndex].getEntry(entryName);
+                        }
                     }
                 }
             }
+            m_moduleIndex++;
         }
 
         return null;

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=786573&r1=786572&r2=786573&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 Jun 19 16:30:15 2009
@@ -428,20 +428,6 @@
         return m_content;
     }
 
-    synchronized Enumeration getEntries()
-    {
-        Enumeration[] ens =
-            new Enumeration[(m_fragmentContents == null)
-                ? 1
-                : m_fragmentContents.length + 1];
-        ens[0] = m_content.getEntries();
-        for (int i = 1; i < ens.length; i++)
-        {
-            ens[i] = m_fragmentContents[i - 1].getEntries();
-        }
-        return new CompoundEnumeration(ens);
-    }
-
     private synchronized IContent[] getContentPath()
     {
         if (m_contentPath == null)