felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r918505 [1/2] - in /felix/trunk/framework: ./ src/main/java/org/apache/felix/framework/ src/main/java/org/apache/felix/framework/cache/ src/main/java/org/apache/felix/framework/util/ src/main/java/org/apache/felix/moduleloader/ src/test/jav...
Date Wed, 03 Mar 2010 15:09:48 GMT
Author: rickhall
Date: Wed Mar  3 15:09:47 2010
New Revision: 918505

URL: http://svn.apache.org/viewvc?rev=918505&view=rev
Log:
More changes due to abstraction changes for the new resolver implementation.
(FELIX-2036, FELIX-2037, FELIX-2035)

Removed:
    felix/trunk/framework/src/main/java/org/apache/felix/moduleloader/
Modified:
    felix/trunk/framework/pom.xml
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/FindEntriesEnumeration.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/RequiredBundleImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/BundleRevision.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/ContentDirectoryContent.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryContent.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarContent.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/VersionRange.java
    felix/trunk/framework/src/test/java/org/apache/felix/framework/util/UtilTest.java

Modified: felix/trunk/framework/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/framework/pom.xml?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/pom.xml (original)
+++ felix/trunk/framework/pom.xml Wed Mar  3 15:09:47 2010
@@ -46,6 +46,15 @@
   <build>
     <plugins>
       <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <target>jsr14</target>
+          <source>1.5</source>
+        </configuration>
+      </plugin>
+
+      <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
         <version>1.4.3</version>

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java Wed Mar  3 15:09:47 2010
@@ -25,9 +25,9 @@
 import java.util.*;
 
 import org.apache.felix.framework.cache.BundleArchive;
+import org.apache.felix.framework.resolver.Module;
 import org.apache.felix.framework.ext.SecurityProvider;
 import org.apache.felix.framework.util.StringMap;
-import org.apache.felix.moduleloader.IModule;
 import org.osgi.framework.*;
 
 class BundleImpl implements Bundle
@@ -36,7 +36,7 @@
     private final Felix __m_felix;
 
     private final BundleArchive m_archive;
-    private IModule[] m_modules = new IModule[0];
+    private final List<Module> m_modules = new ArrayList<Module>(0);
     private volatile int m_state;
     private boolean m_useDeclaredActivationPolicy;
     private BundleActivator m_activator = null;
@@ -76,7 +76,7 @@
         m_activator = null;
         m_context = null;
 
-        IModule module = createModule();
+        Module module = createModule();
         addModule(module);
     }
 
@@ -127,10 +127,10 @@
     {
         // Remove the bundle's associated modules from the resolver state
         // and close them.
-        for (int i = 0; i < m_modules.length; i++)
+        for (int i = 0; i < m_modules.size(); i++)
         {
-            getFramework().getResolverState().removeModule(m_modules[i]);
-            ((ModuleImpl) m_modules[i]).close();
+            getFramework().getResolverState().removeModule(m_modules.get(i));
+            ((ModuleImpl) m_modules.get(i)).close();
         }
     }
 
@@ -143,9 +143,9 @@
      */
     synchronized void cleanAfterUninstall()
     {
-        for (int i = 0; i < m_modules.length; i++)
+        for (int i = 0; i < m_modules.size(); i++)
         {
-            getFramework().getResolverState().unmergeFragment(m_modules[i]);
+            getFramework().getResolverState().unmergeFragment(m_modules.get(i));
         }
     }
 
@@ -166,8 +166,8 @@
 
             // Lastly, we want to reset our bundle be reinitializing our state
             // and recreating a module for the newest revision.
-            m_modules = new IModule[0];
-            final IModule module = createModule();
+            m_modules.clear();
+            final Module module = createModule();
             addModule(module);
             m_state = Bundle.INSTALLED;
             m_stale = false;
@@ -398,7 +398,7 @@
                 {
                     for (Iterator it = resourceList.iterator(); it.hasNext(); )
                     {
-                        URL temp = ((IModule) moduleList.get(modIdx)).getEntry(
+                        URL temp = ((Module) moduleList.get(modIdx)).getEntry(
                             it.next() + ".properties");
                         if (temp != null)
                         {
@@ -469,15 +469,15 @@
         // version instead of the fragment itself. If there are
         // no hosts, but the module is a fragment, then just
         // search the module itself.
-        IModule[] hosts = module.getDependentHosts();
-        if ((hosts != null) && (hosts.length > 0))
+        List<Module> hosts = module.getDependentHosts();
+        if ((hosts != null) && (hosts.size() > 0))
         {
-            module = (ModuleImpl) hosts[0];
-            for (int hostIdx = 1; hostIdx < hosts.length; hostIdx++)
+            module = (ModuleImpl) hosts.get(0);
+            for (int hostIdx = 1; hostIdx < hosts.size(); hostIdx++)
             {
-                if (module.getVersion().compareTo(hosts[hostIdx].getVersion()) < 0)
+                if (module.getVersion().compareTo(hosts.get(hostIdx).getVersion()) < 0)
                 {
-                    module = (ModuleImpl) hosts[hostIdx];
+                    module = (ModuleImpl) hosts.get(hostIdx);
                 }
             }
         }
@@ -485,10 +485,10 @@
         // Create a list of the module and any attached fragments.
         List result = new ArrayList();
         result.add(module);
-        IModule[] fragments = module.getFragments();
-        for (int i = 0; (fragments != null) && (i < fragments.length); i++)
+        List<Module> fragments = module.getFragments();
+        if (fragments != null)
         {
-            result.add(fragments[i]);
+            result.addAll(fragments);
         }
         return result;
     }
@@ -831,9 +831,9 @@
 
     synchronized boolean isExtension()
     {
-        for (int i = (m_modules.length - 1); i > -1; i--)
+        for (int i = (m_modules.size() - 1); i > -1; i--)
         {
-            if (m_modules[i].isExtension())
+            if (m_modules.get(i).isExtension())
             {
                 return true;
             }
@@ -977,7 +977,7 @@
 
     synchronized boolean isRemovalPending()
     {
-        return (m_state == Bundle.UNINSTALLED) || (m_modules.length > 1)  || m_stale;
+        return (m_state == Bundle.UNINSTALLED) || (m_modules.size() > 1)  || m_stale;
     }
 
     //
@@ -996,7 +996,7 @@
      * no limit on the potential number of bundle JAR file revisions.
      * @return array of modules corresponding to the bundle JAR file revisions.
     **/
-    synchronized IModule[] getModules()
+    synchronized List<Module> getModules()
     {
         return m_modules;
     }
@@ -1007,11 +1007,11 @@
      * @return <tt>true</tt> if the specified module is in the array of modules
      *         associated with this bundle, <tt>false</tt> otherwise.
     **/
-    synchronized boolean hasModule(IModule module)
+    synchronized boolean hasModule(Module module)
     {
-        for (int i = 0; i < m_modules.length; i++)
+        for (int i = 0; i < m_modules.size(); i++)
         {
-            if (m_modules[i] == module)
+            if (m_modules.get(i) == module)
             {
                 return true;
             }
@@ -1024,20 +1024,20 @@
      * in the module array.
      * @return the newest module.
     **/
-    synchronized IModule getCurrentModule()
+    synchronized Module getCurrentModule()
     {
-        return m_modules[m_modules.length - 1];
+        return m_modules.get(m_modules.size() - 1);
     }
 
     synchronized boolean isUsed()
     {
         boolean used = false;
-        for (int i = 0; !used && (i < m_modules.length); i++)
+        for (int i = 0; !used && (i < m_modules.size()); i++)
         {
-            IModule[] dependents = ((ModuleImpl) m_modules[i]).getDependents();
-            for (int j = 0; (dependents != null) && (j < dependents.length) && !used; j++)
+            List<Module> dependents = ((ModuleImpl) m_modules.get(i)).getDependents();
+            for (int j = 0; (dependents != null) && (j < dependents.size()) && !used; j++)
             {
-                if (dependents[j] != m_modules[i])
+                if (dependents.get(j) != m_modules.get(i))
                 {
                     used = true;
                 }
@@ -1053,7 +1053,7 @@
         m_archive.revise(location, is);
         try
         {
-            IModule module = createModule();
+            Module module = createModule();
             addModule(module);
         }
         catch (Exception ex)
@@ -1072,13 +1072,9 @@
     // system bundle needs to add its module directly to the bundle,
     // since it doesn't have an archive from which the module will
     // be created, which is the normal case.
-    synchronized void addModule(IModule module) throws Exception
+    synchronized void addModule(Module module) throws Exception
     {
-        IModule[] backup = m_modules;
-        IModule[] dest = new IModule[m_modules.length + 1];
-        System.arraycopy(m_modules, 0, dest, 0, m_modules.length);
-        dest[m_modules.length] = module;
-        m_modules = dest;
+        m_modules.add(module);
 
         // Set protection domain after adding the module to the bundle,
         // since this requires that the bundle has a module.
@@ -1093,7 +1089,7 @@
             }
             catch (Exception ex) 
             {
-                m_modules = backup;
+                m_modules.remove(m_modules.size() - 1);
                 throw ex;
             }
         }
@@ -1109,7 +1105,7 @@
         }
     }
 
-    private IModule createModule() throws Exception
+    private Module createModule() throws Exception
     {
         // Get and parse the manifest from the most recent revision to
         // create an associated module for it.
@@ -1161,9 +1157,9 @@
     {
         ProtectionDomain pd = null;
 
-        for (int i = m_modules.length - 1; (i >= 0) && (pd == null); i--)
+        for (int i = m_modules.size() - 1; (i >= 0) && (pd == null); i--)
         {
-            pd = (ProtectionDomain) m_modules[i].getSecurityContext();
+            pd = (ProtectionDomain) m_modules.get(i).getSecurityContext();
         }
 
         return pd;

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleProtectionDomain.java Wed Mar  3 15:09:47 2010
@@ -20,13 +20,12 @@
 
 import java.lang.ref.WeakReference;
 import java.net.MalformedURLException;
-import java.net.URL;
 import java.security.CodeSource;
 import java.security.Permission;
 import java.security.ProtectionDomain;
 import java.security.cert.Certificate;
 
-import org.apache.felix.moduleloader.IModule;
+import org.apache.felix.framework.resolver.Module;
 
 public class BundleProtectionDomain extends ProtectionDomain
 {
@@ -56,9 +55,9 @@
         m_toString = "[" + bundle + "]";
     }
 
-    IModule getModule() 
+    Module getModule() 
     {
-        return (IModule) m_module.get();
+        return (Module) m_module.get();
     }
 
     public boolean implies(Permission permission)

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java Wed Mar  3 15:09:47 2010
@@ -18,8 +18,9 @@
  */
 package org.apache.felix.framework;
 
-import org.apache.felix.framework.util.manifestparser.Capability;
-import org.apache.felix.moduleloader.IModule;
+import java.util.List;
+import org.apache.felix.framework.capabilityset.Capability;
+import org.apache.felix.framework.resolver.Module;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Version;
 import org.osgi.service.packageadmin.ExportedPackage;
@@ -28,18 +29,22 @@
 {
     private final Felix m_felix;
     private final BundleImpl m_exportingBundle;
-    private final IModule m_exportingModule;
+    private final Module m_exportingModule;
     private final Capability m_export;
-    private volatile String m_toString = null;
-    private volatile String m_versionString = null;
+    private final String m_pkgName;
+    private final Version m_version;
 
     public ExportedPackageImpl(
-        Felix felix, BundleImpl exporter, IModule module, Capability export)
+        Felix felix, BundleImpl exporter, Module module, Capability export)
     {
         m_felix = felix;
         m_exportingBundle = exporter;
         m_exportingModule = module;
         m_export = export;
+        m_pkgName = (String) m_export.getAttribute(Capability.PACKAGE_ATTR).getValue();
+        m_version = (m_export.getAttribute(Capability.VERSION_ATTR) == null)
+            ? Version.emptyVersion
+            : (Version) m_export.getAttribute(Capability.VERSION_ATTR).getValue();
     }
 
     public Bundle getExportingBundle()
@@ -59,30 +64,23 @@
         {
             return null;
         }
-        return m_felix.getImportingBundles(this);
+        List<Bundle> list = m_felix.getImportingBundles(this);
+        return list.toArray(new Bundle[list.size()]);
     }
 
     public String getName()
     {
-        return m_export.getPackageName();
+        return m_pkgName;
     }
 
     public String getSpecificationVersion()
     {
-        if (m_versionString == null)
-        {
-            m_versionString = (m_export.getPackageVersion() == null)
-                ? Version.emptyVersion.toString()
-                : m_export.getPackageVersion().toString();
-        }
-        return m_versionString;
+        return m_version.toString();
     }
 
     public Version getVersion()
     {
-        return (m_export.getPackageVersion() == null)
-            ? Version.emptyVersion
-            : m_export.getPackageVersion();
+        return m_version;
     }
 
     public boolean isRemovalPending()
@@ -92,11 +90,6 @@
 
     public String toString()
     {
-        if (m_toString == null)
-        {
-            m_toString = m_export.getPackageName()
-                + "; version=" + getSpecificationVersion();
-        }
-        return m_toString;
+        return m_pkgName + "; version=" + m_version;
     }
 }
\ No newline at end of file

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=918505&r1=918504&r2=918505&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 Wed Mar  3 15:09:47 2010
@@ -38,17 +38,16 @@
 import java.util.Set;
 
 import org.apache.felix.framework.Felix.FelixResolver;
-import org.apache.felix.framework.ModuleImpl;
+import org.apache.felix.framework.capabilityset.Attribute;
+import org.apache.felix.framework.capabilityset.Capability;
+import org.apache.felix.framework.capabilityset.Directive;
+import org.apache.felix.framework.resolver.Module;
 import org.apache.felix.framework.util.FelixConstants;
 import org.apache.felix.framework.util.StringMap;
 import org.apache.felix.framework.util.Util;
-import org.apache.felix.framework.util.manifestparser.Capability;
+import org.apache.felix.framework.util.manifestparser.CapabilityImpl;
 import org.apache.felix.framework.util.manifestparser.ManifestParser;
-import org.apache.felix.framework.util.manifestparser.R4Attribute;
-import org.apache.felix.framework.util.manifestparser.R4Directive;
-import org.apache.felix.moduleloader.ICapability;
-import org.apache.felix.moduleloader.IContent;
-import org.apache.felix.moduleloader.IModule;
+import org.apache.felix.framework.resolver.Content;
 import org.osgi.framework.AdminPermission;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
@@ -80,7 +79,7 @@
 // with the parent classloader and one instance per framework instance that
 // keeps track of extension bundles and systembundle exports for that framework
 // instance.
-class ExtensionManager extends URLStreamHandler implements IContent
+class ExtensionManager extends URLStreamHandler implements Content
 {
     // The private instance that is added to Felix.class.getClassLoader() -
     // will be null if extension bundles are not supported (i.e., we are not
@@ -119,8 +118,8 @@
 
     private final Logger m_logger;
     private final Map m_headerMap = new StringMap(false);
-    private final IModule m_systemBundleModule;
-    private ICapability[] m_capabilities = null;
+    private final Module m_systemBundleModule;
+    private List<Capability> m_capabilities = null;
     private Set m_exportNames = null;
     private Object m_securityContext = null;
     private final List m_extensions;
@@ -188,12 +187,12 @@
         {
             ManifestParser mp = new ManifestParser(
                 m_logger, felix.getConfig(), m_systemBundleModule, m_headerMap);
-            ICapability[] caps = aliasSymbolicName(mp.getCapabilities());
+            List<Capability> caps = aliasSymbolicName(mp.getCapabilities());
             setCapabilities(caps);
         }
         catch (Exception ex)
         {
-            m_capabilities = new ICapability[0];
+            m_capabilities = new ArrayList<Capability>(0);
             m_logger.log(
                 Logger.LOG_ERROR,
                 "Error parsing system bundle export statement: "
@@ -201,39 +200,39 @@
         }
     }
 
-    private static ICapability[] aliasSymbolicName(ICapability[] caps)
+    private static List<Capability> aliasSymbolicName(List<Capability> caps)
     {
         if (caps == null)
         {
-            return new ICapability[0];
+            return new ArrayList<Capability>(0);
         }
 
-        ICapability[] aliasCaps = new ICapability[caps.length];
-        System.arraycopy(caps, 0, aliasCaps, 0, caps.length);
+        List<Capability> aliasCaps = new ArrayList<Capability>(caps);
 
-        for (int capIdx = 0; capIdx < aliasCaps.length; capIdx++)
+        for (int capIdx = 0; capIdx < aliasCaps.size(); capIdx++)
         {
             // Get the attributes and search for bundle symbolic name.
-            R4Attribute[] attrs = ((Capability) aliasCaps[capIdx]).getAttributes();
-            for (int i = 0; i < attrs.length; i++)
+            List<Attribute> attrs = aliasCaps.get(capIdx).getAttributes();
+            for (int i = 0; i < attrs.size(); i++)
             {
                 // If there is a bundle symbolic name attribute, add the
                 // standard alias as a value.
-                if (attrs[i].getName().equalsIgnoreCase(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE))
+                if (attrs.get(i).getName().equalsIgnoreCase(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE))
                 {
                     // Make a copy of the attribute array.
-                    R4Attribute[] aliasAttrs = new R4Attribute[attrs.length];
-                    System.arraycopy(attrs, 0, aliasAttrs, 0, attrs.length);
+                    List<Attribute> aliasAttrs = new ArrayList<Attribute>(attrs);
                     // Add the aliased value.
-                    aliasAttrs[i] = new R4Attribute(
+                    aliasAttrs.set(i, new Attribute(
                         Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE,
-                        new String[] { (String) attrs[i].getValue(), Constants.SYSTEM_BUNDLE_SYMBOLICNAME }, false);
+                        new String[] {
+                            (String) attrs.get(i).getValue(), Constants.SYSTEM_BUNDLE_SYMBOLICNAME},
+                        false));
                     // Create the aliased capability to replace the old capability.
-                    aliasCaps[capIdx] = new Capability(
-                        caps[capIdx].getModule(),
-                        caps[capIdx].getNamespace(),
-                        ((Capability) caps[capIdx]).getDirectives(),
-                        aliasAttrs);
+                    aliasCaps.set(capIdx, new CapabilityImpl(
+                        caps.get(capIdx).getModule(),
+                        caps.get(capIdx).getNamespace(),
+                        caps.get(capIdx).getDirectives(),
+                        aliasAttrs));
                     // Continue with the next capability.
                     break;
                 }
@@ -243,7 +242,7 @@
         return aliasCaps;
     }
 
-    public IModule getModule()
+    public Module getModule()
     {
         return m_systemBundleModule;
     }
@@ -295,7 +294,7 @@
             throw new SecurityException("Extension Bundles must have AllPermission");
         }
 
-        R4Directive dir = ManifestParser.parseExtensionBundleHeader((String)
+        Directive dir = ManifestParser.parseExtensionBundleHeader((String)
             bundle.getCurrentModule().getHeaders().get(Constants.FRAGMENT_HOST));
 
         // We only support classpath extensions (not bootclasspath).
@@ -312,11 +311,11 @@
 //            bundle.setExtension(true);
 
             // Merge the exported packages with the exported packages of the systembundle.
-            ICapability[] exports = null;
+            List<Capability> exports = null;
             try
             {
                 exports = ManifestParser.parseExportHeader(
-                    m_systemBundleModule,
+                    m_logger, m_systemBundleModule,
                     (String) bundle.getCurrentModule().getHeaders().get(Constants.EXPORT_PACKAGE),
                     m_systemBundleModule.getSymbolicName(), m_systemBundleModule.getVersion());
                 exports = aliasSymbolicName(exports);
@@ -344,9 +343,9 @@
                 throw new UnsupportedOperationException(
                     "Unable to add extension bundle to FrameworkClassLoader - Maybe not an URLClassLoader?");
             }
-            ICapability[] temp = new ICapability[m_capabilities.length + exports.length];
-            System.arraycopy(m_capabilities, 0, temp, 0, m_capabilities.length);
-            System.arraycopy(exports, 0, temp, m_capabilities.length, exports.length);
+            List<Capability> temp = new ArrayList<Capability>(m_capabilities.size() + exports.size());
+            temp.addAll(m_capabilities);
+            temp.addAll(exports);
             setCapabilities(temp);
         }
         catch (Exception ex)
@@ -415,7 +414,7 @@
         }
     }
 
-    private void setCapabilities(ICapability[] capabilities)
+    private void setCapabilities(List<Capability> capabilities)
     {
         m_capabilities = capabilities;
         m_headerMap.put(Constants.EXPORT_PACKAGE, convertCapabilitiesToHeaders(m_headerMap));
@@ -426,9 +425,9 @@
         StringBuffer exportSB = new StringBuffer("");
         Set exportNames = new HashSet();
 
-        for (int i = 0; (m_capabilities != null) && (i < m_capabilities.length); i++)
+        for (int i = 0; (m_capabilities != null) && (i < m_capabilities.size()); i++)
         {
-            if (m_capabilities[i].getNamespace().equals(ICapability.PACKAGE_NAMESPACE))
+            if (m_capabilities.get(i).getNamespace().equals(Capability.PACKAGE_NAMESPACE))
             {
                 // Add a comma separate if there is an existing package.
                 if (exportSB.length() > 0)
@@ -437,13 +436,13 @@
                 }
 
                 // Append exported package information.
-                exportSB.append(((Capability) m_capabilities[i]).getPackageName());
+                exportSB.append(m_capabilities.get(i).getAttribute(Capability.PACKAGE_ATTR).getValue());
                 exportSB.append("; version=\"");
-                exportSB.append(((Capability) m_capabilities[i]).getPackageVersion().toString());
+                exportSB.append(m_capabilities.get(i).getAttribute(Capability.VERSION_ATTR).getValue());
                 exportSB.append("\"");
 
                 // Remember exported packages.
-                exportNames.add(((Capability) m_capabilities[i]).getPackageName());
+                exportNames.add(m_capabilities.get(i).getAttribute(Capability.PACKAGE_ATTR).getValue());
             }
         }
 
@@ -568,7 +567,7 @@
         return null;
     }
 
-    public IContent getEntryAsContent(String name)
+    public Content getEntryAsContent(String name)
     {
         return null;
     }
@@ -651,7 +650,7 @@
             }
         }
 
-        public ICapability[] getCapabilities()
+        public List<Capability> getCapabilities()
         {
             synchronized (ExtensionManager.this)
             {
@@ -714,7 +713,7 @@
             return null;
         }
 
-        public void attachFragmentContents(IContent[] fragmentContents)
+        public void attachFragmentContents(Content[] fragmentContents)
             throws Exception
         {
             throw new UnsupportedOperationException("Should not be used!");
@@ -725,7 +724,7 @@
             // Nothing needed here.
         }
 
-        public IContent getContent()
+        public Content getContent()
         {
             return ExtensionManager.this;
         }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java Wed Mar  3 15:09:47 2010
@@ -23,16 +23,56 @@
 import java.net.*;
 import java.security.*;
 import java.util.*;
-
-import org.apache.felix.framework.cache.*;
-import org.apache.felix.framework.ext.SecurityProvider;
-import org.apache.felix.framework.searchpolicy.*;
+import java.util.Map.Entry;
+import org.apache.felix.framework.ModuleImpl.FragmentRequirement;
 import org.apache.felix.framework.ServiceRegistry.ServiceRegistryCallbacks;
-import org.apache.felix.framework.util.*;
-import org.apache.felix.framework.util.manifestparser.*;
-import org.apache.felix.moduleloader.*;
-import org.osgi.framework.*;
-import org.osgi.framework.hooks.service.*;
+import org.apache.felix.framework.cache.BundleArchive;
+import org.apache.felix.framework.cache.BundleCache;
+import org.apache.felix.framework.capabilityset.Attribute;
+import org.apache.felix.framework.capabilityset.Capability;
+import org.apache.felix.framework.capabilityset.CapabilitySet;
+import org.apache.felix.framework.capabilityset.Directive;
+import org.apache.felix.framework.resolver.Module;
+import org.apache.felix.framework.capabilityset.Requirement;
+import org.apache.felix.framework.resolver.Wire;
+import org.apache.felix.framework.ext.SecurityProvider;
+import org.apache.felix.framework.resolver.ResolveException;
+import org.apache.felix.framework.resolver.Resolver;
+import org.apache.felix.framework.resolver.ResolverImpl;
+import org.apache.felix.framework.util.EventDispatcher;
+import org.apache.felix.framework.util.FelixConstants;
+import org.apache.felix.framework.util.ListenerHookInfoImpl;
+import org.apache.felix.framework.util.MapToDictionary;
+import org.apache.felix.framework.util.SecureAction;
+import org.apache.felix.framework.util.ShrinkableCollection;
+import org.apache.felix.framework.util.StringMap;
+import org.apache.felix.framework.util.ThreadGate;
+import org.apache.felix.framework.util.Util;
+import org.apache.felix.framework.util.manifestparser.R4LibraryClause;
+import org.apache.felix.framework.util.manifestparser.RequirementImpl;
+import org.osgi.framework.AdminPermission;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.BundleReference;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceException;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServicePermission;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.hooks.service.FindHook;
+import org.osgi.framework.hooks.service.ListenerHook;
 import org.osgi.service.packageadmin.ExportedPackage;
 import org.osgi.service.startlevel.StartLevel;
 
@@ -294,7 +334,7 @@
         // Create a resolver and its state.
         m_resolverState = new FelixResolverState(m_logger);
         m_felixResolver = new FelixResolver(
-            new Resolver(m_logger,
+            new ResolverImpl(m_logger,
                 (String) m_configMap.get(Constants.FRAMEWORK_EXECUTIONENVIRONMENT)),
             m_resolverState);
 
@@ -1579,7 +1619,7 @@
 
         // Record whether the bundle is using its declared activation policy.
         boolean wasDeferred = bundle.isDeclaredActivationPolicyUsed()
-            && (bundle.getCurrentModule().getDeclaredActivationPolicy() == IModule.LAZY_ACTIVATION);
+            && (bundle.getCurrentModule().getDeclaredActivationPolicy() == Module.LAZY_ACTIVATION);
         bundle.setDeclaredActivationPolicyUsed(
             (options & Bundle.START_ACTIVATION_POLICY) != 0);
 
@@ -1667,7 +1707,7 @@
             // If the bundle's activation policy is eager or activation has already
             // been triggered, then activate the bundle immediately.
             if (!bundle.isDeclaredActivationPolicyUsed()
-                || (bundle.getCurrentModule().getDeclaredActivationPolicy() != IModule.LAZY_ACTIVATION)
+                || (bundle.getCurrentModule().getDeclaredActivationPolicy() != Module.LAZY_ACTIVATION)
                 || ((ModuleImpl) bundle.getCurrentModule()).isActivationTriggered())
             {
                 // Record the event type for the final event and activate.
@@ -2090,7 +2130,7 @@
                     throw new IllegalStateException("Cannot stop an uninstalled bundle.");
                 case Bundle.STARTING:
                     if (bundle.isDeclaredActivationPolicyUsed()
-                        && bundle.getCurrentModule().getDeclaredActivationPolicy() != IModule.LAZY_ACTIVATION)
+                        && bundle.getCurrentModule().getDeclaredActivationPolicy() != Module.LAZY_ACTIVATION)
                     {
                         throw new BundleException(
                             "Stopping a starting or stopping bundle is currently not supported.");
@@ -2469,7 +2509,6 @@
                             "Could not remove from cache.", ex1);
                     }
                 }
-
                 if (ex instanceof BundleException)
                 {
                     throw (BundleException) ex;
@@ -2990,26 +3029,29 @@
     ExportedPackage[] getExportedPackages(String pkgName)
     {
         // First, get all exporters of the package.
-        List exports =
-            m_resolverState.getResolvedCandidates(
-                new Requirement(
-                    ICapability.PACKAGE_NAMESPACE,
-                    null,
-                    new R4Attribute[] { new R4Attribute(ICapability.PACKAGE_PROPERTY, pkgName, false) }), null);
+        List<Directive> dirs = new ArrayList<Directive>(0);
+        List<Attribute> attrs = new ArrayList<Attribute>(1);
+        attrs.add(new Attribute(Capability.PACKAGE_ATTR, pkgName, false));
+        Requirement req = new RequirementImpl(Capability.PACKAGE_NAMESPACE, dirs, attrs);
+        Set<Capability> exports = m_resolverState.getCandidates(null, req, false);
+
+        // We only want resolved capabilities.
+        for (Iterator<Capability> it = exports.iterator(); it.hasNext(); )
+        {
+            if (!it.next().getModule().isResolved())
+            {
+                it.remove();
+            }
+        }
 
         if (exports != null)
         {
             List pkgs = new ArrayList();
 
-            Requirement req = new Requirement(ICapability.PACKAGE_NAMESPACE,
-                null,
-                new R4Attribute[] { new R4Attribute(ICapability.PACKAGE_PROPERTY, pkgName, false) });
-
-            for (int pkgIdx = 0; pkgIdx < exports.size(); pkgIdx++)
+            for (Iterator<Capability> it = exports.iterator(); it.hasNext(); )
             {
                 // Get the bundle associated with the current exporting module.
-                BundleImpl bundle = (BundleImpl)
-                    ((ICapability) exports.get(pkgIdx)).getModule().getBundle();
+                BundleImpl bundle = (BundleImpl) it.next().getModule().getBundle();
 
                 // We need to find the version of the exported package, but this
                 // is tricky since there may be multiple versions of the package
@@ -3021,16 +3063,18 @@
                 // that the first module found to be exporting the package is the
                 // provider of the package, which makes sense since it must have
                 // been resolved first.
-                IModule[] modules = bundle.getModules();
-                for (int modIdx = 0; modIdx < modules.length; modIdx++)
+                List<Module> modules = bundle.getModules();
+                for (int modIdx = 0; modIdx < modules.size(); modIdx++)
                 {
-                    ICapability[] ec = modules[modIdx].getCapabilities();
-                    for (int i = 0; (ec != null) && (i < ec.length); i++)
+                    List<Capability> ec = modules.get(modIdx).getCapabilities();
+                    for (int i = 0; (ec != null) && (i < ec.size()); i++)
                     {
-                        if (ec[i].getNamespace().equals(req.getNamespace()) &&
-                            req.isSatisfied(ec[i]))
+                        if (ec.get(i).getNamespace().equals(req.getNamespace())
+                            && CapabilitySet.matches(ec.get(i), req.getFilter()))
                         {
-                            pkgs.add(new ExportedPackageImpl(this, bundle, modules[modIdx], (Capability) ec[i]));
+                            pkgs.add(
+                                new ExportedPackageImpl(
+                                    this, bundle, modules.get(modIdx), ec.get(i)));
                         }
                     }
                 }
@@ -3111,31 +3155,43 @@
         // Since a bundle may have many modules associated with it,
         // one for each revision in the cache, search each module
         // for each revision to get all exports.
-        IModule[] modules = bundle.getModules();
-        for (int modIdx = 0; modIdx < modules.length; modIdx++)
+        List<Module> modules = bundle.getModules();
+        for (int modIdx = 0; modIdx < modules.size(); modIdx++)
         {
-            ICapability[] caps = modules[modIdx].getCapabilities();
-            if ((caps != null) && (caps.length > 0))
+            List<Capability> caps = modules.get(modIdx).getCapabilities();
+            if ((caps != null) && (caps.size() > 0))
             {
-                for (int capIdx = 0; capIdx < caps.length; capIdx++)
+                for (int capIdx = 0; capIdx < caps.size(); capIdx++)
                 {
                     // See if the target bundle's module is one of the
                     // resolved exporters of the package.
-                    if (caps[capIdx].getNamespace().equals(ICapability.PACKAGE_NAMESPACE))
+                    if (caps.get(capIdx).getNamespace().equals(Capability.PACKAGE_NAMESPACE))
                     {
-                        List resolvedCaps = m_resolverState.getResolvedCandidates(
-                            new Requirement(
-                                ICapability.PACKAGE_NAMESPACE,
-                                null,
-                                new R4Attribute[] { new R4Attribute(ICapability.PACKAGE_PROPERTY, ((Capability) caps[capIdx]).getPackageName(), false) }), null);
+                        String pkgName = (String)
+                            caps.get(capIdx).getAttribute(Capability.PACKAGE_ATTR).getValue();
+                        List<Directive> dirs = new ArrayList<Directive>(0);
+                        List<Attribute> attrs = new ArrayList<Attribute>(1);
+                        attrs.add(new Attribute(Capability.PACKAGE_ATTR, pkgName, false));
+                        Requirement req =
+                            new RequirementImpl(Capability.PACKAGE_NAMESPACE, dirs, attrs);
+                        Set<Capability> exports = m_resolverState.getCandidates(null, req, false);
+                        // We only want resolved capabilities.
+                        for (Iterator<Capability> it = exports.iterator(); it.hasNext(); )
+                        {
+                            if (!it.next().getModule().isResolved())
+                            {
+                                it.remove();
+                            }
+                        }
+
 
                         // Search through the current providers to find the target module.
-                        for (int i = 0; (resolvedCaps != null) && (i < resolvedCaps.size()); i++)
+                        for (Capability cap : exports)
                         {
-                            if ((ICapability) resolvedCaps.get(i) == caps[capIdx])
+                            if (cap == caps.get(capIdx))
                             {
                                 list.add(new ExportedPackageImpl(
-                                    this, bundle, modules[modIdx], (Capability) caps[capIdx]));
+                                    this, bundle, modules.get(modIdx), caps.get(capIdx)));
                             }
                         }
                     }
@@ -3144,70 +3200,64 @@
         }
     }
 
-    Bundle[] getDependentBundles(BundleImpl exporter)
+    List<Bundle> getDependentBundles(BundleImpl exporter)
     {
         // Create list for storing importing bundles.
-        List list = new ArrayList();
+        List<Bundle> list = new ArrayList();
 
         // Get all dependent modules from all exporter module revisions.
-        IModule[] modules = exporter.getModules();
-        for (int modIdx = 0; modIdx < modules.length; modIdx++)
+        List<Module> modules = exporter.getModules();
+        for (int modIdx = 0; modIdx < modules.size(); modIdx++)
         {
-            IModule[] dependents = ((ModuleImpl) modules[modIdx]).getDependents();
+            List<Module> dependents = ((ModuleImpl) modules.get(modIdx)).getDependents();
             for (int depIdx = 0;
-                (dependents != null) && (depIdx < dependents.length);
+                (dependents != null) && (depIdx < dependents.size());
                 depIdx++)
             {
-                list.add(dependents[depIdx].getBundle());
+                list.add(dependents.get(depIdx).getBundle());
             }
         }
 
-        // Return the results.
-        if (list.size() > 0)
-        {
-            return (Bundle[]) list.toArray(new Bundle[list.size()]);
-        }
-
-        return null;
+        return list;
     }
 
-    Bundle[] getImportingBundles(ExportedPackage ep)
+    List<Bundle> getImportingBundles(ExportedPackage ep)
     {
         // Create list for storing importing bundles.
-        List list = new ArrayList();
+        List<Bundle> list = new ArrayList();
 
         // Get exporting bundle information.
         BundleImpl exporter = (BundleImpl) ep.getExportingBundle();
 
         // Get all importers and requirers for all revisions of the bundle.
         // The spec says that require-bundle should be returned with importers.
-        IModule[] expModules = exporter.getModules();
-        for (int expIdx = 0; (expModules != null) && (expIdx < expModules.length); expIdx++)
+        List<Module> expModules = exporter.getModules();
+        for (int expIdx = 0; (expModules != null) && (expIdx < expModules.size()); expIdx++)
         {
             // Include any importers that have wires to the specific
             // exported package.
-            IModule[] dependents = ((ModuleImpl) expModules[expIdx]).getDependentImporters();
-            for (int depIdx = 0; (dependents != null) && (depIdx < dependents.length); depIdx++)
+            List<Module> dependents = ((ModuleImpl) expModules.get(expIdx)).getDependentImporters();
+            for (int depIdx = 0; (dependents != null) && (depIdx < dependents.size()); depIdx++)
             {
-                IWire[] wires = dependents[depIdx].getWires();
-                for (int wireIdx = 0; (wires != null) && (wireIdx < wires.length); wireIdx++)
+                List<Wire> wires = dependents.get(depIdx).getWires();
+                for (int wireIdx = 0; (wires != null) && (wireIdx < wires.size()); wireIdx++)
                 {
-                    if ((wires[wireIdx].getExporter() == expModules[expIdx])
-                        && (wires[wireIdx].hasPackage(ep.getName())))
+                    if ((wires.get(wireIdx).getExporter() == expModules.get(expIdx))
+                        && (wires.get(wireIdx).hasPackage(ep.getName())))
                     {
-                        list.add(dependents[depIdx].getBundle());
+                        list.add(dependents.get(depIdx).getBundle());
                     }
                 }
             }
-            dependents = ((ModuleImpl) expModules[expIdx]).getDependentRequirers();
-            for (int depIdx = 0; (dependents != null) && (depIdx < dependents.length); depIdx++)
+            dependents = ((ModuleImpl) expModules.get(expIdx)).getDependentRequirers();
+            for (int depIdx = 0; (dependents != null) && (depIdx < dependents.size()); depIdx++)
             {
-                list.add(dependents[depIdx].getBundle());
+                list.add(dependents.get(depIdx).getBundle());
             }
         }
 
         // Return the results.
-        return (Bundle[]) list.toArray(new Bundle[list.size()]);
+        return list;
     }
 
     boolean resolveBundles(Bundle[] targets)
@@ -3473,20 +3523,20 @@
     private void populateDependentGraph(BundleImpl exporter, Map map)
     {
         // Get all dependent bundles of this bundle.
-        Bundle[] dependents = getDependentBundles(exporter);
+        List<Bundle> dependents = getDependentBundles(exporter);
 
         for (int depIdx = 0;
-            (dependents != null) && (depIdx < dependents.length);
+            (dependents != null) && (depIdx < dependents.size());
             depIdx++)
         {
             // Avoid cycles if the bundle is already in map.
-            if (!map.containsKey(dependents[depIdx]))
+            if (!map.containsKey(dependents.get(depIdx)))
             {
                 // Add each importing bundle to map.
-                map.put(dependents[depIdx], dependents[depIdx]);
+                map.put(dependents.get(depIdx), dependents.get(depIdx));
                 // Now recurse into each bundle to get its importers.
                 populateDependentGraph(
-                    (BundleImpl) dependents[depIdx], map);
+                    (BundleImpl) dependents.get(depIdx), map);
             }
         }
     }
@@ -3819,7 +3869,7 @@
             m_resolverState = resolverState;
         }
 
-        public void resolve(IModule rootModule) throws ResolveException
+        public void resolve(Module rootModule) throws ResolveException
         {
             // Although there is a race condition to check the bundle state
             // then lock it, we do this because we don't want to acquire the
@@ -3850,14 +3900,44 @@
                     // must find a host to attach it to and resolve the host
                     // instead, since the underlying resolver doesn't know
                     // how to deal with fragments.
-                    IModule newRootModule = m_resolverState.findHost(rootModule);
+                    Module newRootModule = m_resolverState.findHost(rootModule);
                     if (!Util.isFragment(newRootModule))
                     {
-                        // Resolve the module.
-                        Map resolvedModuleWireMap = m_resolver.resolve(m_resolverState, newRootModule);
+                        // Check singleton status.
+                        m_resolverState.checkSingleton(newRootModule);
 
-                        // Mark all modules as resolved.
-                        markResolvedModules(resolvedModuleWireMap);
+                        boolean repeat;
+                        do
+                        {
+                            repeat = false;
+                            try
+                            {
+                                // Resolve the module.
+                                Map<Module, List<Wire>> wireMap =
+                                    m_resolver.resolve(m_resolverState, newRootModule);
+
+                                // Mark all modules as resolved.
+                                markResolvedModules(wireMap);
+                            }
+                            catch (ResolveException ex)
+                            {
+                                if ((ex.getRequirement() != null)
+                                    && (ex.getRequirement() instanceof FragmentRequirement)
+                                    && (rootModule !=
+                                        ((FragmentRequirement) ex.getRequirement()).getFragment()))
+                                {
+                                    m_resolverState.detachFragment(
+                                        newRootModule,
+                                        ((FragmentRequirement) ex.getRequirement()).getFragment());
+                                    repeat = true;
+                                }
+                                else
+                                {
+                                    throw ex;
+                                }
+                            }
+                        }
+                        while (repeat);
                     }
                 }
                 finally
@@ -3868,24 +3948,23 @@
             }
         }
 
-        public IWire resolveDynamicImport(IModule importer, String pkgName) throws ResolveException
+        public Wire resolve(Module module, String pkgName) throws ResolveException
         {
-            IWire candidateWire = null;
-
-            // We cannot dynamically import if the module is already resolved or
-            // if it is not allowed, so check that first. Note: We check if the
+            Wire candidateWire = null;
+            // We cannot dynamically import if the module is not already resolved
+            // or if it is not allowed, so check that first. Note: We check if the
             // dynamic import is allowed without holding any locks, but this is
             // okay since the resolver will double check later after we have
             // acquired the global lock below.
-            if (importer.isResolved()
-                && (Resolver.findAllowedDynamicImport(importer, pkgName) != null))
+            if (module.isResolved()
+                && (ResolverImpl.isAllowedDynamicImport(m_resolverState, module, pkgName, new HashMap())))
             {
                 // Acquire global lock.
                 boolean locked = acquireGlobalLock();
                 if (!locked)
                 {
                     throw new ResolveException(
-                        "Unable to acquire global lock for resolve.", importer, null);
+                        "Unable to acquire global lock for resolve.", module, null);
                 }
 
                 try
@@ -3894,42 +3973,34 @@
                     // dynamically importing the package, which can happen if two
                     // threads are racing to do so. If we have an existing wire,
                     // then just return it instead.
-                    IWire[] wires = importer.getWires();
-                    for (int i = 0; (wires != null) && (i < wires.length); i++)
+                    List<Wire> wires = module.getWires();
+                    for (int i = 0; (wires != null) && (i < wires.size()); i++)
                     {
-                        if (wires[i].hasPackage(pkgName))
+                        if (wires.get(i).hasPackage(pkgName))
                         {
-                            return wires[i];
+                            return wires.get(i);
                         }
                     }
 
-                    Object[] result = m_resolver.resolveDynamicImport(m_resolverState, importer, pkgName);
-                    if (result != null)
+                    Map<Module, List<Wire>> wireMap =
+                        m_resolver.resolve(m_resolverState, module, pkgName);
+
+                    if ((wireMap != null) && wireMap.containsKey(module))
                     {
-                        candidateWire = (IWire) result[0];
-                        Map resolvedModuleWireMap = (Map) result[1];
+                        List<Wire> dynamicWires = wireMap.remove(module);
+                        candidateWire = dynamicWires.get(0);
 
                         // Mark all modules as resolved.
-                        markResolvedModules(resolvedModuleWireMap);
+                        markResolvedModules(wireMap);
 
                         // Dynamically add new wire to importing module.
                         if (candidateWire != null)
                         {
-                            wires = importer.getWires();
-                            IWire[] newWires = null;
-                            if (wires == null)
-                            {
-                                newWires = new IWire[1];
-                            }
-                            else
-                            {
-                                newWires = new IWire[wires.length + 1];
-                                System.arraycopy(wires, 0, newWires, 0, wires.length);
-                            }
-
-                            newWires[newWires.length - 1] = candidateWire;
-                            ((ModuleImpl) importer).setWires(newWires);
-m_logger.log(Logger.LOG_DEBUG, "DYNAMIC WIRE: " + newWires[newWires.length - 1]);
+                            wires = new ArrayList(wires.size() + 1);
+                            wires.addAll(module.getWires());
+                            wires.add(candidateWire);
+                            ((ModuleImpl) module).setWires(wires);
+m_logger.log(Logger.LOG_DEBUG, "DYNAMIC WIRE: " + wires.get(wires.size() - 1));
                         }
                     }
                 }
@@ -3943,58 +4014,45 @@
             return candidateWire;
         }
 
-        public synchronized List getResolvedCandidates(IRequirement req, IModule reqModule)
-        {
-            return m_resolverState.getResolvedCandidates(req, reqModule);
-        }
-
-        public synchronized List getUnresolvedCandidates(IRequirement req, IModule reqModule)
+        public synchronized Set<Capability> getCandidates(
+            Module reqModule, Requirement req, boolean obeyMandatory)
         {
-            return m_resolverState.getUnresolvedCandidates(req, reqModule);
+            return m_resolverState.getCandidates(reqModule, req, obeyMandatory);
         }
 
-        private void markResolvedModules(Map resolvedModuleWireMap)
+        private void markResolvedModules(Map<Module, List<Wire>> wireMap)
         {
-            if (resolvedModuleWireMap != null)
+            if (wireMap != null)
             {
-                Iterator iter = resolvedModuleWireMap.entrySet().iterator();
+                Iterator<Entry<Module, List<Wire>>> iter = wireMap.entrySet().iterator();
                 // Iterate over the map to mark the modules as resolved and
                 // update our resolver data structures.
-                List wireList = new ArrayList();
                 while (iter.hasNext())
                 {
-                    wireList.clear();
-
-                    Map.Entry entry = (Map.Entry) iter.next();
-                    IModule module = (IModule) entry.getKey();
-                    IWire[] wires = (IWire[]) entry.getValue();
+                    Entry<Module, List<Wire>> entry = iter.next();
+                    Module module = entry.getKey();
+                    List<Wire> wires = entry.getValue();
 
                     // Only add wires attribute if some exist; export
                     // only modules may not have wires.
-// TODO: RESOLVER - Seems stupid that we package these up as wires to tear them apart.
-                    if (wires.length > 0)
+                    for (int wireIdx = 0; wireIdx < wires.size(); wireIdx++)
                     {
-                        for (int wireIdx = 0; wireIdx < wires.length; wireIdx++)
-                        {
-                            wireList.add(wires[wireIdx]);
-                            m_logger.log(
-                                Logger.LOG_DEBUG,
-                                "WIRE: " + wires[wireIdx]);
-                        }
-                        wires = (IWire[]) wireList.toArray(new IWire[wireList.size()]);
-                        ((ModuleImpl) module).setWires(wires);
+                        m_logger.log(
+                            Logger.LOG_DEBUG,
+                            "WIRE: " + wires.get(wireIdx));
                     }
+                    ((ModuleImpl) module).setWires(wires);
 
                     // Resolve all attached fragments.
-                    IModule[] fragments = ((ModuleImpl) module).getFragments();
-                    for (int i = 0; (fragments != null) && (i < fragments.length); i++)
+                    List<Module> fragments = ((ModuleImpl) module).getFragments();
+                    for (int i = 0; (fragments != null) && (i < fragments.size()); i++)
                     {
-                        ((ModuleImpl) fragments[i]).setResolved();
+                        ((ModuleImpl) fragments.get(i)).setResolved();
                         // Update the state of the module's bundle to resolved as well.
-                        markBundleResolved(fragments[i]);
+                        markBundleResolved(fragments.get(i));
                         m_logger.log(
                             Logger.LOG_DEBUG,
-                            "FRAGMENT WIRE: " + fragments[i] + " -> hosted by -> " + module);
+                            "FRAGMENT WIRE: " + fragments.get(i) + " -> hosted by -> " + module);
                     }
                     // Update the resolver state to show the module as resolved.
                     ((ModuleImpl) module).setResolved();
@@ -4005,7 +4063,7 @@
             }
         }
 
-        private void markBundleResolved(IModule module)
+        private void markBundleResolved(Module module)
         {
             // Update the bundle's state to resolved when the
             // current module is resolved; just ignore resolve

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=918505&r1=918504&r2=918505&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 Wed Mar  3 15:09:47 2010
@@ -19,18 +19,18 @@
 package org.apache.felix.framework;
 
 import java.util.*;
+import org.apache.felix.framework.resolver.Module;
 
 import org.apache.felix.framework.util.Util;
-import org.apache.felix.moduleloader.IModule;
 
 class FindEntriesEnumeration implements Enumeration
 {
     private final BundleImpl m_bundle;
-    private final Enumeration[] m_enumerations;
-    private final IModule[] m_modules;
+    private final List<Enumeration> m_enumerations;
+    private final List<Module> m_modules;
     private int m_moduleIndex = 0;
     private final String m_path;
-    private final String[] m_filePattern;
+    private final List<String> m_filePattern;
     private final boolean m_recurse;
     private Object m_next = null;
 
@@ -38,23 +38,20 @@
         BundleImpl bundle, String path, String filePattern, boolean recurse)
     {
         m_bundle = bundle;
-        IModule bundleModule = m_bundle.getCurrentModule();
-        IModule[] fragmentModules = ((ModuleImpl) bundleModule).getFragments();
+        Module bundleModule = m_bundle.getCurrentModule();
+        List<Module> fragmentModules = ((ModuleImpl) bundleModule).getFragments();
         if (fragmentModules == null)
         {
-            fragmentModules = new IModule[0];
+            fragmentModules = new ArrayList<Module>(0);
         }
-        m_modules = new IModule[fragmentModules.length + 1];
-        m_modules[0] = bundleModule;
-        for (int i = 0; i < fragmentModules.length; i++)
+        m_modules = new ArrayList<Module>(fragmentModules.size() + 1);
+        m_modules.add(bundleModule);
+        m_modules.addAll(fragmentModules);
+        m_enumerations = new ArrayList<Enumeration>(m_modules.size());
+        for (int i = 0; i < m_modules.size(); 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_enumerations.add(m_modules.get(i).getContent() != null ?
+                m_modules.get(i).getContent().getEntries() : null);
         }
         m_recurse = recurse;
 
@@ -109,13 +106,13 @@
         {
             return null;
         }
-        while (m_moduleIndex < m_enumerations.length)
+        while (m_moduleIndex < m_enumerations.size())
         {
-            while (m_enumerations[m_moduleIndex] != null
-                &&  m_enumerations[m_moduleIndex].hasMoreElements())
+            while (m_enumerations.get(m_moduleIndex) != null
+                &&  m_enumerations.get(m_moduleIndex).hasMoreElements())
             {
                 // Get the next entry name.
-                String entryName = (String) m_enumerations[m_moduleIndex].nextElement();
+                String entryName = (String) m_enumerations.get(m_moduleIndex).nextElement();
                 // Check to see if it is a descendent of the specified path.
                 if (!entryName.equals(m_path) && entryName.startsWith(m_path))
                 {
@@ -141,7 +138,7 @@
                         if (Util.checkSubstring(m_filePattern, lastElement))
                         {
                             // Convert entry name into an entry URL.
-                            return m_modules[m_moduleIndex].getEntry(entryName);
+                            return m_modules.get(m_moduleIndex).getEntry(entryName);
                         }
                     }
                 }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java Wed Mar  3 15:09:47 2010
@@ -19,13 +19,16 @@
 package org.apache.felix.framework;
 
 import java.util.*;
-
-import org.apache.felix.framework.ModuleImpl;
-import org.apache.felix.framework.util.Util;
+import org.apache.felix.framework.resolver.Module;
 import org.apache.felix.framework.util.VersionRange;
-import org.apache.felix.moduleloader.IModule;
-import org.osgi.framework.*;
-import org.osgi.service.packageadmin.*;
+import org.osgi.framework.AdminPermission;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Version;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.packageadmin.RequiredBundle;
+
 
 class PackageAdminImpl implements PackageAdmin, Runnable
 {
@@ -191,14 +194,14 @@
         if ((getBundleType(bundle) & BUNDLE_TYPE_FRAGMENT) == 0)
         {
             // Get attached fragments.
-            IModule[] modules =
+            List<Module> modules =
                 ((ModuleImpl)
                     ((BundleImpl) bundle).getCurrentModule()).getFragments();
             // Convert fragment modules to bundles.
             List list = new ArrayList();
-            for (int i = 0; (modules != null) && (i < modules.length); i++)
+            for (int i = 0; (modules != null) && (i < modules.size()); i++)
             {
-                Bundle b = modules[i].getBundle();
+                Bundle b = modules.get(i).getBundle();
                 if (b != null)
                 {
                     list.add(b);
@@ -216,7 +219,11 @@
     {
         if (getBundleType(bundle) == BUNDLE_TYPE_FRAGMENT)
         {
-            return m_felix.getDependentBundles((BundleImpl) bundle);
+            List<Bundle> hosts = m_felix.getDependentBundles((BundleImpl) bundle);
+            if (hosts != null)
+            {
+                return hosts.toArray(new Bundle[hosts.size()]);
+            }
         }
         return null;
     }
@@ -347,4 +354,4 @@
             }
         }
     }
-}
+}
\ No newline at end of file

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/RequiredBundleImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/RequiredBundleImpl.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/RequiredBundleImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/RequiredBundleImpl.java Wed Mar  3 15:09:47 2010
@@ -18,16 +18,11 @@
  */
 package org.apache.felix.framework;
 
-import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import org.apache.felix.framework.ModuleImpl;
-import org.apache.felix.framework.util.Util;
-import org.apache.felix.moduleloader.ICapability;
-import org.apache.felix.moduleloader.IModule;
+import org.apache.felix.framework.resolver.Module;
 import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
 import org.osgi.service.packageadmin.RequiredBundle;
 
@@ -67,17 +62,17 @@
         // of the dependent modules.
         Set bundleSet = new HashSet();
         // Loop through all of this bundle's modules.
-        IModule[] modules = m_bundle.getModules();
-        for (int modIdx = 0; (modules != null) && (modIdx < modules.length); modIdx++)
+        List<Module> modules = m_bundle.getModules();
+        for (int modIdx = 0; (modules != null) && (modIdx < modules.size()); modIdx++)
         {
             // For each of this bundle's modules, loop through all of the
             // modules that require it and add them to the module list.
-            IModule[] dependents = ((ModuleImpl) modules[modIdx]).getDependentRequirers();
-            for (int depIdx = 0; (dependents != null) && (depIdx < dependents.length); depIdx++)
+            List<Module> dependents = ((ModuleImpl) modules.get(modIdx)).getDependentRequirers();
+            for (int depIdx = 0; (dependents != null) && (depIdx < dependents.size()); depIdx++)
             {
-                if (dependents[depIdx].getBundle() != null)
+                if (dependents.get(depIdx).getBundle() != null)
                 {
-                    bundleSet.add(dependents[depIdx].getBundle());
+                    bundleSet.add(dependents.get(depIdx).getBundle());
                 }
             }
         }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java Wed Mar  3 15:09:47 2010
@@ -22,12 +22,12 @@
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.*;
+import org.apache.felix.framework.resolver.Module;
+import org.apache.felix.framework.resolver.Wire;
 
 import org.apache.felix.framework.util.MapToDictionary;
 import org.apache.felix.framework.util.StringMap;
 import org.apache.felix.framework.util.Util;
-import org.apache.felix.moduleloader.IModule;
-import org.apache.felix.moduleloader.IWire;
 import org.osgi.framework.*;
 import org.osgi.framework.BundleReference;
 
@@ -434,12 +434,12 @@
             // Get the package.
             String pkgName =
                 Util.getClassPackage(className);
-            IModule requesterModule = ((BundleImpl) requester).getCurrentModule();
+            Module requesterModule = ((BundleImpl) requester).getCurrentModule();
             // Get package wiring from service requester.
-            IWire requesterWire = Util.getWire(requesterModule, pkgName);
+            Wire requesterWire = Util.getWire(requesterModule, pkgName);
             // Get package wiring from service provider.
-            IModule providerModule = ((BundleImpl) m_bundle).getCurrentModule();
-            IWire providerWire = Util.getWire(providerModule, pkgName);
+            Module providerModule = ((BundleImpl) m_bundle).getCurrentModule();
+            Wire providerWire = Util.getWire(providerModule, pkgName);
 
             // There are four situations that may occur here:
             //   1. Neither the requester, nor provider have wires for the package.

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/URLHandlersBundleURLConnection.java Wed Mar  3 15:09:47 2010
@@ -23,14 +23,15 @@
 import java.net.URL;
 import java.net.URLConnection;
 import java.security.Permission;
+import java.util.List;
+import org.apache.felix.framework.resolver.Module;
 
 import org.apache.felix.framework.util.Util;
-import org.apache.felix.moduleloader.IModule;
 
 class URLHandlersBundleURLConnection extends URLConnection
 {
     private Felix m_framework;
-    private IModule m_targetModule;
+    private Module m_targetModule;
     private int m_classPathIdx = -1;
     private int m_contentLength;
     private long m_contentTime;
@@ -77,8 +78,8 @@
         m_contentTime = bundle.getLastModified();
 
         int revision = Util.getModuleRevisionFromModuleId(url.getHost());
-        IModule[] modules = bundle.getModules();
-        if ((modules == null) || (revision >= modules.length))
+        List<Module> modules = bundle.getModules();
+        if ((modules == null) || (revision >= modules.size()))
         {
             throw new IOException("Resource does not exist: " + url);
         }
@@ -86,7 +87,7 @@
         // If the revision is not specified, check the latest
         if (revision < 0)
         {
-            revision = modules.length - 1;
+            revision = modules.size() - 1;
         }
 
         // If the resource cannot be found at the current class path index,
@@ -96,15 +97,15 @@
         // Of course, this approach won't work in cases where there are multiple
         // resources with the same path, since it will always find the first
         // one on the class path.
-        m_targetModule = modules[revision];
+        m_targetModule = modules.get(revision);
         m_classPathIdx = url.getPort();
         if (m_classPathIdx < 0)
         {
             m_classPathIdx = 0;
         }
-        if (!modules[revision].hasInputStream(m_classPathIdx, url.getPath()))
+        if (!modules.get(revision).hasInputStream(m_classPathIdx, url.getPath()))
         {
-            URL newurl = modules[revision].getResourceByDelegation(url.getPath());
+            URL newurl = modules.get(revision).getResourceByDelegation(url.getPath());
             if (newurl == null)
             {
                 throw new IOException("Resource does not exist: " + url);

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/BundleRevision.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/BundleRevision.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/BundleRevision.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/BundleRevision.java Wed Mar  3 15:09:47 2010
@@ -22,7 +22,7 @@
 import java.util.Map;
 
 import org.apache.felix.framework.Logger;
-import org.apache.felix.moduleloader.IContent;
+import org.apache.felix.framework.resolver.Content;
 
 /**
  * <p>
@@ -128,7 +128,7 @@
     **/
     public abstract Map getManifestHeader() throws Exception;
 
-    public abstract IContent getContent() throws Exception;
+    public abstract Content getContent() throws Exception;
 
     /**
      * <p>

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/ContentDirectoryContent.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/ContentDirectoryContent.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/ContentDirectoryContent.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/ContentDirectoryContent.java Wed Mar  3 15:09:47 2010
@@ -18,18 +18,18 @@
  */
 package org.apache.felix.framework.cache;
 
-import org.apache.felix.moduleloader.*;
+import org.apache.felix.framework.resolver.Content;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Enumeration;
 import java.util.NoSuchElementException;
 
-public class ContentDirectoryContent implements IContent
+public class ContentDirectoryContent implements Content
 {
-    private IContent m_content = null;
+    private Content m_content = null;
     private String m_rootPath = null;
 
-    public ContentDirectoryContent(IContent content, String path)
+    public ContentDirectoryContent(Content content, String path)
     {
         m_content = content;
         // Add a '/' to the end if not present.
@@ -82,7 +82,7 @@
         return m_content.getEntryAsStream(m_rootPath + name);
     }
 
-    public IContent getEntryAsContent(String name)
+    public Content getEntryAsContent(String name)
     {
         if ((name.length() > 0) && (name.charAt(0) == '/'))
         {

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryContent.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryContent.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryContent.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryContent.java Wed Mar  3 15:09:47 2010
@@ -18,7 +18,7 @@
  */
 package org.apache.felix.framework.cache;
 
-import org.apache.felix.moduleloader.*;
+import org.apache.felix.framework.resolver.Content;
 import java.io.*;
 import java.util.*;
 import org.apache.felix.framework.Logger;
@@ -26,7 +26,7 @@
 import org.apache.felix.framework.util.Util;
 import org.osgi.framework.Constants;
 
-public class DirectoryContent implements IContent
+public class DirectoryContent implements Content
 {
     private static final int BUFSIZE = 4096;
     private static final transient String EMBEDDED_DIRECTORY = "-embedded";
@@ -131,7 +131,7 @@
         return new FileInputStream(new File(m_dir, name));
     }
 
-    public synchronized IContent getEntryAsContent(String entryName)
+    public synchronized Content getEntryAsContent(String entryName)
     {
         // If the entry name refers to the content itself, then
         // just return it immediately.

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/DirectoryRevision.java Wed Mar  3 15:09:47 2010
@@ -26,7 +26,7 @@
 
 import org.apache.felix.framework.Logger;
 import org.apache.felix.framework.util.StringMap;
-import org.apache.felix.moduleloader.IContent;
+import org.apache.felix.framework.resolver.Content;
 
 /**
  * <p>
@@ -94,7 +94,7 @@
         }
     }
 
-    public synchronized IContent getContent() throws Exception
+    public synchronized Content getContent() throws Exception
     {
         return new DirectoryContent(getLogger(), getConfig(), this, getRevisionRootDir(), m_refDir);
     }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarContent.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarContent.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarContent.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarContent.java Wed Mar  3 15:09:47 2010
@@ -32,10 +32,10 @@
 import org.apache.felix.framework.util.FelixConstants;
 import org.apache.felix.framework.util.JarFileX;
 import org.apache.felix.framework.util.Util;
-import org.apache.felix.moduleloader.IContent;
+import org.apache.felix.framework.resolver.Content;
 import org.osgi.framework.Constants;
 
-public class JarContent implements IContent
+public class JarContent implements Content
 {
     private static final int BUFSIZE = 4096;
     private static final transient String EMBEDDED_DIRECTORY = "-embedded";
@@ -190,7 +190,7 @@
         return is;
     }
 
-    public IContent getEntryAsContent(String entryName)
+    public Content getEntryAsContent(String entryName)
     {
         // If the entry name refers to the content itself, then
         // just return it immediately.

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/cache/JarRevision.java Wed Mar  3 15:09:47 2010
@@ -30,7 +30,7 @@
 import org.apache.felix.framework.util.JarFileX;
 import org.apache.felix.framework.util.StringMap;
 import org.apache.felix.framework.util.Util;
-import org.apache.felix.moduleloader.IContent;
+import org.apache.felix.framework.resolver.Content;
 
 /**
  * <p>
@@ -107,7 +107,7 @@
         return new StringMap(mf.getMainAttributes(), false);
     }
 
-    public synchronized IContent getContent() throws Exception
+    public synchronized Content getContent() throws Exception
     {
         return new JarContent(getLogger(), getConfig(), this, getRevisionRootDir(),
             m_bundleFile, m_jarFile);

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java?rev=918505&r1=918504&r2=918505&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java Wed Mar  3 15:09:47 2010
@@ -25,9 +25,12 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import org.apache.felix.framework.capabilityset.Capability;
+import org.apache.felix.framework.capabilityset.CapabilitySet;
+import org.apache.felix.framework.resolver.Module;
+import org.apache.felix.framework.capabilityset.Requirement;
+import org.apache.felix.framework.resolver.Wire;
 
-import org.apache.felix.framework.util.manifestparser.Capability;
-import org.apache.felix.moduleloader.*;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
@@ -229,15 +232,15 @@
         return allow;
     }
 
-    public static ICapability getSatisfyingCapability(IModule m, IRequirement req)
+    public static Capability getSatisfyingCapability(Module m, Requirement req)
     {
-        ICapability[] caps = m.getCapabilities();
-        for (int i = 0; (caps != null) && (i < caps.length); i++)
+        List<Capability> caps = m.getCapabilities();
+        for (int i = 0; (caps != null) && (i < caps.size()); i++)
         {
-            if (caps[i].getNamespace().equals(req.getNamespace()) &&
-                req.isSatisfied(caps[i]))
+            if (caps.get(i).getNamespace().equals(req.getNamespace())
+                && CapabilitySet.matches(caps.get(i), req.getFilter()))
             {
-                return caps[i];
+                return caps.get(i);
             }
         }
         return null;
@@ -250,29 +253,29 @@
      * @param namespace capability namespace
      * @return array of matching capabilities or empty if none found
      */
-    public static ICapability[] getCapabilityByNamespace(IModule module, String namespace)
+    public static List<Capability> getCapabilityByNamespace(Module module, String namespace)
     {
-        final List matching = new ArrayList();
-        final ICapability[] caps = module.getCapabilities();
-        for (int capIdx = 0; (caps != null) && (capIdx < caps.length); capIdx++)
+        final List<Capability> matching = new ArrayList();
+        final List<Capability> caps = module.getCapabilities();
+        for (int capIdx = 0; (caps != null) && (capIdx < caps.size()); capIdx++)
         {
-            if (caps[capIdx].getNamespace().equals(namespace))
+            if (caps.get(capIdx).getNamespace().equals(namespace))
             {
-                matching.add(caps[capIdx]);
+                matching.add(caps.get(capIdx));
             }
         }
-        return (ICapability[]) matching.toArray(new ICapability[matching.size()]);
+        return matching;
     }
 
-    public static IWire getWire(IModule m, String name)
+    public static Wire getWire(Module m, String name)
     {
-        IWire[] wires = m.getWires();
-        for (int i = 0; (wires != null) && (i < wires.length); i++)
+        List<Wire> wires = m.getWires();
+        for (int i = 0; (wires != null) && (i < wires.size()); i++)
         {
-            if (wires[i].getCapability().getNamespace().equals(ICapability.PACKAGE_NAMESPACE) &&
-                ((Capability) wires[i].getCapability()).getPackageName().equals(name))
+            if (wires.get(i).getCapability().getNamespace().equals(Capability.PACKAGE_NAMESPACE) &&
+                wires.get(i).getCapability().getAttribute(Capability.PACKAGE_ATTR).getValue().equals(name))
             {
-                return wires[i];
+                return wires.get(i);
             }
         }
         return null;
@@ -522,21 +525,20 @@
      * @return <code>true</code> if the module declares a fragment host, <code>false</code>
      *      otherwise.
      */
-    public static boolean isFragment(IModule module)
+    public static boolean isFragment(Module module)
     {
         Map headerMap = module.getHeaders();
         return headerMap.containsKey(Constants.FRAGMENT_HOST);
     }
 
-
     //
     // The following substring-related code was lifted and modified
     // from the LDAP parser code.
     //
 
-    public static String[] parseSubstring(String target)
+    public static List<String> parseSubstring(String target)
     {
-        List pieces = new ArrayList();
+        ArrayList pieces = new ArrayList();
         StringBuffer ss = new StringBuffer();
         // int kind = SIMPLE; // assume until proven otherwise
         boolean wasStar = false; // indicates last piece was a star
@@ -608,10 +610,11 @@
                 pieces.add(0, "");
             }
         }
-        return (String[]) pieces.toArray(new String[pieces.size()]);
+        pieces.trimToSize();
+        return pieces;
     }
 
-    public static boolean checkSubstring(String[] pieces, String s)
+    public static boolean checkSubstring(List<String> pieces, String s)
     {
         // Walk the pieces to match the string
         // There are implicit stars between each piece,
@@ -620,13 +623,13 @@
         // minimal case is <string>*<string>
 
         boolean result = true;
-        int len = pieces.length;
+        int len = pieces.size();
 
         int index = 0;
 
 loop:   for (int i = 0; i < len; i++)
         {
-            String piece = pieces[i];
+            String piece = pieces.get(i);
 
             // If this is the first piece, then make sure the
             // string starts with it.
@@ -672,4 +675,4 @@
 
         return result;
     }
-}
+}
\ No newline at end of file



Mime
View raw message