felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r885920 [1/2] - in /felix/sandbox/rickhall/resolver/src/main: java/org/apache/felix/resolver/ java/org/apache/felix/resolver/felix/ java/org/apache/felix/resolver/manifestparser/ java/org/apache/felix/resolver/prototype/ resources/
Date Tue, 01 Dec 2009 20:50:54 GMT
Author: rickhall
Date: Tue Dec  1 20:50:51 2009
New Revision: 885920

URL: http://svn.apache.org/viewvc?rev=885920&view=rev
Log:
Bug fixed and performance improvements.

Added:
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Main2.java
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolveConflictException.java
      - copied, changed from r835915, felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolverConflictException.java
    felix/sandbox/rickhall/resolver/src/main/resources/
Removed:
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolverConflictException.java
Modified:
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Main.java
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Module.java
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/felix/FelixResolver.java
    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/Main.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Main.java?rev=885920&r1=885919&r2=885920&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 Tue Dec  1 20:50:51 2009
@@ -25,6 +25,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import org.apache.felix.resolver.felix.FelixResolver;
 import org.apache.felix.resolver.prototype.ProtoResolver;
 
 public class Main
@@ -56,8 +57,7 @@
         List<Module> moduleList = new ArrayList<Module>();
         Module targetModule = setupScenario(moduleList, scenario);
 
-//        Resolver resolver = (legacy) ? new FelixResolver(moduleList) : new ProtoResolver(moduleList);
-        Resolver resolver = new ProtoResolver(moduleList);
+        Resolver resolver = (legacy) ? new FelixResolver(moduleList) : new ProtoResolver(moduleList);
 
         try
         {
@@ -70,6 +70,7 @@
                 it.hasNext(); )
             {
                 Entry<Module, List<Wire>> entry = it.next();
+                entry.getKey().resolve(entry.getValue());
                 if (entry.getValue().size() > 0)
                 {
                     System.out.println("   " + entry.getKey());

Added: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Main2.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Main2.java?rev=885920&view=auto
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Main2.java (added)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Main2.java Tue Dec  1 20:50:51 2009
@@ -0,0 +1,188 @@
+/*
+ *  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;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.felix.resolver.felix.FelixResolver;
+import org.apache.felix.resolver.prototype.ProtoResolver;
+
+public class Main2
+{
+    public static void main(String[] args)
+        throws NoSuchMethodException, IllegalAccessException,
+            IllegalArgumentException, InvocationTargetException
+    {
+        if (args.length > 2)
+        {
+            System.out.println("[-legacy] [scenario-number]");
+            System.exit(0);
+        }
+
+        String scenario = "1";
+        boolean legacy = false;
+        for (int i = 0; i < args.length; i++)
+        {
+            if (args[i].equals("-legacy"))
+            {
+                legacy = true;
+            }
+            else
+            {
+                scenario = args[i];
+            }
+        }
+
+        List<Module> moduleList = new ArrayList<Module>();
+        List<Module> targets = setupScenario(moduleList, scenario);
+
+        Resolver resolver = (legacy) ? new FelixResolver(moduleList) : new ProtoResolver(moduleList);
+
+        try
+        {
+            for (Module target: targets)
+            {
+                long starttime = System.currentTimeMillis();
+                Map<Module, List<Wire>> wireMap = resolver.resolve(target);
+                long endtime = System.currentTimeMillis();
+                System.out.println("Resolve time: " + (endtime - starttime));
+                System.out.println("Wires:");
+                for (Iterator<Entry<Module, List<Wire>>> it = wireMap.entrySet().iterator();
+                    it.hasNext(); )
+                {
+                    Entry<Module, List<Wire>> entry = it.next();
+                    entry.getKey().resolve(entry.getValue());
+                    if (entry.getValue().size() > 0)
+                    {
+                        System.out.println("   " + entry.getKey());
+                        for (int i = 0; i < entry.getValue().size(); i++)
+                        {
+                            System.out.println("      " + entry.getValue().get(i));
+                        }
+                    }
+                }
+            }
+        }
+        catch (Exception ex)
+        {
+            ex.printStackTrace(System.out);
+        }
+    }
+
+    private static List<Module> setupScenario(List<Module> moduleList, String scenario)
+        throws NoSuchMethodException, IllegalAccessException,
+            IllegalArgumentException, InvocationTargetException
+    {
+        int i = Integer.parseInt(scenario);
+        String methodName = "scenario" + i;
+        System.out.println(methodName + ":\n");
+        Method method = Main2.class.getDeclaredMethod(methodName, new Class<?>[] { List.class });
+        return (List<Module>) method.invoke(null, moduleList);
+    }
+
+    // SOLUTION:
+    // A: bar->B, baz->E
+    // B: woz->D
+    // E: dit->F
+    private static List<Module> scenario1(List<Module> moduleList)
+    {
+        List<Module> targets = new ArrayList<Module>();
+
+        Module m;
+
+        // Bundle A
+        moduleList.add(
+            (m = new Module("A"))
+                .importing(new ImportedPackage("bar"))
+                .importing(new ImportedPackage("baz")));
+        targets.add(m);
+        // Bundle B
+        moduleList.add(
+            (m = new Module("B"))
+                .exporting(new ExportedPackage(m, "bar").using("woz"))
+                .importing(new ImportedPackage("woz")));
+        // Bundle C
+        moduleList.add(
+            (m = new Module("C"))
+                .exporting(new ExportedPackage(m, "woz").using("foo"))
+                .exporting(new ExportedPackage(m, "foo")));
+        // Bundle D
+        moduleList.add(
+            (m = new Module("D"))
+                .exporting(new ExportedPackage(m, "woz"))
+                .exporting(new ExportedPackage(m, "unused")));
+        // Bundle E
+        moduleList.add(
+            (m = new Module("E"))
+                .exporting(new ExportedPackage(m, "baz").using("dit"))
+                .exporting(new ExportedPackage(m, "unused"))
+                .importing(new ImportedPackage("dit")));
+        // Bundle F
+        moduleList.add(
+            (m = new Module("F"))
+                .exporting(new ExportedPackage(m, "dit").using("foo"))
+                .exporting(new ExportedPackage(m, "foo")));
+        // Bundle G
+        moduleList.add(
+            (m = new Module("G"))
+                .importing(new ImportedPackage("bar"))
+                .importing(new ImportedPackage("woz")));
+        targets.add(m);
+
+        return targets;
+    }
+
+    private static List<Module> scenario2(List<Module> moduleList)
+    {
+        List<Module> targets = new ArrayList<Module>();
+
+        Module m = new Module("A");
+        moduleList.add(m);
+        targets.add(m);
+
+        for (int i = 0; i < 1000; i++)
+        {
+            m.exporting(new ExportedPackage(m, "org.foo" + i));
+            m.importing(new ImportedPackage("org.foo" + i));
+        }
+
+        return targets;
+    }
+
+    private static List<Module> scenario3(List<Module> moduleList)
+    {
+        List<Module> targets = new ArrayList<Module>();
+
+        Module m = new Module("A");
+        moduleList.add(m);
+        targets.add(m);
+
+        for (int i = 0; i < 1000; i++)
+        {
+            m.exporting(new ExportedPackage(m, "org.foo" + i));
+        }
+
+        return targets;
+    }
+}
\ No newline at end of file

Modified: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Module.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Module.java?rev=885920&r1=885919&r2=885920&view=diff
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Module.java (original)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/Module.java Tue Dec  1 20:50:51 2009
@@ -25,13 +25,16 @@
 {
     private final String m_name;
     private final List<ExportedPackage> m_exports;
+    private final List<ExportedPackage> m_substExports;
     private final List<ImportedPackage> m_imports;
     private boolean m_isResolved = false;
+    private List<Wire> m_wires = null;
 
     public Module(String name)
     {
         m_name = name;
         m_exports = new ArrayList<ExportedPackage>();
+        m_substExports = new ArrayList<ExportedPackage>();
         m_imports = new ArrayList<ImportedPackage>();
     }
 
@@ -46,6 +49,12 @@
         return this;
     }
 
+    public Module substExporting(ExportedPackage ep)
+    {
+        m_substExports.add(ep);
+        return this;
+    }
+
     public Module importing(ImportedPackage ip)
     {
         m_imports.add(ip);
@@ -57,19 +66,29 @@
         return m_exports;
     }
 
+    public List<ExportedPackage> getSubstitutableExports()
+    {
+        return m_substExports;
+    }
+
     public List<ImportedPackage> getImports()
     {
         return m_imports;
     }
 
-    public synchronized void resolve()
+    public synchronized void resolve(List<Wire> wires)
     {
-        m_isResolved = true;
+        m_wires = wires;
     }
 
     public synchronized boolean isResolved()
     {
-        return m_isResolved;
+        return (m_wires != null);
+    }
+
+    public synchronized List<Wire> getWires()
+    {
+        return m_wires;
     }
 
     public String toString()

Copied: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolveConflictException.java (from r835915, felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolverConflictException.java)
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolveConflictException.java?p2=felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolveConflictException.java&p1=felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolverConflictException.java&r1=835915&r2=885920&rev=885920&view=diff
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolverConflictException.java (original)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/ResolveConflictException.java Tue Dec  1 20:50:51 2009
@@ -18,13 +18,13 @@
  */
 package org.apache.felix.resolver;
 
-public class ResolverConflictException extends RuntimeException
+public class ResolveConflictException extends ResolveException
 {
     /**
      * Constructs an instance of <code>ResolverConflictException</code> with the specified detail message.
      * @param msg the detail message.
      */
-    public ResolverConflictException(String msg)
+    public ResolveConflictException(String msg)
     {
         super(msg);
     }

Modified: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/felix/FelixResolver.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/felix/FelixResolver.java?rev=885920&r1=885919&r2=885920&view=diff
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/felix/FelixResolver.java (original)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/felix/FelixResolver.java Tue Dec  1 20:50:51 2009
@@ -43,6 +43,7 @@
 
     public FelixResolver(List<Module> moduleList)
     {
+System.out.println("+++ FELIX RESOLVER");
         m_moduleList = moduleList;
         for (int i = 0; i < m_moduleList.size(); i++)
         {
@@ -125,7 +126,6 @@
 
     public Map<Module, List<Wire>> resolve(Module module)
     {
-System.out.println("+++ FELIX RESOLVER");
         Map wireMap = m_resolver.resolve(m_state, module);
         Map<Module, List<Wire>> newWireMap = new HashMap<Module, List<Wire>>();
         for (Iterator it = wireMap.entrySet().iterator(); it.hasNext(); )

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=885920&r1=885919&r2=885920&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 Tue Dec  1 20:50:51 2009
@@ -22,19 +22,19 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import org.apache.felix.resolver.*;
+import org.apache.felix.resolver.ExportedPackage;
+import org.apache.felix.resolver.ImportedPackage;
+import org.apache.felix.resolver.Module;
+import org.apache.felix.resolver.ResolveException;
+import org.apache.felix.resolver.Wire;
 
 public class FelixResolverImpl
 {
     // Reusable empty array.
     private static final Wire[] m_emptyWires = new Wire[0];
-    private static final Module[] m_emptyModules = new Module[0];
 
     public FelixResolverImpl()
     {
@@ -121,7 +121,6 @@
             // at the front of the list of candidates.
             List<ExportedPackage> candidates = state.getResolvedCandidates(reqs.get(reqIdx));
             candidates.addAll(state.getUnresolvedCandidates(reqs.get(reqIdx)));
-
             // If we have candidates, then we need to recursively populate
             // the resolver map with each of them.
             ResolveException rethrow = null;
@@ -642,7 +641,9 @@
     private static Map calculateImportedPackages(Module targetModule, Map candidatesMap)
         throws ResolveException
     {
-        return calculateImportedPackagesUnresolved(targetModule, candidatesMap);
+        return (candidatesMap.get(targetModule) == null)
+            ? calculateImportedPackagesResolved(targetModule)
+            : calculateImportedPackagesUnresolved(targetModule, candidatesMap);
     }
 
     private static Map calculateImportedPackagesUnresolved(Module targetModule, Map candidatesMap)
@@ -666,7 +667,7 @@
             ExportedPackage candCap = (ExportedPackage) cs.m_candidates.get(cs.m_idx);
 
             String pkgName = (String)
-                candCap.getName();
+            candCap.getName();
 
             ResolvedPackage rp = new ResolvedPackage(pkgName, cs);
             rp.m_capList.add(candCap);
@@ -676,6 +677,30 @@
         return pkgMap;
     }
 
+    private static Map calculateImportedPackagesResolved(Module targetModule)
+        throws ResolveException
+    {
+//System.out.println("calculateImportedPackagesResolved("+targetModule+")");
+        Map pkgMap = new HashMap();
+
+        // Loop through the target module's wires for package
+        // dependencies and add the resolved packages to the
+        // imported package map.
+        List<Wire> wires = targetModule.getWires();
+        for (int wireIdx = 0; (wires != null) && (wireIdx < wires.size()); wireIdx++)
+        {
+            Wire wire = wires.get(wireIdx);
+            String pkgName = (String)
+                wire.getExportedPackage().getName();
+            ResolvedPackage rp = (ResolvedPackage) pkgMap.get(pkgName);
+            rp = (rp == null) ? new ResolvedPackage(pkgName, null) : rp;
+            rp.m_capList.add(wire.getExportedPackage());
+            pkgMap.put(rp.m_name, rp);
+        }
+
+        return pkgMap;
+    }
+
     private static Map calculateExportedPackages(Module targetModule)
     {
 //System.out.println("calculateExportedPackages("+targetModule+")");
@@ -687,7 +712,7 @@
         for (int capIdx = 0; (caps != null) && (capIdx < caps.size()); capIdx++)
         {
             String pkgName = (String)
-                caps.get(capIdx).getName();
+            caps.get(capIdx).getName();
             ResolvedPackage rp = (ResolvedPackage) pkgMap.get(pkgName);
             rp = (rp == null) ? new ResolvedPackage(pkgName, null) : rp;
             rp.m_capList.add(caps.get(capIdx));

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=885920&r1=885919&r2=885920&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 Tue Dec  1 20:50:51 2009
@@ -42,18 +42,25 @@
 {
     public static void main(String[] args) throws IOException, Exception
     {
-        if ((args.length < 1) || (args.length > 2))
+        if (args.length < 1)
         {
-            System.err.println("usage: [-legacy] <bundle-dir>");
+            System.err.println("usage: [-Dinvoke.count=true] [-legacy] [-nodupes] <bundle-dir>");
             System.exit(0);
         }
 
-        String choice = "";
-        String dir = args[0];
-        if (args.length == 2)
+        boolean legacy = false;
+        boolean duplicates = true;
+        String dir = args[args.length - 1];
+        for (int i = 0; i < args.length - 1; i++)
         {
-            choice = args[0];
-            dir = args[1];
+            if (args[i].equals("-legacy"))
+            {
+                legacy = true;
+            }
+            else if (args[i].equals("-nodupes"))
+            {
+                duplicates = false;
+            }
         }
 
         // Look in the specified bundle directory to create a list
@@ -76,21 +83,28 @@
 
         Module m;
         moduleList.add((m = new Module("system.bundle"))
+            .exporting(new ExportedPackage(m, "javax.activity"))
+            .exporting(new ExportedPackage(m, "javax.accessibility"))
             .exporting(new ExportedPackage(m, "javax.annotation").with("version=1.1.0"))
             .exporting(new ExportedPackage(m, "javax.annotation.security").with("version=1.1.0"))
             .exporting(new ExportedPackage(m, "javax.annotation.sql").with("version=1.1.0"))
             .exporting(new ExportedPackage(m, "javax.activation").with("version=1.1.0"))
             .exporting(new ExportedPackage(m, "javax.crypto"))
             .exporting(new ExportedPackage(m, "javax.crypto.spec"))
+            .exporting(new ExportedPackage(m, "javax.help"))
             .exporting(new ExportedPackage(m, "javax.imageio"))
+            .exporting(new ExportedPackage(m, "javax.imageio.spi"))
             .exporting(new ExportedPackage(m, "javax.imageio.stream"))
             .exporting(new ExportedPackage(m, "javax.jws").with("version=2.0.0"))
             .exporting(new ExportedPackage(m, "javax.jws.soap"))
             .exporting(new ExportedPackage(m, "javax.management"))
             .exporting(new ExportedPackage(m, "javax.management.loading"))
             .exporting(new ExportedPackage(m, "javax.management.modelmbean"))
+            .exporting(new ExportedPackage(m, "javax.management.monitor"))
             .exporting(new ExportedPackage(m, "javax.management.openmbean"))
+            .exporting(new ExportedPackage(m, "javax.management.relation"))
             .exporting(new ExportedPackage(m, "javax.management.remote"))
+            .exporting(new ExportedPackage(m, "javax.management.remote.rmi"))
             .exporting(new ExportedPackage(m, "javax.naming"))
             .exporting(new ExportedPackage(m, "javax.naming.directory"))
             .exporting(new ExportedPackage(m, "javax.naming.ldap"))
@@ -108,8 +122,12 @@
             .exporting(new ExportedPackage(m, "javax.security.cert"))
             .exporting(new ExportedPackage(m, "javax.security.sasl"))
             .exporting(new ExportedPackage(m, "javax.sql"))
+            .exporting(new ExportedPackage(m, "javax.sql.rowset"))
+            .exporting(new ExportedPackage(m, "javax.sql.rowset.serial"))
+            .exporting(new ExportedPackage(m, "javax.sql.rowset.spi"))
             .exporting(new ExportedPackage(m, "javax.swing"))
             .exporting(new ExportedPackage(m, "javax.swing.border"))
+            .exporting(new ExportedPackage(m, "javax.swing.event"))
             .exporting(new ExportedPackage(m, "javax.swing.tree"))
             .exporting(new ExportedPackage(m, "javax.tools"))
             .exporting(new ExportedPackage(m, "javax.xml"))
@@ -124,16 +142,16 @@
             .exporting(new ExportedPackage(m, "javax.xml.parsers"))
             .exporting(new ExportedPackage(m, "javax.xml.registry"))
             .exporting(new ExportedPackage(m, "javax.xml.registry.infomodel"))
-            .exporting(new ExportedPackage(m, "javax.xml.rpc").with("version=1.1.0"))
+//            .exporting(new ExportedPackage(m, "javax.xml.rpc").with("version=1.1.0"))
             .exporting(new ExportedPackage(m, "javax.xml.rpc.encoding").with("version=1.1.0"))
-            .exporting(new ExportedPackage(m, "javax.xml.rpc.handler.soap").with("version=1.1.0"))
+//            .exporting(new ExportedPackage(m, "javax.xml.rpc.handler.soap").with("version=1.1.0"))
             .exporting(new ExportedPackage(m, "javax.xml.rpc.holders").with("version=1.1.0"))
-            .exporting(new ExportedPackage(m, "javax.xml.rpc.server").with("version=1.1.0"))
-            .exporting(new ExportedPackage(m, "javax.xml.rpc.soap").with("version=1.1.0"))
-            .exporting(new ExportedPackage(m, "javax.xml.soap").with("version=1.3.0"))
-            .exporting(new ExportedPackage(m, "javax.xml.stream").with("version=1.0.0"))
+//            .exporting(new ExportedPackage(m, "javax.xml.rpc.server").with("version=1.1.0"))
+//            .exporting(new ExportedPackage(m, "javax.xml.rpc.soap").with("version=1.1.0"))
+//            .exporting(new ExportedPackage(m, "javax.xml.soap").with("version=1.3.0"))
+//            .exporting(new ExportedPackage(m, "javax.xml.stream").with("version=1.0.0"))
             .exporting(new ExportedPackage(m, "javax.xml.stream.events"))
-            .exporting(new ExportedPackage(m, "javax.xml.stream.util").with("version=1.0.0"))
+//            .exporting(new ExportedPackage(m, "javax.xml.stream.util").with("version=1.0.0"))
             .exporting(new ExportedPackage(m, "javax.xml.transform"))
             .exporting(new ExportedPackage(m, "javax.xml.transform.dom"))
             .exporting(new ExportedPackage(m, "javax.xml.transform.sax"))
@@ -156,25 +174,50 @@
             .exporting(new ExportedPackage(m, "org.omg.CORBA.portable"))
             .exporting(new ExportedPackage(m, "org.omg.CORBA.TypeCodePackage"))
             .exporting(new ExportedPackage(m, "org.omg.CosNaming"))
+            .exporting(new ExportedPackage(m, "org.omg.CosNaming.NamingContextExtPackage"))
+            .exporting(new ExportedPackage(m, "org.omg.CosNaming.NamingContextPackage"))
+            .exporting(new ExportedPackage(m, "org.omg.Dynamic"))
+            .exporting(new ExportedPackage(m, "org.omg.DynamicAny"))
+            .exporting(new ExportedPackage(m, "org.omg.DynamicAny.DynAnyFactoryPackage"))
+            .exporting(new ExportedPackage(m, "org.omg.DynamicAny.DynAnyPackage"))
             .exporting(new ExportedPackage(m, "org.omg.IOP"))
+            .exporting(new ExportedPackage(m, "org.omg.IOP.CodecFactoryPackage"))
+            .exporting(new ExportedPackage(m, "org.omg.IOP.CodecPackage"))
             .exporting(new ExportedPackage(m, "org.omg.PortableInterceptor"))
+            .exporting(new ExportedPackage(m, "org.omg.PortableInterceptor.ORBInitInfoPackage"))
             .exporting(new ExportedPackage(m, "org.omg.PortableServer"))
+            .exporting(new ExportedPackage(m, "org.omg.PortableServer.CurrentPackage"))
+            .exporting(new ExportedPackage(m, "org.omg.PortableServer.POAManagerPackage"))
+            .exporting(new ExportedPackage(m, "org.omg.PortableServer.POAPackage"))
+            .exporting(new ExportedPackage(m, "org.omg.PortableServer.portable"))
+            .exporting(new ExportedPackage(m, "org.omg.PortableServer.ServantLocatorPackage"))
+            .exporting(new ExportedPackage(m, "org.omg.SendingContext"))
             .exporting(new ExportedPackage(m, "org.osgi.framework").with("version=1.4.0"))
             .exporting(new ExportedPackage(m, "org.osgi.service.packageadmin").with("version=1.2.0"))
+            .exporting(new ExportedPackage(m, "org.osgi.service.startlevel").with("version=1.1.0"))
             .exporting(new ExportedPackage(m, "org.osgi.service.url").with("version=1.0.0"))
-            .exporting(new ExportedPackage(m, "org.osgi.util.tracker"))
+            .exporting(new ExportedPackage(m, "org.osgi.util.tracker").with("version=1.3.0"))
             .exporting(new ExportedPackage(m, "org.w3c.dom"))
+            .exporting(new ExportedPackage(m, "org.w3c.dom.bootstrap"))
             .exporting(new ExportedPackage(m, "org.w3c.dom.ls"))
             .exporting(new ExportedPackage(m, "org.xml.sax"))
             .exporting(new ExportedPackage(m, "org.xml.sax.ext"))
             .exporting(new ExportedPackage(m, "org.xml.sax.helpers"))
 // Optional
+            .exporting(new ExportedPackage(m, "com.sun.corba.ee.impl.orbutil.closure"))
+            .exporting(new ExportedPackage(m, "com.sun.enterprise"))
+            .exporting(new ExportedPackage(m, "com.sun.enterprise.admin.servermgmt.services"))
+            .exporting(new ExportedPackage(m, "com.sun.enterprise.deployment.node"))
             .exporting(new ExportedPackage(m, "com.sun.enterprise.security.jauth.callback"))
             .exporting(new ExportedPackage(m, "com.sun.enterprise.web.connector.grizzly.algorithms"))
             .exporting(new ExportedPackage(m, "com.sun.enterprise.web.connector.grizzly.ssl"))
             .exporting(new ExportedPackage(m, "com.sun.enterprise.web.portunif"))
             .exporting(new ExportedPackage(m, "com.sun.enterprise.web.portunif.util"))
             .exporting(new ExportedPackage(m, "com.sun.enterprise.webservice.monitoring"))
+            .exporting(new ExportedPackage(m, "com.sun.jdi"))
+            .exporting(new ExportedPackage(m, "com.sun.jdi.connect"))
+            .exporting(new ExportedPackage(m, "com.sun.jdi.event"))
+            .exporting(new ExportedPackage(m, "com.sun.jdi.request"))
             .exporting(new ExportedPackage(m, "com.sun.mail.util"))
             .exporting(new ExportedPackage(m, "com.sun.msv.datatype"))
             .exporting(new ExportedPackage(m, "com.sun.msv.datatype.xsd"))
@@ -186,16 +229,75 @@
             .exporting(new ExportedPackage(m, "com.sun.msv.util"))
             .exporting(new ExportedPackage(m, "com.sun.msv.verifier"))
             .exporting(new ExportedPackage(m, "com.sun.msv.verifier.regexp"))
+            .exporting(new ExportedPackage(m, "com.sun.sql.rowset"))
+            .exporting(new ExportedPackage(m, "com.sun.syndication.feed"))
+            .exporting(new ExportedPackage(m, "com.sun.syndication.feed.atom"))
+            .exporting(new ExportedPackage(m, "com.sun.syndication.io"))
             .exporting(new ExportedPackage(m, "com.sun.xml.bind.serializer"))
             .exporting(new ExportedPackage(m, "com.sun.xml.bind.validator"))
             .exporting(new ExportedPackage(m, "com.sun.xml.ws.spi.runtime"))
+            .exporting(new ExportedPackage(m, "groovy.lang"))
+            .exporting(new ExportedPackage(m, "groovy.util"))
+            .exporting(new ExportedPackage(m, "oracle.AQ"))
+            .exporting(new ExportedPackage(m, "oracle.spatial.geometry"))
+            .exporting(new ExportedPackage(m, "oracle.sql"))
+            .exporting(new ExportedPackage(m, "oracle.xdb"))
+            .exporting(new ExportedPackage(m, "oracle.xdb.dom"))
+            .exporting(new ExportedPackage(m, "oracle.xml.jaxp"))
+            .exporting(new ExportedPackage(m, "oracle.xml.parser.schema"))
+            .exporting(new ExportedPackage(m, "oracle.xml.parser.v2"))
+            .exporting(new ExportedPackage(m, "oracle.xml.util"))
+            .exporting(new ExportedPackage(m, "org.apache"))
+            .exporting(new ExportedPackage(m, "org.apache.avalon.framework.logger"))
             .exporting(new ExportedPackage(m, "org.apache.coyote"))
+            .exporting(new ExportedPackage(m, "org.apache.log"))
             .exporting(new ExportedPackage(m, "org.apache.log4j"))
             .exporting(new ExportedPackage(m, "org.apache.tomcat.util.buf"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.eis").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.eis.interactions").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.exceptions").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.expressions").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.internal.databaseaccess").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.internal.expressions").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.internal.helper").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.internal.platform.database").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.internal.security").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.internal.sessions").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.oxm").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.oxm.record").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.oxm.schema").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.platform.database").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.platform.database.converters").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.platform.server").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.platform.xml").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.queries").with("version=2.0.0.v20091031-r5713"))
+            .exporting(new ExportedPackage(m, "org.eclipse.persistence.sessions").with("version=2.0.0.v20091031-r5713"))
             .exporting(new ExportedPackage(m, "org.iso_relax.verifier.impl"))
+            .exporting(new ExportedPackage(m, "org.jdom"))
+            .exporting(new ExportedPackage(m, "org.jdom.input"))
+            .exporting(new ExportedPackage(m, "org.jdom.output"))
+            .exporting(new ExportedPackage(m, "org.mortbay.jetty.annotations"))
+            .exporting(new ExportedPackage(m, "org.mortbay.jetty.plus.annotation"))
+            .exporting(new ExportedPackage(m, "org.netbeans.api.db.explorer"))
+            .exporting(new ExportedPackage(m, "org.netbeans.api.db.explorer.support"))
+            .exporting(new ExportedPackage(m, "org.netbeans.api.progress"))
+            .exporting(new ExportedPackage(m, "org.netbeans.api.project"))
+            .exporting(new ExportedPackage(m, "org.netbeans.lib.ddl.impl"))
+            .exporting(new ExportedPackage(m, "org.netbeans.spi.project.ui.templates.support"))
+            .exporting(new ExportedPackage(m, "org.openide"))
+            .exporting(new ExportedPackage(m, "org.openide.actions"))
+            .exporting(new ExportedPackage(m, "org.openide.awt"))
+            .exporting(new ExportedPackage(m, "org.openide.filesystems"))
+            .exporting(new ExportedPackage(m, "org.openide.loaders"))
+            .exporting(new ExportedPackage(m, "org.openide.nodes"))
+            .exporting(new ExportedPackage(m, "org.openide.util"))
+            .exporting(new ExportedPackage(m, "org.openide.util.actions"))
+            .exporting(new ExportedPackage(m, "org.openide.util.datatransfer"))
+            .exporting(new ExportedPackage(m, "org.openide.windows"))
+            .exporting(new ExportedPackage(m, "sun.reflect"))
         );
-
-        Module maxImporter = null;
+        m.resolve(new ArrayList<Wire>());
 
         for (int jarIdx = 0; jarIdx < jarList.size(); jarIdx++)
         {
@@ -204,19 +306,13 @@
             {
 //                Map headerMap = new StringMap(getMainAttributes(jarFile), false);
                 Map headerMap = new StringMap(jarFile.getManifest().getMainAttributes(), false);
-//compareMaps(headerMap, manifestMap);
                 if (headerMap.containsKey("Bundle-SymbolicName"))
                 {
                     ManifestParser mp = new ManifestParser(headerMap);
-                    Module module = createModule(mp);
+                    Module module = createModule(mp, duplicates);
                     if (module != null)
                     {
                         moduleList.add(module);
-                        if ((maxImporter == null)
-                            || (maxImporter.getImports().size() < module.getImports().size()))
-                        {
-                            maxImporter = module;
-                        }
                     }
                 }
             }
@@ -227,10 +323,9 @@
         }
 
         System.out.println("Generated " + moduleList.size() + " modules.");
-        System.out.println("Max importer: " + maxImporter + " (" + maxImporter.getImports().size() + ")");
 
         Resolver resolver = null;
-        if (choice.equals("-legacy"))
+        if (legacy)
         {
             resolver = new FelixResolver(moduleList);
         }
@@ -241,27 +336,38 @@
 
         try
         {
-            long starttime = System.currentTimeMillis();
-            Map<Module, List<Wire>> wireMap = resolver.resolve(maxImporter);
-//            Map<Module, List<Wire>> wireMap = resolver.resolve(resolver.getModule("com.sun.enterprise.hk2-core"));
-//            Map<Module, List<Wire>> wireMap = resolver.resolve(resolver.getModule("com.sun.pkg.client"));
-            long endtime = System.currentTimeMillis();
-            System.out.println("Resolve time: " + (endtime - starttime));
-            System.out.println("Modules resolved: " + wireMap.size());
-            System.out.println("Wires:");
-            for (Iterator<Entry<Module, List<Wire>>> it = wireMap.entrySet().iterator();
-                it.hasNext(); )
-            {
-                Entry<Module, List<Wire>> entry = it.next();
-                if (entry.getValue().size() > 0)
-                {
-//                    System.out.println("   " + entry.getKey());
-                    for (int i = 0; i < entry.getValue().size(); i++)
+            for (Module target = getTargetUnresolvedModule(moduleList);
+                target != null;
+                target = getTargetUnresolvedModule(moduleList))
+            {
+                System.out.println("Target: " + target + " (" + target.getImports().size() + ")");
+                long starttime = System.currentTimeMillis();
+                Map<Module, List<Wire>> wireMap = resolver.resolve(target);
+                long endtime = System.currentTimeMillis();
+                System.out.println("Resolve time: " + (endtime - starttime));
+                System.out.println("Modules resolved: " + wireMap.size());
+//                System.out.println("Wires:");
+                for (Iterator<Entry<Module, List<Wire>>> it = wireMap.entrySet().iterator();
+                    it.hasNext(); )
+                {
+                    Entry<Module, List<Wire>> entry = it.next();
+                    entry.getKey().resolve(entry.getValue());
+//System.out.println("SETTING WIRES FOR " + entry.getKey());
+                    if (entry.getValue().size() > 0)
                     {
+//                    System.out.println("   " + entry.getKey());
+                        for (int i = 0; i < entry.getValue().size(); i++)
+                        {
 //                        System.out.println("      " + entry.getValue().get(i));
-                        System.out.println("   " + entry.getKey() + " - " + entry.getValue().get(i));
+//                            System.out.println("   " + entry.getKey() + " - " + entry.getValue().get(i));
+                        }
                     }
                 }
+
+                if (target.getName().equals("jersey-bundle"))
+                {
+                    System.exit(0);
+                }
             }
         }
         catch (Exception ex)
@@ -270,6 +376,24 @@
         }
     }
 
+    private static Module getTargetUnresolvedModule(List<Module> modules)
+    {
+        Module maxImporter = null;
+
+        for (int modIdx = 0; modIdx < modules.size(); modIdx++)
+        {
+            Module m = modules.get(modIdx);
+            if (!m.isResolved()
+                && ((maxImporter == null)
+                    || (maxImporter.getImports().size() < m.getImports().size())))
+            {
+                maxImporter = m;
+            }
+        }
+
+        return maxImporter;
+    }
+
     private static Map getMainAttributes(JarFile jarFile) throws IOException
     {
         Map map = new HashMap();
@@ -389,13 +513,20 @@
         }
     }
 
-    private static Module createModule(ManifestParser mp)
+    private static Module createModule(ManifestParser mp, boolean duplicates)
     {
         Module module = new Module(mp.getSymbolicName());
         try
         {
-            addCapabilities(module, mp.getCapabilities());
-            addRequirements(module, mp.getRequirements());
+            List<Capability> caps = new ArrayList<Capability>(Arrays.asList(mp.getCapabilities()));
+            List<Requirement> reqs = new ArrayList<Requirement>(Arrays.asList(mp.getRequirements()));
+
+            if (!duplicates)
+            {
+                removeOverlappingRequirements(caps, reqs);
+            }
+            addCapabilities(module, caps);
+            addRequirements(module, reqs);
         }
         catch (RuntimeException ex)
         {
@@ -405,102 +536,149 @@
         return module;
     }
 
-    private static void addCapabilities(Module module, Capability[] caps)
+    private static ExportedPackage convertToExportedPackage(Module module, Capability cap)
     {
-        for (int capIdx = 0; (caps != null) && (capIdx < caps.length); capIdx++)
+        ExportedPackage ep = new ExportedPackage(module, cap.getPackageName());
+
+        R4Directive[] dirs = cap.getDirectives();
+        for (int dirIdx = 0; (dirs != null) && (dirIdx < dirs.length); dirIdx++)
         {
-            if (caps[capIdx].getNamespace().equals(Capability.MODULE_NAMESPACE)
-                || caps[capIdx].getNamespace().equals(Capability.HOST_NAMESPACE))
+            if (dirs[dirIdx].getName().equals(Constants.INCLUDE_DIRECTIVE)
+                || dirs[dirIdx].getName().equals(Constants.MANDATORY_DIRECTIVE))
             {
                 continue;
             }
-            else if (!caps[capIdx].getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+            else if (!dirs[dirIdx].getName().equals(Constants.USES_DIRECTIVE))
             {
-                throw new RuntimeException("Unsupported capability: " + caps[capIdx].getNamespace());
+                throw new RuntimeException("Unsupported capability directive: " + dirs[dirIdx].getName());
             }
+            ep.using(dirs[dirIdx].getValue());
+        }
 
-            ExportedPackage ep = new ExportedPackage(module, caps[capIdx].getPackageName());
-
-            R4Directive[] dirs = caps[capIdx].getDirectives();
-            for (int dirIdx = 0; (dirs != null) && (dirIdx < dirs.length); dirIdx++)
+        R4Attribute[] attrs = cap.getAttributes();
+        for (int attrIdx = 0; (attrs != null) && (attrIdx < attrs.length); attrIdx++)
+        {
+            if (attrs[attrIdx].getName().equals(Capability.PACKAGE_PROPERTY))
             {
-                if (dirs[dirIdx].getName().equals(Constants.INCLUDE_DIRECTIVE)
-                    || dirs[dirIdx].getName().equals(Constants.MANDATORY_DIRECTIVE))
-                {
-                    continue;
-                }
-                else if (!dirs[dirIdx].getName().equals(Constants.USES_DIRECTIVE))
-                {
-                    throw new RuntimeException("Unsupported capability directive: " + dirs[dirIdx].getName());
-                }
-                ep.using(dirs[dirIdx].getValue());
+                continue;
+            }
+            if (attrs[attrIdx].isMandatory())
+            {
+                ep.withMandatory(attrs[attrIdx].getName() + "=" + attrs[attrIdx].getValue());
+            }
+            else
+            {
+                ep.with(attrs[attrIdx].getName() + "=" + attrs[attrIdx].getValue());
             }
+        }
+
+        return ep;
+    }
+
+    private static ImportedPackage convertToImportedPackage(Module module, Requirement req)
+    {
+        ImportedPackage ip = new ImportedPackage(req.getTargetName());
 
-            R4Attribute[] attrs = caps[capIdx].getAttributes();
-            for (int attrIdx = 0; (attrs != null) && (attrIdx < attrs.length); attrIdx++)
+        R4Directive[] dirs = req.getDirectives();
+        for (int dirIdx = 0; (dirs != null) && (dirIdx < dirs.length); dirIdx++)
+        {
+            if (!dirs[dirIdx].getName().equals(Constants.RESOLUTION_DIRECTIVE))
             {
-                if (attrs[attrIdx].getName().equals(Capability.PACKAGE_PROPERTY))
-                {
-                    continue;
-                }
-                if (attrs[attrIdx].isMandatory())
-                {
-                    ep.withMandatory(attrs[attrIdx].getName() + "=" + attrs[attrIdx].getValue());
-                }
-                else
-                {
-                    ep.with(attrs[attrIdx].getName() + "=" + attrs[attrIdx].getValue());
-                }
+                throw new RuntimeException("Unsupported requirement directive: " + dirs[dirIdx].getName());
+            }
+            if (dirs[dirIdx].getValue().equals(Constants.RESOLUTION_OPTIONAL))
+            {
+                ip.optional();
             }
+        }
 
-            module.exporting(ep);
+        R4Attribute[] attrs = req.getAttributes();
+        for (int attrIdx = 0; (attrs != null) && (attrIdx < attrs.length); attrIdx++)
+        {
+            if (attrs[attrIdx].getName().equals(Capability.PACKAGE_PROPERTY))
+            {
+                continue;
+            }
+            else
+            {
+                ip.with(attrs[attrIdx].getName() + "=" + attrs[attrIdx].getValue());
+            }
         }
+
+        return ip;
     }
 
-    private static void addRequirements(Module module, Requirement[] reqs)
+    private static void removeOverlappingRequirements(
+        List<Capability> caps, List<Requirement> reqs)
     {
-        for (int reqIdx = 0; (reqs != null) && (reqIdx < reqs.length); reqIdx++)
+        for (Iterator<Capability> itCap = caps.iterator(); itCap.hasNext(); )
         {
-            if (!reqs[reqIdx].getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+            Capability cap = itCap.next();
+            if (cap.getNamespace().equals(Capability.MODULE_NAMESPACE)
+                || cap.getNamespace().equals(Capability.HOST_NAMESPACE))
             {
-                // Generate invalid source for now.
-                throw new RuntimeException("Require-Bundle not supported.");
+                continue;
             }
-            else if (!reqs[reqIdx].getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+            else if (!cap.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
             {
-                System.out.println("Unsupported requirement: " + reqs[reqIdx].getNamespace());
-                System.exit(0);
+                throw new RuntimeException("Unsupported capability: " + cap.getNamespace());
             }
 
-            ImportedPackage ip = new ImportedPackage(reqs[reqIdx].getTargetName());
-
-            R4Directive[] dirs = reqs[reqIdx].getDirectives();
-            for (int dirIdx = 0; (dirs != null) && (dirIdx < dirs.length); dirIdx++)
+            for (Iterator<Requirement> itReq = reqs.iterator(); itReq.hasNext(); )
             {
-                if (!dirs[dirIdx].getName().equals(Constants.RESOLUTION_DIRECTIVE))
+                Requirement req = itReq.next();
+                if (!req.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
                 {
-                    throw new RuntimeException("Unsupported requirement directive: " + dirs[dirIdx].getName());
+                    // Generate invalid source for now.
+                    throw new RuntimeException("Require-Bundle not supported.");
                 }
-                if (dirs[dirIdx].getValue().equals(Constants.RESOLUTION_OPTIONAL))
+                else if (!req.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
                 {
-                    ip.optional();
+                    System.out.println("Unsupported requirement: " + req.getNamespace());
+                    System.exit(0);
                 }
-            }
 
-            R4Attribute[] attrs = reqs[reqIdx].getAttributes();
-            for (int attrIdx = 0; (attrs != null) && (attrIdx < attrs.length); attrIdx++)
-            {
-                if (attrs[attrIdx].getName().equals(Capability.PACKAGE_PROPERTY))
+                if (cap.getPackageName().equals(req.getTargetName()))
                 {
-                    continue;
-                }
-                else
-                {
-                    ip.with(attrs[attrIdx].getName() + "=" + attrs[attrIdx].getValue());
+                    itReq.remove();
+                    break;
                 }
             }
+        }
+    }
 
-            module.importing(ip);
+    private static void addCapabilities(Module module, List<Capability> caps)
+    {
+        for (int capIdx = 0; (caps != null) && (capIdx < caps.size()); capIdx++)
+        {
+            if (caps.get(capIdx).getNamespace().equals(Capability.MODULE_NAMESPACE)
+                || caps.get(capIdx).getNamespace().equals(Capability.HOST_NAMESPACE))
+            {
+                continue;
+            }
+            else if (!caps.get(capIdx).getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+            {
+                throw new RuntimeException("Unsupported capability: " + caps.get(capIdx).getNamespace());
+            }
+            module.exporting(convertToExportedPackage(module, caps.get(capIdx)));
+        }
+    }
+
+    private static void addRequirements(Module module, List<Requirement> reqs)
+    {
+        for (int reqIdx = 0; (reqs != null) && (reqIdx < reqs.size()); reqIdx++)
+        {
+            if (!reqs.get(reqIdx).getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+            {
+                // Generate invalid source for now.
+                throw new RuntimeException("Require-Bundle not supported.");
+            }
+            else if (!reqs.get(reqIdx).getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+            {
+                System.out.println("Unsupported requirement: " + reqs.get(reqIdx).getNamespace());
+                System.exit(0);
+            }
+            module.importing(convertToImportedPackage(module, reqs.get(reqIdx)));
         }
     }
 }
\ No newline at end of file



Mime
View raw message