FELIX-4787 : Update DS Implementation to R6

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1684339 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/bnd.bnd b/scr/bnd.bnd
index eda3b59..3795574 100644
--- a/scr/bnd.bnd
+++ b/scr/bnd.bnd
@@ -20,30 +20,23 @@
  org.osgi.util.promise;version=1.0
 
 Private-Package: org.apache.felix.scr.impl.*, \
- org.osgi.util.tracker;-split-package:=first, \
  org.apache.felix.utils.extender
 
-#  Configuration Admin is optional and dynamic, but allow eager wiring by importing it
-#  Metatype import is optional and dynamic, but allow eager wiring by importing it
+# Configuration Admin is optional and dynamic, but allow eager wiring by importing it
+# LogService is optional but if present the R4.0 version 1.3 is sufficient.
+# Metatype import is optional and dynamic, but allow eager wiring by importing it
+# PackageAdmin is used to find reference types if the component's bundle does not import it.
+#    R4.0 version 1.2 is sufficient.
 # optional import for Gogo annotations 
 # The Felix Shell support is optional 
-# Framework version 1.6 (from R4.3) is required
-# While the DS spec is based on R6 (because of prototype scope), this
-# implementation works on R4.3 as well; of course prototype scope is
-# not supported in that case.
-# LogService is optional but if present the R4.0 version 1.3 is sufficient.
-# PackageAdmin is used to find reference types if the component's bundle does not import it.
-# See BindMethod.getParameterClass(Class) for details. R4.0 version 1.2 is sufficient. 
 Import-Package: \
  org.osgi.service.cm;version="[1.2,2)";resolution:=optional, \
+ org.osgi.service.log;version="[1.3,2)";resolution:=optional, \
  org.osgi.service.metatype;version="[1.1,2)";resolution:=optional, \
+ org.osgi.service.packageadmin;version="[1.2,2)";resolution:=optional, \
+ org.osgi.util.function;version="[1.0,2)", \
  org.apache.felix.service.command;resolution:=optional, \
  org.apache.felix.shell;provide:=true;resolution:=optional, \
- org.osgi.framework;version="[1.6,2)", \
- org.osgi.service.log;version="[1.3,2)";resolution:=optional, \
- org.osgi.service.packageadmin;version="[1.2,2)";resolution:=optional, \
- org.osgi.framework.wiring;version="[1.0,2)", \
- org.osgi.util.function;version="[1.0,2)", \
  *
 
 DynamicImport-Package: \
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/helper/BindMethod.java b/scr/src/main/java/org/apache/felix/scr/impl/helper/BindMethod.java
index 147f095..b563283 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/helper/BindMethod.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/helper/BindMethod.java
@@ -89,7 +89,7 @@
     {
         /* 112.3.1 The method is searched for using the following priority
          1 - ServiceReference single parameter
-         2 - ServiceObjects single parameter (DS 1.3+ only)
+         2 - ComponentServiceObjects single parameter (DS 1.3+ only)
          3 - Service object single parameter
          4 - Service interface assignment compatible single parameter
          5 - two parameters, first the type of or assignment compatible with the service, the second Map (DS 1.1, 1.2 only)
@@ -128,7 +128,7 @@
         //case 2 ComponentServiceObjects parameter
         try
         {
-            method = getServiceObjectsMethod( targetClass, acceptPrivate, acceptPackage, logger );
+            method = getComponentObjectsMethod( targetClass, acceptPrivate, acceptPackage, logger );
             if ( method != null )
             {
                 if ( logger.isLogEnabled( LogService.LOG_DEBUG ) )
@@ -346,7 +346,7 @@
             { ClassUtils.SERVICE_REFERENCE_CLASS }, acceptPrivate, acceptPackage, logger );
     }
 
-    private Method getServiceObjectsMethod( final Class<?> targetClass, boolean acceptPrivate, boolean acceptPackage, SimpleLogger logger )
+    private Method getComponentObjectsMethod( final Class<?> targetClass, boolean acceptPrivate, boolean acceptPackage, SimpleLogger logger )
         throws SuitableMethodNotAccessibleException, InvocationTargetException
     {
         if ( m_referenceScope == ReferenceMetadata.ReferenceScope.prototype )
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/helper/ClassUtils.java b/scr/src/main/java/org/apache/felix/scr/impl/helper/ClassUtils.java
index 81f2c40..0f88c29 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/helper/ClassUtils.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/helper/ClassUtils.java
@@ -41,7 +41,7 @@
 
     public static final Class<?> SERVICE_REFERENCE_CLASS = ServiceReference.class;
 
-    public static final Class<?> COMPONENTS_SERVICE_OBJECTS_CLASS;
+    public static final Class<?> COMPONENTS_SERVICE_OBJECTS_CLASS = ComponentServiceObjects.class;
 
     public static final Class<?> MAP_CLASS = Map.class;
     public static final Class<?> MAP_ENTRY_CLASS = Map.Entry.class;
@@ -49,18 +49,6 @@
     public static final Class<?> COLLECTION_CLASS = Collection.class;
     public static final Class<?> LIST_CLASS = List.class;
 
-    static {
-        Class<?> serviceObjectsClass = null;
-        try {
-            serviceObjectsClass = ComponentServiceObjects.class;
-        }
-        catch (Throwable t)
-        {
-            //can't load class
-        }
-        COMPONENTS_SERVICE_OBJECTS_CLASS = serviceObjectsClass;
-    }
-
     /**
      * Returns the class object representing the class of the field reference
      * The class loader of the component class is used to load the service class.
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentContextImpl.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentContextImpl.java
index a9687de..fd40ea5 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentContextImpl.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentContextImpl.java
@@ -25,7 +25,6 @@
 
 import org.apache.felix.scr.component.ExtComponentContext;
 import org.apache.felix.scr.impl.BundleComponentActivator;
-import org.apache.felix.scr.impl.helper.ClassUtils;
 import org.apache.felix.scr.impl.helper.ComponentServiceObjectsHelper;
 import org.apache.felix.scr.impl.helper.ReadOnlyDictionary;
 import org.osgi.framework.Bundle;
@@ -55,7 +54,7 @@
 
     private final CountDownLatch accessibleLatch = new CountDownLatch(1);
 
-    private final Object serviceObjectsHelper;
+    private final ComponentServiceObjectsHelper serviceObjectsHelper;
 
     public ComponentContextImpl( SingleComponentManager<S> componentManager, Bundle usingBundle )
     {
@@ -66,22 +65,12 @@
         {
             edgeInfos[i] = new EdgeInfo();
         }
-        if ( ClassUtils.COMPONENTS_SERVICE_OBJECTS_CLASS != null )
-        {
-            this.serviceObjectsHelper = new ComponentServiceObjectsHelper(usingBundle.getBundleContext());
-        }
-        else
-        {
-            this.serviceObjectsHelper = null;
-        }
+        this.serviceObjectsHelper = new ComponentServiceObjectsHelper(usingBundle.getBundleContext());
     }
 
     public void cleanup()
     {
-        if ( this.serviceObjectsHelper != null )
-        {
-            ((ComponentServiceObjectsHelper)this.serviceObjectsHelper).cleanup();
-        }
+        this.serviceObjectsHelper.cleanup();
     }
 
     public Object getComponentServiceObjectsHelper()