felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1153630 - in /felix/trunk/framework/src/main/java/org/apache/felix/framework: ./ resolver/ util/ wiring/
Date Wed, 03 Aug 2011 19:52:41 GMT
Author: rickhall
Date: Wed Aug  3 19:52:39 2011
New Revision: 1153630

URL: http://svn.apache.org/viewvc?rev=1153630&view=rev
Log:
Removed impl-specific method for getting fragments and added a
utility method to get fragments using standard API, along with
other minor clean up. (FELIX-2950)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverWireImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/wiring/BundleWireImpl.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java?rev=1153630&r1=1153629&r2=1153630&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleImpl.java Wed Aug
 3 19:52:39 2011
@@ -509,9 +509,7 @@ class BundleImpl implements Bundle, Bund
         BundleWiring wiring = br.getWiring();
         if (wiring != null)
         {
-// TODO: OSGi R4.3 - Technically, I think we can get the fragments using standard
-//       R4.3 API once we get everything implemented.
-            List<BundleRevision> fragments = ((BundleWiringImpl) wiring).getFragments();
+            List<BundleRevision> fragments = Util.getFragments(wiring);
             if (fragments != null)
             {
                 result.addAll(fragments);

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java?rev=1153630&r1=1153629&r2=1153630&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
Wed Aug  3 19:52:39 2011
@@ -32,6 +32,7 @@ import java.util.Map;
 import org.apache.felix.framework.cache.Content;
 import org.apache.felix.framework.util.FelixConstants;
 import org.apache.felix.framework.util.SecureAction;
+import org.apache.felix.framework.util.Util;
 import org.apache.felix.framework.util.manifestparser.ManifestParser;
 import org.apache.felix.framework.util.manifestparser.R4Library;
 import org.osgi.framework.Bundle;
@@ -282,7 +283,7 @@ public class BundleRevisionImpl implemen
         {
             // If the wiring has fragments, then close the old content path,
             // since it'll need to be recalculated to include fragments.
-            if (wiring.getFragments() != null)
+            if (!Util.getFragments(wiring).isEmpty())
             {
                 for (int i = 0; (m_contentPath != null) && (i < m_contentPath.size());
i++)
                 {
@@ -359,7 +360,7 @@ public class BundleRevisionImpl implemen
         List<Content> fragmentContents = null;
         if (m_wiring != null)
         {
-            fragments = m_wiring.getFragments();
+            fragments = Util.getFragments(m_wiring);
             fragmentContents = m_wiring.getFragmentContents();
         }
         if (fragments != null)

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java?rev=1153630&r1=1153629&r2=1153630&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java Wed
Aug  3 19:52:39 2011
@@ -446,11 +446,6 @@ public class BundleWiringImpl implements
         return m_importedPkgs.get(pkgName);
     }
 
-    List<BundleRevision> getFragments()
-    {
-        return m_fragments;
-    }
-
     List<Content> getFragmentContents()
     {
         return m_fragmentContents;

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java?rev=1153630&r1=1153629&r2=1153630&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/EntryFilterEnumeration.java
Wed Aug  3 19:52:39 2011
@@ -22,6 +22,7 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.*;
 import org.apache.felix.framework.capabilityset.SimpleFilter;
+import org.apache.felix.framework.util.Util;
 import org.osgi.framework.wiring.BundleRevision;
 
 class EntryFilterEnumeration implements Enumeration
@@ -42,13 +43,10 @@ class EntryFilterEnumeration implements 
         String filePattern, boolean recurse, boolean isURLValues)
     {
         m_revision = revision;
-        if (includeFragments
-            && (m_revision.getWiring() != null)
-            && (((BundleWiringImpl) m_revision.getWiring()).getFragments() != null))
-        {
-            m_revisions = new ArrayList(
-                ((BundleWiringImpl) m_revision.getWiring()).getFragments().size() + 1);
-            m_revisions.addAll(((BundleWiringImpl) m_revision.getWiring()).getFragments());
+        List<BundleRevision> fragments = Util.getFragments(revision.getWiring());
+        if (includeFragments && !fragments.isEmpty())
+        {
+            m_revisions = fragments;
         }
         else
         {

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java?rev=1153630&r1=1153629&r2=1153630&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/PackageAdminImpl.java Wed
Aug  3 19:52:39 2011
@@ -19,6 +19,7 @@
 package org.apache.felix.framework;
 
 import java.util.*;
+import org.apache.felix.framework.util.Util;
 import org.apache.felix.framework.util.VersionRange;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
@@ -171,8 +172,8 @@ class PackageAdminImpl implements Packag
                 if (revision.getWiring() != null)
                 {
                     List<BundleRevision> fragments =
-                        ((BundleWiringImpl) revision.getWiring()).getFragments();
-                    for (int i = 0; (fragments != null) && (i < fragments.size());
i++)
+                        Util.getFragments(revision.getWiring());
+                    for (int i = 0; i < fragments.size(); i++)
                     {
                         Bundle b = fragments.get(i).getBundle();
                         if (b != null)

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java?rev=1153630&r1=1153629&r2=1153630&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java Wed
Aug  3 19:52:39 2011
@@ -394,7 +394,6 @@ class StatefulResolver
             try
             {
                 // Resolve the revision.
-// TODO: OSGi R4.3 - Shouldn't we still be passing in greedy attach fragments here?
                 wireMap = m_resolver.resolve(
                     m_resolverState, revisions, m_resolverState.getFragments());
             }
@@ -982,7 +981,8 @@ class StatefulResolver
     {
         if (wireMap != null)
         {
-            Iterator<Entry<BundleRevision, List<ResolverWire>>> iter =
wireMap.entrySet().iterator();
+            Iterator<Entry<BundleRevision, List<ResolverWire>>> iter =
+                wireMap.entrySet().iterator();
             // Iterate over the map to fire necessary RESOLVED events.
             while (iter.hasNext())
             {
@@ -991,10 +991,11 @@ class StatefulResolver
 
                 // Fire RESOLVED events for all fragments.
                 List<BundleRevision> fragments =
-                    ((BundleWiringImpl) revision.getWiring()).getFragments();
-                for (int i = 0; (fragments != null) && (i < fragments.size());
i++)
+                    Util.getFragments(revision.getWiring());
+                for (int i = 0; i < fragments.size(); i++)
                 {
-                    m_felix.fireBundleEvent(BundleEvent.RESOLVED, fragments.get(i).getBundle());
+                    m_felix.fireBundleEvent(
+                        BundleEvent.RESOLVED, fragments.get(i).getBundle());
                 }
                 m_felix.fireBundleEvent(BundleEvent.RESOLVED, revision.getBundle());
             }
@@ -1300,12 +1301,6 @@ class StatefulResolver
             {
                 // It we have a whitelist, then first filter out candidates
                 // from disallowed revisions.
-// TODO: OSGi R4.3 - It would be better if we could think of a way to do this
-//       filtering that was less costly. One possibility it to do the check in
-//       ResolverState.checkExecutionEnvironment(), since it will only need to
-//       be done once for any black listed revision. However, as we move toward
-//       OBR-like API, this is a non-standard call, so doing it here is the only
-//       standard way of achieving it.
                 if (m_whitelist != null)
                 {
                     for (Iterator<BundleCapability> it = result.iterator(); it.hasNext();
)
@@ -1376,8 +1371,6 @@ class StatefulResolver
         {
             // Next, try to resolve any native code, since the revision is
             // not resolvable if its native code cannot be loaded.
-// TODO: OSGi R4.3 - Is it sufficient to just check declared native libs here?
-//        List<R4Library> libs = ((BundleWiringImpl) revision.getWiring()).getNativeLibraries();
             List<R4Library> libs = ((BundleRevisionImpl) revision).getDeclaredNativeLibraries();
             if (libs != null)
             {

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java?rev=1153630&r1=1153629&r2=1153630&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java
Wed Aug  3 19:52:39 2011
@@ -1053,9 +1053,6 @@ class Candidates
                     System.out.println("    " + req + ": " + candidates);
                 }
             }
-// TODO: OSGi R4.3 - Need to check what getWiring().getRequirements() returns
-//       with respect to dynamic imports; is it the union of all declared
-//       dynamic imports from fragments and host?
             reqs = (br.getWiring() != null)
                 ? Util.getDynamicRequirements(br.getWiring().getRequirements(null))
                 : Util.getDynamicRequirements(br.getDeclaredRequirements(null));

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java?rev=1153630&r1=1153629&r2=1153630&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
Wed Aug  3 19:52:39 2011
@@ -41,7 +41,6 @@ import org.osgi.framework.wiring.BundleR
 import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.framework.wiring.BundleWire;
 
-// TODO: OSGi R4.3 - Make sure we have sufficient wrapping of caps/reqs.
 public class ResolverImpl implements Resolver
 {
     private final Logger m_logger;

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverWireImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverWireImpl.java?rev=1153630&r1=1153629&r2=1153630&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverWireImpl.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverWireImpl.java
Wed Aug  3 19:52:39 2011
@@ -63,7 +63,6 @@ class ResolverWireImpl implements Resolv
     {
         return m_req
             + " -> "
-            + "[" + m_cap.getRevision() + " VIA " + m_provider + "]";
-// TODO: OSGi R4.3 - Simplify this message once we know wiring works.
+            + "[" + m_provider + "]";
     }
 }
\ No newline at end of file

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java?rev=1153630&r1=1153629&r2=1153630&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/util/Util.java Wed Aug
 3 19:52:39 2011
@@ -22,6 +22,7 @@ import java.io.*;
 import java.net.URL;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -38,6 +39,7 @@ import org.osgi.framework.wiring.BundleC
 import org.osgi.framework.wiring.BundleRequirement;
 import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.framework.wiring.BundleWire;
+import org.osgi.framework.wiring.BundleWiring;
 
 public class Util
 {
@@ -618,4 +620,30 @@ public class Util
     {
         return ((revision.getTypes() & BundleRevision.TYPE_FRAGMENT) > 0);
     }
+
+    public static List<BundleRevision> getFragments(BundleWiring wiring)
+    {
+        List<BundleRevision> fragments = Collections.EMPTY_LIST;
+        if (wiring != null)
+        {
+            List<BundleWire> wires = wiring.getProvidedWires(null);
+            if (wires != null)
+            {
+                for (BundleWire w : wires)
+                {
+                    if (w.getCapability().getNamespace()
+                        .equals(BundleRevision.HOST_NAMESPACE))
+                    {
+                        // Create array list if needed.
+                        if (fragments.isEmpty())
+                        {
+                            fragments = new ArrayList<BundleRevision>();
+                        }
+                        fragments.add(w.getRequirerWiring().getRevision());
+                    }
+                }
+            }
+        }
+        return fragments;
+    }
 }
\ No newline at end of file

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/wiring/BundleWireImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/wiring/BundleWireImpl.java?rev=1153630&r1=1153629&r2=1153630&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/wiring/BundleWireImpl.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/wiring/BundleWireImpl.java
Wed Aug  3 19:52:39 2011
@@ -24,7 +24,6 @@ import org.osgi.framework.wiring.BundleR
 import org.osgi.framework.wiring.BundleWire;
 import org.osgi.framework.wiring.BundleWiring;
 
-// TODO: OSGi R4.3 - Should this be in framework package?
 public class BundleWireImpl implements BundleWire
 {
     private final BundleRevision m_requirer;
@@ -75,7 +74,6 @@ public class BundleWireImpl implements B
     {
         return m_req
             + " -> "
-            + "[" + m_cap.getRevision() + " VIA " + m_provider + "]";
-// TODO: OSGi R4.3 - Simplify this message once we know wiring works.
+            + "[" + m_provider + "]";
     }
 }
\ No newline at end of file



Mime
View raw message