Author: rickhall
Date: Thu Jan 21 16:18:15 2010
New Revision: 901759

URL: http://svn.apache.org/viewvc?rev=901759&view=rev
Log:
It compiles, now let the debugging commence.

Removed:
    
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/ResolverStateImpl.java
    
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/StatefulResolver.java
Modified:
    
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
    
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/Felix.java
    
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/ModuleImpl.java
    
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
    
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java

Modified: 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java?rev=901759&r1=901758&r2=901759&view=diff
==============================================================================
--- 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
 (original)
+++ 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
 Thu Jan 21 16:18:15 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.framework;
 
+import java.util.List;
 import org.apache.felix.framework.candidateset.Capability;
 import org.apache.felix.framework.candidateset.Module;
 import org.osgi.framework.Bundle;
@@ -63,7 +64,8 @@
         {
             return null;
         }
-        return m_felix.getImportingBundles(this);
+        List<Bundle> list = m_felix.getImportingBundles(this);
+        return list.toArray(new Bundle[list.size()]);
     }
 
     public String getName()

Modified: 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/Felix.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/Felix.java?rev=901759&r1=901758&r2=901759&view=diff
==============================================================================
--- 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/Felix.java
 (original)
+++ 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/Felix.java
 Thu Jan 21 16:18:15 2010
@@ -23,16 +23,55 @@
 import java.net.*;
 import java.security.*;
 import java.util.*;
-
-import org.apache.felix.framework.cache.*;
-import org.apache.felix.framework.ext.SecurityProvider;
-import org.apache.felix.framework.searchpolicy.*;
+import java.util.Map.Entry;
 import org.apache.felix.framework.ServiceRegistry.ServiceRegistryCallbacks;
-import org.apache.felix.framework.util.*;
-import org.apache.felix.framework.util.manifestparser.*;
-import org.apache.felix.moduleloader.*;
-import org.osgi.framework.*;
-import org.osgi.framework.hooks.service.*;
+import org.apache.felix.framework.cache.BundleArchive;
+import org.apache.felix.framework.cache.BundleCache;
+import org.apache.felix.framework.candidateset.Attribute;
+import org.apache.felix.framework.candidateset.Capability;
+import org.apache.felix.framework.candidateset.CapabilitySet;
+import org.apache.felix.framework.candidateset.Directive;
+import org.apache.felix.framework.candidateset.Module;
+import org.apache.felix.framework.candidateset.Requirement;
+import org.apache.felix.framework.candidateset.Wire;
+import org.apache.felix.framework.ext.SecurityProvider;
+import org.apache.felix.framework.resolver.ResolveException;
+import org.apache.felix.framework.resolver.Resolver;
+import org.apache.felix.framework.resolver.ResolverImpl;
+import org.apache.felix.framework.util.EventDispatcher;
+import org.apache.felix.framework.util.FelixConstants;
+import org.apache.felix.framework.util.ListenerHookInfoImpl;
+import org.apache.felix.framework.util.MapToDictionary;
+import org.apache.felix.framework.util.SecureAction;
+import org.apache.felix.framework.util.ShrinkableCollection;
+import org.apache.felix.framework.util.StringMap;
+import org.apache.felix.framework.util.ThreadGate;
+import org.apache.felix.framework.util.Util;
+import org.apache.felix.framework.util.manifestparser.R4LibraryClause;
+import org.apache.felix.framework.util.manifestparser.RequirementImpl;
+import org.osgi.framework.AdminPermission;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.BundleReference;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceException;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServicePermission;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.hooks.service.FindHook;
+import org.osgi.framework.hooks.service.ListenerHook;
 import org.osgi.service.packageadmin.ExportedPackage;
 import org.osgi.service.startlevel.StartLevel;
 
@@ -294,7 +333,7 @@
         // Create a resolver and its state.
         m_resolverState = new FelixResolverState(m_logger);
         m_felixResolver = new FelixResolver(
-            new Resolver(m_logger,
+            new ResolverImpl(m_logger,
                 (String) 
m_configMap.get(Constants.FRAMEWORK_EXECUTIONENVIRONMENT)),
             m_resolverState);
 
@@ -1579,7 +1618,7 @@
 
         // Record whether the bundle is using its declared activation policy.
         boolean wasDeferred = bundle.isDeclaredActivationPolicyUsed()
-            && (bundle.getCurrentModule().getDeclaredActivationPolicy() == 
IModule.LAZY_ACTIVATION);
+            && (bundle.getCurrentModule().getDeclaredActivationPolicy() == 
Module.LAZY_ACTIVATION);
         bundle.setDeclaredActivationPolicyUsed(
             (options & Bundle.START_ACTIVATION_POLICY) != 0);
 
@@ -1667,7 +1706,7 @@
             // If the bundle's activation policy is eager or activation has 
already
             // been triggered, then activate the bundle immediately.
             if (!bundle.isDeclaredActivationPolicyUsed()
-                || (bundle.getCurrentModule().getDeclaredActivationPolicy() != 
IModule.LAZY_ACTIVATION)
+                || (bundle.getCurrentModule().getDeclaredActivationPolicy() != 
Module.LAZY_ACTIVATION)
                 || ((ModuleImpl) 
bundle.getCurrentModule()).isActivationTriggered())
             {
                 // Record the event type for the final event and activate.
@@ -2090,7 +2129,7 @@
                     throw new IllegalStateException("Cannot stop an 
uninstalled bundle.");
                 case Bundle.STARTING:
                     if (bundle.isDeclaredActivationPolicyUsed()
-                        && 
bundle.getCurrentModule().getDeclaredActivationPolicy() != 
IModule.LAZY_ACTIVATION)
+                        && 
bundle.getCurrentModule().getDeclaredActivationPolicy() != 
Module.LAZY_ACTIVATION)
                     {
                         throw new BundleException(
                             "Stopping a starting or stopping bundle is 
currently not supported.");
@@ -2986,26 +3025,29 @@
     ExportedPackage[] getExportedPackages(String pkgName)
     {
         // First, get all exporters of the package.
-        List exports =
-            m_resolverState.getResolvedCandidates(
-                new Requirement(
-                    ICapability.PACKAGE_NAMESPACE,
-                    null,
-                    new R4Attribute[] { new 
R4Attribute(ICapability.PACKAGE_PROPERTY, pkgName, false) }), null);
+        List<Directive> dirs = new ArrayList<Directive>(0);
+        List<Attribute> attrs = new ArrayList<Attribute>(1);
+        attrs.add(new Attribute(Capability.PACKAGE_ATTR, pkgName, false));
+        Requirement req = new RequirementImpl(Capability.PACKAGE_NAMESPACE, 
dirs, attrs);
+        Set<Capability> exports = m_resolverState.getCandidates(null, req);
+
+        // We only want resolved capabilities.
+        for (Iterator<Capability> it = exports.iterator(); it.hasNext(); )
+        {
+            if (!it.next().getModule().isResolved())
+            {
+                it.remove();
+            }
+        }
 
         if (exports != null)
         {
             List pkgs = new ArrayList();
 
-            Requirement req = new Requirement(ICapability.PACKAGE_NAMESPACE,
-                null,
-                new R4Attribute[] { new 
R4Attribute(ICapability.PACKAGE_PROPERTY, pkgName, false) });
-
-            for (int pkgIdx = 0; pkgIdx < exports.size(); pkgIdx++)
+            for (Iterator<Capability> it = exports.iterator(); it.hasNext(); )
             {
                 // Get the bundle associated with the current exporting module.
-                BundleImpl bundle = (BundleImpl)
-                    ((ICapability) 
exports.get(pkgIdx)).getModule().getBundle();
+                BundleImpl bundle = (BundleImpl) 
it.next().getModule().getBundle();
 
                 // We need to find the version of the exported package, but 
this
                 // is tricky since there may be multiple versions of the 
package
@@ -3017,16 +3059,18 @@
                 // that the first module found to be exporting the package is 
the
                 // provider of the package, which makes sense since it must 
have
                 // been resolved first.
-                IModule[] modules = bundle.getModules();
-                for (int modIdx = 0; modIdx < modules.length; modIdx++)
+                List<Module> modules = bundle.getModules();
+                for (int modIdx = 0; modIdx < modules.size(); modIdx++)
                 {
-                    ICapability[] ec = modules[modIdx].getCapabilities();
-                    for (int i = 0; (ec != null) && (i < ec.length); i++)
+                    List<Capability> ec = 
modules.get(modIdx).getCapabilities();
+                    for (int i = 0; (ec != null) && (i < ec.size()); i++)
                     {
-                        if (ec[i].getNamespace().equals(req.getNamespace()) &&
-                            req.isSatisfied(ec[i]))
+                        if (ec.get(i).getNamespace().equals(req.getNamespace())
+                            && CapabilitySet.matches(ec.get(i), 
req.getFilter()))
                         {
-                            pkgs.add(new ExportedPackageImpl(this, bundle, 
modules[modIdx], (Capability) ec[i]));
+                            pkgs.add(
+                                new ExportedPackageImpl(
+                                    this, bundle, modules.get(modIdx), 
ec.get(i)));
                         }
                     }
                 }
@@ -3107,31 +3151,42 @@
         // Since a bundle may have many modules associated with it,
         // one for each revision in the cache, search each module
         // for each revision to get all exports.
-        IModule[] modules = bundle.getModules();
-        for (int modIdx = 0; modIdx < modules.length; modIdx++)
+        List<Module> modules = bundle.getModules();
+        for (int modIdx = 0; modIdx < modules.size(); modIdx++)
         {
-            ICapability[] caps = modules[modIdx].getCapabilities();
-            if ((caps != null) && (caps.length > 0))
+            List<Capability> caps = modules.get(modIdx).getCapabilities();
+            if ((caps != null) && (caps.size() > 0))
             {
-                for (int capIdx = 0; capIdx < caps.length; capIdx++)
+                for (int capIdx = 0; capIdx < caps.size(); capIdx++)
                 {
                     // See if the target bundle's module is one of the
                     // resolved exporters of the package.
-                    if 
(caps[capIdx].getNamespace().equals(ICapability.PACKAGE_NAMESPACE))
+                    if 
(caps.get(capIdx).getNamespace().equals(Capability.PACKAGE_NAMESPACE))
                     {
-                        List resolvedCaps = 
m_resolverState.getResolvedCandidates(
-                            new Requirement(
-                                ICapability.PACKAGE_NAMESPACE,
-                                null,
-                                new R4Attribute[] { new 
R4Attribute(ICapability.PACKAGE_PROPERTY, ((Capability) 
caps[capIdx]).getPackageName(), false) }), null);
+                        String pkgName = (String)
+                            
caps.get(capIdx).getAttribute(Capability.PACKAGE_ATTR).getValue();
+                        List<Directive> dirs = new ArrayList<Directive>(0);
+                        List<Attribute> attrs = new ArrayList<Attribute>(1);
+                        attrs.add(new Attribute(Capability.PACKAGE_ATTR, 
pkgName, false));
+                        Requirement req = new 
RequirementImpl(Capability.PACKAGE_NAMESPACE, dirs, attrs);
+                        Set<Capability> exports = 
m_resolverState.getCandidates(null, req);
+                        // We only want resolved capabilities.
+                        for (Iterator<Capability> it = exports.iterator(); 
it.hasNext(); )
+                        {
+                            if (!it.next().getModule().isResolved())
+                            {
+                                it.remove();
+                            }
+                        }
+
 
                         // Search through the current providers to find the 
target module.
-                        for (int i = 0; (resolvedCaps != null) && (i < 
resolvedCaps.size()); i++)
+                        for (Capability cap : exports)
                         {
-                            if ((ICapability) resolvedCaps.get(i) == 
caps[capIdx])
+                            if (cap == caps.get(capIdx))
                             {
                                 list.add(new ExportedPackageImpl(
-                                    this, bundle, modules[modIdx], 
(Capability) caps[capIdx]));
+                                    this, bundle, modules.get(modIdx), 
caps.get(capIdx)));
                             }
                         }
                     }
@@ -3140,70 +3195,64 @@
         }
     }
 
-    Bundle[] getDependentBundles(BundleImpl exporter)
+    List<Bundle> getDependentBundles(BundleImpl exporter)
     {
         // Create list for storing importing bundles.
-        List list = new ArrayList();
+        List<Bundle> list = new ArrayList();
 
         // Get all dependent modules from all exporter module revisions.
-        IModule[] modules = exporter.getModules();
-        for (int modIdx = 0; modIdx < modules.length; modIdx++)
+        List<Module> modules = exporter.getModules();
+        for (int modIdx = 0; modIdx < modules.size(); modIdx++)
         {
-            IModule[] dependents = ((ModuleImpl) 
modules[modIdx]).getDependents();
+            List<Module> dependents = ((ModuleImpl) 
modules.get(modIdx)).getDependents();
             for (int depIdx = 0;
-                (dependents != null) && (depIdx < dependents.length);
+                (dependents != null) && (depIdx < dependents.size());
                 depIdx++)
             {
-                list.add(dependents[depIdx].getBundle());
+                list.add(dependents.get(depIdx).getBundle());
             }
         }
 
-        // Return the results.
-        if (list.size() > 0)
-        {
-            return (Bundle[]) list.toArray(new Bundle[list.size()]);
-        }
-
-        return null;
+        return list;
     }
 
-    Bundle[] getImportingBundles(ExportedPackage ep)
+    List<Bundle> getImportingBundles(ExportedPackage ep)
     {
         // Create list for storing importing bundles.
-        List list = new ArrayList();
+        List<Bundle> list = new ArrayList();
 
         // Get exporting bundle information.
         BundleImpl exporter = (BundleImpl) ep.getExportingBundle();
 
         // Get all importers and requirers for all revisions of the bundle.
         // The spec says that require-bundle should be returned with importers.
-        IModule[] expModules = exporter.getModules();
-        for (int expIdx = 0; (expModules != null) && (expIdx < 
expModules.length); expIdx++)
+        List<Module> expModules = exporter.getModules();
+        for (int expIdx = 0; (expModules != null) && (expIdx < 
expModules.size()); expIdx++)
         {
             // Include any importers that have wires to the specific
             // exported package.
-            IModule[] dependents = ((ModuleImpl) 
expModules[expIdx]).getDependentImporters();
-            for (int depIdx = 0; (dependents != null) && (depIdx < 
dependents.length); depIdx++)
+            List<Module> dependents = ((ModuleImpl) 
expModules.get(expIdx)).getDependentImporters();
+            for (int depIdx = 0; (dependents != null) && (depIdx < 
dependents.size()); depIdx++)
             {
-                IWire[] wires = dependents[depIdx].getWires();
-                for (int wireIdx = 0; (wires != null) && (wireIdx < 
wires.length); wireIdx++)
+                List<Wire> wires = dependents.get(depIdx).getWires();
+                for (int wireIdx = 0; (wires != null) && (wireIdx < 
wires.size()); wireIdx++)
                 {
-                    if ((wires[wireIdx].getExporter() == expModules[expIdx])
-                        && (wires[wireIdx].hasPackage(ep.getName())))
+                    if ((wires.get(wireIdx).getExporter() == 
expModules.get(expIdx))
+                        && (wires.get(wireIdx).hasPackage(ep.getName())))
                     {
-                        list.add(dependents[depIdx].getBundle());
+                        list.add(dependents.get(depIdx).getBundle());
                     }
                 }
             }
-            dependents = ((ModuleImpl) 
expModules[expIdx]).getDependentRequirers();
-            for (int depIdx = 0; (dependents != null) && (depIdx < 
dependents.length); depIdx++)
+            dependents = ((ModuleImpl) 
expModules.get(expIdx)).getDependentRequirers();
+            for (int depIdx = 0; (dependents != null) && (depIdx < 
dependents.size()); depIdx++)
             {
-                list.add(dependents[depIdx].getBundle());
+                list.add(dependents.get(depIdx).getBundle());
             }
         }
 
         // Return the results.
-        return (Bundle[]) list.toArray(new Bundle[list.size()]);
+        return list;
     }
 
     boolean resolveBundles(Bundle[] targets)
@@ -3469,20 +3518,20 @@
     private void populateDependentGraph(BundleImpl exporter, Map map)
     {
         // Get all dependent bundles of this bundle.
-        Bundle[] dependents = getDependentBundles(exporter);
+        List<Bundle> dependents = getDependentBundles(exporter);
 
         for (int depIdx = 0;
-            (dependents != null) && (depIdx < dependents.length);
+            (dependents != null) && (depIdx < dependents.size());
             depIdx++)
         {
             // Avoid cycles if the bundle is already in map.
-            if (!map.containsKey(dependents[depIdx]))
+            if (!map.containsKey(dependents.get(depIdx)))
             {
                 // Add each importing bundle to map.
-                map.put(dependents[depIdx], dependents[depIdx]);
+                map.put(dependents.get(depIdx), dependents.get(depIdx));
                 // Now recurse into each bundle to get its importers.
                 populateDependentGraph(
-                    (BundleImpl) dependents[depIdx], map);
+                    (BundleImpl) dependents.get(depIdx), map);
             }
         }
     }
@@ -3807,7 +3856,7 @@
             m_resolverState = resolverState;
         }
 
-        public void resolve(IModule rootModule) throws ResolveException
+        public void resolve(Module rootModule) throws ResolveException
         {
             // Although there is a race condition to check the bundle state
             // then lock it, we do this because we don't want to acquire the
@@ -3838,14 +3887,15 @@
                     // must find a host to attach it to and resolve the host
                     // instead, since the underlying resolver doesn't know
                     // how to deal with fragments.
-                    IModule newRootModule = 
m_resolverState.findHost(rootModule);
+                    Module newRootModule = 
m_resolverState.findHost(rootModule);
                     if (!Util.isFragment(newRootModule))
                     {
                         // Resolve the module.
-                        Map resolvedModuleWireMap = 
m_resolver.resolve(m_resolverState, newRootModule);
+                        Map<Module, List<Wire>> wireMap =
+                            m_resolver.resolve(m_resolverState, newRootModule);
 
                         // Mark all modules as resolved.
-                        markResolvedModules(resolvedModuleWireMap);
+                        markResolvedModules(wireMap);
                     }
                 }
                 finally
@@ -3856,10 +3906,11 @@
             }
         }
 
-        public IWire resolveDynamicImport(IModule importer, String pkgName) 
throws ResolveException
+        public Wire resolveDynamicImport(Module importer, String pkgName) 
throws ResolveException
         {
-            IWire candidateWire = null;
-
+            Wire candidateWire = null;
+// TODO: FELIX3 - Fix dynamic imports!
+/*
             // We cannot dynamically import if the module is already resolved 
or
             // if it is not allowed, so check that first. Note: We check if the
             // dynamic import is allowed without holding any locks, but this is
@@ -3927,62 +3978,51 @@
                     releaseGlobalLock();
                 }
             }
-
+*/
             return candidateWire;
         }
 
-        public synchronized List getResolvedCandidates(IRequirement req, 
IModule reqModule)
+        public synchronized Set<Capability> getCandidates(Module reqModule, 
Requirement req)
         {
-            return m_resolverState.getResolvedCandidates(req, reqModule);
+            return m_resolverState.getCandidates(reqModule, req);
         }
 
-        public synchronized List getUnresolvedCandidates(IRequirement req, 
IModule reqModule)
+        private void markResolvedModules(Map<Module, List<Wire>> wireMap)
         {
-            return m_resolverState.getUnresolvedCandidates(req, reqModule);
-        }
-
-        private void markResolvedModules(Map resolvedModuleWireMap)
-        {
-            if (resolvedModuleWireMap != null)
+            if (wireMap != null)
             {
-                Iterator iter = resolvedModuleWireMap.entrySet().iterator();
+                Iterator<Entry<Module, List<Wire>>> iter = 
wireMap.entrySet().iterator();
                 // Iterate over the map to mark the modules as resolved and
                 // update our resolver data structures.
-                List wireList = new ArrayList();
                 while (iter.hasNext())
                 {
-                    wireList.clear();
-
-                    Map.Entry entry = (Map.Entry) iter.next();
-                    IModule module = (IModule) entry.getKey();
-                    IWire[] wires = (IWire[]) entry.getValue();
+                    Entry<Module, List<Wire>> entry = iter.next();
+                    Module module = entry.getKey();
+                    List<Wire> wires = entry.getValue();
 
                     // Only add wires attribute if some exist; export
                     // only modules may not have wires.
-// TODO: RESOLVER - Seems stupid that we package these up as wires to tear 
them apart.
-                    if (wires.length > 0)
+                    if (wires.size() > 0)
                     {
-                        for (int wireIdx = 0; wireIdx < wires.length; 
wireIdx++)
+                        for (int wireIdx = 0; wireIdx < wires.size(); 
wireIdx++)
                         {
-                            wireList.add(wires[wireIdx]);
                             m_logger.log(
                                 Logger.LOG_DEBUG,
-                                "WIRE: " + wires[wireIdx]);
+                                "WIRE: " + wires.get(wireIdx));
                         }
-                        wires = (IWire[]) wireList.toArray(new 
IWire[wireList.size()]);
                         ((ModuleImpl) module).setWires(wires);
                     }
 
                     // Resolve all attached fragments.
-                    IModule[] fragments = ((ModuleImpl) module).getFragments();
-                    for (int i = 0; (fragments != null) && (i < 
fragments.length); i++)
+                    List<Module> fragments = ((ModuleImpl) 
module).getFragments();
+                    for (int i = 0; (fragments != null) && (i < 
fragments.size()); i++)
                     {
-                        ((ModuleImpl) fragments[i]).setResolved();
+                        ((ModuleImpl) fragments.get(i)).setResolved();
                         // Update the state of the module's bundle to resolved 
as well.
-                        markBundleResolved(fragments[i]);
+                        markBundleResolved(fragments.get(i));
                         m_logger.log(
                             Logger.LOG_DEBUG,
-                            "FRAGMENT WIRE: " + fragments[i] + " -> hosted by 
-> " + module);
+                            "FRAGMENT WIRE: " + fragments.get(i) + " -> hosted 
by -> " + module);
                     }
                     // Update the resolver state to show the module as 
resolved.
                     ((ModuleImpl) module).setResolved();
@@ -3993,7 +4033,7 @@
             }
         }
 
-        private void markBundleResolved(IModule module)
+        private void markBundleResolved(Module module)
         {
             // Update the bundle's state to resolved when the
             // current module is resolved; just ignore resolve

Modified: 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/ModuleImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/ModuleImpl.java?rev=901759&r1=901758&r2=901759&view=diff
==============================================================================
--- 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/ModuleImpl.java
 (original)
+++ 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/ModuleImpl.java
 Thu Jan 21 16:18:15 2010
@@ -2115,11 +2115,8 @@
         pkgReq = new RequirementImpl(
             Capability.PACKAGE_NAMESPACE,
             new ArrayList<Directive>(0), attrs);
-        List<Capability> exports =
-            resolver.getResolvedCandidates(pkgReq, module);
-        exports = (exports.size() == 0)
-            ? resolver.getUnresolvedCandidates(pkgReq, module)
-            : exports;
+        Set<Capability> exports =
+            resolver.getCandidates(module, pkgReq);
         if (exports.size() > 0)
         {
             boolean classpath = false;
@@ -2137,7 +2134,7 @@
                 // Ignore
             }
 
-            String exporter = 
exports.get(0).getModule().getBundle().toString();
+            String exporter = 
exports.iterator().next().getModule().getBundle().toString();
 
             StringBuffer sb = new StringBuffer("*** Class '");
             sb.append(name);

Modified: 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/PackageAdminImpl.java?rev=901759&r1=901758&r2=901759&view=diff
==============================================================================
--- 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
 (original)
+++ 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
 Thu Jan 21 16:18:15 2010
@@ -219,7 +219,11 @@
     {
         if (getBundleType(bundle) == BUNDLE_TYPE_FRAGMENT)
         {
-            return m_felix.getDependentBundles((BundleImpl) bundle);
+            List<Bundle> hosts = m_felix.getDependentBundles((BundleImpl) 
bundle);
+            if (hosts != null)
+            {
+                return hosts.toArray(new Bundle[hosts.size()]);
+            }
         }
         return null;
     }

Modified: 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
URL: 
http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java?rev=901759&r1=901758&r2=901759&view=diff
==============================================================================
--- 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
 (original)
+++ 
felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
 Thu Jan 21 16:18:15 2010
@@ -26,7 +26,9 @@
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.StringTokenizer;
 import java.util.TreeSet;
+import org.apache.felix.framework.Logger;
 import org.apache.felix.framework.candidateset.Capability;
 import org.apache.felix.framework.candidateset.CapabilitySet;
 import org.apache.felix.framework.candidateset.Module;
@@ -38,15 +40,26 @@
 // 3. Uses constraints cannot conflict with other uses constraints, only with 
hard constraints.
 public class ResolverImpl implements Resolver
 {
+    private final Logger m_logger;
+
+    // Execution environment.
+    private final String m_fwkExecEnvStr;
+    private final Set m_fwkExecEnvSet;
+
     private static final Map<String, Long> m_invokeCounts = new 
HashMap<String, Long>();
     private static boolean m_isInvokeCount = false;
 
     // Reusable empty array.
     private static final List<Wire> m_emptyWires = new ArrayList<Wire>(0);
 
-    public ResolverImpl()
+    public ResolverImpl(Logger logger, String fwkExecEnvStr)
     {
 System.out.println("+++ PROTO3 RESOLVER");
+        m_logger = logger;
+// TODO: FELIX3 - Need to implement execution environment checking.
+        m_fwkExecEnvStr = (fwkExecEnvStr != null) ? fwkExecEnvStr.trim() : 
null;
+        m_fwkExecEnvSet = parseExecutionEnvironments(fwkExecEnvStr);
+
         String v = System.getProperty("invoke.count");
         m_isInvokeCount = (v == null) ? false : Boolean.valueOf(v);
     }
@@ -122,6 +135,7 @@
     private static void dumpCandidateMap(
         ResolverState state, Map<Requirement, Set<Capability>> candidateMap)
     {
+/*
         System.out.println("=== CANDIDATE MAP ===");
         for (Module module : ((ResolverStateImpl) state).getModules())
         {
@@ -138,6 +152,7 @@
                 }
             }
         }
+*/
     }
 
     private static void dumpModulePkgMap(Map<Module, Packages> modulePkgMap)
@@ -906,6 +921,26 @@
         return null;
     }
 
+    /**
+     * Updates the framework wide execution environment string and a cached 
Set of
+     * execution environment tokens from the comma delimited list specified by 
the
+     * system variable 'org.osgi.framework.executionenvironment'.
+     * @param frameworkEnvironment Comma delimited string of provided 
execution environments
+    **/
+    private static Set parseExecutionEnvironments(String fwkExecEnvStr)
+    {
+        Set newSet = new HashSet();
+        if (fwkExecEnvStr != null)
+        {
+            StringTokenizer tokens = new StringTokenizer(fwkExecEnvStr, ",");
+            while (tokens.hasMoreTokens())
+            {
+                newSet.add(tokens.nextToken().trim());
+            }
+        }
+        return newSet;
+    }
+
     private static class Packages
     {
         public final Map<String, Blame> m_exportedPkgs


Reply via email to