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 2009/12/02 21:30:06 UTC
svn commit: r886296 - in
/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver:
felix/FelixResolverImpl.java manifestparser/Main.java
prototype/ProtoResolver.java
Author: rickhall
Date: Wed Dec 2 20:30:06 2009
New Revision: 886296
URL: http://svn.apache.org/viewvc?rev=886296&view=rev
Log:
Added support for optional requirements.
Modified:
felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/felix/FelixResolverImpl.java
felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/manifestparser/Main.java
felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java
Modified: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/felix/FelixResolverImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/felix/FelixResolverImpl.java?rev=886296&r1=886295&r2=886296&view=diff
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/felix/FelixResolverImpl.java (original)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/felix/FelixResolverImpl.java Wed Dec 2 20:30:06 2009
@@ -155,7 +155,7 @@
// If no candidates exist at this point, then throw a
// resolve exception unless the import is optional.
- if ((candidates.size() == 0))
+ if ((candidates.size() == 0) && !reqs.get(reqIdx).isOptional())
{
// Remove invalid candidate and any cycle byproduct resolved modules.
removeInvalidCandidate(targetModule, candidatesMap, new ArrayList());
Modified: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/manifestparser/Main.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/manifestparser/Main.java?rev=886296&r1=886295&r2=886296&view=diff
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/manifestparser/Main.java (original)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/manifestparser/Main.java Wed Dec 2 20:30:06 2009
@@ -205,6 +205,7 @@
.exporting(new CapabilityImpl(m, FelixCapability.PACKAGE_NAMESPACE, "org.xml.sax.ext"))
.exporting(new CapabilityImpl(m, FelixCapability.PACKAGE_NAMESPACE, "org.xml.sax.helpers"))
// Optional
+/*
.exporting(new CapabilityImpl(m, FelixCapability.PACKAGE_NAMESPACE, "com.sun.corba.ee.impl.orbutil.closure"))
.exporting(new CapabilityImpl(m, FelixCapability.PACKAGE_NAMESPACE, "com.sun.enterprise"))
.exporting(new CapabilityImpl(m, FelixCapability.PACKAGE_NAMESPACE, "com.sun.enterprise.admin.servermgmt.services"))
@@ -297,6 +298,7 @@
.exporting(new CapabilityImpl(m, FelixCapability.PACKAGE_NAMESPACE, "org.openide.util.datatransfer"))
.exporting(new CapabilityImpl(m, FelixCapability.PACKAGE_NAMESPACE, "org.openide.windows"))
.exporting(new CapabilityImpl(m, FelixCapability.PACKAGE_NAMESPACE, "sun.reflect"))
+*/
);
m.resolve(new ArrayList<Wire>());
Modified: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java?rev=886296&r1=886295&r2=886296&view=diff
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java (original)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java Wed Dec 2 20:30:06 2009
@@ -176,12 +176,15 @@
if (candidateMap.get(ip) == null)
{
Set<Capability> exporters = findExporters(ip);
- if (exporters.size() == 0)
+ if ((exporters.size() == 0) && !ip.isOptional())
{
throw new RuntimeException("Unable to resolve " + module
+ ": missing requirement " + ip);
}
- candidateMap.put(ip, exporters);
+ else if (exporters.size() > 0)
+ {
+ candidateMap.put(ip, exporters);
+ }
}
}
@@ -206,6 +209,11 @@
{
// Get the current candidate capability for the current import.
Set<Capability> exporters = candidateMap.get(ip);
+ // Optional imports may not have any exporters.
+ if (exporters == null)
+ {
+ continue;
+ }
Iterator<Capability> itExporters = exporters.iterator();
Capability cap = itExporters.next();
//System.out.println("+++ RESOLVING " + cap + " FOR " + module);
@@ -251,7 +259,7 @@
// Remove offending candidate.
itExporters.remove();
//System.out.println("Updated candidate map : " + candidateMap);
- if (!itExporters.hasNext())
+ if (!itExporters.hasNext() && !ip.isOptional())
{
// TODO: PROTO RESOLVER - Maybe this should be moved.
if ((module == m_rootModule) && (m_candidatePermutations.size() > 0))
@@ -844,20 +852,24 @@
List<RequirementImpl> imports = module.getImports();
for (int i = 0; i < imports.size(); i++)
{
- Capability cap = candidateMap.get(imports.get(i)).iterator().next();
- if (!cap.getModule().isResolved())
+ Set<Capability> candidates = candidateMap.get(imports.get(i));
+ if (candidates != null)
{
- populateWireMap(cap.getModule(), candidateMap, wireMap);
- }
+ Capability cap = candidates.iterator().next();
+ if (!cap.getModule().isResolved())
+ {
+ populateWireMap(cap.getModule(), candidateMap, wireMap);
+ }
- // Ignore modules that import themselves.
- if (!module.equals(cap.getModule()))
- {
- moduleWires.add(
- new Wire(module,
- imports.get(i),
- cap.getModule(),
- (CapabilityImpl) cap));
+ // Ignore modules that import themselves.
+ if (!module.equals(cap.getModule()))
+ {
+ moduleWires.add(
+ new Wire(module,
+ imports.get(i),
+ cap.getModule(),
+ (CapabilityImpl) cap));
+ }
}
}
}