felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1031185 - in /felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver: ./ proto3/
Date Thu, 04 Nov 2010 19:46:25 GMT
Author: rickhall
Date: Thu Nov  4 19:46:25 2010
New Revision: 1031185

URL: http://svn.apache.org/viewvc?rev=1031185&view=rev
Log:
First attempt at self-contained fragment support.

Added:
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedCapability.java
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedModule.java
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedRequirement.java
Modified:
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/CandidateComparator.java
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/CapabilityImpl.java
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Main.java
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolverStateImpl.java
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/Proto3Resolver.java

Modified: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/CandidateComparator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/CandidateComparator.java?rev=1031185&r1=1031184&r2=1031185&view=diff
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/CandidateComparator.java
(original)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/CandidateComparator.java
Thu Nov  4 19:46:25 2010
@@ -63,8 +63,7 @@ public class CandidateComparator impleme
         }
 // TODO: PROTO3 RESOLVER - Need to change this to handle arbitrary capabilities
 //       that may not have a natural ordering.
-        // Assume everything else is a package capability.
-        else if (c == 0)
+        else if ((c == 0) && cap1.getNamespace().equals(Capability.PACKAGE_ATTR))
         {
             c = ((Comparable) cap1.getAttribute(Capability.PACKAGE_ATTR).getValue())
                 .compareTo(cap2.getAttribute(Capability.PACKAGE_ATTR).getValue());

Modified: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/CapabilityImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/CapabilityImpl.java?rev=1031185&r1=1031184&r2=1031185&view=diff
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/CapabilityImpl.java
(original)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/CapabilityImpl.java
Thu Nov  4 19:46:25 2010
@@ -39,8 +39,8 @@ public class CapabilityImpl implements C
 
     public CapabilityImpl(Module module, String namespace)
     {
-        m_namespace = namespace;
         m_module = module;
+        m_namespace = namespace;
         m_uses = new ArrayList<String>();
         m_dirs = new ArrayList<Directive>();
         m_dirsConst = Collections.unmodifiableList(m_dirs);

Modified: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Main.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Main.java?rev=1031185&r1=1031184&r2=1031185&view=diff
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Main.java (original)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Main.java Thu
Nov  4 19:46:25 2010
@@ -2897,4 +2897,109 @@ System.out.println("EX " + ex);
 
         return target;
     }
+
+    // SOLUTION:
+    // A: bar->D
+    private static Map<Module, List<Wire>> solution33(List<Module> modules)
+    {
+        Map<String, Module> moduleMap = new HashMap();
+        for (Module m : modules)
+        {
+            moduleMap.put(m.getName(), m);
+        }
+        Map<Module, List<Wire>> wireMap = new HashMap();
+
+        List<Wire> wires = new ArrayList();
+//        wires.add(
+//            new WireImpl(
+//                moduleMap.get("C"),
+//                moduleMap.get("C").getRequirements().get(0),
+//                moduleMap.get("A"),
+//                moduleMap.get("A").getCapabilities().get(1)));
+        wireMap.put(moduleMap.get("C"), wires);
+
+        return wireMap;
+    }
+
+    private static Module scenario33(List<Module> moduleList)
+    {
+        Module m, target;
+
+        // Bundle A
+        moduleList.add(
+            (m = new Module("A"))
+                .providing(new CapabilityImpl(m, Capability.HOST_NAMESPACE).with("bundle-symbolic-name=A")));
+        // Bundle B
+        moduleList.add(
+            (m = new Module("B"))
+                .providing(new CapabilityImpl(m, Capability.PACKAGE_NAMESPACE).with("package=foo"))
+                .requiring(new RequirementImpl(m, Capability.HOST_NAMESPACE).with("bundle-symbolic-name=A")));
+        // Bundle C
+        moduleList.add(
+            target = (m = new Module("C"))
+                .requiring(new RequirementImpl(m, Capability.PACKAGE_NAMESPACE).with("package=foo")));
+
+        return target;
+    }
+
+    // SOLUTION:
+    // A: bar->D
+    private static Map<Module, List<Wire>> solution34(List<Module> modules)
+    {
+        Map<String, Module> moduleMap = new HashMap();
+        for (Module m : modules)
+        {
+            moduleMap.put(m.getName(), m);
+        }
+        Map<Module, List<Wire>> wireMap = new HashMap();
+
+        List<Wire> wires = new ArrayList();
+//        wires.add(
+//            new WireImpl(
+//                moduleMap.get("C"),
+//                moduleMap.get("C").getRequirements().get(0),
+//                moduleMap.get("A"),
+//                moduleMap.get("A").getCapabilities().get(1)));
+        wireMap.put(moduleMap.get("C"), wires);
+
+        return wireMap;
+    }
+
+    private static Module scenario34(List<Module> moduleList)
+    {
+        Module m, target;
+
+        // Bundle A1
+        moduleList.add(
+            (m = new Module("A1"))
+                .providing(new CapabilityImpl(m, Capability.HOST_NAMESPACE).with("bundle-symbolic-name=A"))
+                .providing(new CapabilityImpl(m, Capability.PACKAGE_NAMESPACE).with("package=foo")));
+        // Bundle A2
+        moduleList.add(
+            (m = new Module("A2"))
+                .providing(new CapabilityImpl(m, Capability.HOST_NAMESPACE).with("bundle-symbolic-name=A"))
+                .providing(new CapabilityImpl(m, Capability.PACKAGE_NAMESPACE).with("package=foo")));
+        // Bundle B
+        moduleList.add(
+            (m = new Module("B"))
+                .providing(new CapabilityImpl(m, Capability.PACKAGE_NAMESPACE).with("package=bar"))
+                .requiring(new RequirementImpl(m, Capability.HOST_NAMESPACE).with("bundle-symbolic-name=A")));
+        // Bundle C
+        moduleList.add(
+            (m = new Module("C"))
+                .providing(new CapabilityImpl(m, Capability.PACKAGE_NAMESPACE).with("package=woz"))
+                .requiring(new RequirementImpl(m, Capability.HOST_NAMESPACE).with("bundle-symbolic-name=A")));
+        // Bundle D
+        moduleList.add(
+            (m = new Module("D"))
+                .providing(new CapabilityImpl(m, Capability.PACKAGE_NAMESPACE).with("package=baz"))
+                .requiring(new RequirementImpl(m, Capability.PACKAGE_NAMESPACE).with("package=bar")));
+        // Bundle E
+        moduleList.add(
+            target = (m = new Module("E"))
+                .requiring(new RequirementImpl(m, Capability.PACKAGE_NAMESPACE).with("package=woz"))
+                .requiring(new RequirementImpl(m, Capability.PACKAGE_NAMESPACE).with("package=baz")));
+
+        return target;
+    }
 }
\ No newline at end of file

Modified: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolverStateImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolverStateImpl.java?rev=1031185&r1=1031184&r2=1031185&view=diff
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolverStateImpl.java
(original)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolverStateImpl.java
Thu Nov  4 19:46:25 2010
@@ -33,6 +33,7 @@ public class ResolverStateImpl implement
     private final List<Module> m_modules;
     private final CapabilitySet m_pkgCapSet;
     private final CapabilitySet m_modCapSet;
+    private final CapabilitySet m_otherCapSet;
 
     public ResolverStateImpl(List<Module> modules)
     {
@@ -46,6 +47,8 @@ public class ResolverStateImpl implement
         indices.add(Capability.PACKAGE_ATTR);
         m_pkgCapSet = new CapabilitySet(indices);
 
+        m_otherCapSet = new CapabilitySet(null);
+
         for (int modIdx = 0; modIdx < m_modules.size(); modIdx++)
         {
             List<Capability> caps = m_modules.get(modIdx).getCapabilities();
@@ -61,8 +64,7 @@ public class ResolverStateImpl implement
                 }
                 else
                 {
-                    System.err.println(
-                        "Ignoring unknown capability: " + caps.get(capIdx).getNamespace());
+                    m_otherCapSet.addCapability(caps.get(capIdx));
                 }
             }
         }
@@ -85,6 +87,10 @@ public class ResolverStateImpl implement
         {
             result.addAll(m_pkgCapSet.match(req.getFilter(), obeyMandatory));
         }
+        else
+        {
+            result.addAll(m_otherCapSet.match(req.getFilter(), obeyMandatory));
+        }
 
         return result;
     }

Modified: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/Proto3Resolver.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/Proto3Resolver.java?rev=1031185&r1=1031184&r2=1031185&view=diff
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/Proto3Resolver.java
(original)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/Proto3Resolver.java
Thu Nov  4 19:46:25 2010
@@ -34,7 +34,6 @@ import org.apache.felix.resolver.Require
 import org.apache.felix.resolver.ResolveException;
 import org.apache.felix.resolver.Resolver;
 import org.apache.felix.resolver.Resolver.ResolverState;
-import org.apache.felix.resolver.ResolverStateImpl;
 import org.apache.felix.resolver.Wire;
 import org.apache.felix.resolver.WireImpl;
 import org.apache.felix.resolver.WireModuleImpl;
@@ -44,7 +43,6 @@ import org.apache.felix.resolver.cs.Capa
 import org.apache.felix.resolver.cs.Directive;
 import org.apache.felix.resolver.cs.Requirement;
 import org.apache.felix.resolver.manifestparser.Constants;
-import org.apache.felix.resolver.manifestparser.Util;
 
 public class Proto3Resolver implements Resolver
 {
@@ -91,8 +89,14 @@ System.out.println("+++ PROTO3 RESOLVER"
                 Map<Requirement, Set<Capability>> candidateMap =
                     new HashMap<Requirement, Set<Capability>>();
 
+                // Populate all candidates.
                 populateCandidates(
                     state, module, candidateMap, new HashMap<Module, Object>());
+
+                // Merge any fragments into hosts.
+                mergeFragments(candidateMap);
+
+                // Record the initial candidate permutation.
                 m_usesPermutations.add(candidateMap);
 
                 ResolveException rethrow = null;
@@ -583,6 +587,145 @@ System.out.println("+++ PACKAGE SPACES E
         }
     }
 
+    private static Map<Module, WrappedModule> mergeFragments(
+        Map<Requirement, Set<Capability>> candidateMap)
+    {
+        // Map of fragment module to its merged hosts.
+        Map<Module, Set<Module>> fragments = new HashMap<Module, Set<Module>>();
+        // Map of hosts to wrapped module.
+        Map<Module, WrappedModule> wrappedHosts = new HashMap<Module, WrappedModule>();
+
+        for (Entry<Requirement, Set<Capability>> entry : candidateMap.entrySet())
+        {
+            // Find all host requirements to determine all fragments and
+            // the hosts into which they should be merged.
+            if (entry.getKey().getNamespace().equals(Capability.HOST_NAMESPACE))
+            {
+                for (Capability hostCap : entry.getValue())
+                {
+                    // Wrap the host.
+                    WrappedModule wrappedHost = wrappedHosts.get(hostCap.getModule());
+                    if (wrappedHost == null)
+                    {
+                        wrappedHost = new WrappedModule(hostCap.getModule());
+                        wrappedHosts.put(hostCap.getModule(), wrappedHost);
+                    }
+System.out.println("+++ ATTACHING FRAGMENT "
+    + entry.getKey().getModule()
+    + " TO HOST "
+    + wrappedHost);
+                    wrappedHost.attachFragment(entry.getKey().getModule());
+
+                    // Remember wrapped hosts per fragment.
+                    Set<Module> hosts = fragments.get(entry.getKey().getModule());
+                    if (hosts == null)
+                    {
+                        hosts = new HashSet<Module>();
+                        fragments.put(entry.getKey().getModule(), hosts);
+                    }
+                    hosts.add(wrappedHost);
+                }
+            }
+        }
+System.out.println("+++ WRAPPED HOSTS: " + wrappedHosts);
+System.out.println("+++ FRAGMENTS: " + fragments);
+
+        // Replace the unmerged host with the wrapped host wherever the
+        // unmerged host is a candidate. First we find the required capabilities
+        // from the unmerged host.
+        Map<Requirement, Set<Capability>> requiredHosts =
+            new HashMap<Requirement, Set<Capability>>();
+        for (Entry<Requirement, Set<Capability>> entry : candidateMap.entrySet())
+        {
+            for (Capability cap : entry.getValue())
+            {
+                if (wrappedHosts.containsKey(cap.getModule()))
+                {
+                    Set<Capability> caps = requiredHosts.get(entry.getKey());
+                    if (caps == null)
+                    {
+                        caps = new HashSet<Capability>();
+                        requiredHosts.put(entry.getKey(), caps);
+                    }
+                    caps.add(cap);
+                }
+            }
+        }
+        // Then we replace them with capabilities from the wrapped host.
+        for (Entry<Requirement, Set<Capability>> entry : requiredHosts.entrySet())
+        {
+            Set<Capability> cands = candidateMap.get(entry.getKey());
+            for (Capability cap : entry.getValue())
+            {
+                cands.remove(cap);
+                Module wrappedHost = wrappedHosts.get(cap.getModule());
+                for (Capability wrappedCap : wrappedHost.getCapabilities())
+                {
+                    if (CapabilitySet.matches(wrappedCap, entry.getKey().getFilter()))
+                    {
+                        cands.add(wrappedCap);
+                    }
+                }
+            }
+        }
+
+        // Replace any fragment capabilities with capabilities from the
+        // wrapped host. First we find the required capabilities from the
+        // fragments.
+        Map<Requirement, Set<Capability>> requiredFragments =
+            new HashMap<Requirement, Set<Capability>>();
+        for (Entry<Requirement, Set<Capability>> entry : candidateMap.entrySet())
+        {
+            for (Capability cap : entry.getValue())
+            {
+                if (fragments.containsKey(cap.getModule()))
+                {
+                    Set<Capability> caps = requiredFragments.get(entry.getKey());
+                    if (caps == null)
+                    {
+                        caps = new HashSet<Capability>();
+                        requiredFragments.put(entry.getKey(), caps);
+                    }
+                    caps.add(cap);
+                }
+            }
+        }
+        // Then we replace them with capabilities from the wrapped host.
+        for (Entry<Requirement, Set<Capability>> entry : requiredFragments.entrySet())
+        {
+            Set<Capability> cands = candidateMap.get(entry.getKey());
+            for (Capability cap : entry.getValue())
+            {
+                cands.remove(cap);
+                Set<Module> hosts = fragments.get(cap.getModule());
+                for (Module host : hosts)
+                {
+                    for (Capability wrappedCap : host.getCapabilities())
+                    {
+                        if (CapabilitySet.matches(wrappedCap, entry.getKey().getFilter()))
+                        {
+                            cands.add(wrappedCap);
+                        }
+                    }
+                }
+            }
+        }
+
+        return wrappedHosts;
+    }
+
+    private static boolean isFragment(Module m)
+    {
+        for (Requirement req : m.getRequirements())
+        {
+            if (req.getNamespace().equals(Capability.HOST_NAMESPACE))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
     private void calculatePackageSpaces(
         Module module,
         Map<Requirement, Set<Capability>> candidateMap,

Added: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedCapability.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedCapability.java?rev=1031185&view=auto
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedCapability.java
(added)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedCapability.java
Thu Nov  4 19:46:25 2010
@@ -0,0 +1,91 @@
+/*
+ * 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.resolver.proto3;
+
+import java.util.List;
+import org.apache.felix.resolver.Module;
+import org.apache.felix.resolver.cs.Attribute;
+import org.apache.felix.resolver.cs.Capability;
+import org.apache.felix.resolver.cs.Directive;
+
+class WrappedCapability implements Capability
+{
+    private final Module m_module;
+    private final Capability m_cap;
+
+    public WrappedCapability(Module module, Capability cap)
+    {
+        m_module = module;
+        m_cap = cap;
+    }
+
+    public Capability getWrappedCapability()
+    {
+        return m_cap;
+    }
+
+    public Module getModule()
+    {
+        return m_module;
+    }
+
+    public String getNamespace()
+    {
+        return m_cap.getNamespace();
+    }
+
+    public Directive getDirective(String name)
+    {
+        return m_cap.getDirective(name);
+    }
+
+    public List<Directive> getDirectives()
+    {
+        return m_cap.getDirectives();
+    }
+
+    public Attribute getAttribute(String name)
+    {
+        return m_cap.getAttribute(name);
+    }
+
+    public List<Attribute> getAttributes()
+    {
+        return m_cap.getAttributes();
+    }
+
+    public List<String> getUses()
+    {
+        return m_cap.getUses();
+    }
+
+    public String toString()
+    {
+        if (m_module == null)
+        {
+            return getAttributes().toString();
+        }
+        if (getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+        {
+            return "[" + m_module + "] "
+                + getNamespace() + "; " + getAttribute(Capability.PACKAGE_ATTR);
+        }
+        return "[" + m_module + "] " + getNamespace() + "; " + getAttributes();
+    }
+}
\ No newline at end of file

Added: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedModule.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedModule.java?rev=1031185&view=auto
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedModule.java
(added)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedModule.java
Thu Nov  4 19:46:25 2010
@@ -0,0 +1,108 @@
+/*
+ * 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.resolver.proto3;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.felix.resolver.Module;
+import org.apache.felix.resolver.cs.Capability;
+import org.apache.felix.resolver.cs.Requirement;
+
+class WrappedModule extends Module
+{
+    private final Module m_module;
+    private final List<Module> m_fragments = new ArrayList();
+    private List<Capability> m_cachedCapabilities = null;
+    private List<Requirement> m_cachedRequirements = null;
+
+// TODO: RESOLVER - WE COULD PASS ALL FRAGMENTS INTO THE CONSTRUCTOR.
+    public WrappedModule(Module module)
+    {
+        super(module.getName());
+        m_module = module;
+    }
+
+    public Module getWrappedModule()
+    {
+        return m_module;
+    }
+
+    public void attachFragment(Module fragment)
+    {
+        m_fragments.add(fragment);
+    }
+
+    public List<Capability> getCapabilities()
+    {
+        if (m_cachedCapabilities == null)
+        {
+            List capList = (m_module.getCapabilities() == null)
+                ? new ArrayList<Capability>()
+                : new ArrayList<Capability>(m_module.getCapabilities());
+            for (int fragIdx = 0;
+                (m_fragments != null) && (fragIdx < m_fragments.size());
+                fragIdx++)
+            {
+                List<Capability> caps = m_fragments.get(fragIdx).getCapabilities();
+                for (int capIdx = 0;
+                    (caps != null) && (capIdx < caps.size());
+                    capIdx++)
+                {
+                    if (caps.get(capIdx).getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+                    {
+                        capList.add(
+                            new WrappedCapability(this, caps.get(capIdx)));
+                    }
+                }
+            }
+            m_cachedCapabilities = Collections.unmodifiableList(capList);
+        }
+        return m_cachedCapabilities;
+    }
+
+    public List<Requirement> getRequirements()
+    {
+        if (m_cachedRequirements == null)
+        {
+            List<Requirement> reqList = (m_module.getRequirements() == null)
+                ? new ArrayList() : new ArrayList(m_module.getRequirements());
+            for (int fragIdx = 0;
+                (m_fragments != null) && (fragIdx < m_fragments.size());
+                fragIdx++)
+            {
+                List<Requirement> reqs = m_fragments.get(fragIdx).getRequirements();
+                for (int reqIdx = 0;
+                    (reqs != null) && (reqIdx < reqs.size());
+                    reqIdx++)
+                {
+                    if (reqs.get(reqIdx).getNamespace().equals(Capability.PACKAGE_NAMESPACE)
+                        || reqs.get(reqIdx).getNamespace().equals(Capability.MODULE_NAMESPACE))
+                    {
+                        reqList.add(
+                            new WrappedRequirement(
+                                this, reqs.get(reqIdx)));
+                    }
+                }
+            }
+            m_cachedRequirements = Collections.unmodifiableList(reqList);
+        }
+        return m_cachedRequirements;
+    }
+}
\ No newline at end of file

Added: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedRequirement.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedRequirement.java?rev=1031185&view=auto
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedRequirement.java
(added)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/proto3/WrappedRequirement.java
Thu Nov  4 19:46:25 2010
@@ -0,0 +1,77 @@
+/*
+ * 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.resolver.proto3;
+
+import java.util.List;
+import org.apache.felix.resolver.Module;
+import org.apache.felix.resolver.cs.Directive;
+import org.apache.felix.resolver.cs.Requirement;
+import org.apache.felix.resolver.cs.SimpleFilter;
+
+class WrappedRequirement implements Requirement
+{
+    private final Module m_module;
+    private final Requirement m_req;
+
+    public WrappedRequirement(Module module, Requirement req)
+    {
+        m_module = module;
+        m_req = req;
+    }
+
+    public Requirement getWrappedRequirement()
+    {
+        return m_req;
+    }
+
+    public Module getModule()
+    {
+        return m_module;
+    }
+
+    public String getNamespace()
+    {
+        return m_req.getNamespace();
+    }
+
+    public SimpleFilter getFilter()
+    {
+        return m_req.getFilter();
+    }
+
+    public boolean isOptional()
+    {
+        return m_req.isOptional();
+    }
+
+    public Directive getDirective(String name)
+    {
+        return m_req.getDirective(name);
+    }
+
+    public List<Directive> getDirectives()
+    {
+        return m_req.getDirectives();
+    }
+
+    public String toString()
+    {
+        return "[" + m_module + "] " + getNamespace() + "; " + getFilter().toString();
+    }
+}
\ No newline at end of file



Mime
View raw message