felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1091216 [3/4] - in /felix/sandbox/rickhall/framework-r43: ./ src/main/java/org/apache/felix/framework/ src/main/java/org/apache/felix/framework/capabilityset/ src/main/java/org/apache/felix/framework/resolver/ src/main/java/org/apache/feli...
Date Mon, 11 Apr 2011 21:11:59 GMT
Modified: felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/resolver/WireImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/resolver/WireImpl.java?rev=1091216&r1=1091215&r2=1091216&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/resolver/WireImpl.java (original)
+++ felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/resolver/WireImpl.java Mon Apr 11 21:11:58 2011
@@ -20,24 +20,24 @@ package org.apache.felix.framework.resol
 
 import java.net.URL;
 import java.util.Enumeration;
-import org.apache.felix.framework.capabilityset.Capability;
-import org.apache.felix.framework.capabilityset.Requirement;
 import org.apache.felix.framework.util.Util;
-import org.apache.felix.framework.util.manifestparser.CapabilityImpl;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
 
 class WireImpl implements Wire
 {
     private final Module m_importer;
-    private final Requirement m_req;
+    private final BundleRequirementImpl m_req;
     private final Module m_exporter;
-    private final Capability m_cap;
+    private final BundleCapabilityImpl m_cap;
 
-    public WireImpl(Module importer, Requirement ip, Module exporter, Capability ep)
+    public WireImpl(Module importer, BundleRequirementImpl ip,
+        Module exporter, BundleCapabilityImpl cap)
     {
         m_importer = importer;
         m_req = ip;
         m_exporter = exporter;
-        m_cap = ep;
+        m_cap = cap;
     }
 
     public Module getImporter()
@@ -45,7 +45,7 @@ class WireImpl implements Wire
         return m_importer;
     }
 
-    public Requirement getRequirement()
+    public BundleRequirementImpl getRequirement()
     {
         return m_req;
     }
@@ -55,7 +55,7 @@ class WireImpl implements Wire
         return m_exporter;
     }
 
-    public Capability getCapability()
+    public BundleCapabilityImpl getCapability()
     {
         return m_cap;
     }
@@ -73,8 +73,8 @@ class WireImpl implements Wire
      */
     public boolean hasPackage(String pkgName)
     {
-        return (m_cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE) &&
-            m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue().equals(pkgName));
+        return (m_cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE) &&
+            m_cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).equals(pkgName));
     }
 
     /* (non-Javadoc)
@@ -89,15 +89,15 @@ class WireImpl implements Wire
 
         // Only check when the package of the target class is
         // the same as the package for the wire.
-        if (m_cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE) &&
-            m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue().equals(pkgName))
+        if (m_cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE) &&
+            m_cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).equals(pkgName))
         {
             // Check the include/exclude filters from the target package
             // to make sure that the class is actually visible. We delegate
             // to the exporting module, rather than its content, so it can
             // it can follow any internal wires it may have (e.g., if the
             // package has multiple sources).
-            if (((CapabilityImpl) m_cap).isIncluded(name))
+            if (m_cap.isIncluded(name))
             {
                 clazz = m_exporter.getClassByDelegation(name);
             }
@@ -126,8 +126,8 @@ class WireImpl implements Wire
 
         // Only check when the package of the target resource is
         // the same as the package for the wire.
-        if (m_cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE) &&
-            m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue().equals(pkgName))
+        if (m_cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE) &&
+            m_cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).equals(pkgName))
         {
             // Delegate to the exporting module, rather than its
             // content, so that it can follow any internal wires it may have
@@ -158,8 +158,8 @@ class WireImpl implements Wire
 
         // Only check when the package of the target resource is
         // the same as the package for the wire.
-        if (m_cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE) &&
-            m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue().equals(pkgName))
+        if (m_cap.getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE) &&
+            m_cap.getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).equals(pkgName))
         {
             urls = m_exporter.getResourcesByDelegation(name);
 

Modified: felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/resolver/WireModuleImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/resolver/WireModuleImpl.java?rev=1091216&r1=1091215&r2=1091216&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/resolver/WireModuleImpl.java (original)
+++ felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/resolver/WireModuleImpl.java Mon Apr 11 21:11:58 2011
@@ -21,25 +21,25 @@ package org.apache.felix.framework.resol
 import java.net.URL;
 import java.util.Enumeration;
 import java.util.List;
-import org.apache.felix.framework.capabilityset.Capability;
-import org.apache.felix.framework.capabilityset.Requirement;
 import org.apache.felix.framework.util.Util;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
 
 class WireModuleImpl implements Wire
 {
     private final Module m_importer;
-    private final Requirement m_req;
+    private final BundleRequirementImpl m_req;
     private final Module m_exporter;
-    private final Capability m_cap;
+    private final BundleCapabilityImpl m_cap;
     private final List<String> m_packages;
 
-    public WireModuleImpl(Module importer, Requirement requirement,
-        Module exporter, Capability capability, List<String> packages)
+    public WireModuleImpl(Module importer, BundleRequirementImpl requirement,
+        Module exporter, BundleCapabilityImpl cap, List<String> packages)
     {
         m_importer = importer;
         m_req = requirement;
         m_exporter = exporter;
-        m_cap = capability;
+        m_cap = cap;
         m_packages = packages;
     }
 
@@ -54,7 +54,7 @@ class WireModuleImpl implements Wire
     /* (non-Javadoc)
      * @see org.apache.felix.framework.searchpolicy.IWire#getRequirement()
      */
-    public Requirement getRequirement()
+    public BundleRequirementImpl getRequirement()
     {
         return m_req;
     }
@@ -70,7 +70,7 @@ class WireModuleImpl implements Wire
     /* (non-Javadoc)
      * @see org.apache.felix.framework.searchpolicy.IWire#getCapability()
      */
-    public Capability getCapability()
+    public BundleCapabilityImpl getCapability()
     {
         return m_cap;
     }

Modified: felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/util/Util.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/util/Util.java?rev=1091216&r1=1091215&r2=1091216&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/util/Util.java (original)
+++ felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/util/Util.java Mon Apr 11 21:11:58 2011
@@ -22,17 +22,16 @@ import java.io.*;
 import java.net.URL;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import org.apache.felix.framework.Logger;
-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.wiring.BundleCapabilityImpl;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
 
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
@@ -280,9 +279,9 @@ public class Util
         return allow;
     }
 
-    public static Capability getSatisfyingCapability(Module m, Requirement req)
+    public static BundleCapabilityImpl getSatisfyingCapability(Module m, BundleRequirementImpl req)
     {
-        List<Capability> caps = m.getCapabilities();
+        List<BundleCapabilityImpl> caps = m.getCapabilities();
         for (int i = 0; (caps != null) && (i < caps.size()); i++)
         {
             if (caps.get(i).getNamespace().equals(req.getNamespace())
@@ -301,10 +300,10 @@ public class Util
      * @param namespace capability namespace
      * @return array of matching capabilities or empty if none found
      */
-    public static List<Capability> getCapabilityByNamespace(Module module, String namespace)
+    public static List<BundleCapabilityImpl> getCapabilityByNamespace(Module module, String namespace)
     {
-        final List<Capability> matching = new ArrayList();
-        final List<Capability> caps = module.getCapabilities();
+        final List<BundleCapabilityImpl> matching = new ArrayList();
+        final List<BundleCapabilityImpl> caps = module.getCapabilities();
         for (int capIdx = 0; (caps != null) && (capIdx < caps.size()); capIdx++)
         {
             if (caps.get(capIdx).getNamespace().equals(namespace))
@@ -320,8 +319,8 @@ public class Util
         List<Wire> wires = m.getWires();
         for (int i = 0; (wires != null) && (i < wires.size()); i++)
         {
-            if (wires.get(i).getCapability().getNamespace().equals(Capability.PACKAGE_NAMESPACE) &&
-                wires.get(i).getCapability().getAttribute(Capability.PACKAGE_ATTR).getValue().equals(name))
+            if (wires.get(i).getCapability().getNamespace().equals(BundleCapabilityImpl.PACKAGE_NAMESPACE) &&
+                wires.get(i).getCapability().getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR).equals(name))
             {
                 return wires.get(i);
             }

Modified: felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java?rev=1091216&r1=1091215&r2=1091216&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java (original)
+++ felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java Mon Apr 11 21:11:58 2011
@@ -23,13 +23,11 @@ import java.util.ArrayList;
 import java.util.Map.Entry;
 
 import org.apache.felix.framework.Logger;
-import org.apache.felix.framework.capabilityset.Capability;
-import org.apache.felix.framework.capabilityset.Attribute;
-import org.apache.felix.framework.capabilityset.Directive;
+import org.apache.felix.framework.wiring.BundleCapabilityImpl;
 import org.apache.felix.framework.resolver.Module;
-import org.apache.felix.framework.capabilityset.Requirement;
 import org.apache.felix.framework.util.FelixConstants;
 import org.apache.felix.framework.util.VersionRange;
+import org.apache.felix.framework.wiring.BundleRequirementImpl;
 import org.osgi.framework.*;
 
 public class ManifestParser
@@ -43,9 +41,9 @@ public class ManifestParser
     private volatile boolean m_isExtension = false;
     private volatile String m_bundleSymbolicName;
     private volatile Version m_bundleVersion;
-    private volatile List<Capability> m_capabilities;
-    private volatile List<Requirement> m_requirements;
-    private volatile List<Requirement> m_dynamicRequirements;
+    private volatile List<BundleCapabilityImpl> m_capabilities;
+    private volatile List<BundleRequirementImpl> m_requirements;
+    private volatile List<BundleRequirementImpl> m_dynamicRequirements;
     private volatile List<R4LibraryClause> m_libraryClauses;
     private volatile boolean m_libraryHeadersOptional = false;
 
@@ -65,7 +63,7 @@ public class ManifestParser
         }
 
         // Create lists to hold capabilities and requirements.
-        List<Capability> capList = new ArrayList();
+        List<BundleCapabilityImpl> capList = new ArrayList();
 
         //
         // Parse bundle version.
@@ -76,7 +74,8 @@ public class ManifestParser
         {
             try
             {
-                m_bundleVersion = Version.parseVersion((String) headerMap.get(Constants.BUNDLE_VERSION));
+                m_bundleVersion = Version.parseVersion(
+                    (String) headerMap.get(Constants.BUNDLE_VERSION));
             }
             catch (RuntimeException ex)
             {
@@ -93,11 +92,11 @@ public class ManifestParser
         // Parse bundle symbolic name.
         //
 
-        Capability moduleCap = parseBundleSymbolicName(owner, m_headerMap);
+        BundleCapabilityImpl moduleCap = parseBundleSymbolicName(owner, m_headerMap);
         if (moduleCap != null)
         {
             m_bundleSymbolicName = (String)
-                moduleCap.getAttribute(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE).getValue();
+                moduleCap.getAttributes().get(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE);
 
             // Add a module capability and a host capability to all
             // non-fragment bundles. A host capability is the same
@@ -108,9 +107,11 @@ public class ManifestParser
             if (headerMap.get(Constants.FRAGMENT_HOST) == null)
             {
                 capList.add(moduleCap);
-                capList.add(new CapabilityImpl(
-                    owner, Capability.HOST_NAMESPACE, new ArrayList<Directive>(0),
-                    ((CapabilityImpl) moduleCap).getAttributes()));
+                capList.add(new BundleCapabilityImpl(
+                    owner, BundleCapabilityImpl.HOST_NAMESPACE,
+                    Collections.EMPTY_MAP,
+// TODO: OSGi R4.3 - Wraps map as unmodifiable twice.
+                    moduleCap.getAttributes()));
             }
 
             // Add a singleton capability if the bundle is a singleton.
@@ -121,9 +122,11 @@ public class ManifestParser
             // can be singletons too.
             if (isSingleton(moduleCap))
             {
-                capList.add(new CapabilityImpl(
-                    owner, Capability.SINGLETON_NAMESPACE, new ArrayList<Directive>(0),
-                    ((CapabilityImpl) moduleCap).getAttributes()));
+                capList.add(new BundleCapabilityImpl(
+                    owner, BundleCapabilityImpl.SINGLETON_NAMESPACE,
+                    Collections.EMPTY_MAP,
+// TODO: OSGi R4.3 - Wraps map as unmodifiable twice.
+                    moduleCap.getAttributes()));
             }
         }
 
@@ -138,7 +141,7 @@ public class ManifestParser
         // Parse Fragment-Host.
         //
 
-        List<Requirement> hostReqs = parseFragmentHost(m_logger, owner, m_headerMap);
+        List<BundleRequirementImpl> hostReqs = parseFragmentHost(m_logger, owner, m_headerMap);
 
         //
         // Parse Require-Bundle
@@ -147,7 +150,7 @@ public class ManifestParser
         List<ParsedHeaderClause> requireClauses =
             parseStandardHeader((String) headerMap.get(Constants.REQUIRE_BUNDLE));
         requireClauses = normalizeRequireClauses(m_logger, requireClauses, getManifestVersion());
-        List<Requirement> requireReqs = convertRequires(requireClauses, owner);
+        List<BundleRequirementImpl> requireReqs = convertRequires(requireClauses, owner);
 
         //
         // Parse Import-Package.
@@ -156,7 +159,7 @@ public class ManifestParser
         List<ParsedHeaderClause> importClauses =
             parseStandardHeader((String) headerMap.get(Constants.IMPORT_PACKAGE));
         importClauses = normalizeImportClauses(m_logger, importClauses, getManifestVersion());
-        List<Requirement> importReqs = convertImports(importClauses, owner);
+        List<BundleRequirementImpl> importReqs = convertImports(importClauses, owner);
 
         //
         // Parse DynamicImport-Package.
@@ -176,7 +179,7 @@ public class ManifestParser
             parseStandardHeader((String) headerMap.get(Constants.EXPORT_PACKAGE));
         exportClauses = normalizeExportClauses(logger, exportClauses,
             getManifestVersion(), m_bundleSymbolicName, m_bundleVersion);
-        List<Capability> exportCaps = convertExports(exportClauses, owner);
+        List<BundleCapabilityImpl> exportCaps = convertExports(exportClauses, owner);
 
         //
         // Calculate implicit imports.
@@ -239,18 +242,14 @@ public class ManifestParser
         m_isExtension = checkExtensionBundle(headerMap);
     }
 
-    private static boolean isSingleton(Capability cap)
+    private static boolean isSingleton(BundleCapabilityImpl cap)
     {
-        if (cap.getNamespace().equals(Capability.MODULE_NAMESPACE))
+        if (cap.getNamespace().equals(BundleCapabilityImpl.MODULE_NAMESPACE))
         {
-            final List<Directive> dirs = cap.getDirectives();
-            for (int dirIdx = 0; (dirs != null) && (dirIdx < dirs.size()); dirIdx++)
+            String value = cap.getDirectives().get(Constants.SINGLETON_DIRECTIVE);
+            if ((value != null) && Boolean.valueOf(value))
             {
-                if (dirs.get(dirIdx).getName().equalsIgnoreCase(Constants.SINGLETON_DIRECTIVE)
-                    && Boolean.valueOf((String) dirs.get(dirIdx).getValue()))
-                {
-                    return true;
-                }
+                return true;
             }
         }
         return false;
@@ -262,27 +261,16 @@ public class ManifestParser
     {
         // Verify that the values are equals if the package specifies
         // both version and specification-version attributes.
-        Map<String, Attribute> attrMap = new HashMap();
         for (int clauseIdx = 0; clauseIdx < clauses.size(); clauseIdx++)
         {
-            // Put attributes for current clause in a map for easy lookup.
-            attrMap.clear();
-            for (int attrIdx = 0;
-                attrIdx < clauses.get(clauseIdx).m_attrs.size();
-                attrIdx++)
-            {
-                Attribute attr = clauses.get(clauseIdx).m_attrs.get(attrIdx);
-                attrMap.put(attr.getName(), attr);
-            }
-
             // Check for "version" and "specification-version" attributes
             // and verify they are the same if both are specified.
-            Attribute v = attrMap.get(Constants.VERSION_ATTRIBUTE);
-            Attribute sv = attrMap.get(Constants.PACKAGE_SPECIFICATION_VERSION);
+            Object v = clauses.get(clauseIdx).m_attrs.get(Constants.VERSION_ATTRIBUTE);
+            Object sv = clauses.get(clauseIdx).m_attrs.get(Constants.PACKAGE_SPECIFICATION_VERSION);
             if ((v != null) && (sv != null))
             {
                 // Verify they are equal.
-                if (!((String) v.getValue()).trim().equals(((String) sv.getValue()).trim()))
+                if (!((String) v).trim().equals(((String) sv).trim()))
                 {
                     throw new IllegalArgumentException(
                         "Both version and specification-version are specified, but they are not equal.");
@@ -293,29 +281,21 @@ public class ManifestParser
             // it to the VersionRange type.
             if ((v != null) || (sv != null))
             {
-                attrMap.remove(Constants.PACKAGE_SPECIFICATION_VERSION);
+                clauses.get(clauseIdx).m_attrs.remove(Constants.PACKAGE_SPECIFICATION_VERSION);
                 v = (v == null) ? sv : v;
-                attrMap.put(Constants.VERSION_ATTRIBUTE,
-                    new Attribute(
-                        Constants.VERSION_ATTRIBUTE,
-                        VersionRange.parse(v.getValue().toString()),
-                        v.isMandatory()));
+                clauses.get(clauseIdx).m_attrs.put(
+                    Constants.VERSION_ATTRIBUTE,
+                    VersionRange.parse(v.toString()));
             }
 
             // If bundle version is specified, then convert its type to VersionRange.
-            v = attrMap.get(Constants.BUNDLE_VERSION_ATTRIBUTE);
+            v = clauses.get(clauseIdx).m_attrs.get(Constants.BUNDLE_VERSION_ATTRIBUTE);
             if (v != null)
             {
-                attrMap.put(Constants.BUNDLE_VERSION_ATTRIBUTE,
-                    new Attribute(
-                        Constants.BUNDLE_VERSION_ATTRIBUTE,
-                        VersionRange.parse(v.getValue().toString()),
-                        v.isMandatory()));
+                clauses.get(clauseIdx).m_attrs.put(
+                    Constants.BUNDLE_VERSION_ATTRIBUTE,
+                    VersionRange.parse(v.toString()));
             }
-
-            // Re-copy the attributes in case they changed.
-            clauses.get(clauseIdx).m_attrs.clear();
-            clauses.get(clauseIdx).m_attrs.addAll(attrMap.values());
         }
 
         // Verify java.* is not imported, nor any duplicate imports.
@@ -358,7 +338,7 @@ public class ManifestParser
             for (int clauseIdx = 0; clauseIdx < clauses.size(); clauseIdx++)
             {
                 // R3 bundles cannot have directives on their imports.
-                if (clauses.get(clauseIdx).m_dirs.size() != 0)
+                if (!clauses.get(clauseIdx).m_dirs.isEmpty())
                 {
                     throw new BundleException("R3 imports cannot contain directives.");
                 }
@@ -368,33 +348,29 @@ public class ManifestParser
                 // because the package class normalizes to "version" to avoid having
                 // future special cases. This could be changed if more strict behavior
                 // is required.
-                if (clauses.get(clauseIdx).m_attrs.size() != 0)
+                if (!clauses.get(clauseIdx).m_attrs.isEmpty())
                 {
                     // R3 package requirements should only have version attributes.
-                    Attribute pkgVersion =
-                        new Attribute(Capability.VERSION_ATTR,
-                            new VersionRange(Version.emptyVersion, true, null, true), false);
-                    for (int attrIdx = 0;
-                        attrIdx < clauses.get(clauseIdx).m_attrs.size();
-                        attrIdx++)
+                    Object pkgVersion = new VersionRange(Version.emptyVersion, true, null, true);
+                    for (Entry<String, Object> entry : clauses.get(clauseIdx).m_attrs.entrySet())
                     {
-                        if (clauses.get(clauseIdx).m_attrs.get(attrIdx)
-                          .getName().equals(Capability.VERSION_ATTR))
+                        if (entry.getKey().equals(BundleCapabilityImpl.VERSION_ATTR))
                         {
-                            pkgVersion = clauses.get(clauseIdx).m_attrs.get(attrIdx);
+                            pkgVersion = entry.getValue();
                         }
                         else
                         {
                             logger.log(Logger.LOG_WARNING,
                                 "Unknown R3 import attribute: "
-                                    + clauses.get(clauseIdx).m_attrs.get(attrIdx).getName());
+                                    + entry.getKey());
                         }
                     }
 
                     // Recreate the import to remove any other attributes
                     // and add version if missing.
-                    ArrayList<Attribute> attrs = new ArrayList<Attribute>(1);
-                    attrs.add(pkgVersion);
+                    Map<String, Object> attrs = new HashMap<String, Object>(1);
+                    attrs.put(
+                        BundleCapabilityImpl.VERSION_ATTR, pkgVersion);
                     clauses.set(clauseIdx, new ParsedHeaderClause(
                         clauses.get(clauseIdx).m_paths,
                         clauses.get(clauseIdx).m_dirs,
@@ -406,7 +382,7 @@ public class ManifestParser
         return clauses;
     }
 
-    private static List<Requirement> convertImports(
+    private static List<BundleRequirementImpl> convertImports(
         List<ParsedHeaderClause> clauses, Module owner)
     {
         // Now convert generic header clauses into requirements.
@@ -418,18 +394,23 @@ public class ManifestParser
                 pathIdx++)
             {
                 // Prepend the package name to the array of attributes.
-                List<Attribute> attrs = clauses.get(clauseIdx).m_attrs;
-                List<Attribute> newAttrs = new ArrayList<Attribute>(attrs.size() + 1);
-                newAttrs.add(new Attribute(
-                    Capability.PACKAGE_ATTR,
-                    clauses.get(clauseIdx).m_paths.get(pathIdx), false));
-                newAttrs.addAll(attrs);
+                Map<String, Object> attrs = clauses.get(clauseIdx).m_attrs;
+                // Note that we use a linked hash map here to ensure the
+                // package attribute is first, which will make indexing
+                // more efficient.
+// TODO: OSGi R4.3 - This is a hack...perhaps we should use the standard "key"
+//       notion where namespace is also the name of the key attribute.
+                Map<String, Object> newAttrs = new LinkedHashMap<String, Object>(attrs.size() + 1);
+                newAttrs.put(
+                    BundleCapabilityImpl.PACKAGE_ATTR,
+                    clauses.get(clauseIdx).m_paths.get(pathIdx));
+                newAttrs.putAll(attrs);
 
                 // Create package requirement and add to requirement list.
                 reqList.add(
-                    new RequirementImpl(
+                    new BundleRequirementImpl(
                         owner,
-                        Capability.PACKAGE_NAMESPACE,
+                        BundleCapabilityImpl.PACKAGE_NAMESPACE,
                         clauses.get(clauseIdx).m_dirs,
                         newAttrs));
             }
@@ -444,27 +425,16 @@ public class ManifestParser
     {
         // Verify that the values are equals if the package specifies
         // both version and specification-version attributes.
-        Map<String, Attribute> attrMap = new HashMap();
         for (int clauseIdx = 0; clauseIdx < clauses.size(); clauseIdx++)
         {
-            // Put attributes for current clause in a map for easy lookup.
-            attrMap.clear();
-            for (int attrIdx = 0;
-                attrIdx < clauses.get(clauseIdx).m_attrs.size();
-                attrIdx++)
-            {
-                Attribute attr = clauses.get(clauseIdx).m_attrs.get(attrIdx);
-                attrMap.put(attr.getName(), attr);
-            }
-
             // Check for "version" and "specification-version" attributes
             // and verify they are the same if both are specified.
-            Attribute v = attrMap.get(Constants.VERSION_ATTRIBUTE);
-            Attribute sv = attrMap.get(Constants.PACKAGE_SPECIFICATION_VERSION);
+            Object v = clauses.get(clauseIdx).m_attrs.get(Constants.VERSION_ATTRIBUTE);
+            Object sv = clauses.get(clauseIdx).m_attrs.get(Constants.PACKAGE_SPECIFICATION_VERSION);
             if ((v != null) && (sv != null))
             {
                 // Verify they are equal.
-                if (!((String) v.getValue()).trim().equals(((String) sv.getValue()).trim()))
+                if (!((String) v).trim().equals(((String) sv).trim()))
                 {
                     throw new IllegalArgumentException(
                         "Both version and specification-version are specified, but they are not equal.");
@@ -475,29 +445,21 @@ public class ManifestParser
             // it to the VersionRange type.
             if ((v != null) || (sv != null))
             {
-                attrMap.remove(Constants.PACKAGE_SPECIFICATION_VERSION);
+                clauses.get(clauseIdx).m_attrs.remove(Constants.PACKAGE_SPECIFICATION_VERSION);
                 v = (v == null) ? sv : v;
-                attrMap.put(Constants.VERSION_ATTRIBUTE,
-                    new Attribute(
-                        Constants.VERSION_ATTRIBUTE,
-                        VersionRange.parse(v.getValue().toString()),
-                        v.isMandatory()));
+                clauses.get(clauseIdx).m_attrs.put(
+                    Constants.VERSION_ATTRIBUTE,
+                    VersionRange.parse(v.toString()));
             }
 
             // If bundle version is specified, then convert its type to VersionRange.
-            v = attrMap.get(Constants.BUNDLE_VERSION_ATTRIBUTE);
+            v = clauses.get(clauseIdx).m_attrs.get(Constants.BUNDLE_VERSION_ATTRIBUTE);
             if (v != null)
             {
-                attrMap.put(Constants.BUNDLE_VERSION_ATTRIBUTE,
-                    new Attribute(
-                        Constants.BUNDLE_VERSION_ATTRIBUTE,
-                        VersionRange.parse(v.getValue().toString()),
-                        v.isMandatory()));
+                clauses.get(clauseIdx).m_attrs.put(
+                    Constants.BUNDLE_VERSION_ATTRIBUTE,
+                    VersionRange.parse(v.toString()));
             }
-
-            // Re-copy the attributes in case they changed.
-            clauses.get(clauseIdx).m_attrs.clear();
-            clauses.get(clauseIdx).m_attrs.addAll(attrMap.values());
         }
 
         // Dynamic imports can have duplicates, so just check for import
@@ -530,7 +492,7 @@ public class ManifestParser
             for (int clauseIdx = 0; clauseIdx < clauses.size(); clauseIdx++)
             {
                 // R3 bundles cannot have directives on their imports.
-                if (clauses.get(clauseIdx).m_dirs.size() != 0)
+                if (!clauses.get(clauseIdx).m_dirs.isEmpty())
                 {
                     throw new BundleException("R3 imports cannot contain directives.");
                 }
@@ -568,27 +530,16 @@ public class ManifestParser
 
         // If both version and specification-version attributes are specified,
         // then verify that the values are equal.
-        Map<String, Attribute> attrMap = new HashMap();
         for (int clauseIdx = 0; clauseIdx < clauses.size(); clauseIdx++)
         {
-            // Put attributes for current clause in a map for easy lookup.
-            attrMap.clear();
-            for (int attrIdx = 0;
-                attrIdx < clauses.get(clauseIdx).m_attrs.size();
-                attrIdx++)
-            {
-                Attribute attr = clauses.get(clauseIdx).m_attrs.get(attrIdx);
-                attrMap.put(attr.getName(), attr);
-            }
-
             // Check for "version" and "specification-version" attributes
             // and verify they are the same if both are specified.
-            Attribute v = attrMap.get(Constants.VERSION_ATTRIBUTE);
-            Attribute sv = attrMap.get(Constants.PACKAGE_SPECIFICATION_VERSION);
+            Object v = clauses.get(clauseIdx).m_attrs.get(Constants.VERSION_ATTRIBUTE);
+            Object sv = clauses.get(clauseIdx).m_attrs.get(Constants.PACKAGE_SPECIFICATION_VERSION);
             if ((v != null) && (sv != null))
             {
                 // Verify they are equal.
-                if (!((String) v.getValue()).trim().equals(((String) sv.getValue()).trim()))
+                if (!((String) v).trim().equals(((String) sv).trim()))
                 {
                     throw new IllegalArgumentException(
                         "Both version and specification-version are specified, but they are not equal.");
@@ -598,8 +549,7 @@ public class ManifestParser
             // Always add the default version if not specified.
             if ((v == null) && (sv == null))
             {
-                v = new Attribute(
-                    Constants.VERSION_ATTRIBUTE, Version.emptyVersion, false);
+                v = Version.emptyVersion;
             }
 
             // Ensure that only the "version" attribute is used and convert
@@ -607,17 +557,11 @@ public class ManifestParser
             if ((v != null) || (sv != null))
             {
                 // Convert version attribute to type Version.
-                attrMap.remove(Constants.PACKAGE_SPECIFICATION_VERSION);
+                clauses.get(clauseIdx).m_attrs.remove(Constants.PACKAGE_SPECIFICATION_VERSION);
                 v = (v == null) ? sv : v;
-                attrMap.put(Constants.VERSION_ATTRIBUTE,
-                    new Attribute(
-                        Constants.VERSION_ATTRIBUTE,
-                        Version.parseVersion(v.getValue().toString()),
-                        v.isMandatory()));
-
-                // Re-copy the attributes since they have changed.
-                clauses.get(clauseIdx).m_attrs.clear();
-                clauses.get(clauseIdx).m_attrs.addAll(attrMap.values());
+                clauses.get(clauseIdx).m_attrs.put(
+                    Constants.VERSION_ATTRIBUTE,
+                    Version.parseVersion(v.toString()));
             }
         }
 
@@ -627,26 +571,20 @@ public class ManifestParser
         {
             for (int clauseIdx = 0; clauseIdx < clauses.size(); clauseIdx++)
             {
-                // R3 package capabilities should only have a version attribute.
-                List<Attribute> attrs = clauses.get(clauseIdx).m_attrs;
-                for (int attrIdx = 0; attrIdx < attrs.size(); attrIdx++)
-                {
-                    // Find symbolic name and version attribute, if present.
-                    if (attrs.get(attrIdx).getName().equals(Constants.BUNDLE_VERSION_ATTRIBUTE) ||
-                        attrs.get(attrIdx).getName().equals(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE))
-                    {
-                        throw new BundleException(
-                            "Exports must not specify bundle symbolic name or bundle version.");
-                    }
+                // Find symbolic name and version attribute, if present.
+                if (clauses.get(clauseIdx).m_attrs.containsKey(Constants.BUNDLE_VERSION_ATTRIBUTE)
+                    || clauses.get(clauseIdx).m_attrs.containsKey(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE))
+                {
+                    throw new BundleException(
+                        "Exports must not specify bundle symbolic name or bundle version.");
                 }
 
                 // Now that we know that there are no bundle symbolic name and version
                 // attributes, add them since the spec says they are there implicitly.
-                attrs.add(new Attribute(
-                    Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, bsn, false));
-                attrs.add(new Attribute(
-                    Constants.BUNDLE_VERSION_ATTRIBUTE, bv, false));
-                ((ArrayList) attrs).trimToSize();
+                clauses.get(clauseIdx).m_attrs.put(
+                    Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, bsn);
+                clauses.get(clauseIdx).m_attrs.put(
+                    Constants.BUNDLE_VERSION_ATTRIBUTE, bv);
             }
         }
         else if (!mv.equals("2"))
@@ -657,7 +595,7 @@ public class ManifestParser
             for (int clauseIdx = 0; clauseIdx < clauses.size(); clauseIdx++)
             {
                 // R3 bundles cannot have directives on their exports.
-                if (clauses.get(clauseIdx).m_dirs.size() != 0)
+                if (!clauses.get(clauseIdx).m_dirs.isEmpty())
                 {
                     throw new BundleException("R3 exports cannot contain directives.");
                 }
@@ -667,30 +605,31 @@ public class ManifestParser
                 // because the package class normalizes to "version" to avoid having
                 // future special cases. This could be changed if more strict behavior
                 // is required.
-                if (clauses.get(clauseIdx).m_attrs.size() != 0)
+                if (!clauses.get(clauseIdx).m_attrs.isEmpty())
                 {
                     // R3 package capabilities should only have a version attribute.
-                    List<Attribute> attrs = clauses.get(clauseIdx).m_attrs;
-                    Attribute pkgVersion = new Attribute(Capability.VERSION_ATTR, Version.emptyVersion, false);
-                    for (int attrIdx = 0; attrIdx < attrs.size(); attrIdx++)
+                    Map<String, Object> attrs = clauses.get(clauseIdx).m_attrs;
+                    Object pkgVersion = clauses.get(clauseIdx).m_attrs
+                        .get(BundleCapabilityImpl.VERSION_ATTR);
+                    pkgVersion = (pkgVersion == null)
+                        ? Version.emptyVersion
+                        : pkgVersion;
+                    for (Entry<String, Object> entry : clauses.get(clauseIdx).m_attrs.entrySet())
                     {
-                        if (attrs.get(attrIdx).getName().equals(Capability.VERSION_ATTR))
-                        {
-                            pkgVersion = attrs.get(attrIdx);
-                        }
-                        else
+                        if (!entry.getKey().equals(
+                            BundleCapabilityImpl.VERSION_ATTR))
                         {
                             logger.log(
                                 Logger.LOG_WARNING,
                                 "Unknown R3 export attribute: "
-                                + attrs.get(attrIdx).getName());
+                                + entry.getKey());
                         }
                     }
 
                     // Recreate the export to remove any other attributes
                     // and add version if missing.
-                    List<Attribute> newAttrs = new ArrayList<Attribute>(2);
-                    newAttrs.add(pkgVersion);
+                    Map<String, Object> newAttrs = new HashMap<String, Object>(1);
+                    newAttrs.put(BundleCapabilityImpl.VERSION_ATTR, pkgVersion);
                     clauses.set(clauseIdx, new ParsedHeaderClause(
                         clauses.get(clauseIdx).m_paths,
                         clauses.get(clauseIdx).m_dirs,
@@ -743,17 +682,17 @@ public class ManifestParser
         return m_bundleVersion;
     }
 
-    public List<Capability> getCapabilities()
+    public List<BundleCapabilityImpl> getCapabilities()
     {
         return m_capabilities;
     }
 
-    public List<Requirement> getRequirements()
+    public List<BundleRequirementImpl> getRequirements()
     {
         return m_requirements;
     }
 
-    public List<Requirement> getDynamicRequirements()
+    public List<BundleRequirementImpl> getDynamicRequirements()
     {
         return m_dynamicRequirements;
     }
@@ -853,7 +792,7 @@ public class ManifestParser
 
             // Select the matching native clause.
             int selected = 0;
-            if (clauseList.size() == 0)
+            if (clauseList.isEmpty())
             {
                 // If optional clause exists, no error thrown.
                 if (m_libraryHeadersOptional)
@@ -936,7 +875,7 @@ public class ManifestParser
             }
         }
 
-        if (selection.size() == 0)
+        if (selection.isEmpty())
         {
             // Re-init index list.
             selection.clear();
@@ -967,7 +906,7 @@ public class ManifestParser
         }
 
         // Return the first sorted clause
-        if (selection.size() == 0)
+        if (selection.isEmpty())
         {
             return 0;
         }
@@ -978,7 +917,7 @@ public class ManifestParser
     }
 
     private static List<ParsedHeaderClause> calculateImplicitImports(
-        List<Capability> exports, List<ParsedHeaderClause> imports)
+        List<BundleCapabilityImpl> exports, List<ParsedHeaderClause> imports)
         throws BundleException
     {
         List<ParsedHeaderClause> clauseList = new ArrayList();
@@ -1000,34 +939,32 @@ public class ManifestParser
         // Add import requirement for each export capability.
         for (int i = 0; i < exports.size(); i++)
         {
-            if (map.get(exports.get(i).getAttribute(Capability.PACKAGE_ATTR).getValue()) == null)
+            if (map.get(exports.get(i).getAttributes()
+                .get(BundleCapabilityImpl.PACKAGE_ATTR)) == null)
             {
                 // Convert Version to VersionRange.
-                List<Attribute> attrs = new ArrayList<Attribute>(exports.get(i).getAttributes());
-                for (int attrIdx = 0; (attrs != null) && (attrIdx < attrs.size()); attrIdx++)
+                Map<String, Object> attrs = new HashMap<String, Object>();
+                Object version = exports.get(i).getAttributes().get(Constants.VERSION_ATTRIBUTE);
+                if (version != null)
                 {
-                    if (attrs.get(attrIdx).getName().equals(Constants.VERSION_ATTRIBUTE))
-                    {
-                        attrs.set(attrIdx, new Attribute(
-                            attrs.get(attrIdx).getName(),
-                            VersionRange.parse(attrs.get(attrIdx).getValue().toString()),
-                            attrs.get(attrIdx).isMandatory()));
-                    }
+                    attrs.put(
+                        Constants.VERSION_ATTRIBUTE,
+                        VersionRange.parse(version.toString()));
                 }
 
                 List<String> paths = new ArrayList();
                 paths.add((String)
-                    exports.get(i).getAttribute(Capability.PACKAGE_ATTR).getValue());
+                    exports.get(i).getAttributes().get(BundleCapabilityImpl.PACKAGE_ATTR));
                 clauseList.add(
-                    new ParsedHeaderClause(paths, new ArrayList<Directive>(0), attrs));
+                    new ParsedHeaderClause(paths, Collections.EMPTY_MAP, attrs));
             }
         }
 
         return clauseList;
     }
 
-    private static List<Capability> calculateImplicitUses(
-        List<Capability> exports, List<ParsedHeaderClause> imports)
+    private static List<BundleCapabilityImpl> calculateImplicitUses(
+        List<BundleCapabilityImpl> exports, List<ParsedHeaderClause> imports)
         throws BundleException
     {
         // Add a "uses" directive onto each export of R3 bundles
@@ -1045,16 +982,14 @@ public class ManifestParser
                     + imports.get(i).m_paths.get(pathIdx);
             }
         }
-        Directive uses = new Directive(
-            Constants.USES_DIRECTIVE, usesValue);
         for (int i = 0; i < exports.size(); i++)
         {
-            List<Directive> dirList = new ArrayList<Directive>(1);
-            dirList.add(uses);
-            exports.set(i, new CapabilityImpl(
+            Map<String, String> dirs = new HashMap<String, String>(1);
+            dirs.put(Constants.USES_DIRECTIVE, usesValue);
+            exports.set(i, new BundleCapabilityImpl(
                 exports.get(i).getModule(),
-                Capability.PACKAGE_NAMESPACE,
-                dirList,
+                BundleCapabilityImpl.PACKAGE_NAMESPACE,
+                dirs,
                 exports.get(i).getAttributes()));
         }
 
@@ -1063,13 +998,13 @@ public class ManifestParser
 
     private static boolean checkExtensionBundle(Map headerMap) throws BundleException
     {
-        Directive extension = parseExtensionBundleHeader(
+        Object extension = parseExtensionBundleHeader(
             (String) headerMap.get(Constants.FRAGMENT_HOST));
 
         if (extension != null)
         {
-            if (!(Constants.EXTENSION_FRAMEWORK.equals(extension.getValue()) ||
-                Constants.EXTENSION_BOOTCLASSPATH.equals(extension.getValue())))
+            if (!(Constants.EXTENSION_FRAMEWORK.equals(extension) ||
+                Constants.EXTENSION_BOOTCLASSPATH.equals(extension)))
             {
                 throw new BundleException(
                     "Extension bundle must have either 'extension:=framework' or 'extension:=bootclasspath'");
@@ -1087,7 +1022,7 @@ public class ManifestParser
         return false;
     }
 
-    private static Capability parseBundleSymbolicName(Module owner, Map headerMap)
+    private static BundleCapabilityImpl parseBundleSymbolicName(Module owner, Map headerMap)
         throws BundleException
     {
         List<ParsedHeaderClause> clauses = parseStandardHeader(
@@ -1130,14 +1065,12 @@ public class ManifestParser
 
             // Create a module capability and return it.
             String symName = (String) clauses.get(0).m_paths.get(0);
-            List<Attribute> attrs = new ArrayList<Attribute>(2);
-            attrs.add(new Attribute(
-                Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, symName, false));
-            attrs.add(new Attribute(
-                Constants.BUNDLE_VERSION_ATTRIBUTE, bundleVersion, false));
-            return new CapabilityImpl(
+            Map<String, Object> attrs = new HashMap<String, Object>(2);
+            attrs.put(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, symName);
+            attrs.put(Constants.BUNDLE_VERSION_ATTRIBUTE, bundleVersion);
+            return new BundleCapabilityImpl(
                 owner,
-                Capability.MODULE_NAMESPACE,
+                BundleCapabilityImpl.MODULE_NAMESPACE,
                 clauses.get(0).m_dirs,
                 attrs);
         }
@@ -1145,11 +1078,11 @@ public class ManifestParser
         return null;
     }
 
-    private static List<Requirement> parseFragmentHost(
+    private static List<BundleRequirementImpl> parseFragmentHost(
         Logger logger, Module owner, Map headerMap)
         throws BundleException
     {
-        List<Requirement> reqs = new ArrayList();
+        List<BundleRequirementImpl> reqs = new ArrayList();
 
         String mv = getManifestVersion(headerMap);
         if ((mv != null) && mv.equals("2"))
@@ -1173,10 +1106,12 @@ public class ManifestParser
                 }
 
                 // Strip all attributes other than bundle-version.
-                for (Iterator<Attribute> it = clauses.get(0).m_attrs.iterator(); it.hasNext(); )
+                for (Iterator<Entry<String, Object>> it =
+                        clauses.get(0).m_attrs.entrySet().iterator();
+                    it.hasNext(); )
                 {
-                    Attribute attr = it.next();
-                    if (!attr.getName().equals(Constants.BUNDLE_VERSION_ATTRIBUTE))
+                    Entry<String, Object> entry = it.next();
+                    if (!entry.getKey().equals(Constants.BUNDLE_VERSION_ATTRIBUTE))
                     {
                         it.remove();
                     }
@@ -1184,26 +1119,24 @@ public class ManifestParser
 
                 // If the bundle-version attribute is specified, then convert
                 // it to the proper type.
-                if (clauses.get(0).m_attrs.size() == 1)
+                Object value = clauses.get(0).m_attrs.get(Constants.BUNDLE_VERSION_ATTRIBUTE);
+                if (value != null)
                 {
-                    Attribute attr = clauses.get(0).m_attrs.get(0);
-                    clauses.get(0).m_attrs.set(0,
-                        new Attribute(
-                            Constants.BUNDLE_VERSION_ATTRIBUTE,
-                            VersionRange.parse(attr.getValue().toString()),
-                            attr.isMandatory()));
+                    clauses.get(0).m_attrs.put(
+                        Constants.BUNDLE_VERSION_ATTRIBUTE,
+                        VersionRange.parse(value.toString()));
                 }
 
                 // Prepend the host symbolic name to the array of attributes.
-                List<Attribute> attrs = clauses.get(0).m_attrs;
-                List<Attribute> newAttrs = new ArrayList<Attribute>(attrs.size() + 1);
-                newAttrs.add(new Attribute(
+                Map<String, Object> attrs = clauses.get(0).m_attrs;
+                Map<String, Object> newAttrs = new HashMap<String, Object>(attrs.size() + 1);
+                newAttrs.put(
                     Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE,
-                    clauses.get(0).m_paths.get(0), false));
-                newAttrs.addAll(attrs);
+                    clauses.get(0).m_paths.get(0));
+                newAttrs.putAll(attrs);
 
-                reqs.add(new RequirementImpl(
-                    owner, Capability.HOST_NAMESPACE,
+                reqs.add(new BundleRequirementImpl(
+                    owner, BundleCapabilityImpl.HOST_NAMESPACE,
                     clauses.get(0).m_dirs,
                     newAttrs));
             }
@@ -1222,11 +1155,11 @@ public class ManifestParser
         return reqs;
     }
 
-    public static List<Capability> parseExportHeader(
+    public static List<BundleCapabilityImpl> parseExportHeader(
         Logger logger, Module owner, String header, String bsn, Version bv)
     {
 
-        List<Capability> caps = null;
+        List<BundleCapabilityImpl> caps = null;
         try
         {
             List<ParsedHeaderClause> exportClauses = parseStandardHeader(header);
@@ -1240,10 +1173,10 @@ public class ManifestParser
         return caps;
     }
 
-    private static List<Capability> convertExports(
+    private static List<BundleCapabilityImpl> convertExports(
         List<ParsedHeaderClause> clauses, Module owner)
     {
-        List<Capability> capList = new ArrayList();
+        List<BundleCapabilityImpl> capList = new ArrayList();
         for (int clauseIdx = 0; clauseIdx < clauses.size(); clauseIdx++)
         {
             for (int pathIdx = 0;
@@ -1251,18 +1184,18 @@ public class ManifestParser
                 pathIdx++)
             {
                 // Prepend the package name to the array of attributes.
-                List<Attribute> attrs = clauses.get(clauseIdx).m_attrs;
-                List<Attribute> newAttrs = new ArrayList<Attribute>(attrs.size() + 1);
-                newAttrs.add(new Attribute(
-                    Capability.PACKAGE_ATTR,
-                    clauses.get(clauseIdx).m_paths.get(pathIdx), false));
-                newAttrs.addAll(attrs);
+                Map<String, Object> attrs = clauses.get(clauseIdx).m_attrs;
+                Map<String, Object> newAttrs = new HashMap<String, Object>(attrs.size() + 1);
+                newAttrs.put(
+                    BundleCapabilityImpl.PACKAGE_ATTR,
+                    clauses.get(clauseIdx).m_paths.get(pathIdx));
+                newAttrs.putAll(attrs);
 
                 // Create package capability and add to capability list.
                 capList.add(
-                    new CapabilityImpl(
+                    new BundleCapabilityImpl(
                         owner,
-                        Capability.PACKAGE_NAMESPACE,
+                        BundleCapabilityImpl.PACKAGE_NAMESPACE,
                         clauses.get(clauseIdx).m_dirs,
                         newAttrs));
             }
@@ -1284,19 +1217,13 @@ public class ManifestParser
             // Convert bundle version attribute to VersionRange type.
             for (int clauseIdx = 0; clauseIdx < clauses.size(); clauseIdx++)
             {
-                for (int attrIdx = 0;
-                    attrIdx < clauses.get(clauseIdx).m_attrs.size();
-                    attrIdx++)
+                Object value = clauses.get(clauseIdx).m_attrs.get(
+                    Constants.BUNDLE_VERSION_ATTRIBUTE);
+                if (value != null)
                 {
-                    Attribute attr = clauses.get(clauseIdx).m_attrs.get(attrIdx);
-                    if (attr.getName().equals(Constants.BUNDLE_VERSION_ATTRIBUTE))
-                    {
-                        clauses.get(clauseIdx).m_attrs.set(attrIdx,
-                            new Attribute(
-                                Constants.BUNDLE_VERSION_ATTRIBUTE,
-                                VersionRange.parse(attr.getValue().toString()),
-                                attr.isMandatory()));
-                    }
+                    clauses.get(clauseIdx).m_attrs.put(
+                        Constants.BUNDLE_VERSION_ATTRIBUTE,
+                        VersionRange.parse(value.toString()));
                 }
             }
         }
@@ -1304,30 +1231,35 @@ public class ManifestParser
         return clauses;
     }
 
-    private static List<Requirement> convertRequires(
+    private static List<BundleRequirementImpl> convertRequires(
         List<ParsedHeaderClause> clauses, Module owner)
     {
-        List<Requirement> reqList = new ArrayList();
+        List<BundleRequirementImpl> reqList = new ArrayList();
         for (int clauseIdx = 0; clauseIdx < clauses.size(); clauseIdx++)
         {
-            List<Attribute> attrs = clauses.get(clauseIdx).m_attrs;
-
             for (int pathIdx = 0;
                 pathIdx < clauses.get(clauseIdx).m_paths.size();
                 pathIdx++)
             {
+                // Prepend the bundle symbolic name to the array of attributes.
+                Map<String, Object> attrs = clauses.get(clauseIdx).m_attrs;
+                // Note that we use a linked hash map here to ensure the
+                // package attribute is first, which will make indexing
+                // more efficient.
+// TODO: OSGi R4.3 - This is a hack...perhaps we should use the standard "key"
+//       notion where namespace is also the name of the key attribute.
                 // Prepend the symbolic name to the array of attributes.
-                List<Attribute> newAttrs = new ArrayList<Attribute>(attrs.size() + 1);
-                newAttrs.add(new Attribute(
+                Map<String, Object> newAttrs = new LinkedHashMap<String, Object>(attrs.size() + 1);
+                newAttrs.put(
                     Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE,
-                    clauses.get(clauseIdx).m_paths.get(pathIdx), false));
-                newAttrs.addAll(attrs);
+                    clauses.get(clauseIdx).m_paths.get(pathIdx));
+                newAttrs.putAll(attrs);
 
                 // Create package requirement and add to requirement list.
                 reqList.add(
-                    new RequirementImpl(
+                    new BundleRequirementImpl(
                         owner,
-                        Capability.MODULE_NAMESPACE,
+                        BundleCapabilityImpl.MODULE_NAMESPACE,
                         clauses.get(clauseIdx).m_dirs,
                         newAttrs));
             }
@@ -1336,27 +1268,26 @@ public class ManifestParser
         return reqList;
     }
 
-    public static Directive parseExtensionBundleHeader(String header)
+    public static String parseExtensionBundleHeader(String header)
         throws BundleException
     {
         List<ParsedHeaderClause> clauses = parseStandardHeader(header);
 
-        Directive result = null;
+        String result = null;
 
         if (clauses.size() == 1)
         {
             // See if there is the "extension" directive.
-            List<Directive> dirs = clauses.get(0).m_dirs;
-            for (int dirIdx = 0; (result == null) && (dirIdx < dirs.size()); dirIdx++)
+            for (Entry<String, String> entry : clauses.get(0).m_dirs.entrySet())
             {
-                if (Constants.EXTENSION_DIRECTIVE.equals(dirs.get(dirIdx).getName()))
+                if (Constants.EXTENSION_DIRECTIVE.equals(entry.getKey()))
                 {
                     // If the extension directive is specified, make sure
                     // the target is the system bundle.
                     if (FelixConstants.SYSTEM_BUNDLE_SYMBOLICNAME.equals(clauses.get(0).m_paths.get(0)) ||
                         Constants.SYSTEM_BUNDLE_SYMBOLICNAME.equals(clauses.get(0).m_paths.get(0)))
                     {
-                        result = (Directive) dirs.get(dirIdx);
+                        return entry.getValue();
                     }
                     else
                     {
@@ -1386,16 +1317,15 @@ public class ManifestParser
                 if (clauses.get(0).m_paths.get(clauseIdx).equals(Constants.ACTIVATION_LAZY))
                 {
                     m_activationPolicy = Module.LAZY_ACTIVATION;
-                    for (int dirIdx = 0; dirIdx < clauses.get(0).m_dirs.size(); dirIdx++)
+                    for (Entry<String, String> entry : clauses.get(0).m_dirs.entrySet())
                     {
-                        Directive dir = clauses.get(0).m_dirs.get(dirIdx);
-                        if (dir.getName().equalsIgnoreCase(Constants.INCLUDE_DIRECTIVE))
+                        if (entry.getKey().equalsIgnoreCase(Constants.INCLUDE_DIRECTIVE))
                         {
-                            m_activationIncludeDir = (String) dir.getValue();
+                            m_activationIncludeDir = entry.getValue();
                         }
-                        else if (dir.getName().equalsIgnoreCase(Constants.EXCLUDE_DIRECTIVE))
+                        else if (entry.getKey().equalsIgnoreCase(Constants.EXCLUDE_DIRECTIVE))
                         {
-                            m_activationExcludeDir = (String) dir.getValue();
+                            m_activationExcludeDir = entry.getValue();
                         }
                     }
                     break;
@@ -1471,8 +1401,8 @@ public class ManifestParser
         }
 
         // Parse the directives/attributes.
-        Map<String, Directive> dirsMap = new HashMap();
-        Map<String, Attribute> attrsMap = new HashMap();
+        Map<String, String> dirs = new HashMap<String, String>();
+        Map<String, Object> attrs = new HashMap<String, Object>();
         int idx = -1;
         String sep = null;
         for (int pieceIdx = pathCount; pieceIdx < pieces.size(); pieceIdx++)
@@ -1506,36 +1436,25 @@ public class ManifestParser
             if (sep.equals(FelixConstants.DIRECTIVE_SEPARATOR))
             {
                 // Check for duplicates.
-                if (dirsMap.get(key) != null)
+                if (dirs.get(key) != null)
                 {
                     throw new IllegalArgumentException(
                         "Duplicate directive: " + key);
                 }
-                dirsMap.put(key, new Directive(key, value));
+                dirs.put(key, value);
             }
             else
             {
                 // Check for duplicates.
-                if (attrsMap.get(key) != null)
+                if (attrs.get(key) != null)
                 {
                     throw new IllegalArgumentException(
                         "Duplicate attribute: " + key);
                 }
-                attrsMap.put(key, new Attribute(key, value, false));
+                attrs.put(key, value);
             }
         }
 
-        List<Directive> dirs = new ArrayList<Directive>(dirsMap.size());
-        for (Entry<String, Directive> entry : dirsMap.entrySet())
-        {
-            dirs.add(entry.getValue());
-        }
-        List<Attribute> attrs = new ArrayList<Attribute>(attrsMap.size());
-        for (Entry<String, Attribute> entry : attrsMap.entrySet())
-        {
-            attrs.add(entry.getValue());
-        }
-
         return new ParsedHeaderClause(paths, dirs, attrs);
     }
 
@@ -1633,4 +1552,4 @@ public class ManifestParser
 
         return libList;
     }
-}
+}
\ No newline at end of file

Modified: felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/util/manifestparser/ParsedHeaderClause.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/util/manifestparser/ParsedHeaderClause.java?rev=1091216&r1=1091215&r2=1091216&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/util/manifestparser/ParsedHeaderClause.java (original)
+++ felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/util/manifestparser/ParsedHeaderClause.java Mon Apr 11 21:11:58 2011
@@ -19,16 +19,16 @@
 package org.apache.felix.framework.util.manifestparser;
 
 import java.util.List;
-import org.apache.felix.framework.capabilityset.Attribute;
-import org.apache.felix.framework.capabilityset.Directive;
+import java.util.Map;
 
 public class ParsedHeaderClause
 {
     public final List<String> m_paths;
-    public final List<Directive> m_dirs;
-    public final List<Attribute> m_attrs;
+    public final Map<String, String> m_dirs;
+    public final Map<String, Object> m_attrs;
 
-    public ParsedHeaderClause(List<String> paths, List<Directive> dirs, List<Attribute> attrs)
+    public ParsedHeaderClause(
+        List<String> paths, Map<String, String> dirs, Map<String, Object> attrs)
     {
         m_paths = paths;
         m_dirs = dirs;

Added: felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/wiring/BundleCapabilityImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/wiring/BundleCapabilityImpl.java?rev=1091216&view=auto
==============================================================================
--- felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/wiring/BundleCapabilityImpl.java (added)
+++ felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/wiring/BundleCapabilityImpl.java Mon Apr 11 21:11:58 2011
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.framework.wiring;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Collections;
+import java.util.Set;
+import java.util.Map;
+import java.util.List;
+import java.util.StringTokenizer;
+import org.apache.felix.framework.capabilityset.SimpleFilter;
+import org.apache.felix.framework.resolver.Module;
+import org.apache.felix.framework.util.Util;
+import org.apache.felix.framework.util.manifestparser.ManifestParser;
+import org.osgi.framework.Constants;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRevision;
+
+public class BundleCapabilityImpl implements BundleCapability
+{
+    public static final String MODULE_NAMESPACE = "module";
+    public static final String HOST_NAMESPACE = "host";
+    public static final String PACKAGE_NAMESPACE = "package";
+    public static final String SINGLETON_NAMESPACE = "singleton";
+
+    public static final String PACKAGE_ATTR = "package";
+    public static final String VERSION_ATTR = "version";
+
+    private final Module m_module;
+    private final String m_namespace;
+    private final Map<String, String> m_dirs;
+    private final Map<String, Object> m_attrs;
+    private final List<String> m_uses;
+    private final List<List<String>> m_includeFilter;
+    private final List<List<String>> m_excludeFilter;
+    private final Set<String> m_mandatory;
+
+    public BundleCapabilityImpl(Module module, String namespace,
+        Map<String, String> dirs, Map<String, Object> attrs)
+    {
+        m_namespace = namespace;
+        m_module = module;
+        m_dirs = Collections.unmodifiableMap(dirs);
+        m_attrs = Collections.unmodifiableMap(attrs);
+
+        // Find all export directives: uses, mandatory, include, and exclude.
+        
+        m_uses = new ArrayList(0);
+        String value = m_dirs.get(Constants.USES_DIRECTIVE);
+        if (value != null)
+        {
+            // Parse these uses directive.
+            StringTokenizer tok = new StringTokenizer(value, ",");
+            while (tok.hasMoreTokens())
+            {
+                m_uses.add(tok.nextToken().trim());
+            }
+        }
+
+        value = m_dirs.get(Constants.INCLUDE_DIRECTIVE);
+        if (value != null)
+        {
+            List<String> filters = ManifestParser.parseDelimitedString(value, ",");
+            m_includeFilter = new ArrayList<List<String>>(filters.size());
+            for (int filterIdx = 0; filterIdx < filters.size(); filterIdx++)
+            {
+                List<String> substrings = SimpleFilter.parseSubstring(filters.get(filterIdx));
+                m_includeFilter.add(substrings);
+            }
+        }
+        else
+        {
+            m_includeFilter = null;
+        }
+
+        value = m_dirs.get(Constants.EXCLUDE_DIRECTIVE);
+        if (value != null)
+        {
+            List<String> filters = ManifestParser.parseDelimitedString(value, ",");
+            m_excludeFilter = new ArrayList<List<String>>(filters.size());
+            for (int filterIdx = 0; filterIdx < filters.size(); filterIdx++)
+            {
+                List<String> substrings = SimpleFilter.parseSubstring(filters.get(filterIdx));
+                m_excludeFilter.add(substrings);
+            }
+        }
+        else
+        {
+            m_excludeFilter = null;
+        }
+
+        m_mandatory = new HashSet<String>(0);
+        value = m_dirs.get(Constants.MANDATORY_DIRECTIVE);
+        if (value != null)
+        {
+            List<String> names = ManifestParser.parseDelimitedString(value, ",");
+            for (String name : names)
+            {
+                // If attribute exists, then record it as mandatory.
+                if (m_attrs.containsKey(name))
+                {
+                    m_mandatory.add(name);
+                }
+                // Otherwise, report an error.
+                else
+                {
+                    throw new IllegalArgumentException(
+                        "Mandatory attribute '" + name + "' does not exist.");
+                }
+            }
+        }
+    }
+
+    public Module getModule()
+    {
+        return m_module;
+    }
+
+    public BundleRevision getRevision()
+    {
+        return null;
+    }
+
+    public String getNamespace()
+    {
+        return m_namespace;
+    }
+
+    public Map<String, String> getDirectives()
+    {
+        return m_dirs;
+    }
+
+    public Map<String, Object> getAttributes()
+    {
+        return m_attrs;
+    }
+
+    public boolean isAttributeMandatory(String name)
+    {
+        return !m_mandatory.isEmpty() && m_mandatory.contains(name);
+    }
+
+    public List<String> getUses()
+    {
+        return m_uses;
+    }
+
+    public boolean isIncluded(String name)
+    {
+        if ((m_includeFilter == null) && (m_excludeFilter == null))
+        {
+            return true;
+        }
+
+        // Get the class name portion of the target class.
+        String className = Util.getClassName(name);
+
+        // If there are no include filters then all classes are included
+        // by default, otherwise try to find one match.
+        boolean included = (m_includeFilter == null);
+        for (int i = 0;
+            (!included) && (m_includeFilter != null) && (i < m_includeFilter.size());
+            i++)
+        {
+            included = SimpleFilter.compareSubstring(m_includeFilter.get(i), className);
+        }
+
+        // If there are no exclude filters then no classes are excluded
+        // by default, otherwise try to find one match.
+        boolean excluded = false;
+        for (int i = 0;
+            (!excluded) && (m_excludeFilter != null) && (i < m_excludeFilter.size());
+            i++)
+        {
+            excluded = SimpleFilter.compareSubstring(m_excludeFilter.get(i), className);
+        }
+        return included && !excluded;
+    }
+
+    public String toString()
+    {
+        if (m_module == null)
+        {
+            return m_attrs.toString();
+        }
+        if (m_namespace.equals(PACKAGE_NAMESPACE))
+        {
+            return "[" + m_module + "] "
+                + m_namespace + "; " + m_attrs.get(PACKAGE_ATTR);
+        }
+        return "[" + m_module + "] " + m_namespace + "; " + m_attrs;
+    }
+}
\ No newline at end of file

Added: felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/wiring/BundleRequirementImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/wiring/BundleRequirementImpl.java?rev=1091216&view=auto
==============================================================================
--- felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/wiring/BundleRequirementImpl.java (added)
+++ felix/sandbox/rickhall/framework-r43/src/main/java/org/apache/felix/framework/wiring/BundleRequirementImpl.java Mon Apr 11 21:11:58 2011
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.framework.wiring;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.felix.framework.capabilityset.CapabilitySet;
+import org.apache.felix.framework.capabilityset.SimpleFilter;
+import org.apache.felix.framework.resolver.Module;
+import org.apache.felix.framework.util.VersionRange;
+import org.osgi.framework.Constants;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
+
+public class BundleRequirementImpl implements BundleRequirement
+{
+    private final Module m_module;
+    private final String m_namespace;
+    private final SimpleFilter m_filter;
+    private final boolean m_optional;
+    private final Map<String, String> m_dirs;
+    private final Map<String, Object> m_attrs;
+
+    public BundleRequirementImpl(
+        Module module, String namespace,
+        Map<String, String> dirs, Map<String, Object> attrs)
+    {
+        m_module = module;
+        m_namespace = namespace;
+        m_dirs = Collections.unmodifiableMap(dirs);
+        m_attrs = Collections.unmodifiableMap(attrs);
+        m_filter = convertToFilter(attrs);
+
+        // Find resolution import directives.
+        boolean optional = false;
+        if (m_dirs.containsKey(Constants.RESOLUTION_DIRECTIVE)
+            && m_dirs.get(Constants.RESOLUTION_DIRECTIVE).equals(Constants.RESOLUTION_OPTIONAL))
+        {
+            optional = true;
+        }
+        m_optional = optional;
+    }
+
+    public String getNamespace()
+    {
+        return m_namespace;
+    }
+
+    public Map<String, String> getDirectives()
+    {
+        return m_dirs;
+    }
+
+    public Map<String, Object> getAttributes()
+    {
+        return m_attrs;
+    }
+
+    public Module getModule()
+    {
+        return m_module;
+    }
+
+    public BundleRevision getRevision()
+    {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public boolean matches(BundleCapability cap)
+    {
+        return CapabilitySet.matches((BundleCapabilityImpl) cap, getFilter());
+    }
+
+    public boolean isOptional()
+    {
+        return m_optional;
+    }
+
+    public SimpleFilter getFilter()
+    {
+        return m_filter;
+    }
+
+    public String toString()
+    {
+        return "[" + m_module + "] " + m_namespace + "; " + getFilter().toString();
+    }
+
+    private static SimpleFilter convertToFilter(Map<String, Object> attrs)
+    {
+        // Rather than building a filter string to be parsed into a SimpleFilter,
+        // we will just create the parsed SimpleFilter directly.
+
+        List<SimpleFilter> filters = new ArrayList<SimpleFilter>();
+
+        for (Entry<String, Object> entry : attrs.entrySet())
+        {
+            if (entry.getValue() instanceof VersionRange)
+            {
+                VersionRange vr = (VersionRange) entry.getValue();
+                if (vr.isFloorInclusive())
+                {
+                    filters.add(
+                        new SimpleFilter(
+                            entry.getKey(),
+                            vr.getFloor().toString(),
+                            SimpleFilter.GTE));
+                }
+                else
+                {
+                    SimpleFilter not =
+                        new SimpleFilter(null, new ArrayList(), SimpleFilter.NOT);
+                    ((List) not.getValue()).add(
+                        new SimpleFilter(
+                            entry.getKey(),
+                            vr.getFloor().toString(),
+                            SimpleFilter.LTE));
+                    filters.add(not);
+                }
+
+                if (vr.getCeiling() != null)
+                {
+                    if (vr.isCeilingInclusive())
+                    {
+                        filters.add(
+                            new SimpleFilter(
+                                entry.getKey(),
+                                vr.getCeiling().toString(),
+                                SimpleFilter.LTE));
+                    }
+                    else
+                    {
+                        SimpleFilter not =
+                            new SimpleFilter(null, new ArrayList(), SimpleFilter.NOT);
+                        ((List) not.getValue()).add(
+                            new SimpleFilter(
+                                entry.getKey(),
+                                vr.getCeiling().toString(),
+                                SimpleFilter.GTE));
+                        filters.add(not);
+                    }
+                }
+            }
+            else
+            {
+                List<String> values = SimpleFilter.parseSubstring(entry.getValue().toString());
+                if (values.size() > 1)
+                {
+                    filters.add(
+                        new SimpleFilter(
+                            entry.getKey(),
+                            values,
+                            SimpleFilter.SUBSTRING));
+                }
+                else
+                {
+                    filters.add(
+                        new SimpleFilter(
+                            entry.getKey(),
+                            values.get(0),
+                            SimpleFilter.EQ));
+                }
+            }
+        }
+
+        SimpleFilter sf = null;
+
+        if (filters.size() == 1)
+        {
+            sf = filters.get(0);
+        }
+        else if (attrs.size() > 1)
+        {
+            sf = new SimpleFilter(null, filters, SimpleFilter.AND);
+        }
+        else if (filters.isEmpty())
+        {
+            sf = new SimpleFilter(null, null, SimpleFilter.MATCH_ALL);
+        }
+
+        return sf;
+    }
+}
\ No newline at end of file

Added: felix/sandbox/rickhall/framework-r43/src/main/java/org/osgi/framework/wiring/BundleCapability.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r43/src/main/java/org/osgi/framework/wiring/BundleCapability.java?rev=1091216&view=auto
==============================================================================
--- felix/sandbox/rickhall/framework-r43/src/main/java/org/osgi/framework/wiring/BundleCapability.java (added)
+++ felix/sandbox/rickhall/framework-r43/src/main/java/org/osgi/framework/wiring/BundleCapability.java Mon Apr 11 21:11:58 2011
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) OSGi Alliance (2010, 2011). All Rights Reserved.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.osgi.framework.wiring;
+
+import java.util.Map;
+
+/**
+ * A capability that has been declared from a {@link BundleRevision bundle
+ * revision}.
+ * 
+ * @ThreadSafe
+ * @noimplement
+ * @version $Id: 0fde13c3228af1aa97872b37ccf0aa6e23123b11 $
+ */
+public interface BundleCapability {
+	/**
+	 * Returns the name space of this capability.
+	 * 
+	 * @return The name space of this capability.
+	 */
+	String getNamespace();
+
+	/**
+	 * Returns the directives of this capability.
+	 * 
+	 * @return An unmodifiable map of directive names to directive values for
+	 *         this capability, or an empty map if this capability has no
+	 *         directives.
+	 */
+	Map<String, String> getDirectives();
+
+	/**
+	 * Returns the attributes of this capability.
+	 * 
+	 * @return An unmodifiable map of attribute names to attribute values for
+	 *         this capability, or an empty map if this capability has no
+	 *         attributes.
+	 */
+	Map<String, Object> getAttributes();
+
+	/**
+	 * Returns the bundle revision declaring this capability.
+	 * 
+	 * @return The bundle revision declaring this capability.
+	 */
+	BundleRevision getRevision();
+}

Added: felix/sandbox/rickhall/framework-r43/src/main/java/org/osgi/framework/wiring/BundleRequirement.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r43/src/main/java/org/osgi/framework/wiring/BundleRequirement.java?rev=1091216&view=auto
==============================================================================
--- felix/sandbox/rickhall/framework-r43/src/main/java/org/osgi/framework/wiring/BundleRequirement.java (added)
+++ felix/sandbox/rickhall/framework-r43/src/main/java/org/osgi/framework/wiring/BundleRequirement.java Mon Apr 11 21:11:58 2011
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) OSGi Alliance (2010, 2011). All Rights Reserved.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.osgi.framework.wiring;
+
+import java.util.Map;
+
+/**
+ * A requirement that has been declared from a {@link BundleRevision bundle
+ * revision}.
+ * 
+ * @ThreadSafe
+ * @noimplement
+ * @version $Id: 659132c1fac7526240df377ead0e1bc8d4af2e77 $
+ */
+public interface BundleRequirement {
+	/**
+	 * Returns the name space of this requirement.
+	 * 
+	 * @return The name space of this requirement.
+	 */
+	String getNamespace();
+
+	/**
+	 * Returns the directives of this requirement.
+	 * 
+	 * @return An unmodifiable map of directive names to directive values for
+	 *         this requirement, or an empty map if this requirement has no
+	 *         directives.
+	 */
+	Map<String, String> getDirectives();
+
+	/**
+	 * Returns the attributes of this requirement.
+	 * 
+	 * @return An unmodifiable map of attribute names to attribute values for
+	 *         this requirement, or an empty map if this requirement has no
+	 *         attributes.
+	 */
+	Map<String, Object> getAttributes();
+
+	/**
+	 * Returns the bundle revision declaring this requirement.
+	 * 
+	 * @return The bundle revision declaring this requirement.
+	 */
+	BundleRevision getRevision();
+
+	/**
+	 * Returns whether the specified capability matches this requirement.
+	 * 
+	 * @param capability The capability to match to this requirement.
+	 * @return {@code true} if the specified capability has the same
+	 *         {@link #getNamespace() name space} as this requirement and the
+	 *         filter for this requirement matches the
+	 *         {@link BundleCapability#getAttributes() attributes of the
+	 *         specified capability}; {@code false} otherwise.
+	 */
+	boolean matches(BundleCapability capability);
+}



Mime
View raw message