Moved a utility method from Felix to the Util class to avoid exposing it
as public API of the Felix class.


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@554743 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index e8c6cdb..4573d02 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -2683,7 +2683,7 @@
                 ServiceReference ref = (ServiceReference) refList.get(refIdx);
 
                 // Now check for castability.
-                if (!Felix.isServiceAssignable(bundle, ref))
+                if (!Util.isServiceAssignable(bundle, ref))
                 {
                     refList.remove(refIdx);
                     refIdx--;
@@ -2760,37 +2760,6 @@
 
     }
 
-    /**
-     * This method determines if the requesting bundle is able to cast
-     * the specified service reference based on class visibility rules
-     * of the underlying modules.
-     * @param requester The bundle requesting the service.
-     * @param ref The service in question.
-     * @return <tt>true</tt> if the requesting bundle is able to case
-     *         the service object to a known type.
-    **/
-    public static boolean isServiceAssignable(Bundle requester, ServiceReference ref)
-    {
-        // Boolean flag.
-        boolean allow = true;
-        // Get the service's objectClass property.
-        String[] objectClass = (String[]) ref.getProperty(FelixConstants.OBJECTCLASS);
-
-        // The the service reference is not assignable when the requesting
-        // bundle is wired to a different version of the service object.
-        // NOTE: We are pessimistic here, if any class in the service's
-        // objectClass is not usable by the requesting bundle, then we
-        // disallow the service reference.
-        for (int classIdx = 0; (allow) && (classIdx < objectClass.length); classIdx++)
-        {
-            if (!ref.isAssignableTo(requester, objectClass[classIdx]))
-            {
-                allow = false;
-            }
-        }
-        return allow;
-    }
-
     protected Object getService(Bundle bundle, ServiceReference ref)
     {
         // Check that the bundle has permission to get at least
diff --git a/framework/src/main/java/org/apache/felix/framework/util/EventDispatcher.java b/framework/src/main/java/org/apache/felix/framework/util/EventDispatcher.java
index b771df6..1f97d09 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/EventDispatcher.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/EventDispatcher.java
@@ -717,7 +717,7 @@
                 if ((filter == null) || filter.match(((ServiceEvent) event).getServiceReference()))
                 {
                     if ((l instanceof AllServiceListener) ||
-                        Felix.isServiceAssignable(bundle, ((ServiceEvent) event).getServiceReference()))
+                        Util.isServiceAssignable(bundle, ((ServiceEvent) event).getServiceReference()))
                     {
                         if (System.getSecurityManager() != null)
                         {
diff --git a/framework/src/main/java/org/apache/felix/framework/util/Util.java b/framework/src/main/java/org/apache/felix/framework/util/Util.java
index ea258fd..c5d57a9 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/Util.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/Util.java
@@ -22,6 +22,8 @@
 
 import org.apache.felix.framework.util.manifestparser.Capability;
 import org.apache.felix.moduleloader.*;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
 
 public class Util
 {
@@ -187,6 +189,37 @@
         return null;
     }
 
+    /**
+     * This method determines if the requesting bundle is able to cast
+     * the specified service reference based on class visibility rules
+     * of the underlying modules.
+     * @param requester The bundle requesting the service.
+     * @param ref The service in question.
+     * @return <tt>true</tt> if the requesting bundle is able to case
+     *         the service object to a known type.
+    **/
+    public static boolean isServiceAssignable(Bundle requester, ServiceReference ref)
+    {
+        // Boolean flag.
+        boolean allow = true;
+        // Get the service's objectClass property.
+        String[] objectClass = (String[]) ref.getProperty(FelixConstants.OBJECTCLASS);
+
+        // The the service reference is not assignable when the requesting
+        // bundle is wired to a different version of the service object.
+        // NOTE: We are pessimistic here, if any class in the service's
+        // objectClass is not usable by the requesting bundle, then we
+        // disallow the service reference.
+        for (int classIdx = 0; (allow) && (classIdx < objectClass.length); classIdx++)
+        {
+            if (!ref.isAssignableTo(requester, objectClass[classIdx]))
+            {
+                allow = false;
+            }
+        }
+        return allow;
+    }
+
     public static ICapability getSatisfyingCapability(IModule m, IRequirement req)
     {
         ICapability[] caps = m.getDefinition().getCapabilities();