Return-Path: Delivered-To: apmail-felix-commits-archive@www.apache.org Received: (qmail 40847 invoked from network); 4 Nov 2010 19:47:16 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 4 Nov 2010 19:47:16 -0000 Received: (qmail 68187 invoked by uid 500); 4 Nov 2010 19:47:47 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 68141 invoked by uid 500); 4 Nov 2010 19:47:46 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 68134 invoked by uid 99); 4 Nov 2010 19:47:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Nov 2010 19:47:46 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Nov 2010 19:47:41 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0605523888D2; Thu, 4 Nov 2010 19:46:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@felix.apache.org From: rickhall@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101104194626.0605523888D2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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(); m_dirs = new ArrayList(); 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> solution33(List modules) + { + Map moduleMap = new HashMap(); + for (Module m : modules) + { + moduleMap.put(m.getName(), m); + } + Map> wireMap = new HashMap(); + + List 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 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> solution34(List modules) + { + Map moduleMap = new HashMap(); + for (Module m : modules) + { + moduleMap.put(m.getName(), m); + } + Map> wireMap = new HashMap(); + + List 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 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 m_modules; private final CapabilitySet m_pkgCapSet; private final CapabilitySet m_modCapSet; + private final CapabilitySet m_otherCapSet; public ResolverStateImpl(List 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 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> candidateMap = new HashMap>(); + // Populate all candidates. populateCandidates( state, module, candidateMap, new HashMap()); + + // 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 mergeFragments( + Map> candidateMap) + { + // Map of fragment module to its merged hosts. + Map> fragments = new HashMap>(); + // Map of hosts to wrapped module. + Map wrappedHosts = new HashMap(); + + for (Entry> 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 hosts = fragments.get(entry.getKey().getModule()); + if (hosts == null) + { + hosts = new HashSet(); + 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> requiredHosts = + new HashMap>(); + for (Entry> entry : candidateMap.entrySet()) + { + for (Capability cap : entry.getValue()) + { + if (wrappedHosts.containsKey(cap.getModule())) + { + Set caps = requiredHosts.get(entry.getKey()); + if (caps == null) + { + caps = new HashSet(); + requiredHosts.put(entry.getKey(), caps); + } + caps.add(cap); + } + } + } + // Then we replace them with capabilities from the wrapped host. + for (Entry> entry : requiredHosts.entrySet()) + { + Set 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> requiredFragments = + new HashMap>(); + for (Entry> entry : candidateMap.entrySet()) + { + for (Capability cap : entry.getValue()) + { + if (fragments.containsKey(cap.getModule())) + { + Set caps = requiredFragments.get(entry.getKey()); + if (caps == null) + { + caps = new HashSet(); + requiredFragments.put(entry.getKey(), caps); + } + caps.add(cap); + } + } + } + // Then we replace them with capabilities from the wrapped host. + for (Entry> entry : requiredFragments.entrySet()) + { + Set cands = candidateMap.get(entry.getKey()); + for (Capability cap : entry.getValue()) + { + cands.remove(cap); + Set 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> 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 getDirectives() + { + return m_cap.getDirectives(); + } + + public Attribute getAttribute(String name) + { + return m_cap.getAttribute(name); + } + + public List getAttributes() + { + return m_cap.getAttributes(); + } + + public List 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 m_fragments = new ArrayList(); + private List m_cachedCapabilities = null; + private List 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 getCapabilities() + { + if (m_cachedCapabilities == null) + { + List capList = (m_module.getCapabilities() == null) + ? new ArrayList() + : new ArrayList(m_module.getCapabilities()); + for (int fragIdx = 0; + (m_fragments != null) && (fragIdx < m_fragments.size()); + fragIdx++) + { + List 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 getRequirements() + { + if (m_cachedRequirements == null) + { + List 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 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 getDirectives() + { + return m_req.getDirectives(); + } + + public String toString() + { + return "[" + m_module + "] " + getNamespace() + "; " + getFilter().toString(); + } +} \ No newline at end of file