You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pa...@apache.org on 2009/10/02 14:13:49 UTC

svn commit: r820985 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java

Author: pauls
Date: Fri Oct  2 12:13:48 2009
New Revision: 820985

URL: http://svn.apache.org/viewvc?rev=820985&view=rev
Log:
Fix an issue when the requester doesn't have a wire but the provider does and the service is a service factory. In that case, we should see whether the provider has access and if so whether the class is the same as of the requester. (FELIX-1600)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java?rev=820985&r1=820984&r2=820985&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java Fri Oct  2 12:13:48 2009
@@ -442,9 +442,10 @@
             // the exporting modules from the package wiring to determine if we
             // need to filter the service reference.
 
-            // Case 1: Always include service reference.
-            if (requesterWire == null)
+            // Case r=null && p = null
+            if ((requesterWire == null) && (providerWire == null))
             {
+                // if r has no access then true, otherwise service registration must have same class as r
                 try
                 {
                     Class requestClass = requesterModule.getClassByDelegation(className);
@@ -455,11 +456,43 @@
                     allow = true;
                 }
             }
-
-            // Case 2: Only include service reference if the provider and
-            // requester are using the same class.
-            else if (providerWire == null)
+            else if ((requesterWire == null) && (providerWire != null))
+            {
+                // r = null && p != null && p == r
+                if (providerWire.getExporter().equals(requesterModule))
+                {
+                    allow = true;
+                }
+                // otherwise (r = null && p != null && p != r)
+                else
+                {
+                    // if r has no access true or if r's class is same as provider wire's class true (otherwise still possibly check registration's class)
+                    try
+                    {
+                        Class requestClass = requesterModule.getClassByDelegation(className);
+                        try
+                        {
+                            allow = providerWire.getClass(className) == requestClass;
+                        }
+                        catch (Exception ex)
+                        {
+                            allow = false;
+                        }
+                        if (!allow)
+                        {
+                            allow = getRegistration().isClassAccessible(requestClass);
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        allow = true;
+                    }
+                }
+            }
+            else if ((requesterWire != null) && (providerWire == null))
             {
+                // Only include service reference if the provider and
+                // requester are using the same class.
                 // If the provider is the exporter of the requester's package, then check
                 // if the requester is wired to the latest version of the provider, if so
                 // then allow else don't (the provider has been updated but not refreshed).
@@ -488,10 +521,10 @@
                     }
                 }
             }
-            // Case 3: Include service reference if the wires have the
-            // same source module.
             else
             {
+                // Include service reference if the wires have the
+                // same source module.
                 allow = providerWire.getExporter().equals(requesterWire.getExporter());
             }