felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1778088 - in /felix/trunk/osgi-r7/scr/src/main/java/org: apache/felix/scr/impl/inject/ apache/felix/scr/impl/manager/ apache/felix/scr/impl/metadata/ apache/felix/scr/impl/runtime/ osgi/service/component/runtime/dto/
Date Tue, 10 Jan 2017 07:15:52 GMT
Author: cziegeler
Date: Tue Jan 10 07:15:52 2017
New Revision: 1778088

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

Modified:
    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/inject/FieldHandler.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/manager/DependencyManager.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/metadata/ComponentMetadata.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java
    felix/trunk/osgi-r7/scr/src/main/java/org/osgi/service/component/runtime/dto/ComponentDescriptionDTO.java
    felix/trunk/osgi-r7/scr/src/main/java/org/osgi/service/component/runtime/dto/ReferenceDTO.java

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=1778088&r1=1778087&r2=1778088&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 07:15:52 2017
@@ -20,7 +20,9 @@
 
 package org.apache.felix.scr.impl.inject;
 
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.felix.scr.impl.helper.ComponentMethod;
@@ -70,22 +72,25 @@ public class ComponentMethodsImpl<T> imp
         for ( ReferenceMetadata referenceMetadata: componentMetadata.getDependencies() )
         {
             final String refName = referenceMetadata.getName();
-            final ReferenceMethods methods;
-            if ( referenceMetadata.getField() != null && referenceMetadata.getBind()
!= null)
+            final List<ReferenceMethods> methods = new ArrayList<ReferenceMethods>();
+            // TODO add methods for constructor injection
+            if ( referenceMetadata.getField() != null )
             {
-                methods = new DuplexReferenceMethods(
-                        new FieldMethods( referenceMetadata, implementationObjectClass, dsVersion,
configurableServiceProperties),
-                        new BindMethods( referenceMetadata, implementationObjectClass, dsVersion,
configurableServiceProperties));
+                methods.add(new FieldMethods( referenceMetadata, implementationObjectClass,
dsVersion, configurableServiceProperties));
             }
-            else if ( referenceMetadata.getField() != null )
+            if ( referenceMetadata.getBind() != null )
             {
-                methods = new FieldMethods( referenceMetadata, implementationObjectClass,
dsVersion, configurableServiceProperties);
+            	methods.add(new BindMethods( referenceMetadata, implementationObjectClass, dsVersion,
configurableServiceProperties));
+            }
+
+            if ( methods.size() == 1 )
+            {
+            	bindMethodMap.put( refName, methods.get(0) );
             }
             else
             {
-                methods = new BindMethods( referenceMetadata, implementationObjectClass,
dsVersion, configurableServiceProperties);
+            	bindMethodMap.put( refName, new DuplexReferenceMethods(methods) );
             }
-            bindMethodMap.put( refName, methods );
         }
         
         // special constructor handling with activation fields and/or constructor injection

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=1778088&r1=1778087&r2=1778088&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 07:15:52 2017
@@ -62,8 +62,8 @@ public class ConstructorMethodImpl<T> im
 				int index = 0;
 				for(final String fieldName : componentContext.getComponentMetadata().getActivationFields()
) 
 				{
-					final FieldUtils.FieldSearchResult result = FieldUtils.findField(componentClass, fieldName,
logger);
-					if ( result == null )
+					final FieldUtils.FieldSearchResult result = FieldUtils.searchField(componentClass, fieldName,
logger);
+					if ( result == null || result.field == null )
 					{
 						m_paramTypes[index] = null;
 						m_fields[index] = null;
@@ -100,23 +100,15 @@ public class ConstructorMethodImpl<T> im
 				m_constructorArgTypes = new FieldUtils.ValueType[argTypes.length];
 				for(int i=0;i<m_constructorArgTypes.length;i++)
 				{
-					// TODO get reference metadata
-					ReferenceMetadata reference = null;
-					for(final ReferenceMetadata ref : componentContext.getComponentMetadata().getDependencies())
-					{
-						if ( ref.getParamterIndex() == i )
-						{
-							reference = ref;
-							break;
-						}
-					}
+					final DependencyManager<S, ?> dm = parameterMap.get(i);
+					ReferenceMetadata reference = dm == null ? null : dm.getReferenceMetadata();
 					if ( reference == null )
 					{
 						m_constructorArgTypes[i] = FieldUtils.getValueType(argTypes[i]);
 					}
 					else 
 					{
-						m_constructorArgTypes[i] = FieldUtils.getReferenceValueType(componentClass, null, argTypes[i],
null, logger);
+						m_constructorArgTypes[i] = FieldUtils.getReferenceValueType(componentClass, reference,
argTypes[i], null, logger);
 					}
 					if ( m_constructorArgTypes[i] == FieldUtils.ValueType.ignore )
 					{
@@ -154,7 +146,7 @@ public class ConstructorMethodImpl<T> im
 			final Object[] args = new Object[m_constructorArgTypes.length];
 			for(int i=0; i<args.length; i++) 
 			{
-				// TODO key pair for reference
+				final DependencyManager<S, ?> dm = parameterMap.get(i);
 				args[i] = FieldUtils.getValue(m_constructorArgTypes[i], 
 						m_constructor.getParameterTypes()[i], 
 						componentContext, 

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=1778088&r1=1778087&r2=1778088&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 07:15:52 2017
@@ -18,6 +18,8 @@
  */
 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;
@@ -29,31 +31,48 @@ import org.osgi.framework.BundleContext;
 
 public class DuplexReferenceMethods implements ReferenceMethods
 {
-    /** First is field methods. */
-    private final ReferenceMethods first;
-
-    /** Second is method methods. */
-    private final ReferenceMethods second;
+    /** The methods in the order they need to be called. */
+    private final List<ReferenceMethods> methods;
 
-    public DuplexReferenceMethods(final ReferenceMethods first, final ReferenceMethods second)
+    public DuplexReferenceMethods(final List<ReferenceMethods> methods)
     {
-        this.first = first;
-        this.second = second;
+        this.methods = methods;
     }
 
     public ReferenceMethod getBind()
     {
-        return new DuplexReferenceMethod(first.getBind(), second.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()
     {
-        return new DuplexReferenceMethod(first.getUnbind(), second.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()
     {
-        return new DuplexReferenceMethod(first.getUpdated(), second.getUpdated());
+    	final ReferenceMethod[] list = new ReferenceMethod[methods.size()];
+    	int index = 0;
+    	for(final ReferenceMethods m : methods)
+    	{
+    		list[index] = m.getUpdated();
+    		index++;
+    	}
+        return new DuplexReferenceMethod(list);
     }
 
     public InitReferenceMethod getInit()
@@ -63,23 +82,20 @@ public class DuplexReferenceMethods impl
 
             public boolean init(Object componentInstance, SimpleLogger logger)
             {
-                final InitReferenceMethod i1 = first.getInit();
-                if ( i1 != null )
-                {
-                    if ( !i1.init(componentInstance, logger))
-                    {
-                        return false;
-                    }
-                }
-                final InitReferenceMethod i2 = second.getInit();
-                if ( i2 != null )
-                {
-                    if ( !i2.init(componentInstance, logger))
-                    {
-                        return false;
-                    }
-                }
-                return true;
+            	boolean result = true;
+            	for(final ReferenceMethods m : methods)
+            	{
+            		final InitReferenceMethod init = m.getInit();
+            		if ( init != null )
+            		{
+            			result = init.init(componentInstance, logger);
+            			if ( !result ) 
+            			{
+            				break;
+            			}
+            		}
+            	}
+                return result;
             }
         };
     }
@@ -87,14 +103,11 @@ public class DuplexReferenceMethods impl
     private static final class DuplexReferenceMethod implements ReferenceMethod
     {
 
-        private final ReferenceMethod first;
-
-        private final ReferenceMethod second;
+        private final ReferenceMethod[] methods;
 
-        public DuplexReferenceMethod(final ReferenceMethod first, final ReferenceMethod second)
+        public DuplexReferenceMethod(final ReferenceMethod[] methods)
         {
-            this.first = first;
-            this.second = second;
+            this.methods = methods;
         }
 
         public MethodResult invoke(Object componentInstance,
@@ -102,25 +115,33 @@ public class DuplexReferenceMethods impl
                                    RefPair<?, ?> refPair,
                                    MethodResult methodCallFailureResult,
                                    SimpleLogger logger) {
-            if ( first.invoke(componentInstance, componentContext, refPair, methodCallFailureResult,
logger) != null )
-            {
-                return second.invoke(componentInstance, componentContext, refPair, methodCallFailureResult,
logger);
-            }
-            return null;
+        	MethodResult result = null;
+        	for(final ReferenceMethod m : methods) 
+        	{
+        		result = m.invoke(componentInstance, componentContext, refPair, methodCallFailureResult,
logger);
+        		if ( result == null )        			
+        		{
+        			break;
+        		}
+        	}
+            return result;
         }
 
         public <S, T> boolean getServiceObject(ComponentContextImpl<S> key,
                 RefPair<S, T> refPair, BundleContext context,
                 SimpleLogger logger)
         {
-            // only if both return true, we return true
-            boolean result = first.getServiceObject(key, refPair, context, logger);
-            if ( result )
-            {
-                result = second.getServiceObject(key, refPair, context, logger);
-            }
+            // only if all return true, we return true
+        	boolean result = false;
+        	for(final ReferenceMethod m : methods) 
+        	{
+        		result = m.getServiceObject(key, refPair, context, logger);
+        		if (!result )        			
+        		{
+        			break;
+        		}
+        	}
             return result;
         }
-
     }
 }

Modified: 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/FieldHandler.java?rev=1778088&r1=1778087&r2=1778088&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/FieldHandler.java
Tue Jan 10 07:15:52 2017
@@ -86,31 +86,6 @@ public class FieldHandler
         this.state = NotResolved.INSTANCE;
     }
 
-    /**
-     * Set the field.
-     * If the field is found, the state transitions to resolved, if the field is
-     * {@code null} the state transitions to not found.
-     * @param f The field or {@code null}.
-     * @param logger The logger
-     */
-    private void setField( final Field f, final SimpleLogger logger )
-    {
-        this.field = f;
-
-        if ( f != null )
-        {
-            state = Resolved.INSTANCE;
-            logger.log( LogService.LOG_DEBUG, "Found field: {0}",
-                    new Object[] { field }, null );
-        }
-        else
-        {
-            state = NotFound.INSTANCE;
-            logger.log(LogService.LOG_ERROR, "Field [{0}] not found; Component will fail",
-                new Object[] { this.metadata.getField() }, null);
-        }
-    }
-
     private enum METHOD_TYPE
     {
         BIND,
@@ -390,15 +365,18 @@ public class FieldHandler
                     {handler.metadata.getField()}, null );
 
             // resolve the field
-            final Field field;
-        	final FieldUtils.FieldSearchResult result = FieldUtils.findField( handler.componentClass,
handler.metadata.getField(), logger );
+        	final FieldUtils.FieldSearchResult result = FieldUtils.searchField( handler.componentClass,
handler.metadata.getField(), logger );
         	if ( result == null ) 
         	{
-                field = null;            		
+        		handler.field = null;         
+        		handler.valueType = null;
+        		handler.state = NotFound.INSTANCE;
+                logger.log(LogService.LOG_ERROR, "Field [{0}] not found; Component will fail",
+                    new Object[] { handler.metadata.getField() }, null);
         	}
         	else 
         	{
-        		field = result.field;
+        		handler.field = result.field;
             	if ( !result.usable ) 
             	{
             		handler.valueType = FieldUtils.ValueType.ignore;
@@ -408,13 +386,14 @@ public class FieldHandler
             		handler.valueType = FieldUtils.getReferenceValueType( 
             				handler.componentClass,
             				handler.metadata,
-            				field.getType(),
-            				field, 
+            				result.field.getType(),
+            				result.field, 
             				logger );
             	}
+                handler.state = Resolved.INSTANCE;
+                logger.log( LogService.LOG_DEBUG, "Found field: {0}",
+                        new Object[] { result.field }, null );
         	}
-
-            handler.setField( field, logger );
         }
 
         public MethodResult invoke( final FieldHandler handler,

Modified: 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/FieldUtils.java?rev=1778088&r1=1778087&r2=1778088&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/FieldUtils.java
Tue Jan 10 07:15:52 2017
@@ -33,8 +33,14 @@ import org.apache.felix.scr.impl.metadat
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.log.LogService;
 
+/**
+ * Utility methods for handling field and constructor injection.
+ */
 public class FieldUtils {
 
+	/**
+	 * The value type of the field, activation field or constructor parameter
+	 */
 	public enum ValueType
     {
         ignore,
@@ -49,8 +55,12 @@ public class FieldUtils {
         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 
 	{
 		public final Field field;
@@ -64,18 +74,25 @@ public class FieldUtils {
 	}
 	
     /**
-     * Finds the field named {@code fieldName} in the given
+     * Searches the field named {@code fieldName} in the given
      * {@code targetClass}. If the target class has no acceptable field
      * the class hierarchy is traversed until a field is found or the root
      * of the class hierarchy is reached without finding a field.
+     * <p>
+     * If an unexpected error occurs while searching, {@code null} is
+     * returned. In all other cases a {@code FieldSearchResult} is
+     * returned. If no field is found, {@code FieldSearchResult#field}
+     * is set to {@code null}. If the field is found, but not usable
+     * (e.g. due to visibility restrictions), {@code FieldSearchResult#usable}
+     * is set to {@code false}.
      *
      * @param targetClass The class of the component
      * @param fieldName The name of the field
      * @param logger A logger to log errors / problems
-     * @return The requested field or {@code null} if no acceptable field
-     *      can be found in the target class or any super class.
+     * @return A field search result or {@code null} if an unexpected
+     *         error occurred.
      */
-    public static FieldSearchResult findField( final Class<?> componentClass,
+    public static FieldSearchResult searchField( final Class<?> componentClass,
     		final String fieldName,
     		final SimpleLogger logger )
     {
@@ -128,7 +145,7 @@ public class FieldUtils {
         // nothing found 
         logger.log( LogService.LOG_WARNING, "{0} cannot be found in component class {1}",
new Object[]
                         {fieldName, componentClass.getName()}, null );
-        return null;
+        return new FieldSearchResult(null, false);
     }
 
     /**
@@ -373,7 +390,7 @@ public class FieldUtils {
             	else
             	{
 	                logger.log( LogService.LOG_ERROR, "Constructor argument {0} in component
{1} has unsupported type {2}", new Object[]
-	                        {metadata.getParamterIndex(), componentClass, typeClass.getName()},
null );            		
+	                        {metadata.getParameterIndex(), componentClass, typeClass.getName()},
null );            		
             	}
                 valueType = ValueType.ignore;
             }
@@ -427,7 +444,7 @@ public class FieldUtils {
             	else
             	{
                     logger.log( LogService.LOG_ERROR, "Constructor argument {0} in component
{1} has unsupported type {2}", new Object[]
-                            {metadata.getParamterIndex(), componentClass, typeClass.getName()},
null );            		
+                            {metadata.getParameterIndex(), componentClass, typeClass.getName()},
null );            		
             	}
                 valueType = ValueType.ignore;
             }
@@ -506,6 +523,9 @@ public class FieldUtils {
     	return value;
     }
 
+    /**
+     * Comparable map entry using the service reference to compare.
+     */
     @SuppressWarnings("rawtypes")
     private static final class MapEntryImpl implements Map.Entry, Comparable<Map.Entry<?,
?>>
     {
@@ -552,6 +572,5 @@ public class FieldUtils {
             }
             return new Integer(this.hashCode()).compareTo(o.hashCode());
         }
-
     }
 }

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java?rev=1778088&r1=1778087&r2=1778088&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
(original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
Tue Jan 10 07:15:52 2017
@@ -1488,9 +1488,9 @@ public class DependencyManager<S, T> imp
         return m_dependencyMetadata.getName();
     }
 
-    public int getParameterIndex() 
+    public ReferenceMetadata getReferenceMetadata() 
     {
-    	return m_dependencyMetadata.getParamterIndex();
+    	return m_dependencyMetadata;
     }
     
     /**

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java?rev=1778088&r1=1778087&r2=1778088&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
(original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
Tue Jan 10 07:15:52 2017
@@ -241,7 +241,7 @@ public class SingleComponentManager<S> e
 	        {
 	            if ( failedDm == null )
 	            {
-	            	if ( dm.getParameterIndex() != - 1)
+	            	if ( dm.getReferenceMetadata().getParameterIndex() != null)
 	            	{
 		                // if a dependency turned unresolved since the validation check,
 		                // creating the instance fails here, so we deactivate and return
@@ -254,7 +254,7 @@ public class SingleComponentManager<S> e
 		
 		                    failedDm = dm;
 		                }
-		                paramMap.put(dm.getParameterIndex(), dm);
+		                paramMap.put(dm.getReferenceMetadata().getParameterIndex(), dm);
 	                }
 	            }
 	        }
@@ -273,7 +273,7 @@ public class SingleComponentManager<S> e
 	                }
 	                else
 	                {
-	                	if ( md.getParameterIndex() != -1 )
+	                	if ( md.getReferenceMetadata().getParameterIndex() != null )
 	                	{
 	                		md.close( componentContext, componentContext.getEdgeInfo( md ) );
 	                	}
@@ -318,7 +318,7 @@ public class SingleComponentManager<S> e
         {
             if ( failedDm == null )
             {
-            	if ( dm.getParameterIndex() == - 1)
+            	if (dm.getReferenceMetadata().getParameterIndex() == null)
             	{
 	                // if a dependency turned unresolved since the validation check,
 	                // creating the instance fails here, so we deactivate and return
@@ -336,7 +336,7 @@ public class SingleComponentManager<S> e
             }
             else
             {
-            	if ( dm.getParameterIndex() == - 1)
+            	if ( dm.getReferenceMetadata().getParameterIndex() == null )
             	{
             		componentContext.getEdgeInfo( dm ).ignore();
             	}
@@ -353,7 +353,7 @@ public class SingleComponentManager<S> e
                 {
                     skip = false;
                 }
-                if ( !skip || md.getParameterIndex() != -1 )
+                if ( !skip || md.getReferenceMetadata().getParameterIndex() != null )
                 {
                     md.close( componentContext, componentContext.getEdgeInfo( md ) );
                 }

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java?rev=1778088&r1=1778087&r2=1778088&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
(original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
Tue Jan 10 07:15:52 2017
@@ -1018,9 +1018,9 @@ public class ComponentMetadata
         	final Set<Integer> parIndexSet = new HashSet<Integer>();
         	for(final ReferenceMetadata ref : this.m_references) 
         	{
-        		if ( ref.getParamterIndex() != -1 && !parIndexSet.add(ref.getParamterIndex())
) 
+        		if ( ref.getParameterIndex() != null && !parIndexSet.add(ref.getParameterIndex())
) 
         		{
-                    throw validationFailure( "Duplicate reference for argument " + ref.getParamterIndex()
+ " in constructor" );        	                        
+                    throw validationFailure( "Duplicate reference for argument " + ref.getParameterIndex()
+ " in constructor" );        	                        
         		}
         	}
         }
@@ -1029,7 +1029,7 @@ public class ComponentMetadata
         	// no constructor injection, check references for having a parameter index
         	for(final ReferenceMetadata ref : this.m_references) 
         	{
-        		if ( ref.getParamterIndex() != -1 )
+        		if ( ref.getParameterIndex() != null )
         		{
                     throw validationFailure( "Reference must not use parameter attribute
if no constructor injection is used" );        			
         		}

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java?rev=1778088&r1=1778087&r2=1778088&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java
(original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/metadata/ReferenceMetadata.java
Tue Jan 10 07:15:52 2017
@@ -134,7 +134,7 @@ public class ReferenceMetadata
     private String m_parameter;
     
     // Parameter index, set based on {@code m_parameter} after validation
-    private int m_parameterIndex = -1;
+    private Integer m_parameterIndex;
     
     // Flags that store the values passed as strings
     private boolean m_isStatic = true;
@@ -539,12 +539,12 @@ public class ReferenceMetadata
 
     /**
      * Get the parameter index, if specified.
-     * This method returns the correct value only of this metadata object has been validated
+     * This method returns the correct value only after this metadata object has been validated
      * by a call to {@link #validate(ComponentMetadata, Logger)} and the validation has been
      * successful.
-     * @return The parameter index , if no parameter is set this returns {@code -1}
+     * @return The parameter index , if no parameter is set this returns {@code -null}
      */
-    public int getParamterIndex() 
+    public Integer getParameterIndex() 
     {
     	return m_parameterIndex;
     }

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java?rev=1778088&r1=1778087&r2=1778088&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java
(original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java
Tue Jan 10 07:15:52 2017
@@ -320,6 +320,7 @@ public class ServiceComponentRuntimeImpl
 		dto.serviceInterfaces = m.getServiceMetadata() == null? EMPTY: m.getServiceMetadata().getProvides();
 		// DS 1.4
 		dto.factoryProperties = m.isFactory() ? m.getFactoryProperties() : null;
+		dto.activationFields = (m.getActivationFields() == null ? EMPTY : m.getActivationFields().toArray(new
String[m.getActivationFields().size()]));
 		return dto;
 	}
 
@@ -400,7 +401,7 @@ public class ServiceComponentRuntimeImpl
 			dto.unbind = r.getUnbind();
 			dto.updated = r.getUpdated();
 			// DS 1.4
-			dto.parameter = (r.getParamterIndex() == -1 ? 0 : r.getParamterIndex());
+			dto.parameter = r.getParameterIndex();
 			dto.collectionType = r.getFieldCollectionType();
 			dtos[i++] = dto;
 		}

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/osgi/service/component/runtime/dto/ComponentDescriptionDTO.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/osgi/service/component/runtime/dto/ComponentDescriptionDTO.java?rev=1778088&r1=1778087&r2=1778088&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/osgi/service/component/runtime/dto/ComponentDescriptionDTO.java
(original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/osgi/service/component/runtime/dto/ComponentDescriptionDTO.java
Tue Jan 10 07:15:52 2017
@@ -181,4 +181,15 @@ public class ComponentDescriptionDTO ext
 	 * @since 1.4
 	 */
 	public Map<String,Object>	factoryProperties;
+
+	/**
+	 * The activation fields.
+	 * <p>
+	 * These are declared in the {@code activation-fields} attribute of the
+	 * {@code component} element. The array must be empty if the component
+	 * description does not declare any activation fields.
+	 * 
+	 * @since 1.4
+	 */
+	public String[]				activationFields;
 }

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/osgi/service/component/runtime/dto/ReferenceDTO.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/osgi/service/component/runtime/dto/ReferenceDTO.java?rev=1778088&r1=1778087&r2=1778088&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/osgi/service/component/runtime/dto/ReferenceDTO.java
(original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/osgi/service/component/runtime/dto/ReferenceDTO.java
Tue Jan 10 07:15:52 2017
@@ -151,12 +151,12 @@ public class ReferenceDTO extends DTO {
 	 * reference.
 	 * <p>
 	 * This is declared in the {@code parameter} attribute of the
-	 * {@code reference} element. This must be zero if the component description
-	 * does not declare a parameter number for the reference.
+	 * {@code reference} element. This must be {@code null} if the component
+	 * description does not declare a parameter number for the reference.
 	 * 
 	 * @since 1.4
 	 */
-	public int		parameter;
+	public Integer	parameter;
 
 	/**
 	 * The collection type for the reference.



Mime
View raw message