You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2010/01/15 21:07:05 UTC

svn commit: r899798 - in /felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework: candidateset/ util/manifestparser/

Author: rickhall
Date: Fri Jan 15 20:07:04 2010
New Revision: 899798

URL: http://svn.apache.org/viewvc?rev=899798&view=rev
Log:
Start breaking everything, by starting to get the manifest parser using
the new resolver interfaces.

Added:
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/CapabilityImpl.java
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/RequirementImpl.java
Removed:
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/Capability.java
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/R4Attribute.java
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/R4Directive.java
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/Requirement.java
Modified:
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/candidateset/Module.java
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java

Modified: felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/candidateset/Module.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/candidateset/Module.java?rev=899798&r1=899797&r2=899798&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/candidateset/Module.java (original)
+++ felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/candidateset/Module.java Fri Jan 15 20:07:04 2010
@@ -22,6 +22,9 @@
 
 public interface Module
 {
+    final static int EAGER_ACTIVATION = 0;
+    final static int LAZY_ACTIVATION = 1;
+
     String getName();
     List<Capability> getCapabilities();
     List<Requirement> getRequirements();

Added: felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/CapabilityImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/CapabilityImpl.java?rev=899798&view=auto
==============================================================================
--- felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/CapabilityImpl.java (added)
+++ felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/CapabilityImpl.java Fri Jan 15 20:07:04 2010
@@ -0,0 +1,112 @@
+/*
+ *  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.util.manifestparser;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.felix.framework.candidateset.Attribute;
+import org.apache.felix.framework.candidateset.Capability;
+import org.apache.felix.framework.candidateset.Directive;
+import org.apache.felix.framework.candidateset.Module;
+
+public class CapabilityImpl implements Capability
+{
+    private final Module m_module;
+    private final String m_namespace;
+    private final List m_uses;
+    private final List<Directive> m_dirs;
+    private final List<Directive> m_dirsConst;
+    private final List<Attribute> m_attrs;
+    private final List<Attribute> m_attrsConst;
+
+    public CapabilityImpl(Module module, String namespace)
+    {
+        m_namespace = namespace;
+        m_module = module;
+        m_uses = new ArrayList<String>();
+        m_dirs = new ArrayList<Directive>();
+        m_dirsConst = Collections.unmodifiableList(m_dirs);
+        m_attrs = new ArrayList<Attribute>();
+        m_attrsConst = Collections.unmodifiableList(m_attrs);
+    }
+
+    public Module getModule()
+    {
+        return m_module;
+    }
+
+    public String getNamespace()
+    {
+        return m_namespace;
+    }
+
+    public Directive getDirective(String name)
+    {
+        for (int i = 0; i < m_dirs.size(); i++)
+        {
+            if (m_dirs.get(i).getName().equals(name))
+            {
+                return m_dirs.get(i);
+            }
+        }
+        return null;
+    }
+
+    public List<Directive> getDirectives()
+    {
+        return m_dirsConst;
+    }
+
+    public Attribute getAttribute(String name)
+    {
+        for (int i = 0; i < m_attrs.size(); i++)
+        {
+            if (m_attrs.get(i).getName().equals(name))
+            {
+                return m_attrs.get(i);
+            }
+        }
+        return null;
+    }
+
+    public List<Attribute> getAttributes()
+    {
+        return m_attrsConst;
+    }
+
+    public List<String> getUses()
+    {
+        return m_uses;
+    }
+
+    public String toString()
+    {
+        if (m_module == null)
+        {
+            return m_attrs.toString();
+        }
+        if (m_namespace.equals(Capability.PACKAGE_NAMESPACE))
+        {
+            return "[" + m_module + "] "
+                + m_namespace + "; " + getAttribute(Capability.PACKAGE_ATTR);
+        }
+        return "[" + m_module + "] " + m_namespace + "; " + m_attrs;
+    }
+}
\ No newline at end of file

Modified: felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java?rev=899798&r1=899797&r2=899798&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java (original)
+++ felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java Fri Jan 15 20:07:04 2010
@@ -21,11 +21,13 @@
 import java.util.*;
 
 import org.apache.felix.framework.Logger;
+import org.apache.felix.framework.candidateset.Capability;
+import org.apache.felix.framework.candidateset.Attribute;
+import org.apache.felix.framework.candidateset.Directive;
+import org.apache.felix.framework.candidateset.Module;
+import org.apache.felix.framework.candidateset.Requirement;
 import org.apache.felix.framework.util.FelixConstants;
 import org.apache.felix.framework.util.VersionRange;
-import org.apache.felix.moduleloader.ICapability;
-import org.apache.felix.moduleloader.IModule;
-import org.apache.felix.moduleloader.IRequirement;
 import org.osgi.framework.*;
 
 public class ManifestParser
@@ -33,19 +35,19 @@
     private final Logger m_logger;
     private final Map m_configMap;
     private final Map m_headerMap;
-    private volatile int m_activationPolicy = IModule.EAGER_ACTIVATION;
+    private volatile int m_activationPolicy = Module.EAGER_ACTIVATION;
     private volatile String m_activationIncludeDir;
     private volatile String m_activationExcludeDir;
     private volatile boolean m_isExtension = false;
     private volatile String m_bundleSymbolicName;
     private volatile Version m_bundleVersion;
-    private volatile ICapability[] m_capabilities;
-    private volatile IRequirement[] m_requirements;
-    private volatile IRequirement[] m_dynamicRequirements;
+    private volatile Capability[] m_capabilities;
+    private volatile Requirement[] m_requirements;
+    private volatile Requirement[] m_dynamicRequirements;
     private volatile R4LibraryClause[] m_libraryHeaders;
     private volatile boolean m_libraryHeadersOptional = false;
 
-    public ManifestParser(Logger logger, Map configMap, IModule owner, Map headerMap)
+    public ManifestParser(Logger logger, Map configMap, Module owner, Map headerMap)
         throws BundleException
     {
         m_logger = logger;
@@ -90,7 +92,7 @@
         // Parse bundle symbolic name.
         //
 
-        ICapability moduleCap = parseBundleSymbolicName(owner, m_headerMap);
+        Capability moduleCap = parseBundleSymbolicName(owner, m_headerMap);
         if (moduleCap != null)
         {
             m_bundleSymbolicName = (String)
@@ -105,9 +107,9 @@
             if (headerMap.get(Constants.FRAGMENT_HOST) == null)
             {
                 capList.add(moduleCap);
-                capList.add(new Capability(
-                    owner, ICapability.HOST_NAMESPACE, null,
-                    ((Capability) moduleCap).getAttributes()));
+                capList.add(new CapabilityImpl(
+                    owner, Capability.HOST_NAMESPACE, null,
+                    ((CapabilityImpl) moduleCap).getAttributes()));
             }
         }
 
@@ -116,7 +118,7 @@
         //
 
         // Get exported packages from bundle manifest.
-        ICapability[] exportCaps = parseExportHeader(
+        Capability[] exportCaps = parseExportHeader(
             owner, (String) headerMap.get(Constants.EXPORT_PACKAGE));
 
         // Verify that "java.*" packages are not exported.
@@ -124,7 +126,7 @@
         {
             // Verify that the named package has not already been declared.
             String pkgName = (String)
-                exportCaps[capIdx].getProperties().get(ICapability.PACKAGE_PROPERTY);
+                exportCaps[capIdx].getProperties().get(Capability.PACKAGE_PROPERTY);
             // Verify that java.* packages are not exported.
             if (pkgName.startsWith("java."))
             {
@@ -135,13 +137,13 @@
         }
 
         // Create an array of all capabilities.
-        m_capabilities = (ICapability[]) capList.toArray(new ICapability[capList.size()]);
+        m_capabilities = (Capability[]) capList.toArray(new Capability[capList.size()]);
 
         //
         // Parse Fragment-Host.
         //
 
-        IRequirement req = parseFragmentHost(m_logger, m_headerMap);
+        Requirement req = parseFragmentHost(m_logger, m_headerMap);
         if (req != null)
         {
             reqList.add(req);
@@ -151,7 +153,7 @@
         // Parse Require-Bundle
         //
 
-        IRequirement[] bundleReq = parseRequireBundleHeader(
+        Requirement[] bundleReq = parseRequireBundleHeader(
             (String) headerMap.get(Constants.REQUIRE_BUNDLE));
         for (int reqIdx = 0; reqIdx < bundleReq.length; reqIdx++)
         {
@@ -163,7 +165,7 @@
         //
 
         // Get import packages from bundle manifest.
-        IRequirement[] importReqs = parseImportHeader(
+        Requirement[] importReqs = parseImportHeader(
             (String) headerMap.get(Constants.IMPORT_PACKAGE));
 
         // Verify there are no duplicate import declarations.
@@ -171,7 +173,7 @@
         for (int reqIdx = 0; reqIdx < importReqs.length; reqIdx++)
         {
             // Verify that the named package has not already been declared.
-            String pkgName = ((Requirement) importReqs[reqIdx]).getTargetName();
+            String pkgName = ((RequirementImpl) importReqs[reqIdx]).getTargetName();
             if (!dupeSet.contains(pkgName))
             {
                 // Verify that java.* packages are not imported.
@@ -192,7 +194,7 @@
         }
 
         // Create an array of all requirements.
-        m_requirements = (IRequirement[]) reqList.toArray(new IRequirement[reqList.size()]);
+        m_requirements = (Requirement[]) reqList.toArray(new Requirement[reqList.size()]);
 
         //
         // Parse DynamicImport-Package.
@@ -207,7 +209,7 @@
         for (int reqIdx = 0; reqIdx < m_dynamicRequirements.length; reqIdx++)
         {
             // Verify that java.* packages are not imported.
-            String pkgName = ((Requirement) m_dynamicRequirements[reqIdx]).getTargetName();
+            String pkgName = ((RequirementImpl) m_dynamicRequirements[reqIdx]).getTargetName();
             if (pkgName.startsWith("java."))
             {
                 throw new BundleException(
@@ -307,12 +309,12 @@
         return m_capabilities;
     }
 
-    public IRequirement[] getRequirements()
+    public Requirement[] getRequirements()
     {
         return m_requirements;
     }
 
-    public IRequirement[] getDynamicRequirements()
+    public Requirement[] getDynamicRequirements()
     {
         return m_dynamicRequirements;
     }
@@ -550,10 +552,10 @@
             (m_capabilities != null) && (capIdx < m_capabilities.length);
             capIdx++)
         {
-            if (m_capabilities[capIdx].getNamespace().equals(ICapability.PACKAGE_NAMESPACE))
+            if (m_capabilities[capIdx].getNamespace().equals(Capability.PACKAGE_NAMESPACE))
             {
                 // R3 bundles cannot have directives on their exports.
-                if (((Capability) m_capabilities[capIdx]).getDirectives().length != 0)
+                if (((CapabilityImpl) m_capabilities[capIdx]).getDirectives().length != 0)
                 {
                     throw new BundleException("R3 exports cannot contain directives.");
                 }
@@ -563,41 +565,41 @@
                 // because the package class normalizes to "version" to avoid having
                 // future special cases. This could be changed if more strict behavior
                 // is required.
-                if (((Capability) m_capabilities[capIdx]).getAttributes() != null)
+                if (((CapabilityImpl) m_capabilities[capIdx]).getAttributes() != null)
                 {
                     // R3 package capabilities should only have name and
                     // version attributes.
-                    R4Attribute pkgName = null;
-                    R4Attribute pkgVersion = new R4Attribute(ICapability.VERSION_PROPERTY, Version.emptyVersion, false);
+                    Attribute pkgName = null;
+                    Attribute pkgVersion = new Attribute(Capability.VERSION_ATTR, Version.emptyVersion, false);
                     for (int attrIdx = 0;
-                        attrIdx < ((Capability) m_capabilities[capIdx]).getAttributes().length;
+                        attrIdx < ((CapabilityImpl) m_capabilities[capIdx]).getAttributes().length;
                         attrIdx++)
                     {
-                        if (((Capability) m_capabilities[capIdx]).getAttributes()[attrIdx]
-                            .getName().equals(ICapability.PACKAGE_PROPERTY))
+                        if (((CapabilityImpl) m_capabilities[capIdx]).getAttributes()[attrIdx]
+                            .getName().equals(Capability.PACKAGE_PROPERTY))
                         {
-                            pkgName = ((Capability) m_capabilities[capIdx]).getAttributes()[attrIdx];
+                            pkgName = ((CapabilityImpl) m_capabilities[capIdx]).getAttributes()[attrIdx];
                         }
-                        else if (((Capability) m_capabilities[capIdx]).getAttributes()[attrIdx]
-                            .getName().equals(ICapability.VERSION_PROPERTY))
+                        else if (((CapabilityImpl) m_capabilities[capIdx]).getAttributes()[attrIdx]
+                            .getName().equals(Capability.VERSION_PROPERTY))
                         {
-                            pkgVersion = ((Capability) m_capabilities[capIdx]).getAttributes()[attrIdx];
+                            pkgVersion = ((CapabilityImpl) m_capabilities[capIdx]).getAttributes()[attrIdx];
                         }
                         else
                         {
                             m_logger.log(Logger.LOG_WARNING,
                                 "Unknown R3 export attribute: "
-                                    + ((Capability) m_capabilities[capIdx]).getAttributes()[attrIdx].getName());
+                                    + ((CapabilityImpl) m_capabilities[capIdx]).getAttributes()[attrIdx].getName());
                         }
                     }
 
                     // Recreate the export to remove any other attributes
                     // and add version if missing.
-                    m_capabilities[capIdx] = new Capability(
+                    m_capabilities[capIdx] = new CapabilityImpl(
                         m_capabilities[capIdx].getModule(),
-                        ICapability.PACKAGE_NAMESPACE,
+                        Capability.PACKAGE_NAMESPACE,
                         null,
-                        new R4Attribute[] { pkgName, pkgVersion } );
+                        new Attribute[] { pkgName, pkgVersion } );
                 }
             }
         }
@@ -607,10 +609,10 @@
         // on their imports; ignore all unknown attributes.
         for (int reqIdx = 0; (m_requirements != null) && (reqIdx < m_requirements.length); reqIdx++)
         {
-            if (m_requirements[reqIdx].getNamespace().equals(ICapability.PACKAGE_NAMESPACE))
+            if (m_requirements[reqIdx].getNamespace().equals(Capability.PACKAGE_NAMESPACE))
             {
                 // R3 bundles cannot have directives on their imports.
-                if (((Requirement) m_requirements[reqIdx]).getDirectives().length != 0)
+                if (((RequirementImpl) m_requirements[reqIdx]).getDirectives().length != 0)
                 {
                     throw new BundleException("R3 imports cannot contain directives.");
                 }
@@ -620,42 +622,42 @@
                 // because the package class normalizes to "version" to avoid having
                 // future special cases. This could be changed if more strict behavior
                 // is required.
-                if (((Requirement) m_requirements[reqIdx]).getAttributes() != null)
+                if (((RequirementImpl) m_requirements[reqIdx]).getAttributes() != null)
                 {
                     // R3 package requirements should only have name and
                     // version attributes.
-                    R4Attribute pkgName = null;
-                    R4Attribute pkgVersion =
-                        new R4Attribute(ICapability.VERSION_PROPERTY,
+                    Attribute pkgName = null;
+                    Attribute pkgVersion =
+                        new Attribute(Capability.VERSION_ATTR,
                             new VersionRange(Version.emptyVersion, true, null, true), false);
                     for (int attrIdx = 0;
-                        attrIdx < ((Requirement) m_requirements[reqIdx]).getAttributes().length;
+                        attrIdx < ((RequirementImpl) m_requirements[reqIdx]).getAttributes().length;
                         attrIdx++)
                     {
-                        if (((Requirement) m_requirements[reqIdx]).getAttributes()[attrIdx]
-                            .getName().equals(ICapability.PACKAGE_PROPERTY))
+                        if (((RequirementImpl) m_requirements[reqIdx]).getAttributes()[attrIdx]
+                            .getName().equals(Capability.PACKAGE_ATTR))
                         {
-                            pkgName = ((Requirement) m_requirements[reqIdx]).getAttributes()[attrIdx];
+                            pkgName = ((RequirementImpl) m_requirements[reqIdx]).getAttributes()[attrIdx];
                         }
-                        else if (((Requirement) m_requirements[reqIdx]).getAttributes()[attrIdx]
-                          .getName().equals(ICapability.VERSION_PROPERTY))
+                        else if (((RequirementImpl) m_requirements[reqIdx]).getAttributes()[attrIdx]
+                          .getName().equals(Capability.VERSION_ATTR))
                         {
-                            pkgVersion = ((Requirement) m_requirements[reqIdx]).getAttributes()[attrIdx];
+                            pkgVersion = ((RequirementImpl) m_requirements[reqIdx]).getAttributes()[attrIdx];
                         }
                         else
                         {
                             m_logger.log(Logger.LOG_WARNING,
                                 "Unknown R3 import attribute: "
-                                    + ((Requirement) m_requirements[reqIdx]).getAttributes()[attrIdx].getName());
+                                    + ((RequirementImpl) m_requirements[reqIdx]).getAttributes()[attrIdx].getName());
                         }
                     }
 
                     // Recreate the import to remove any other attributes
                     // and add version if missing.
-                    m_requirements[reqIdx] = new Requirement(
-                        ICapability.PACKAGE_NAMESPACE,
+                    m_requirements[reqIdx] = new RequirementImpl(
+                        Capability.PACKAGE_NAMESPACE,
                         null,
-                        new R4Attribute[] { pkgName, pkgVersion });
+                        new Attribute[] { pkgName, pkgVersion });
                 }
             }
         }
@@ -667,26 +669,26 @@
         // Add existing imports.
         for (int i = 0; i < m_requirements.length; i++)
         {
-            if (m_requirements[i].getNamespace().equals(ICapability.PACKAGE_NAMESPACE))
+            if (m_requirements[i].getNamespace().equals(Capability.PACKAGE_NAMESPACE))
             {
                 map.put(
-                    ((Requirement) m_requirements[i]).getTargetName(),
+                    ((RequirementImpl) m_requirements[i]).getTargetName(),
                     m_requirements[i]);
             }
         }
         // Add import requirement for each export capability.
         for (int i = 0; i < m_capabilities.length; i++)
         {
-            if (m_capabilities[i].getNamespace().equals(ICapability.PACKAGE_NAMESPACE) &&
-                (map.get(m_capabilities[i].getProperties().get(ICapability.PACKAGE_PROPERTY)) == null))
+            if (m_capabilities[i].getNamespace().equals(Capability.PACKAGE_NAMESPACE) &&
+                (map.get(m_capabilities[i].getProperties().get(Capability.PACKAGE_ATTR)) == null))
             {
                 // Convert Version to VersionRange.
-                R4Attribute[] attrs = (R4Attribute[]) ((Capability) m_capabilities[i]).getAttributes().clone();
+                Attribute[] attrs = (Attribute[]) ((CapabilityImpl) m_capabilities[i]).getAttributes().clone();
                 for (int attrIdx = 0; (attrs != null) && (attrIdx < attrs.length); attrIdx++)
                 {
                     if (attrs[attrIdx].getName().equals(Constants.VERSION_ATTRIBUTE))
                     {
-                        attrs[attrIdx] = new R4Attribute(
+                        attrs[attrIdx] = new Attribute(
                             attrs[attrIdx].getName(),
                             VersionRange.parse(attrs[attrIdx].getValue().toString()),
                             attrs[attrIdx].isMandatory());
@@ -694,12 +696,12 @@
                 }
 
                 map.put(
-                    m_capabilities[i].getProperties().get(ICapability.PACKAGE_PROPERTY),
-                    new Requirement(ICapability.PACKAGE_NAMESPACE, null, attrs));
+                    m_capabilities[i].getProperties().get(Capability.PACKAGE_ATTR),
+                    new RequirementImpl(Capability.PACKAGE_NAMESPACE, null, attrs));
             }
         }
         m_requirements =
-            (IRequirement[]) map.values().toArray(new IRequirement[map.size()]);
+            (Requirement[]) map.values().toArray(new Requirement[map.size()]);
 
         // Add a "uses" directive onto each export of R3 bundles
         // that references every other import (which will include
@@ -709,24 +711,24 @@
         String usesValue = "";
         for (int i = 0; (m_requirements != null) && (i < m_requirements.length); i++)
         {
-            if (m_requirements[i].getNamespace().equals(ICapability.PACKAGE_NAMESPACE))
+            if (m_requirements[i].getNamespace().equals(Capability.PACKAGE_NAMESPACE))
             {
                 usesValue = usesValue
                     + ((usesValue.length() > 0) ? "," : "")
-                    + ((Requirement) m_requirements[i]).getTargetName();
+                    + ((RequirementImpl) m_requirements[i]).getTargetName();
             }
         }
-        R4Directive uses = new R4Directive(
+        Directive uses = new Directive(
             Constants.USES_DIRECTIVE, usesValue);
         for (int i = 0; (m_capabilities != null) && (i < m_capabilities.length); i++)
         {
-            if (m_capabilities[i].getNamespace().equals(ICapability.PACKAGE_NAMESPACE))
+            if (m_capabilities[i].getNamespace().equals(Capability.PACKAGE_NAMESPACE))
             {
-                m_capabilities[i] = new Capability(
+                m_capabilities[i] = new CapabilityImpl(
                     m_capabilities[i].getModule(),
-                    ICapability.PACKAGE_NAMESPACE,
-                    new R4Directive[] { uses },
-                    ((Capability) m_capabilities[i]).getAttributes());
+                    Capability.PACKAGE_NAMESPACE,
+                    new Directive[] { uses },
+                    ((CapabilityImpl) m_capabilities[i]).getAttributes());
             }
         }
 
@@ -736,11 +738,11 @@
             (m_dynamicRequirements != null) && (i < m_dynamicRequirements.length);
             i++)
         {
-            if (((Requirement) m_dynamicRequirements[i]).getDirectives().length != 0)
+            if (((RequirementImpl) m_dynamicRequirements[i]).getDirectives().length != 0)
             {
                 throw new BundleException("R3 dynamic imports cannot contain directives.");
             }
-            if (((Requirement) m_dynamicRequirements[i]).getAttributes().length != 0)
+            if (((RequirementImpl) m_dynamicRequirements[i]).getAttributes().length != 0)
             {
 //                throw new BundleException("R3 dynamic imports cannot contain attributes.");
             }
@@ -758,7 +760,7 @@
         m_capabilities = checkAndNormalizeR4Exports(
             m_capabilities, m_bundleSymbolicName, m_bundleVersion);
 
-        R4Directive extension = parseExtensionBundleHeader((String)
+        Directive extension = parseExtensionBundleHeader((String)
             m_headerMap.get(Constants.FRAGMENT_HOST));
 
         if (extension != null)
@@ -774,17 +776,17 @@
         }
     }
 
-    private static ICapability[] checkAndNormalizeR4Exports(
-        ICapability[] caps, String bsn, Version bv)
+    private static Capability[] checkAndNormalizeR4Exports(
+        Capability[] caps, String bsn, Version bv)
         throws BundleException
     {
         // Verify that the exports do not specify bundle symbolic name
         // or bundle version.
         for (int i = 0; (caps != null) && (i < caps.length); i++)
         {
-            if (caps[i].getNamespace().equals(ICapability.PACKAGE_NAMESPACE))
+            if (caps[i].getNamespace().equals(Capability.PACKAGE_NAMESPACE))
             {
-                R4Attribute[] attrs = ((Capability) caps[i]).getAttributes();
+                Attribute[] attrs = ((CapabilityImpl) caps[i]).getAttributes();
                 for (int attrIdx = 0; attrIdx < attrs.length; attrIdx++)
                 {
                     // Find symbolic name and version attribute, if present.
@@ -798,16 +800,16 @@
 
                 // Now that we know that there are no bundle symbolic name and version
                 // attributes, add them since the spec says they are there implicitly.
-                R4Attribute[] newAttrs = new R4Attribute[attrs.length + 2];
+                Attribute[] newAttrs = new Attribute[attrs.length + 2];
                 System.arraycopy(attrs, 0, newAttrs, 0, attrs.length);
-                newAttrs[attrs.length] = new R4Attribute(
+                newAttrs[attrs.length] = new Attribute(
                     Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, bsn, false);
-                newAttrs[attrs.length + 1] = new R4Attribute(
+                newAttrs[attrs.length + 1] = new Attribute(
                     Constants.BUNDLE_VERSION_ATTRIBUTE, bv, false);
-                caps[i] = new Capability(
+                caps[i] = new CapabilityImpl(
                     caps[i].getModule(),
-                    ICapability.PACKAGE_NAMESPACE,
-                    ((Capability) caps[i]).getDirectives(),
+                    Capability.PACKAGE_NAMESPACE,
+                    ((CapabilityImpl) caps[i]).getDirectives(),
                     newAttrs);
             }
         }
@@ -827,7 +829,7 @@
         }
     }
 
-    private static ICapability parseBundleSymbolicName(IModule owner, Map headerMap)
+    private static Capability parseBundleSymbolicName(Module owner, Map headerMap)
         throws BundleException
     {
         Object[][][] clauses = parseStandardHeader(
@@ -870,25 +872,25 @@
 
             // Create a module capability and return it.
             String symName = (String) clauses[0][CLAUSE_PATHS_INDEX][0];
-            R4Attribute[] attrs = new R4Attribute[2];
-            attrs[0] = new R4Attribute(
+            Attribute[] attrs = new Attribute[2];
+            attrs[0] = new Attribute(
                 Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, symName, false);
-            attrs[1] = new R4Attribute(
+            attrs[1] = new Attribute(
                 Constants.BUNDLE_VERSION_ATTRIBUTE, bundleVersion, false);
-            return new Capability(
+            return new CapabilityImpl(
                 owner,
-                ICapability.MODULE_NAMESPACE,
-                (R4Directive[]) clauses[0][CLAUSE_DIRECTIVES_INDEX],
+                Capability.MODULE_NAMESPACE,
+                (Directive[]) clauses[0][CLAUSE_DIRECTIVES_INDEX],
                 attrs);
         }
 
         return null;
     }
 
-    private static IRequirement parseFragmentHost(Logger logger, Map headerMap)
+    private static Requirement parseFragmentHost(Logger logger, Map headerMap)
         throws BundleException
     {
-        IRequirement req = null;
+        Requirement req = null;
 
         String mv = getManifestVersion(headerMap);
         if ((mv != null) && mv.equals("2"))
@@ -921,7 +923,7 @@
                     if (attr.getName().equals(Constants.BUNDLE_VERSION_ATTRIBUTE))
                     {
                         clauses[0][CLAUSE_ATTRIBUTES_INDEX][attrIdx] =
-                            new R4Attribute(
+                            new Attribute(
                                 Constants.BUNDLE_VERSION_ATTRIBUTE,
                                 VersionRange.parse(attr.getValue().toString()),
                                 attr.isMandatory());
@@ -929,15 +931,15 @@
                 }
 
                 // Prepend the host symbolic name to the array of attributes.
-                R4Attribute[] attrs = (R4Attribute[]) clauses[0][CLAUSE_ATTRIBUTES_INDEX];
-                R4Attribute[] newAttrs = new R4Attribute[attrs.length + 1];
-                newAttrs[0] = new R4Attribute(
+                Attribute[] attrs = (Attribute[]) clauses[0][CLAUSE_ATTRIBUTES_INDEX];
+                Attribute[] newAttrs = new Attribute[attrs.length + 1];
+                newAttrs[0] = new Attribute(
                     Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE,
                     clauses[0][CLAUSE_PATHS_INDEX][0], false);
                 System.arraycopy(attrs, 0, newAttrs, 1, attrs.length);
 
-                req = new Requirement(ICapability.HOST_NAMESPACE,
-                    (R4Directive[]) clauses[0][CLAUSE_DIRECTIVES_INDEX],
+                req = new RequirementImpl(Capability.HOST_NAMESPACE,
+                    (Directive[]) clauses[0][CLAUSE_DIRECTIVES_INDEX],
                     newAttrs);
             }
         }
@@ -949,11 +951,11 @@
         return req;
     }
 
-    public static ICapability[] parseExportHeader(
-        IModule owner, String header, String bsn, Version bv)
+    public static Capability[] parseExportHeader(
+        Module owner, String header, String bsn, Version bv)
         throws BundleException
     {
-        ICapability[] caps = parseExportHeader(owner, header);
+        Capability[] caps = parseExportHeader(owner, header);
         try
         {
             caps = checkAndNormalizeR4Exports(caps, bsn, bv);
@@ -965,7 +967,7 @@
         return caps;
     }
 
-    private static ICapability[] parseExportHeader(IModule owner, String header)
+    private static Capability[] parseExportHeader(Module owner, String header)
     {
         Object[][][] clauses = parseStandardHeader(header);
 
@@ -983,14 +985,14 @@
                 attrIdx < clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX].length;
                 attrIdx++)
             {
-                R4Attribute attr = (R4Attribute) clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX][attrIdx];
+                Attribute attr = (Attribute) clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX][attrIdx];
                 attrMap.put(attr.getName(), attr);
             }
 
             // Check for "version" and "specification-version" attributes
             // and verify they are the same if both are specified.
-            R4Attribute v = (R4Attribute) attrMap.get(Constants.VERSION_ATTRIBUTE);
-            R4Attribute sv = (R4Attribute) attrMap.get(Constants.PACKAGE_SPECIFICATION_VERSION);
+            Attribute v = (Attribute) attrMap.get(Constants.VERSION_ATTRIBUTE);
+            Attribute sv = (Attribute) attrMap.get(Constants.PACKAGE_SPECIFICATION_VERSION);
             if ((v != null) && (sv != null))
             {
                 // Verify they are equal.
@@ -1004,7 +1006,7 @@
             // Always add the default version if not specified.
             if ((v == null) && (sv == null))
             {
-                v = new R4Attribute(
+                v = new Attribute(
                     Constants.VERSION_ATTRIBUTE, Version.emptyVersion, false);
             }
 
@@ -1016,14 +1018,14 @@
                 attrMap.remove(Constants.PACKAGE_SPECIFICATION_VERSION);
                 v = (v == null) ? sv : v;
                 attrMap.put(Constants.VERSION_ATTRIBUTE,
-                    new R4Attribute(
+                    new Attribute(
                         Constants.VERSION_ATTRIBUTE,
                         Version.parseVersion(v.getValue().toString()),
                         v.isMandatory()));
 
                 // Re-copy the attribute array since it has changed.
                 clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX] =
-                    attrMap.values().toArray(new R4Attribute[attrMap.size()]);
+                    attrMap.values().toArray(new Attribute[attrMap.size()]);
             }
         }
 
@@ -1042,27 +1044,27 @@
                         "An empty package name was specified: " + header);
                 }
                 // Prepend the package name to the array of attributes.
-                R4Attribute[] attrs = (R4Attribute[]) clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX];
-                R4Attribute[] newAttrs = new R4Attribute[attrs.length + 1];
-                newAttrs[0] = new R4Attribute(
-                    ICapability.PACKAGE_PROPERTY,
+                Attribute[] attrs = (Attribute[]) clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX];
+                Attribute[] newAttrs = new Attribute[attrs.length + 1];
+                newAttrs[0] = new Attribute(
+                    Capability.PACKAGE_ATTR,
                     clauses[clauseIdx][CLAUSE_PATHS_INDEX][pathIdx], false);
                 System.arraycopy(attrs, 0, newAttrs, 1, attrs.length);
 
                 // Create package capability and add to capability list.
                 capList.add(
-                    new Capability(
+                    new CapabilityImpl(
                         owner,
-                        ICapability.PACKAGE_NAMESPACE,
-                        (R4Directive[]) clauses[clauseIdx][CLAUSE_DIRECTIVES_INDEX],
+                        Capability.PACKAGE_NAMESPACE,
+                        (Directive[]) clauses[clauseIdx][CLAUSE_DIRECTIVES_INDEX],
                         newAttrs));
             }
         }
 
-        return (ICapability[]) capList.toArray(new ICapability[capList.size()]);
+        return (Capability[]) capList.toArray(new Capability[capList.size()]);
     }
 
-    private static IRequirement[] parseImportHeader(String header)
+    private static Requirement[] parseImportHeader(String header)
     {
         Object[][][] clauses = parseStandardHeader(header);
 
@@ -1080,14 +1082,14 @@
                 attrIdx < clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX].length;
                 attrIdx++)
             {
-                R4Attribute attr = (R4Attribute) clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX][attrIdx];
+                Attribute attr = (Attribute) clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX][attrIdx];
                 attrMap.put(attr.getName(), attr);
             }
 
             // Check for "version" and "specification-version" attributes
             // and verify they are the same if both are specified.
-            R4Attribute v = (R4Attribute) attrMap.get(Constants.VERSION_ATTRIBUTE);
-            R4Attribute sv = (R4Attribute) attrMap.get(Constants.PACKAGE_SPECIFICATION_VERSION);
+            Attribute v = (Attribute) attrMap.get(Constants.VERSION_ATTRIBUTE);
+            Attribute sv = (Attribute) attrMap.get(Constants.PACKAGE_SPECIFICATION_VERSION);
             if ((v != null) && (sv != null))
             {
                 // Verify they are equal.
@@ -1105,18 +1107,18 @@
                 attrMap.remove(Constants.PACKAGE_SPECIFICATION_VERSION);
                 v = (v == null) ? sv : v;
                 attrMap.put(Constants.VERSION_ATTRIBUTE,
-                    new R4Attribute(
+                    new Attribute(
                         Constants.VERSION_ATTRIBUTE,
                         VersionRange.parse(v.getValue().toString()),
                         v.isMandatory()));
             }
 
             // If bundle version is specified, then convert its type to VersionRange.
-            v = (R4Attribute) attrMap.get(Constants.BUNDLE_VERSION_ATTRIBUTE);
+            v = (Attribute) attrMap.get(Constants.BUNDLE_VERSION_ATTRIBUTE);
             if (v != null)
             {
                 attrMap.put(Constants.BUNDLE_VERSION_ATTRIBUTE,
-                    new R4Attribute(
+                    new Attribute(
                         Constants.BUNDLE_VERSION_ATTRIBUTE,
                         VersionRange.parse(v.getValue().toString()),
                         v.isMandatory()));
@@ -1124,7 +1126,7 @@
 
             // Re-copy the attribute array in case it has changed.
             clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX] =
-                attrMap.values().toArray(new R4Attribute[attrMap.size()]);
+                attrMap.values().toArray(new Attribute[attrMap.size()]);
         }
 
         // Now convert generic header clauses into requirements.
@@ -1142,26 +1144,26 @@
                         "An empty package name was specified: " + header);
                 }
                 // Prepend the package name to the array of attributes.
-                R4Attribute[] attrs = (R4Attribute[]) clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX];
-                R4Attribute[] newAttrs = new R4Attribute[attrs.length + 1];
-                newAttrs[0] = new R4Attribute(
-                    ICapability.PACKAGE_PROPERTY,
+                Attribute[] attrs = (Attribute[]) clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX];
+                Attribute[] newAttrs = new Attribute[attrs.length + 1];
+                newAttrs[0] = new Attribute(
+                    Capability.PACKAGE_ATTR,
                     clauses[clauseIdx][CLAUSE_PATHS_INDEX][pathIdx], false);
                 System.arraycopy(attrs, 0, newAttrs, 1, attrs.length);
 
                 // Create package requirement and add to requirement list.
                 reqList.add(
-                    new Requirement(
-                        ICapability.PACKAGE_NAMESPACE,
-                        (R4Directive[]) clauses[clauseIdx][CLAUSE_DIRECTIVES_INDEX],
+                    new RequirementImpl(
+                        Capability.PACKAGE_NAMESPACE,
+                        (Directive[]) clauses[clauseIdx][CLAUSE_DIRECTIVES_INDEX],
                         newAttrs));
             }
         }
 
-        return (IRequirement[]) reqList.toArray(new IRequirement[reqList.size()]);
+        return (Requirement[]) reqList.toArray(new Requirement[reqList.size()]);
     }
 
-    private static IRequirement[] parseRequireBundleHeader(String header)
+    private static Requirement[] parseRequireBundleHeader(String header)
     {
         Object[][][] clauses = parseStandardHeader(header);
 
@@ -1175,11 +1177,11 @@
                 attrIdx < clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX].length;
                 attrIdx++)
             {
-                R4Attribute attr = (R4Attribute) clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX][attrIdx];
+                Attribute attr = (Attribute) clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX][attrIdx];
                 if (attr.getName().equals(Constants.BUNDLE_VERSION_ATTRIBUTE))
                 {
                     clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX][attrIdx] =
-                        new R4Attribute(
+                        new Attribute(
                             Constants.BUNDLE_VERSION_ATTRIBUTE,
                             VersionRange.parse(attr.getValue().toString()),
                             attr.isMandatory());
@@ -1196,31 +1198,31 @@
                 pathIdx++)
             {
                 // Prepend the symbolic name to the array of attributes.
-                R4Attribute[] attrs = (R4Attribute[]) clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX];
-                R4Attribute[] newAttrs = new R4Attribute[attrs.length + 1];
-                newAttrs[0] = new R4Attribute(
+                Attribute[] attrs = (Attribute[]) clauses[clauseIdx][CLAUSE_ATTRIBUTES_INDEX];
+                Attribute[] newAttrs = new Attribute[attrs.length + 1];
+                newAttrs[0] = new Attribute(
                     Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE,
                     clauses[clauseIdx][CLAUSE_PATHS_INDEX][pathIdx], false);
                 System.arraycopy(attrs, 0, newAttrs, 1, attrs.length);
 
                 // Create package requirement and add to requirement list.
                 reqList.add(
-                    new Requirement(
-                        ICapability.MODULE_NAMESPACE,
-                        (R4Directive[]) clauses[clauseIdx][CLAUSE_DIRECTIVES_INDEX],
+                    new RequirementImpl(
+                        Capability.MODULE_NAMESPACE,
+                        (Directive[]) clauses[clauseIdx][CLAUSE_DIRECTIVES_INDEX],
                         newAttrs));
             }
         }
 
-        return (IRequirement[]) reqList.toArray(new IRequirement[reqList.size()]);
+        return (Requirement[]) reqList.toArray(new Requirement[reqList.size()]);
     }
 
-    public static R4Directive parseExtensionBundleHeader(String header)
+    public static Directive parseExtensionBundleHeader(String header)
         throws BundleException
     {
         Object[][][] clauses = parseStandardHeader(header);
 
-        R4Directive result = null;
+        Directive result = null;
 
         if (clauses.length == 1)
         {
@@ -1229,7 +1231,7 @@
                 (result == null) && (i < clauses[0][CLAUSE_DIRECTIVES_INDEX].length);
                 i++)
             {
-                if (Constants.EXTENSION_DIRECTIVE.equals(((R4Directive)
+                if (Constants.EXTENSION_DIRECTIVE.equals(((Directive)
                     clauses[0][CLAUSE_DIRECTIVES_INDEX][i]).getName()))
                 {
                     // If the extension directive is specified, make sure
@@ -1237,7 +1239,7 @@
                     if (FelixConstants.SYSTEM_BUNDLE_SYMBOLICNAME.equals(clauses[0][CLAUSE_PATHS_INDEX][0]) ||
                         Constants.SYSTEM_BUNDLE_SYMBOLICNAME.equals(clauses[0][CLAUSE_PATHS_INDEX][0]))
                     {
-                        result = (R4Directive) clauses[0][CLAUSE_DIRECTIVES_INDEX][i];
+                        result = (Directive) clauses[0][CLAUSE_DIRECTIVES_INDEX][i];
                     }
                     else
                     {
@@ -1253,7 +1255,7 @@
 
     private void parseActivationPolicy(Map headerMap)
     {
-        m_activationPolicy = IModule.EAGER_ACTIVATION;
+        m_activationPolicy = Module.EAGER_ACTIVATION;
 
         Object[][][] clauses = parseStandardHeader(
             (String) headerMap.get(Constants.BUNDLE_ACTIVATIONPOLICY));
@@ -1268,10 +1270,10 @@
             {
                 if (clauses[0][CLAUSE_PATHS_INDEX][i].equals(Constants.ACTIVATION_LAZY))
                 {
-                    m_activationPolicy = IModule.LAZY_ACTIVATION;
+                    m_activationPolicy = Module.LAZY_ACTIVATION;
                     for (int j = 0; j < clauses[0][CLAUSE_DIRECTIVES_INDEX].length; j++)
                     {
-                        R4Directive dir = (R4Directive) clauses[0][CLAUSE_DIRECTIVES_INDEX][j];
+                        Directive dir = (Directive) clauses[0][CLAUSE_DIRECTIVES_INDEX][j];
                         if (dir.getName().equalsIgnoreCase(Constants.INCLUDE_DIRECTIVE))
                         {
                             m_activationIncludeDir = dir.getValue();
@@ -1393,7 +1395,7 @@
                     throw new IllegalArgumentException(
                         "Duplicate directive: " + key);
                 }
-                dirsMap.put(key, new R4Directive(key, value));
+                dirsMap.put(key, new Directive(key, value));
             }
             else
             {
@@ -1403,17 +1405,17 @@
                     throw new IllegalArgumentException(
                         "Duplicate attribute: " + key);
                 }
-                attrsMap.put(key, new R4Attribute(key, value, false));
+                attrsMap.put(key, new Attribute(key, value, false));
             }
         }
 
         // Create directive array.
-        R4Directive[] dirs = (R4Directive[])
-            dirsMap.values().toArray(new R4Directive[dirsMap.size()]);
+        Directive[] dirs = (Directive[])
+            dirsMap.values().toArray(new Directive[dirsMap.size()]);
 
         // Create attribute array.
-        R4Attribute[] attrs = (R4Attribute[])
-            attrsMap.values().toArray(new R4Attribute[attrsMap.size()]);
+        Attribute[] attrs = (Attribute[])
+            attrsMap.values().toArray(new Attribute[attrsMap.size()]);
 
         // Create an array to hold the parsed paths, directives, and attributes.
         Object[][] clause = new Object[3][];

Added: felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/RequirementImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/RequirementImpl.java?rev=899798&view=auto
==============================================================================
--- felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/RequirementImpl.java (added)
+++ felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/util/manifestparser/RequirementImpl.java Fri Jan 15 20:07:04 2010
@@ -0,0 +1,56 @@
+/*
+ *  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.util.manifestparser;
+
+import org.apache.felix.framework.candidateset.Requirement;
+import org.apache.felix.framework.candidateset.SimpleFilter;
+
+public class RequirementImpl implements Requirement
+{
+    private final String m_namespace;
+    private final SimpleFilter m_filter;
+    private final boolean m_optional;
+
+    public RequirementImpl(String namespace, SimpleFilter filter, boolean optional)
+    {
+        m_namespace = namespace;
+        m_filter = filter;
+        m_optional = optional;
+    }
+
+    public String getNamespace()
+    {
+        return m_namespace;
+    }
+
+    public SimpleFilter getFilter()
+    {
+        return m_filter;
+    }
+
+    public boolean isOptional()
+    {
+        return m_optional;
+    }
+
+    public String toString()
+    {
+        return m_namespace + "; " + getFilter().toString();
+    }
+}
\ No newline at end of file