felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1778137 [1/2] - in /felix/trunk/osgi-r7/scr: ./ src/main/java/org/apache/felix/scr/impl/ src/main/java/org/apache/felix/scr/impl/helper/ src/main/java/org/apache/felix/scr/impl/inject/ src/main/java/org/apache/felix/scr/impl/inject/field/ ...
Date Tue, 10 Jan 2017 14:59:45 GMT
Author: cziegeler
Date: Tue Jan 10 14:59:45 2017
New Revision: 1778137

URL: http://svn.apache.org/viewvc?rev=1778137&view=rev
Log:
FELIX-5354 : Implement Declarative Service Updates for R7 (RFC 222)

Added:
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ComponentMethods.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ComponentMethods.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ConstructorMethod.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ConstructorMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/InitReferenceMethod.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/InitReferenceMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/LifecycleMethod.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ComponentMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/MethodResult.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/MethodResult.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ReferenceMethod.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ReferenceMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ReferenceMethods.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ReferenceMethods.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ValueUtils.java   (with props)
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldHandler.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldHandler.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldMethods.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldMethods.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldUtils.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldUtils.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/methods/
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/methods/ActivateMethod.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ActivateMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/methods/BaseMethod.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/BaseMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/methods/BindMethod.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/BindMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/methods/BindMethods.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/BindMethods.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/methods/DeactivateMethod.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/DeactivateMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/methods/ModifiedMethod.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ModifiedMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/methods/UnbindMethod.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/UnbindMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/methods/UpdatedMethod.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/UpdatedMethod.java
    felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/impl/inject/methods/
    felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/impl/inject/methods/ActivateMethodTest.java
      - copied, changed from r1778136, felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/impl/inject/ActivateMethodTest.java
Removed:
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ComponentMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ComponentMethods.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ConstructorMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/InitReferenceMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/MethodResult.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ReferenceMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ReferenceMethods.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ActivateMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/BaseMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/BindMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/BindMethods.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/DeactivateMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldHandler.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldMethods.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldUtils.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ModifiedMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/UnbindMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/UpdatedMethod.java
    felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/impl/inject/ActivateMethodTest.java
Modified:
    felix/trunk/osgi-r7/scr/bnd.bnd
    felix/trunk/osgi-r7/scr/pom.xml
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistryKey.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/SimpleLogger.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/BindParameters.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ClassUtils.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ComponentMethodsImpl.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ConstructorMethodImpl.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/DuplexReferenceMethods.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/ConfigurableComponentHolder.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/PrototypeServiceFactoryComponentManager.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/ThreadDump.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
    felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/impl/PackageIsolationTest.java
    felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/impl/inject/BindMethodTest.java
    felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/impl/manager/ConfiguredComponentHolderTest.java
    felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/impl/manager/SingleComponentManagerTest.java

Modified: felix/trunk/osgi-r7/scr/bnd.bnd
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/bnd.bnd?rev=1778137&r1=1778136&r2=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/bnd.bnd (original)
+++ felix/trunk/osgi-r7/scr/bnd.bnd Tue Jan 10 14:59:45 2017
@@ -13,9 +13,9 @@ Provide-Capability: osgi.extender;\
 
 Export-Package: org.apache.felix.scr.component;version=1.1.0;provide:=true, \
  org.apache.felix.scr.info;version=1.0.0;provide:=true, \
- org.osgi.service.component;version=1.3;-split-package:=first;provide:=true, \
- org.osgi.service.component.runtime;version=1.3;provide:=true, \
- org.osgi.service.component.runtime.dto;version=1.3;provide:=true, \
+ org.osgi.service.component;version=1.4;provide:=true, \
+ org.osgi.service.component.runtime;version=1.4;provide:=true, \
+ org.osgi.service.component.runtime.dto;version=1.4;provide:=true, \
  org.osgi.util.function;version=1.0, \
  org.osgi.util.promise;version=1.0
 
@@ -30,7 +30,7 @@ Private-Package: org.apache.felix.scr.im
 # optional import for Gogo annotations 
 # The Felix Shell support is optional 
 Import-Package: \
- org.osgi.service.cm;version="[1.5,2)";resolution:=optional, \
+ org.osgi.service.cm;version="[1.6,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, \
@@ -40,7 +40,7 @@ Import-Package: \
  *
 
 DynamicImport-Package: \
- org.osgi.service.cm;version="[1.2,2)", \
+ org.osgi.service.cm;version="[1.6,2)", \
  org.osgi.service.metatype;version="[1.1,2)"
 
 Embed-Dependency: kxml2;inline=org/kxml2/io/KXmlParser.class|org/xmlpull/v1/XmlPull**

Modified: felix/trunk/osgi-r7/scr/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/pom.xml?rev=1778137&r1=1778136&r2=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/pom.xml (original)
+++ felix/trunk/osgi-r7/scr/pom.xml Tue Jan 10 14:59:45 2017
@@ -256,7 +256,7 @@
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
-                <version>2.5.3</version>
+                <version>3.2.0</version>
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
@@ -315,25 +315,6 @@
                     <excludePackageNames>*.impl</excludePackageNames>
                 </configuration>
             </plugin>
-<!-- Disable for now             
-             <plugin>
-                <groupId>org.apache.aries.versioning</groupId>
-                <artifactId>org.apache.aries.versioning.plugin</artifactId>
-                <version>0.1.0</version>
-                <executions>
-                    <execution>
-                        <id>default-verify</id>
-                        <phase>verify</phase>
-                        <goals>
-                            <goal>version-check</goal>
-                        </goals>
-                        <configuration>
-                            <oldArtifact>org.apache.felix:org.apache.felix.scr:1.6.2</oldArtifact>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
--->
         </plugins>
     </build>
 

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/Activator.java?rev=1778137&r1=1778136&r2=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/Activator.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/Activator.java Tue Jan 10 14:59:45 2017
@@ -523,7 +523,7 @@ public class Activator extends AbstractE
                 PrintStream out = ( level == LogService.LOG_ERROR )? System.err: System.out;
 
                 // level as a string
-                StringBuffer buf = new StringBuffer();
+                StringBuilder buf = new StringBuilder();
                 switch (level)
                 {
                     case ( LogService.LOG_DEBUG ):

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java?rev=1778137&r1=1778136&r2=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java Tue Jan 10 14:59:45 2017
@@ -29,8 +29,8 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
-import org.apache.felix.scr.impl.helper.ComponentMethods;
 import org.apache.felix.scr.impl.helper.SimpleLogger;
+import org.apache.felix.scr.impl.inject.ComponentMethods;
 import org.apache.felix.scr.impl.inject.ComponentMethodsImpl;
 import org.apache.felix.scr.impl.manager.AbstractComponentManager;
 import org.apache.felix.scr.impl.manager.ComponentActivator;
@@ -209,7 +209,7 @@ public class ComponentRegistry
                 Bundle cBundle = existingRegistration.getActivator().getBundleContext().getBundle();
                 ComponentMetadata cMeta = existingRegistration.getComponentMetadata();
 
-                StringBuffer buf = new StringBuffer( message );
+                StringBuilder buf = new StringBuilder( message );
                 buf.append( " by Bundle " ).append( cBundle.getBundleId() );
                 if ( cBundle.getSymbolicName() != null )
                 {
@@ -433,9 +433,9 @@ public class ComponentRegistry
         }
 
         @Override
-        protected ComponentMethods createComponentMethods()
+        protected ComponentMethods<S> createComponentMethods()
         {
-            return new ComponentMethodsImpl();
+            return new ComponentMethodsImpl<S>();
         }
     }
 
@@ -537,7 +537,7 @@ public class ComponentRegistry
         @Override
         public String toString()
         {
-            StringBuffer sb = new StringBuffer();
+        	StringBuilder sb = new StringBuilder();
             for (ServiceReference<?> sr: info)
             {
                 sb.append("ServiceReference: ").append(sr).append("\n");

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistryKey.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistryKey.java?rev=1778137&r1=1778136&r2=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistryKey.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistryKey.java Tue Jan 10 14:59:45 2017
@@ -23,8 +23,8 @@ import org.osgi.framework.Bundle;
 
 
 /**
- * The <code>ComponentRegistryKey</code> isused as the key in the
- * component register to register components by their names.
+ * The <code>ComponentRegistryKey</code> is used as the key in the
+ * component registry to register components by their names.
  * <p>
  * Two instances of this class are equal if they are the same or if there
  * component name and bundle ID is equal.
@@ -78,6 +78,4 @@ final class ComponentRegistryKey
     {
         return componentName;
     }
-    
-    
 }

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/SimpleLogger.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/SimpleLogger.java?rev=1778137&r1=1778136&r2=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/SimpleLogger.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/SimpleLogger.java Tue Jan 10 14:59:45 2017
@@ -16,12 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
-
 package org.apache.felix.scr.impl.helper;
 
 /**
- * @version $Rev:$ $Date:$
+ * @version $Rev$ $Date$
  */
 public interface SimpleLogger
 {

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/BindParameters.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/BindParameters.java?rev=1778137&r1=1778136&r2=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/BindParameters.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/BindParameters.java Tue Jan 10 14:59:45 2017
@@ -32,12 +32,12 @@ public class BindParameters
         this.refPair = refPair;
     }
     
-    public ComponentContextImpl<?> getComponentContext()
+    public ComponentContextImpl getComponentContext()
     {
         return componentContext;
     }
     
-    public RefPair<?, ?> getRefPair()
+    public RefPair getRefPair()
     {
         return refPair;
     }

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ClassUtils.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ClassUtils.java?rev=1778137&r1=1778136&r2=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ClassUtils.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ClassUtils.java Tue Jan 10 14:59:45 2017
@@ -18,7 +18,6 @@
  */
 package org.apache.felix.scr.impl.inject;
 
-
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;

Copied: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ComponentMethods.java (from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ComponentMethods.java)
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ComponentMethods.java?p2=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ComponentMethods.java&p1=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ComponentMethods.java&r1=1778136&r2=1778137&rev=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ComponentMethods.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ComponentMethods.java Tue Jan 10 14:59:45 2017
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr.impl.helper;
+package org.apache.felix.scr.impl.inject;
 
 import org.apache.felix.scr.impl.metadata.ComponentMetadata;
 
@@ -27,11 +27,11 @@ public interface ComponentMethods<T>
 {
     void initComponentMethods( ComponentMetadata componentMetadata, Class<T> implementationObjectClass );
 
-    ComponentMethod getActivateMethod();
+    LifecycleMethod getActivateMethod();
 
-    ComponentMethod getDeactivateMethod();
+    LifecycleMethod getDeactivateMethod();
 
-    ComponentMethod getModifiedMethod();
+    LifecycleMethod getModifiedMethod();
 
     ReferenceMethods getBindMethods(String refName );
 

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ComponentMethodsImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ComponentMethodsImpl.java?rev=1778137&r1=1778136&r2=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ComponentMethodsImpl.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ComponentMethodsImpl.java Tue Jan 10 14:59:45 2017
@@ -25,10 +25,11 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.felix.scr.impl.helper.ComponentMethod;
-import org.apache.felix.scr.impl.helper.ComponentMethods;
-import org.apache.felix.scr.impl.helper.ConstructorMethod;
-import org.apache.felix.scr.impl.helper.ReferenceMethods;
+import org.apache.felix.scr.impl.inject.field.FieldMethods;
+import org.apache.felix.scr.impl.inject.methods.ActivateMethod;
+import org.apache.felix.scr.impl.inject.methods.BindMethods;
+import org.apache.felix.scr.impl.inject.methods.DeactivateMethod;
+import org.apache.felix.scr.impl.inject.methods.ModifiedMethod;
 import org.apache.felix.scr.impl.metadata.ComponentMetadata;
 import org.apache.felix.scr.impl.metadata.DSVersion;
 import org.apache.felix.scr.impl.metadata.ReferenceMetadata;
@@ -39,9 +40,9 @@ import org.apache.felix.scr.impl.metadat
  */
 public class ComponentMethodsImpl<T> implements ComponentMethods<T>
 {
-    private ComponentMethod m_activateMethod;
-    private ComponentMethod m_modifiedMethod;
-    private ComponentMethod m_deactivateMethod;
+    private LifecycleMethod m_activateMethod;
+    private LifecycleMethod m_modifiedMethod;
+    private LifecycleMethod m_deactivateMethod;
     private ConstructorMethod<T> m_constructor;
 
     private final Map<String, ReferenceMethods> bindMethodMap = new HashMap<String, ReferenceMethods>();
@@ -58,7 +59,7 @@ public class ComponentMethodsImpl<T> imp
         boolean supportsInterfaces = componentMetadata.isConfigureWithInterfaces();
         
         m_activateMethod = new ActivateMethod( 
-        		ComponentMetadata.CONSTRUCTOR_MARKER.equals(componentMetadata.getActivate()) ? null : componentMetadata.getActivate(), 
+        		componentMetadata.isActivateConstructor() ? null : componentMetadata.getActivate(), 
         		componentMetadata.isActivateDeclared(), 
         		implementationObjectClass, 
         		dsVersion, 
@@ -73,7 +74,6 @@ public class ComponentMethodsImpl<T> imp
         {
             final String refName = referenceMetadata.getName();
             final List<ReferenceMethods> methods = new ArrayList<ReferenceMethods>();
-            // TODO add methods for constructor injection
             if ( referenceMetadata.getField() != null )
             {
                 methods.add(new FieldMethods( referenceMetadata, implementationObjectClass, dsVersion, configurableServiceProperties));
@@ -83,7 +83,11 @@ public class ComponentMethodsImpl<T> imp
             	methods.add(new BindMethods( referenceMetadata, implementationObjectClass, dsVersion, configurableServiceProperties));
             }
 
-            if ( methods.size() == 1 )
+            if ( methods.isEmpty() )
+            {
+            	bindMethodMap.put( refName, ReferenceMethods.NOPReferenceMethod );
+            }
+            else if ( methods.size() == 1 )
             {
             	bindMethodMap.put( refName, methods.get(0) );
             }
@@ -95,7 +99,7 @@ public class ComponentMethodsImpl<T> imp
         
         // special constructor handling with activation fields and/or constructor injection
         if ( componentMetadata.getActivationFields() != null 
-             || ComponentMetadata.CONSTRUCTOR_MARKER.equals(componentMetadata.getActivate()))
+             || componentMetadata.isActivateConstructor())
         {
         	m_constructor = new ConstructorMethodImpl();
         }
@@ -106,19 +110,19 @@ public class ComponentMethodsImpl<T> imp
     }
 
 	@Override
-    public ComponentMethod getActivateMethod()
+    public LifecycleMethod getActivateMethod()
     {
         return m_activateMethod;
     }
 
 	@Override
-    public ComponentMethod getDeactivateMethod()
+    public LifecycleMethod getDeactivateMethod()
     {
         return m_deactivateMethod;
     }
 
 	@Override
-    public ComponentMethod getModifiedMethod()
+    public LifecycleMethod getModifiedMethod()
     {
         return m_modifiedMethod;
     }

Copied: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ConstructorMethod.java (from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ConstructorMethod.java)
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ConstructorMethod.java?p2=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ConstructorMethod.java&p1=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ConstructorMethod.java&r1=1778136&r2=1778137&rev=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ConstructorMethod.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ConstructorMethod.java Tue Jan 10 14:59:45 2017
@@ -16,10 +16,11 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr.impl.helper;
+package org.apache.felix.scr.impl.inject;
 
-import java.util.TreeMap;
+import java.util.Map;
 
+import org.apache.felix.scr.impl.helper.SimpleLogger;
 import org.apache.felix.scr.impl.manager.ComponentContextImpl;
 import org.apache.felix.scr.impl.manager.DependencyManager;
 
@@ -30,6 +31,11 @@ import org.apache.felix.scr.impl.manager
  */
 public interface ConstructorMethod<T> {
 
+	public class ReferencePair<S> {
+		public DependencyManager<S, ?> dependencyManager;
+		public DependencyManager.OpenStatus<S, ?> openStatus;
+    }
+	
 	/**
 	 * Create a new instance
 	 * @param componentClass The implementation class of the component
@@ -39,7 +45,7 @@ public interface ConstructorMethod<T> {
 	 */
     <S> T newInstance(Class<T> componentClass,
     		           ComponentContextImpl<T> componentContext,
-    		           TreeMap<Integer, DependencyManager<S, ?>> parameterMap,
+    		           Map<Integer, ReferencePair<S>> parameterMap,
                        SimpleLogger logger )
     throws Exception;
     
@@ -48,7 +54,7 @@ public interface ConstructorMethod<T> {
 		@Override
 		public <S> Object newInstance(Class<Object> componentClass, 
 				ComponentContextImpl<Object> componentContext, 
-				TreeMap<Integer, DependencyManager<S, ?>> parameterMap,
+				Map<Integer, ReferencePair<S>> parameterMap,
 				SimpleLogger logger) 
 				throws Exception
 		{

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ConstructorMethodImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ConstructorMethodImpl.java?rev=1778137&r1=1778136&r2=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ConstructorMethodImpl.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ConstructorMethodImpl.java Tue Jan 10 14:59:45 2017
@@ -20,13 +20,12 @@ package org.apache.felix.scr.impl.inject
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
-import java.util.TreeMap;
+import java.util.Map;
 
-import org.apache.felix.scr.impl.helper.ConstructorMethod;
 import org.apache.felix.scr.impl.helper.SimpleLogger;
+import org.apache.felix.scr.impl.inject.ValueUtils.ValueType;
+import org.apache.felix.scr.impl.inject.field.FieldUtils;
 import org.apache.felix.scr.impl.manager.ComponentContextImpl;
-import org.apache.felix.scr.impl.manager.DependencyManager;
-import org.apache.felix.scr.impl.metadata.ComponentMetadata;
 import org.apache.felix.scr.impl.metadata.ReferenceMetadata;
 import org.osgi.service.log.LogService;
 
@@ -38,17 +37,17 @@ public class ConstructorMethodImpl<T> im
 {
     private volatile boolean m_initialized = false;
     
-    private volatile FieldUtils.ValueType[] m_paramTypes;
+    private volatile ValueType[] m_paramTypes;
     private volatile Field[] m_fields;
     
     private volatile Constructor<T> m_constructor;
-    private volatile FieldUtils.ValueType[] m_constructorArgTypes;
+    private volatile ValueType[] m_constructorArgTypes;
     
 	@SuppressWarnings("unchecked")
 	@Override
 	public <S> T newInstance(Class<T> componentClass, 
              			 ComponentContextImpl<T> componentContext, 
-                         TreeMap<Integer, DependencyManager<S, ?>> parameterMap,
+                         Map<Integer, ReferencePair<S>> parameterMap,
 			             SimpleLogger logger)
     throws Exception
 	{
@@ -56,7 +55,7 @@ public class ConstructorMethodImpl<T> im
 			// activation fields
 			if ( componentContext.getComponentMetadata().getActivationFields() != null )
 			{
-				m_paramTypes = new FieldUtils.ValueType[componentContext.getComponentMetadata().getActivationFields().size()];
+				m_paramTypes = new ValueType[componentContext.getComponentMetadata().getActivationFields().size()];
 				m_fields = new Field[m_paramTypes.length];
 			
 				int index = 0;
@@ -72,12 +71,12 @@ public class ConstructorMethodImpl<T> im
 					{
 						if ( result.usable )
 						{
-							m_paramTypes[index] = FieldUtils.getValueType(result.field.getType());
+							m_paramTypes[index] = ValueUtils.getValueType(result.field.getType());
 							m_fields[index] = result.field;
 						}
 						else
 						{
-							m_paramTypes[index] = FieldUtils.ValueType.ignore;
+							m_paramTypes[index] = ValueType.ignore;
 							m_fields[index] = null;
 						}
 					}
@@ -86,31 +85,31 @@ public class ConstructorMethodImpl<T> im
 			}
 			else
 			{
-				m_paramTypes = FieldUtils.EMPTY_TYPES;
+				m_paramTypes = ValueUtils.EMPTY_VALUE_TYPES;
 				m_fields = null;
 			}
 			// constructor injection
-			if ( ComponentMetadata.CONSTRUCTOR_MARKER.equals(componentContext.getComponentMetadata().getActivate() ) ) 
+			if ( componentContext.getComponentMetadata().isActivateConstructor() ) 
 			{
 				// TODO search constructor
 				m_constructor = null;
 				
 				boolean hasFailure = false;
 				final Class<?>[] argTypes = m_constructor.getParameterTypes();
-				m_constructorArgTypes = new FieldUtils.ValueType[argTypes.length];
+				m_constructorArgTypes = new ValueType[argTypes.length];
 				for(int i=0;i<m_constructorArgTypes.length;i++)
 				{
-					final DependencyManager<S, ?> dm = parameterMap.get(i);
-					ReferenceMetadata reference = dm == null ? null : dm.getReferenceMetadata();
+					final ReferencePair<S> pair = parameterMap.get(i);
+					ReferenceMetadata reference = pair == null ? null : pair.dependencyManager.getReferenceMetadata();
 					if ( reference == null )
 					{
-						m_constructorArgTypes[i] = FieldUtils.getValueType(argTypes[i]);
+						m_constructorArgTypes[i] = ValueUtils.getValueType(argTypes[i]);
 					}
 					else 
 					{
-						m_constructorArgTypes[i] = FieldUtils.getReferenceValueType(componentClass, reference, argTypes[i], null, logger);
+						m_constructorArgTypes[i] = ValueUtils.getReferenceValueType(componentClass, reference, argTypes[i], null, logger);
 					}
-					if ( m_constructorArgTypes[i] == FieldUtils.ValueType.ignore )
+					if ( m_constructorArgTypes[i] == ValueType.ignore )
 					{
 						hasFailure = true;
 						break;
@@ -127,7 +126,7 @@ public class ConstructorMethodImpl<T> im
 		}
 		
 		// if we have fields and one is in state failure (type == null) we can directly throw
-		for(final FieldUtils.ValueType t : m_paramTypes)
+		for(final ValueType t : m_paramTypes)
 		{
 			if ( t == null )
 			{
@@ -137,7 +136,7 @@ public class ConstructorMethodImpl<T> im
 
 		// constructor
 		final T component;
-		if ( ComponentMetadata.CONSTRUCTOR_MARKER.equals(componentContext.getComponentMetadata().getActivate() ) ) 
+		if ( componentContext.getComponentMetadata().isActivateConstructor() ) 
 		{
 			if ( m_constructor == null )
 			{
@@ -146,8 +145,9 @@ public class ConstructorMethodImpl<T> im
 			final Object[] args = new Object[m_constructorArgTypes.length];
 			for(int i=0; i<args.length; i++) 
 			{
-				final DependencyManager<S, ?> dm = parameterMap.get(i);
-				args[i] = FieldUtils.getValue(m_constructorArgTypes[i], 
+				// TODO - get ref pair
+				final ReferencePair<S> pair = parameterMap.get(i);
+				args[i] = ValueUtils.getValue(m_constructorArgTypes[i], 
 						m_constructor.getParameterTypes()[i], 
 						componentContext, 
 						null);
@@ -163,9 +163,9 @@ public class ConstructorMethodImpl<T> im
 		// activation fields
 		for(int i = 0; i<m_paramTypes.length; i++)
 		{
-	    	if ( m_paramTypes[i] != FieldUtils.ValueType.ignore )
+	    	if ( m_paramTypes[i] != ValueType.ignore )
 	    	{
-		        final Object value = FieldUtils.getValue(m_paramTypes[i], 
+		        final Object value = ValueUtils.getValue(m_paramTypes[i], 
 		        		m_fields[i].getType(), 
 		        		(ComponentContextImpl<T>) componentContext, 
 		        		null);

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/DuplexReferenceMethods.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/DuplexReferenceMethods.java?rev=1778137&r1=1778136&r2=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/DuplexReferenceMethods.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/DuplexReferenceMethods.java Tue Jan 10 14:59:45 2017
@@ -20,67 +20,35 @@ package org.apache.felix.scr.impl.inject
 
 import java.util.List;
 
-import org.apache.felix.scr.impl.helper.InitReferenceMethod;
-import org.apache.felix.scr.impl.helper.MethodResult;
-import org.apache.felix.scr.impl.helper.ReferenceMethod;
-import org.apache.felix.scr.impl.helper.ReferenceMethods;
 import org.apache.felix.scr.impl.helper.SimpleLogger;
-import org.apache.felix.scr.impl.manager.ComponentContextImpl;
-import org.apache.felix.scr.impl.manager.RefPair;
 import org.osgi.framework.BundleContext;
 
 public class DuplexReferenceMethods implements ReferenceMethods
 {
-    /** The methods in the order they need to be called. */
-    private final List<ReferenceMethods> methods;
+    private final ReferenceMethod bind;
+    private final ReferenceMethod updated;
+    private final ReferenceMethod unbind;
+    private final InitReferenceMethod init;
 
     public DuplexReferenceMethods(final List<ReferenceMethods> methods)
     {
-        this.methods = methods;
-    }
-
-    public ReferenceMethod getBind()
-    {
-    	final ReferenceMethod[] list = new ReferenceMethod[methods.size()];
-    	int index = 0;
-    	for(final ReferenceMethods m : methods)
-    	{
-    		list[index] = m.getBind();
-    		index++;
-    	}
-        return new DuplexReferenceMethod(list);
-    }
-
-    public ReferenceMethod getUnbind()
-    {
-    	final ReferenceMethod[] list = new ReferenceMethod[methods.size()];
-    	int index = 0;
-    	for(final ReferenceMethods m : methods)
-    	{
-    		list[index] = m.getUnbind();
-    		index++;
-    	}
-        return new DuplexReferenceMethod(list);
-    }
-
-    public ReferenceMethod getUpdated()
-    {
-    	final ReferenceMethod[] list = new ReferenceMethod[methods.size()];
+    	final ReferenceMethod[] bindList = new ReferenceMethod[methods.size()];
+    	final ReferenceMethod[] updatedList = new ReferenceMethod[methods.size()];
+    	final ReferenceMethod[] unbindList = new ReferenceMethod[methods.size()];
     	int index = 0;
     	for(final ReferenceMethods m : methods)
     	{
-    		list[index] = m.getUpdated();
+    		bindList[index] = m.getBind();
+    		updatedList[index] = m.getUpdated();
+    		unbindList[index] = m.getUnbind();
     		index++;
     	}
-        return new DuplexReferenceMethod(list);
-    }
-
-    public InitReferenceMethod getInit()
-    {
-        return new InitReferenceMethod()
+        this.bind = new DuplexReferenceMethod(bindList);
+        this.updated = new DuplexReferenceMethod(updatedList);
+        this.unbind = new DuplexReferenceMethod(unbindList);
+        this.init = new InitReferenceMethod()
         {
-
-            public boolean init(Object componentInstance, SimpleLogger logger)
+            public boolean init(final Object componentInstance, final SimpleLogger logger)
             {
             	boolean result = true;
             	for(final ReferenceMethods m : methods)
@@ -100,6 +68,26 @@ public class DuplexReferenceMethods impl
         };
     }
 
+    public ReferenceMethod getBind()
+    {
+    	return this.bind;
+    }
+
+    public ReferenceMethod getUnbind()
+    {
+    	return this.unbind;
+    }
+
+    public ReferenceMethod getUpdated()
+    {
+    	return this.updated;
+    }
+
+    public InitReferenceMethod getInit()
+    {
+    	return this.init;
+    }
+
     private static final class DuplexReferenceMethod implements ReferenceMethod
     {
 
@@ -110,15 +98,14 @@ public class DuplexReferenceMethods impl
             this.methods = methods;
         }
 
-        public MethodResult invoke(Object componentInstance,
-                                   ComponentContextImpl<?> componentContext,
-                                   RefPair<?, ?> refPair,
-                                   MethodResult methodCallFailureResult,
-                                   SimpleLogger logger) {
+        public MethodResult invoke(final Object componentInstance,
+        		final BindParameters parameters,
+        		final MethodResult methodCallFailureResult,
+        		final SimpleLogger logger) {
         	MethodResult result = null;
         	for(final ReferenceMethod m : methods) 
         	{
-        		result = m.invoke(componentInstance, componentContext, refPair, methodCallFailureResult, logger);
+        		result = m.invoke(componentInstance, parameters, methodCallFailureResult, logger);
         		if ( result == null )        			
         		{
         			break;
@@ -127,15 +114,16 @@ public class DuplexReferenceMethods impl
             return result;
         }
 
-        public <S, T> boolean getServiceObject(ComponentContextImpl<S> key,
-                RefPair<S, T> refPair, BundleContext context,
-                SimpleLogger logger)
+        public <S, T> boolean getServiceObject(
+        		final BindParameters parameters,
+        		final BundleContext context,
+        		final SimpleLogger logger)
         {
             // only if all return true, we return true
         	boolean result = false;
         	for(final ReferenceMethod m : methods) 
         	{
-        		result = m.getServiceObject(key, refPair, context, logger);
+        		result = m.getServiceObject(parameters, context, logger);
         		if (!result )        			
         		{
         			break;

Copied: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/InitReferenceMethod.java (from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/InitReferenceMethod.java)
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/InitReferenceMethod.java?p2=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/InitReferenceMethod.java&p1=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/InitReferenceMethod.java&r1=1778136&r2=1778137&rev=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/InitReferenceMethod.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/InitReferenceMethod.java Tue Jan 10 14:59:45 2017
@@ -16,7 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr.impl.helper;
+package org.apache.felix.scr.impl.inject;
+
+import org.apache.felix.scr.impl.helper.SimpleLogger;
 
 /**
  * Callback for initializing the reference (field references)

Copied: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/LifecycleMethod.java (from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ComponentMethod.java)
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/LifecycleMethod.java?p2=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/LifecycleMethod.java&p1=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ComponentMethod.java&r1=1778136&r2=1778137&rev=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ComponentMethod.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/LifecycleMethod.java Tue Jan 10 14:59:45 2017
@@ -16,11 +16,20 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr.impl.helper;
+package org.apache.felix.scr.impl.inject;
 
+import org.apache.felix.scr.impl.helper.SimpleLogger;
 import org.osgi.service.component.ComponentContext;
 
-public interface ComponentMethod {
+/**
+ * Interface for invocation one of the lifecycle methods:
+ * <ul>
+ *   <li>activate</li>
+ *   <li>modified</li>
+ *   <li>deactivate</li>
+ * </ul>
+ */
+public interface LifecycleMethod {
 
     MethodResult invoke(Object componentInstance,
                         ComponentContext componentContext,

Copied: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/MethodResult.java (from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/MethodResult.java)
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/MethodResult.java?p2=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/MethodResult.java&p1=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/MethodResult.java&r1=1778136&r2=1778137&rev=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/MethodResult.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/MethodResult.java Tue Jan 10 14:59:45 2017
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr.impl.helper;
+package org.apache.felix.scr.impl.inject;
 
 import java.util.Map;
 

Copied: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ReferenceMethod.java (from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ReferenceMethod.java)
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ReferenceMethod.java?p2=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ReferenceMethod.java&p1=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ReferenceMethod.java&r1=1778136&r2=1778137&rev=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ReferenceMethod.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ReferenceMethod.java Tue Jan 10 14:59:45 2017
@@ -16,10 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr.impl.helper;
+package org.apache.felix.scr.impl.inject;
 
-import org.apache.felix.scr.impl.manager.ComponentContextImpl;
-import org.apache.felix.scr.impl.manager.RefPair;
+import org.apache.felix.scr.impl.helper.SimpleLogger;
 import org.osgi.framework.BundleContext;
 
 /**
@@ -27,14 +26,43 @@ import org.osgi.framework.BundleContext;
  */
 public interface ReferenceMethod
 {
-    MethodResult invoke( Object componentInstance,
-                         ComponentContextImpl<?> componentContext,
-                         RefPair<?, ?> refPair,
+    /**
+     * Invoke the reference method and bind/unbind/update the reference.
+     *
+     * @param componentInstance The component instance
+     * @param parameters The parameters for the reference.
+     * @param methodCallFailureResult Return result for failure
+     * @param logger Logger
+     * @return The method result
+     */
+	
+	<S, T> MethodResult invoke( Object componentInstance,
+                         BindParameters parameters,
                          MethodResult methodCallFailureResult,
                          SimpleLogger logger );
 
-    <S, T> boolean getServiceObject( ComponentContextImpl<S> key,
-            RefPair<S, T> refPair,
+    <S, T> boolean getServiceObject( BindParameters parameters,
             BundleContext context,
             SimpleLogger logger );
+
+    /**
+     * A NOP implementation.
+     */
+    ReferenceMethod NOPReferenceMethod = new ReferenceMethod() {
+
+		@Override
+		public <S, T> MethodResult invoke(final Object componentInstance, 
+				final BindParameters parameters,
+				final MethodResult methodCallFailureResult, 
+				final SimpleLogger logger) {
+			return MethodResult.VOID;
+		}
+
+		@Override
+		public <S, T> boolean getServiceObject(final BindParameters parameters,
+				final BundleContext context, 
+				final SimpleLogger logger) {
+			return true;
+		}
+    };
 }

Copied: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ReferenceMethods.java (from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ReferenceMethods.java)
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ReferenceMethods.java?p2=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ReferenceMethods.java&p1=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ReferenceMethods.java&r1=1778136&r2=1778137&rev=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/helper/ReferenceMethods.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ReferenceMethods.java Tue Jan 10 14:59:45 2017
@@ -16,10 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr.impl.helper;
+package org.apache.felix.scr.impl.inject;
 
 /**
  * {@code ReferenceMethods} holds pointers to methods for a single reference.
+ * The methods are used for event (method) injection and field injection.
+ *
  * <ul>
  *   <li>The bind method
  *   <li>The unbind method
@@ -29,15 +31,53 @@ package org.apache.felix.scr.impl.helper
  */
 public interface ReferenceMethods
 {
-    /** Never returns {@code null}. */
+    /** 
+     * Get the method to bind a service. 
+     * Never returns {@code null}. 
+     */
     ReferenceMethod getBind();
 
-    /** Never returns {@code null}. */
+    /** 
+     * Get the method to unbind a service. 
+     * Never returns {@code null}. 
+     */
     ReferenceMethod getUnbind();
 
-    /** Never returns {@code null}. */
+    /** 
+     * Get the method to update a service. 
+     * Never returns {@code null}. 
+     */
     ReferenceMethod getUpdated();
 
-    /** This is optional and might return {@code null} */
+    /** 
+     * Get an optional method to initialize the component reference handling.
+     * This is optional and might return {@code null} 
+     */
     InitReferenceMethod getInit();
+
+    /**
+     * This is a NOP implementation.
+     */
+    ReferenceMethods NOPReferenceMethod = new ReferenceMethods() {
+
+		@Override
+		public ReferenceMethod getBind() {
+			return ReferenceMethod.NOPReferenceMethod;
+		}
+
+		@Override
+		public ReferenceMethod getUnbind() {
+			return ReferenceMethod.NOPReferenceMethod;
+		}
+
+		@Override
+		public ReferenceMethod getUpdated() {
+			return ReferenceMethod.NOPReferenceMethod;
+		}
+
+		@Override
+		public InitReferenceMethod getInit() {
+			return null;
+		}    	
+    };
 }

Added: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ValueUtils.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ValueUtils.java?rev=1778137&view=auto
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ValueUtils.java (added)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ValueUtils.java Tue Jan 10 14:59:45 2017
@@ -0,0 +1,320 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scr.impl.inject;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.Map;
+
+import org.apache.felix.scr.impl.helper.ReadOnlyDictionary;
+import org.apache.felix.scr.impl.helper.SimpleLogger;
+import org.apache.felix.scr.impl.manager.ComponentContextImpl;
+import org.apache.felix.scr.impl.manager.RefPair;
+import org.apache.felix.scr.impl.metadata.ReferenceMetadata;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+
+/**
+ * Utility methods for handling references and activation
+ */
+public class ValueUtils {
+
+	/**
+	 * The value type of the field, activation field or constructor parameter
+	 */
+	public enum ValueType
+    {
+        ignore,
+        componentContext,
+        bundleContext,
+        config_map,
+        config_annotation,
+        ref_serviceReference,
+        ref_serviceObjects,
+        ref_serviceType,
+        ref_map,
+        ref_tuple
+    }
+    
+    /** Empty array. */
+	public static final ValueType[] EMPTY_VALUE_TYPES = new ValueType[0];
+
+    /**
+     * Get the value type for the parameter class.
+     * @param typeClass The class of the parameter
+     * @return The value type
+     */
+    public static ValueType getValueType( final Class<?> typeClass )
+    {
+        if ( typeClass == ClassUtils.COMPONENT_CONTEXT_CLASS )
+        {
+        	return ValueType.componentContext;
+        }
+        else if ( typeClass == ClassUtils.BUNDLE_CONTEXT_CLASS )
+        {
+        	return ValueType.bundleContext;
+        }
+        else if ( typeClass == ClassUtils.MAP_CLASS )
+        {
+        	return ValueType.config_map;
+        }
+        else
+        {
+        	return ValueType.config_annotation;
+        }
+    }
+
+    /**
+     * Get the value type of the reference
+     * @param componentClass The component class declaring the reference
+     * @param metadata The reference metadata
+     * @param typeClass The type of the field/parameter
+     * @param f The optional field. If null, this is a constructor reference
+     * @param logger The logger
+     * @return The value type for the field. If invalid, {@code ValueType#ignore}
+     */
+    public static ValueType getReferenceValueType( 
+    		final Class<?> componentClass,
+    		final ReferenceMetadata metadata,
+    		final Class<?> typeClass, 
+    		final Field field,
+    		final SimpleLogger logger )
+    {
+        final Class<?> referenceType = ClassUtils.getClassFromComponentClassLoader(
+                componentClass, metadata.getInterface(), logger);
+
+        ValueType valueType = ValueType.ignore;
+        
+        // unary reference
+        if ( !metadata.isMultiple() )
+        {
+            if ( typeClass.isAssignableFrom(referenceType) )
+            {
+                valueType = ValueType.ref_serviceType;
+            }
+            else if ( typeClass == ClassUtils.SERVICE_REFERENCE_CLASS )
+            {
+                valueType = ValueType.ref_serviceReference;
+            }
+            else if ( typeClass == ClassUtils.COMPONENTS_SERVICE_OBJECTS_CLASS )
+            {
+                valueType = ValueType.ref_serviceObjects;
+            }
+            else if ( typeClass == ClassUtils.MAP_CLASS )
+            {
+                valueType = ValueType.ref_map;
+            }
+            else if ( typeClass == ClassUtils.MAP_ENTRY_CLASS )
+            {
+                valueType = ValueType.ref_tuple;
+            }
+            else
+            {
+            	if ( field != null )
+            	{
+	                logger.log( LogService.LOG_ERROR, "Field {0} in component {1} has unsupported type {2}", new Object[]
+	                        {metadata.getField(), componentClass, typeClass.getName()}, null );
+            	}
+            	else
+            	{
+	                logger.log( LogService.LOG_ERROR, "Constructor argument {0} in component {1} has unsupported type {2}", new Object[]
+	                        {metadata.getParameterIndex(), componentClass, typeClass.getName()}, null );            		
+            	}
+                valueType = ValueType.ignore;
+            }
+
+            // if the field is dynamic, it has to be volatile (field is ignored, case logged) (112.3.8.1)
+            if ( field != null && !metadata.isStatic() && !Modifier.isVolatile(field.getModifiers()) ) {
+                logger.log( LogService.LOG_ERROR, "Field {0} in component {1} must be declared volatile to handle a dynamic reference", new Object[]
+                        {metadata.getField(), componentClass}, null );
+                valueType = ValueType.ignore;
+            }
+
+            // the field must not be final (field is ignored, case logged) (112.3.8.1)
+            if ( field != null && Modifier.isFinal(field.getModifiers()) )
+            {
+                logger.log( LogService.LOG_ERROR, "Field {0} in component {1} must not be declared as final", new Object[]
+                        {metadata.getField(), componentClass}, null );
+                valueType = ValueType.ignore;
+            }
+        }
+        else
+        {
+            if ( ReferenceMetadata.FIELD_VALUE_TYPE_SERVICE.equals(metadata.getFieldCollectionType()) )
+            {
+                valueType = ValueType.ref_serviceType;
+            }
+            else if ( ReferenceMetadata.FIELD_VALUE_TYPE_REFERENCE.equals(metadata.getFieldCollectionType()) )
+            {
+                valueType = ValueType.ref_serviceReference;
+            }
+            else if ( ReferenceMetadata.FIELD_VALUE_TYPE_SERVICEOBJECTS.equals(metadata.getFieldCollectionType()) )
+            {
+                valueType = ValueType.ref_serviceObjects;
+            }
+            else if ( ReferenceMetadata.FIELD_VALUE_TYPE_PROPERTIES.equals(metadata.getFieldCollectionType()) )
+            {
+                valueType = ValueType.ref_map;
+            }
+            else if ( ReferenceMetadata.FIELD_VALUE_TYPE_TUPLE.equals(metadata.getFieldCollectionType()) )
+            {
+                valueType = ValueType.ref_tuple;
+            }
+
+            // multiple cardinality, field type must be collection or subtype
+            if ( !ClassUtils.COLLECTION_CLASS.isAssignableFrom(typeClass) )
+            {
+            	if ( field != null )
+            	{
+	                logger.log( LogService.LOG_ERROR, "Field {0} in component {1} has unsupported type {2}", new Object[]
+	                        {metadata.getField(), componentClass, typeClass.getName()}, null );
+            	}
+            	else
+            	{
+                    logger.log( LogService.LOG_ERROR, "Constructor argument {0} in component {1} has unsupported type {2}", new Object[]
+                            {metadata.getParameterIndex(), componentClass, typeClass.getName()}, null );            		
+            	}
+                valueType = ValueType.ignore;
+            }
+
+            // additional checks for replace strategy:
+            if ( metadata.isReplace() && field != null )
+            {
+                // if the field is dynamic wit has to be volatile (field is ignored, case logged) (112.3.8.1)
+                if ( !metadata.isStatic() && !Modifier.isVolatile(field.getModifiers()) )
+                {
+                    logger.log( LogService.LOG_ERROR, "Field {0} in component {1} must be declared volatile to handle a dynamic reference", new Object[]
+                            {metadata.getField(), componentClass}, null );
+                    valueType = ValueType.ignore;
+                }
+
+                // replace strategy: field must not be final (field is ignored, case logged) (112.3.8.1)
+                //                   only collection and list allowed
+                if ( typeClass != ClassUtils.LIST_CLASS && typeClass != ClassUtils.COLLECTION_CLASS )
+                {
+                    logger.log( LogService.LOG_ERROR, "Field {0} in component {1} has unsupported type {2}."+
+                        " It must be one of java.util.Collection or java.util.List.",
+                        new Object[] {metadata.getField(), componentClass, typeClass.getName()}, null );
+                    valueType = ValueType.ignore;
+
+                }
+                if ( Modifier.isFinal(field.getModifiers()) )
+                {
+                    logger.log( LogService.LOG_ERROR, "Field {0} in component {1} must not be declared as final", new Object[]
+                            {metadata.getField(), componentClass}, null );
+                    valueType = ValueType.ignore;
+                }
+            }
+        }
+        // static references only allowed for replace strategy
+        if ( metadata.isStatic() && !metadata.isReplace() )
+        {
+            logger.log( LogService.LOG_ERROR, "Update strategy for field {0} in component {1} only allowed for non static field references.", new Object[]
+                    {metadata.getField(), componentClass}, null );
+            valueType = ValueType.ignore;
+        }
+        return valueType;
+    }
+
+    /**
+     * Get the value for the parameter type
+     * @param type The parameter type
+     * @param componentContext The component context
+     */
+    @SuppressWarnings("unchecked")
+	public static Object getValue( final ValueType type,
+			final Class<?> targetType,
+    		@SuppressWarnings("rawtypes") final ComponentContextImpl componentContext,
+    		final RefPair<?, ?> refPair)
+    {
+    	final Object value;
+    	switch ( type ) {
+    		case ignore : value = null; break;
+    		case componentContext : value = componentContext; break;
+    		case bundleContext : value = componentContext.getBundleContext(); break;
+    		case config_map : // note: getProperties() returns a ReadOnlyDictionary which is a Map
+    			              value = componentContext.getProperties(); break;
+    		case config_annotation : value = Annotations.toObject(targetType,
+                    (Map<String, Object>) componentContext.getProperties(),
+                    componentContext.getBundleContext().getBundle(), componentContext.getComponentMetadata().isConfigureWithInterfaces());
+    		        break;
+    		case ref_serviceType : value = refPair.getServiceObject(componentContext); break;
+    		case ref_serviceReference : value = refPair.getRef(); break;
+    		case ref_serviceObjects : value = componentContext.getComponentServiceObjectsHelper().getServiceObjects(refPair.getRef()); break;
+    		case ref_map : value = new ReadOnlyDictionary( refPair.getRef() ); break;
+    		case ref_tuple : final Object tupleKey = new ReadOnlyDictionary( refPair.getRef() );
+                 final Object tupleValue = refPair.getServiceObject(componentContext);
+                 value = new MapEntryImpl(tupleKey, tupleValue, refPair.getRef());
+                 break;
+            default: value = null;
+    	}
+    	return value;
+    }
+
+    /**
+     * Comparable map entry using the service reference to compare.
+     */
+    @SuppressWarnings("rawtypes")
+    private static final class MapEntryImpl implements Map.Entry, Comparable<Map.Entry<?, ?>>
+    {
+
+        private final Object key;
+        private final Object value;
+        private final ServiceReference<?> ref;
+
+        public MapEntryImpl(final Object key,
+                final Object value,
+                final ServiceReference<?> ref)
+        {
+            this.key = key;
+            this.value = value;
+            this.ref = ref;
+        }
+
+        public Object getKey()
+        {
+            return this.key;
+        }
+
+        public Object getValue()
+        {
+            return this.value;
+        }
+
+        public Object setValue(final Object value)
+        {
+            throw new UnsupportedOperationException();
+        }
+
+        public int compareTo(final Map.Entry<?, ?> o)
+        {
+            if ( o == null )
+            {
+                return 1;
+            }
+            if ( o instanceof MapEntryImpl )
+            {
+                final MapEntryImpl other = (MapEntryImpl)o;
+                return ref.compareTo(other.ref);
+
+            }
+            return new Integer(this.hashCode()).compareTo(o.hashCode());
+        }
+    }
+}

Propchange: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ValueUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/ValueUtils.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Copied: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldHandler.java (from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldHandler.java)
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldHandler.java?p2=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldHandler.java&p1=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldHandler.java&r1=1778136&r2=1778137&rev=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldHandler.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldHandler.java Tue Jan 10 14:59:45 2017
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr.impl.inject;
+package org.apache.felix.scr.impl.inject.field;
 
 
 import java.lang.reflect.Field;
@@ -31,10 +31,14 @@ import java.util.TreeMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.CopyOnWriteArraySet;
 
-import org.apache.felix.scr.impl.helper.InitReferenceMethod;
-import org.apache.felix.scr.impl.helper.MethodResult;
-import org.apache.felix.scr.impl.helper.ReferenceMethod;
 import org.apache.felix.scr.impl.helper.SimpleLogger;
+import org.apache.felix.scr.impl.inject.BindParameters;
+import org.apache.felix.scr.impl.inject.ClassUtils;
+import org.apache.felix.scr.impl.inject.InitReferenceMethod;
+import org.apache.felix.scr.impl.inject.MethodResult;
+import org.apache.felix.scr.impl.inject.ReferenceMethod;
+import org.apache.felix.scr.impl.inject.ValueUtils;
+import org.apache.felix.scr.impl.inject.ValueUtils.ValueType;
 import org.apache.felix.scr.impl.manager.ComponentContextImpl;
 import org.apache.felix.scr.impl.manager.RefPair;
 import org.apache.felix.scr.impl.metadata.ReferenceMetadata;
@@ -56,7 +60,7 @@ public class FieldHandler
     private volatile Field field;
 
     /** Value type. */
-    private volatile FieldUtils.ValueType valueType;
+    private volatile ValueType valueType;
 
     /** State handling. */
     private volatile State state;
@@ -97,7 +101,7 @@ public class FieldHandler
     private boolean initField(final Object componentInstance,
             final SimpleLogger logger )
     {
-    	if ( valueType == FieldUtils.ValueType.ignore )
+    	if ( valueType == ValueType.ignore )
     	{
     		return true;
     	}
@@ -122,7 +126,7 @@ public class FieldHandler
                         {
                             logger.log( LogService.LOG_ERROR, "Field {0} in component {1} must not be declared as final", new Object[]
                                     {metadata.getField(), this.componentClass}, null );
-                            valueType = FieldUtils.ValueType.ignore;
+                            valueType = ValueType.ignore;
                             return true;
                         }
                         if ( fieldType != ClassUtils.LIST_CLASS && fieldType != ClassUtils.COLLECTION_CLASS )
@@ -130,7 +134,7 @@ public class FieldHandler
                             logger.log( LogService.LOG_ERROR, "Field {0} in component {1} has unsupported type {2}."+
                                 " It must be one of java.util.Collection or java.util.List.",
                                 new Object[] {metadata.getField(), this.componentClass, fieldType.getName()}, null );
-                            valueType = FieldUtils.ValueType.ignore;
+                            valueType = ValueType.ignore;
                             return true;
                         }
                         if ( fieldType == ClassUtils.LIST_CLASS )
@@ -156,7 +160,7 @@ public class FieldHandler
         }
         catch ( final InvocationTargetException ite)
         {
-            valueType = FieldUtils.ValueType.ignore;
+            valueType = ValueType.ignore;
 
             logger.log( LogService.LOG_ERROR, "Field {0} in component {1} can't be initialized.",
                     new Object[] {metadata.getField(), this.componentClass}, ite );
@@ -208,13 +212,13 @@ public class FieldHandler
             // for a static reference we need a reactivation
             else if ( mType == METHOD_TYPE.UPDATED )
             {
-            	if ( this.valueType == FieldUtils.ValueType.ref_map || this.valueType == FieldUtils.ValueType.ref_tuple )
+            	if ( this.valueType == ValueType.ref_map || this.valueType == ValueType.ref_tuple )
             	{
             		if ( this.metadata.isStatic() )
             		{
             			return MethodResult.REACTIVATE;
             		}
-                    final Object obj = FieldUtils.getValue(valueType, field.getType(), key, refPair);
+                    final Object obj = ValueUtils.getValue(valueType, field.getType(), key, refPair);
                     this.setFieldValue(componentInstance, obj);
                     this.boundValues.put(refPair, obj);
             	}
@@ -222,7 +226,7 @@ public class FieldHandler
             // bind needs always be done
             else
             {
-                final Object obj = FieldUtils.getValue(valueType, field.getType(), key, refPair);
+                final Object obj = ValueUtils.getValue(valueType, field.getType(), key, refPair);
                 this.setFieldValue(componentInstance, obj);
                 this.boundValues.put(refPair, obj);
             }
@@ -234,7 +238,7 @@ public class FieldHandler
             // bind: replace or update the field
             if ( mType == METHOD_TYPE.BIND )
             {
-                final Object obj = FieldUtils.getValue(valueType, field.getType(), key, refPair);
+                final Object obj = ValueUtils.getValue(valueType, field.getType(), key, refPair);
                 this.boundValues.put(refPair, obj);
                 if ( metadata.isReplace() )
                 {
@@ -268,11 +272,11 @@ public class FieldHandler
             // updated needs only be done, if the value type is map or tuple
             else if ( mType == METHOD_TYPE.UPDATED)
             {
-            	if ( this.valueType == FieldUtils.ValueType.ref_map || this.valueType == FieldUtils.ValueType.ref_tuple )
+            	if ( this.valueType == ValueType.ref_map || this.valueType == ValueType.ref_tuple )
             	{
                     if ( !this.metadata.isStatic() )
                     {
-	                    final Object obj = FieldUtils.getValue(valueType, field.getType(), key, refPair);
+	                    final Object obj = ValueUtils.getValue(valueType, field.getType(), key, refPair);
 	                    final Object oldObj = this.boundValues.put(refPair, obj);
 
 	                    if ( metadata.isReplace() )
@@ -379,11 +383,11 @@ public class FieldHandler
         		handler.field = result.field;
             	if ( !result.usable ) 
             	{
-            		handler.valueType = FieldUtils.ValueType.ignore;
+            		handler.valueType = ValueType.ignore;
             	}
             	else
             	{
-            		handler.valueType = FieldUtils.getReferenceValueType( 
+            		handler.valueType = ValueUtils.getReferenceValueType( 
             				handler.componentClass,
             				handler.metadata,
             				result.field.getType(),
@@ -480,23 +484,12 @@ public class FieldHandler
             this.handler = handler;
         }
 
-        public MethodResult invoke(Object componentInstance,
-                                   ComponentContextImpl<?> componentContext,
-                                   RefPair<?, ?> refPair,
-                                   MethodResult methodCallFailureResult,
-                                   SimpleLogger logger) {
-            return invoke(componentInstance,
-                    new BindParameters(componentContext, refPair),
-                    methodCallFailureResult,
-                    logger);
-        }
-
-        public MethodResult invoke(final Object componentInstance,
+        public <S, T> MethodResult invoke(final Object componentInstance,
                 final BindParameters rawParameter,
                 final MethodResult methodCallFailureResult,
                 final SimpleLogger logger)
         {
-            if ( handler.valueType == FieldUtils.ValueType.ignore )
+            if ( handler.valueType == ValueType.ignore )
             {
                 return MethodResult.VOID;
             }
@@ -518,19 +511,19 @@ public class FieldHandler
             return methodCallFailureResult;
         }
 
-        public <S, T> boolean getServiceObject(final ComponentContextImpl<S> key,
-                final RefPair<S, T> refPair,
+        public <S, T> boolean getServiceObject(
+                final BindParameters rawParameter,
                 final BundleContext context,
                 final SimpleLogger logger)
         {
             if ( methodType != METHOD_TYPE.UNBIND )
             {
                 //??? this resolves which we need.... better way?
-                if ( refPair.getServiceObject(key) == null
+                if ( rawParameter.getRefPair().getServiceObject(rawParameter.getComponentContext()) == null
                   && handler.fieldExists( logger )
-                  && (handler.valueType == FieldUtils.ValueType.ref_serviceType || handler.valueType == FieldUtils.ValueType.ref_tuple ) )
+                  && (handler.valueType == ValueType.ref_serviceType || handler.valueType == ValueType.ref_tuple ) )
                 {
-                    return refPair.getServiceObject(key, context, logger);
+                    return rawParameter.getRefPair().getServiceObject(rawParameter.getComponentContext(), context, logger);
                 }
             }
             return true;
@@ -554,7 +547,7 @@ public class FieldHandler
 
     public InitReferenceMethod getInit()
     {
-        if ( valueType == FieldUtils.ValueType.ignore )
+        if ( valueType == ValueType.ignore )
         {
             return null;
         }

Copied: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldMethods.java (from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldMethods.java)
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldMethods.java?p2=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldMethods.java&p1=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldMethods.java&r1=1778136&r2=1778137&rev=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldMethods.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldMethods.java Tue Jan 10 14:59:45 2017
@@ -16,11 +16,11 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr.impl.inject;
+package org.apache.felix.scr.impl.inject.field;
 
-import org.apache.felix.scr.impl.helper.InitReferenceMethod;
-import org.apache.felix.scr.impl.helper.ReferenceMethod;
-import org.apache.felix.scr.impl.helper.ReferenceMethods;
+import org.apache.felix.scr.impl.inject.InitReferenceMethod;
+import org.apache.felix.scr.impl.inject.ReferenceMethod;
+import org.apache.felix.scr.impl.inject.ReferenceMethods;
 import org.apache.felix.scr.impl.metadata.DSVersion;
 import org.apache.felix.scr.impl.metadata.ReferenceMetadata;
 

Copied: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldUtils.java (from r1778136, felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldUtils.java)
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldUtils.java?p2=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldUtils.java&p1=felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldUtils.java&r1=1778136&r2=1778137&rev=1778137&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/FieldUtils.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/field/FieldUtils.java Tue Jan 10 14:59:45 2017
@@ -16,49 +16,24 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr.impl.inject;
+package org.apache.felix.scr.impl.inject.field;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Modifier;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import java.util.Map;
 
-import org.apache.felix.scr.impl.helper.ReadOnlyDictionary;
 import org.apache.felix.scr.impl.helper.SimpleLogger;
-import org.apache.felix.scr.impl.manager.ComponentContextImpl;
-import org.apache.felix.scr.impl.manager.RefPair;
-import org.apache.felix.scr.impl.metadata.ReferenceMetadata;
-import org.osgi.framework.ServiceReference;
+import org.apache.felix.scr.impl.inject.ClassUtils;
 import org.osgi.service.log.LogService;
 
 /**
- * Utility methods for handling field and constructor injection.
+ * Utility methods for handling field injection.
  */
 public class FieldUtils {
 
 	/**
-	 * The value type of the field, activation field or constructor parameter
-	 */
-	public enum ValueType
-    {
-        ignore,
-        componentContext,
-        bundleContext,
-        config_map,
-        config_annotation,
-        ref_serviceReference,
-        ref_serviceObjects,
-        ref_serviceType,
-        ref_map,
-        ref_tuple
-    }
-    
-    /** Empty array. */
-	public static final ValueType[] EMPTY_TYPES = new ValueType[0];
-
-	/**
 	 * Return type for {@link FieldUtils#searchField(Class, String, SimpleLogger)}
 	 */
     public static final class FieldSearchResult 
@@ -310,267 +285,4 @@ public class FieldUtils {
             }
         } );
     }
-
-	/**
-     * Get the value type for the parameter class.
-     * @param typeClass The class of the parameter
-     * @return The value type
-     */
-    public static ValueType getValueType( final Class<?> typeClass )
-    {
-        if ( typeClass == ClassUtils.COMPONENT_CONTEXT_CLASS )
-        {
-        	return ValueType.componentContext;
-        }
-        else if ( typeClass == ClassUtils.BUNDLE_CONTEXT_CLASS )
-        {
-        	return ValueType.bundleContext;
-        }
-        else if ( typeClass == ClassUtils.MAP_CLASS )
-        {
-        	return ValueType.config_map;
-        }
-        else
-        {
-        	return ValueType.config_annotation;
-        }
-    }
-
-    /**
-     * Get the value type of the reference
-     * @param componentClass The component class declaring the reference
-     * @param metadata The reference metadata
-     * @param typeClass The type of the field/parameter
-     * @param f The optional field. If null, this is a constructor reference
-     * @param logger The logger
-     * @return The value type for the field. If invalid, {@code ValueType#ignore}
-     */
-    public static ValueType getReferenceValueType( 
-    		final Class<?> componentClass,
-    		final ReferenceMetadata metadata,
-    		final Class<?> typeClass, 
-    		final Field field,
-    		final SimpleLogger logger )
-    {
-        final Class<?> referenceType = ClassUtils.getClassFromComponentClassLoader(
-                componentClass, metadata.getInterface(), logger);
-
-        ValueType valueType = ValueType.ignore;
-        
-        // unary reference
-        if ( !metadata.isMultiple() )
-        {
-            if ( typeClass.isAssignableFrom(referenceType) )
-            {
-                valueType = ValueType.ref_serviceType;
-            }
-            else if ( typeClass == ClassUtils.SERVICE_REFERENCE_CLASS )
-            {
-                valueType = ValueType.ref_serviceReference;
-            }
-            else if ( typeClass == ClassUtils.COMPONENTS_SERVICE_OBJECTS_CLASS )
-            {
-                valueType = ValueType.ref_serviceObjects;
-            }
-            else if ( typeClass == ClassUtils.MAP_CLASS )
-            {
-                valueType = ValueType.ref_map;
-            }
-            else if ( typeClass == ClassUtils.MAP_ENTRY_CLASS )
-            {
-                valueType = ValueType.ref_tuple;
-            }
-            else
-            {
-            	if ( field != null )
-            	{
-	                logger.log( LogService.LOG_ERROR, "Field {0} in component {1} has unsupported type {2}", new Object[]
-	                        {metadata.getField(), componentClass, typeClass.getName()}, null );
-            	}
-            	else
-            	{
-	                logger.log( LogService.LOG_ERROR, "Constructor argument {0} in component {1} has unsupported type {2}", new Object[]
-	                        {metadata.getParameterIndex(), componentClass, typeClass.getName()}, null );            		
-            	}
-                valueType = ValueType.ignore;
-            }
-
-            // if the field is dynamic, it has to be volatile (field is ignored, case logged) (112.3.8.1)
-            if ( field != null && !metadata.isStatic() && !Modifier.isVolatile(field.getModifiers()) ) {
-                logger.log( LogService.LOG_ERROR, "Field {0} in component {1} must be declared volatile to handle a dynamic reference", new Object[]
-                        {metadata.getField(), componentClass}, null );
-                valueType = ValueType.ignore;
-            }
-
-            // the field must not be final (field is ignored, case logged) (112.3.8.1)
-            if ( field != null && Modifier.isFinal(field.getModifiers()) )
-            {
-                logger.log( LogService.LOG_ERROR, "Field {0} in component {1} must not be declared as final", new Object[]
-                        {metadata.getField(), componentClass}, null );
-                valueType = ValueType.ignore;
-            }
-        }
-        else
-        {
-            if ( ReferenceMetadata.FIELD_VALUE_TYPE_SERVICE.equals(metadata.getFieldCollectionType()) )
-            {
-                valueType = ValueType.ref_serviceType;
-            }
-            else if ( ReferenceMetadata.FIELD_VALUE_TYPE_REFERENCE.equals(metadata.getFieldCollectionType()) )
-            {
-                valueType = ValueType.ref_serviceReference;
-            }
-            else if ( ReferenceMetadata.FIELD_VALUE_TYPE_SERVICEOBJECTS.equals(metadata.getFieldCollectionType()) )
-            {
-                valueType = ValueType.ref_serviceObjects;
-            }
-            else if ( ReferenceMetadata.FIELD_VALUE_TYPE_PROPERTIES.equals(metadata.getFieldCollectionType()) )
-            {
-                valueType = ValueType.ref_map;
-            }
-            else if ( ReferenceMetadata.FIELD_VALUE_TYPE_TUPLE.equals(metadata.getFieldCollectionType()) )
-            {
-                valueType = ValueType.ref_tuple;
-            }
-
-            // multiple cardinality, field type must be collection or subtype
-            if ( !ClassUtils.COLLECTION_CLASS.isAssignableFrom(typeClass) )
-            {
-            	if ( field != null )
-            	{
-	                logger.log( LogService.LOG_ERROR, "Field {0} in component {1} has unsupported type {2}", new Object[]
-	                        {metadata.getField(), componentClass, typeClass.getName()}, null );
-            	}
-            	else
-            	{
-                    logger.log( LogService.LOG_ERROR, "Constructor argument {0} in component {1} has unsupported type {2}", new Object[]
-                            {metadata.getParameterIndex(), componentClass, typeClass.getName()}, null );            		
-            	}
-                valueType = ValueType.ignore;
-            }
-
-            // additional checks for replace strategy:
-            if ( metadata.isReplace() && field != null )
-            {
-                // if the field is dynamic wit has to be volatile (field is ignored, case logged) (112.3.8.1)
-                if ( !metadata.isStatic() && !Modifier.isVolatile(field.getModifiers()) )
-                {
-                    logger.log( LogService.LOG_ERROR, "Field {0} in component {1} must be declared volatile to handle a dynamic reference", new Object[]
-                            {metadata.getField(), componentClass}, null );
-                    valueType = ValueType.ignore;
-                }
-
-                // replace strategy: field must not be final (field is ignored, case logged) (112.3.8.1)
-                //                   only collection and list allowed
-                if ( typeClass != ClassUtils.LIST_CLASS && typeClass != ClassUtils.COLLECTION_CLASS )
-                {
-                    logger.log( LogService.LOG_ERROR, "Field {0} in component {1} has unsupported type {2}."+
-                        " It must be one of java.util.Collection or java.util.List.",
-                        new Object[] {metadata.getField(), componentClass, typeClass.getName()}, null );
-                    valueType = ValueType.ignore;
-
-                }
-                if ( Modifier.isFinal(field.getModifiers()) )
-                {
-                    logger.log( LogService.LOG_ERROR, "Field {0} in component {1} must not be declared as final", new Object[]
-                            {metadata.getField(), componentClass}, null );
-                    valueType = ValueType.ignore;
-                }
-            }
-        }
-        // static references only allowed for replace strategy
-        if ( metadata.isStatic() && !metadata.isReplace() )
-        {
-            logger.log( LogService.LOG_ERROR, "Update strategy for field {0} in component {1} only allowed for non static field references.", new Object[]
-                    {metadata.getField(), componentClass}, null );
-            valueType = ValueType.ignore;
-        }
-        return valueType;
-    }
-
-    /**
-     * Get the value for the parameter type
-     * @param type The parameter type
-     * @param componentContext The component context
-     */
-    @SuppressWarnings("unchecked")
-	public static Object getValue( final ValueType type,
-			final Class<?> targetType,
-    		@SuppressWarnings("rawtypes") final ComponentContextImpl componentContext,
-    		final RefPair<?, ?> refPair)
-    {
-    	final Object value;
-    	switch ( type ) {
-    		case ignore : value = null; break;
-    		case componentContext : value = componentContext; break;
-    		case bundleContext : value = componentContext.getBundleContext(); break;
-    		case config_map : // note: getProperties() returns a ReadOnlyDictionary which is a Map
-    			              value = componentContext.getProperties(); break;
-    		case config_annotation : value = Annotations.toObject(targetType,
-                    (Map<String, Object>) componentContext.getProperties(),
-                    componentContext.getBundleContext().getBundle(), componentContext.getComponentMetadata().isConfigureWithInterfaces());
-    		        break;
-    		case ref_serviceType : value = refPair.getServiceObject(componentContext); break;
-    		case ref_serviceReference : value = refPair.getRef(); break;
-    		case ref_serviceObjects : value = componentContext.getComponentServiceObjectsHelper().getServiceObjects(refPair.getRef()); break;
-    		case ref_map : value = new ReadOnlyDictionary( refPair.getRef() ); break;
-    		case ref_tuple : final Object tupleKey = new ReadOnlyDictionary( refPair.getRef() );
-                 final Object tupleValue = refPair.getServiceObject(componentContext);
-                 value = new MapEntryImpl(tupleKey, tupleValue, refPair.getRef());
-                 break;
-            default: value = null;
-    	}
-    	return value;
-    }
-
-    /**
-     * Comparable map entry using the service reference to compare.
-     */
-    @SuppressWarnings("rawtypes")
-    private static final class MapEntryImpl implements Map.Entry, Comparable<Map.Entry<?, ?>>
-    {
-
-        private final Object key;
-        private final Object value;
-        private final ServiceReference<?> ref;
-
-        public MapEntryImpl(final Object key,
-                final Object value,
-                final ServiceReference<?> ref)
-        {
-            this.key = key;
-            this.value = value;
-            this.ref = ref;
-        }
-
-        public Object getKey()
-        {
-            return this.key;
-        }
-
-        public Object getValue()
-        {
-            return this.value;
-        }
-
-        public Object setValue(final Object value)
-        {
-            throw new UnsupportedOperationException();
-        }
-
-        public int compareTo(final Map.Entry<?, ?> o)
-        {
-            if ( o == null )
-            {
-                return 1;
-            }
-            if ( o instanceof MapEntryImpl )
-            {
-                final MapEntryImpl other = (MapEntryImpl)o;
-                return ref.compareTo(other.ref);
-
-            }
-            return new Integer(this.hashCode()).compareTo(o.hashCode());
-        }
-    }
 }



Mime
View raw message