You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2017/12/04 07:25:21 UTC

[sling-org-apache-sling-testing-osgi-mock] branch master updated: SLING-7285 - Add support for Service Reference + Interface

This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git


The following commit(s) were added to refs/heads/master by this push:
     new 09cd449  SLING-7285 - Add support for Service Reference + Interface
09cd449 is described below

commit 09cd4494e5bc3c15529b2e5a18a72fb863038daa
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Mon Dec 4 08:25:06 2017 +0100

    SLING-7285 - Add support for Service Reference + Interface
---
 .../java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java b/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
index f95e72b..b3fd20c 100644
--- a/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
+++ b/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
@@ -458,7 +458,14 @@ final class OsgiServiceUtil {
                 invokeMethod(target, method, new Object[] { serviceInfo.getServiceInstance(), serviceInfo.getServiceConfig() });
                 return;
             }
-        
+
+            // 4. assignable from service reference plus interface
+            method = getMethodWithAssignableTypes(targetClass, methodName, new Class<?>[] {ServiceReference.class, interfaceType});
+            if (method != null) {
+                invokeMethod(target, method, new Object[] { serviceInfo.getServiceReference(), serviceInfo.getServiceInstance() });
+                return;
+            }
+
             throw new RuntimeException((bind ? "Bind" : "Unbind") + " method with name " + methodName + " not found "
                     + "for reference '" + reference.getName() + "' for class " +  targetClass.getName());
         }

-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].