Some initial ground work for creating a generic resolver as the first
step for supporting require-bundle (FELIX-28).


git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@489207 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index 36e8335..f4cf15b 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -456,6 +456,8 @@
             }
             catch (Exception ex)
             {
+// TODO: RB - Should this be system bundle, since bundle could be null?
+//                fireFrameworkEvent(FrameworkEvent.ERROR, systembundle, ex);
                 fireFrameworkEvent(FrameworkEvent.ERROR, bundle, ex);
                 try
                 {
diff --git a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Capability.java b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Capability.java
new file mode 100644
index 0000000..05ccff1
--- /dev/null
+++ b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Capability.java
@@ -0,0 +1,50 @@
+/*
+ * 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.Collections;
+import java.util.Map;
+import org.apache.felix.moduleloader.ICapability;
+
+public class Capability implements ICapability
+{
+    private String m_namespace = null;
+    private Map m_propMap = null;
+
+    public Capability(String namespace, Map propMap)
+    {
+        m_namespace = namespace;
+        m_propMap = Collections.unmodifiableMap(propMap);
+    }
+
+    public String getNamespace()
+    {
+        return m_namespace;
+    }
+
+    public Map getProperties()
+    {
+        return m_propMap;
+    }
+
+    public String[] getUses()
+    {
+        return null;
+    }
+}
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Requirement.java b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Requirement.java
new file mode 100644
index 0000000..740b2b9
--- /dev/null
+++ b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/Requirement.java
@@ -0,0 +1,73 @@
+/*
+ * 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.FilterImpl;
+import org.apache.felix.framework.util.MapToDictionary;
+import org.apache.felix.moduleloader.ICapability;
+import org.apache.felix.moduleloader.IRequirement;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+
+public class Requirement implements IRequirement
+{
+    private String m_namespace = null;
+    private Filter m_filter = null;
+
+    public Requirement(String namespace, String filterStr) throws InvalidSyntaxException
+    {
+        m_namespace = namespace;
+        m_filter = new FilterImpl(filterStr);
+    }
+
+    public String getNamespace()
+    {
+        return m_namespace;
+    }
+
+    public Filter getFilter()
+    {
+        return m_filter;
+    }
+
+    public boolean isMultiple()
+    {
+        return false;
+    }
+
+    public boolean isOptional()
+    {
+        return false;
+    }
+
+    public String getComment()
+    {
+        return null;
+    }
+
+    public boolean isSatisfied(ICapability capability)
+    {
+        return m_filter.match(new MapToDictionary(capability.getProperties()));
+    }
+
+    public String toString()
+    {
+        return m_filter.toString();
+    }
+}
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/moduleloader/ICapability.java b/framework/src/main/java/org/apache/felix/moduleloader/ICapability.java
new file mode 100644
index 0000000..bc271d1
--- /dev/null
+++ b/framework/src/main/java/org/apache/felix/moduleloader/ICapability.java
@@ -0,0 +1,34 @@
+/* 
+ * 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.moduleloader;
+
+import java.util.Map;
+
+public interface ICapability
+{
+    public static final String MODULE_NAMESPACE = "module";
+    public static final String PACKAGE_NAMESPACE = "package";
+
+    public static final String PACKAGE_PROPERTY = "package";
+    public static final String VERSION_PROPERTY = "version";
+
+    String getNamespace();
+    Map getProperties();
+    String[] getUses();
+}
\ No newline at end of file
diff --git a/framework/src/main/java/org/apache/felix/moduleloader/IRequirement.java b/framework/src/main/java/org/apache/felix/moduleloader/IRequirement.java
new file mode 100644
index 0000000..a278fb1
--- /dev/null
+++ b/framework/src/main/java/org/apache/felix/moduleloader/IRequirement.java
@@ -0,0 +1,31 @@
+/* 
+ * 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.moduleloader;
+
+import org.osgi.framework.Filter;
+
+public interface IRequirement
+{
+    String getNamespace();
+    Filter getFilter();
+    boolean isMultiple();
+    boolean isOptional();
+    String getComment();
+    boolean isSatisfied(ICapability capability);
+}
\ No newline at end of file