Fix the Felix-683 issue.
Add the support of list and vector in service dependencies.
So, the pojo can now receive service objects inside a list or a vector instead of an array.


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@686620 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
index 41baeb3..47e1364 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
@@ -22,9 +22,11 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.List;
+import java.util.Vector;
 
 import org.apache.felix.ipojo.FieldInterceptor;
 import org.apache.felix.ipojo.InstanceManager;
@@ -79,6 +81,12 @@
      * Thread Local.
      */
     private final ServiceUsage m_usage;
+    
+    /**
+     * Type of the object to inject.
+     * Cannot change once set.
+     */
+    private int m_type;
 
     /**
      * Nullable object.
@@ -416,42 +424,74 @@
      * @see org.apache.felix.ipojo.FieldInterceptor#onGet(java.lang.Object, java.lang.String, java.lang.Object)
      */
     public Object onGet(Object pojo, String fieldName, Object value) {        
-     //     Initialize the thread local object is not already touched.
+        // Initialize the thread local object is not already touched.
         Usage usage = (Usage) m_usage.get();
         if (usage.m_stack == 0) { // uninitialized usage.
-            ServiceReference[] refs = super.getServiceReferences();
-            if (isAggregate()) { // If we are aggregate we get the objects.
-                if (refs == null) {
-                    usage.m_objects = (Object[]) Array.newInstance(getSpecification(), 0); // Create an empty array.
-                } else {
-                   // Use a reflective construction to avoid class cast exception. This method allow to set the component type.
-                    usage.m_objects = (Object[]) Array.newInstance(getSpecification(), refs.length); 
-                    for (int i = 0; refs != null && i < refs.length; i++) {
-                        ServiceReference ref = refs[i];
-                        usage.m_objects[i] = getService(ref);
-                    }
-                }
-            } else { // We are not aggregate.
-                // Use a reflective construction to avoid class cast exception. This method allow to set the component type.
-                usage.m_objects = (Object[]) Array.newInstance(getSpecification(), 1);
-                if (refs == null) {
-                    if (m_nullable == null && m_supportNullable) {
-                        m_handler.warn("[" + m_handler.getInstanceManager().getInstanceName() + "] The dependency is not optional, however no service object can be injected in " + m_field + " -> " + getSpecification().getName());
-                    }
-                    usage.m_objects[0] = m_nullable; // Add null if the Nullable pattern is disable.
-                } else {
-                    ServiceReference ref = getServiceReference();
-                    usage.m_objects[0] = getService(ref);
-                }
-            }
-            usage.inc(); // Start the tracking, so fix the stack level to 1
+            createServiceObject(usage);
+            usage.inc(); // Start the caching, so set the stack level to 1
             m_usage.set(usage);
         }
 
-        if (isAggregate()) { // Multiple dependency
-            return usage.m_objects;
+        return usage.m_object;
+
+    }
+
+    
+    /**
+     * Creates the object to store in the given Thread Local.
+     * This object will be injected inside the POJO field.
+     * @param usage : Thread Local to populate.
+     */
+    private void createServiceObject(Usage usage) {
+        ServiceReference[] refs = getServiceReferences();
+        if (! isAggregate()) {
+            if (refs == null) {
+                if (m_nullable == null && m_supportNullable) {
+                    m_handler.warn("[" + m_handler.getInstanceManager().getInstanceName() + "] The dependency is not optional, however no service object can be injected in " + m_field + " -> " + getSpecification().getName());
+                }
+                usage.m_object = m_nullable; // Add null if the Nullable pattern is disable.
+            } else {
+                ServiceReference ref = getServiceReference();
+                usage.m_object = getService(ref);
+            }
         } else {
-            return usage.m_objects[0];
+            if (m_type == 0) { // Array
+                if (refs == null) {
+                    usage.m_object = (Object[]) Array.newInstance(getSpecification(), 0); // Create an empty array.
+                } else {
+                   // Use a reflective construction to avoid class cast exception. This method allows setting the component type.
+                    Object[] objs = (Object[]) Array.newInstance(getSpecification(), refs.length); 
+                    for (int i = 0; refs != null && i < refs.length; i++) {
+                        ServiceReference ref = refs[i];
+                        objs[i] = getService(ref);
+                    }
+                    usage.m_object = objs;
+                }
+            } else if (m_type == 1) {
+                if (refs == null) {
+                    usage.m_object = new ArrayList(0); // Create an empty list.
+                } else {
+                   // Use a list to store service objects
+                    List objs = new ArrayList(refs.length); 
+                    for (int i = 0; refs != null && i < refs.length; i++) {
+                        ServiceReference ref = refs[i];
+                        objs.add(getService(ref));
+                    }
+                    usage.m_object = objs;
+                }
+            } else if (m_type == 2) {
+                if (refs == null) {
+                    usage.m_object = new Vector(0); // Create an empty vector.
+                } else {
+                   // Use a vector to store service objects
+                    Vector objs = new Vector(refs.length); 
+                    for (int i = 0; refs != null && i < refs.length; i++) {
+                        ServiceReference ref = refs[i];
+                        objs.add(getService(ref));
+                    }
+                    usage.m_object = objs;
+                }
+            }
         }
     }
 
@@ -538,4 +578,14 @@
         return m_di;
     }
 
+    /**
+     * Set the type to inject.
+     * This method set the dependency as aggregate.
+     * @param type either list of vector
+     */
+    protected void setType(int type) {
+        setAggregate(true);
+        m_type = type;
+    }
+
 }
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
index 27c0371..dcc9fb9 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandler.java
@@ -20,6 +20,8 @@
 
 import java.util.Comparator;
 import java.util.Dictionary;
+import java.util.List;
+import java.util.Vector;
 
 import org.apache.felix.ipojo.ConfigurationException;
 import org.apache.felix.ipojo.IPojoContext;
@@ -44,6 +46,18 @@
 public class DependencyHandler extends PrimitiveHandler implements DependencyStateListener {
 
     /**
+     * Dependency field type : Vector
+     * The dependency will be injected as a vector.
+     */
+    protected static final int VECTOR = 2;
+
+    /**
+     * Dependency Field Type : List.
+     * The dependency will be injected as a list.
+     */
+    protected static final int LIST = 1;
+
+    /**
      * List of dependencies of the component.
      */
     private Dependency[] m_dependencies = new Dependency[0];
@@ -198,6 +212,12 @@
                 // Set the dependency to multiple
                 dep.setAggregate(true);
                 type = type.substring(0, type.length() - 2);
+            } else if (type.equals(List.class.getName())) {
+                dep.setType(LIST);
+                type = null;
+            } else if (type.equals(Vector.class.getName())) {
+                dep.setType(VECTOR);
+                type = null;
             } else {
                 if (dep.isAggregate()) {
                     throw new ConfigurationException("A required service is not correct : the field "
@@ -205,7 +225,7 @@
                             + " must be an array to support aggregate injections");
                 }
             }
-            setSpecification(dep, type, true); // Throw an exception if the filed type mismatch.
+            setSpecification(dep, type, true); // Throws an exception if the field type mismatch.
         }
 
         // Check that all required info are set
@@ -220,31 +240,42 @@
      * @throws ConfigurationException : the specification class cannot be loaded correctly
      */
     private void setSpecification(Dependency dep, String className, boolean error) throws ConfigurationException {
-        // We have to set the dependency in two cases : either the dependency as no specification, or the specification is different from the given
-        // one
-        if (dep.getSpecification() == null || !dep.getSpecification().getName().equals(className)) {
-            if (dep.getSpecification() != null) {
+        if (className == null) {
+            // No found type (list and vector)
+            if (dep.getSpecification() == null) {
                 if (error) {
-                    throw new ConfigurationException("A required service is not correct : the discoevered type ["
+                    throw new ConfigurationException("Cannot discover the required specification for " + dep.getField());
+                } else {
+                    // If the specification is different, warn that we will override it.
+                    warn("Cannot discover the required specification for " + dep.getField());
+                }
+            }
+        } else { // In all other case, className is not null.
+            if (dep.getSpecification() == null || !dep.getSpecification().getName().equals(className)) {
+                if (dep.getSpecification() != null) {
+                    if (error) {
+                        throw new ConfigurationException("A required service is not correct : the discovered type ["
                             + className
                             + "] and the specified (or already discovered)  service interface ["
                             + dep.getSpecification().getName()
                             + "] are not the same");
-                } else {
-                    // If the specification is different, warn that we will overide it.
-                    warn("[DependencyHandler on "
+                    } else {
+                        // If the specification is different, warn that we will override it.
+                        warn("[DependencyHandler on "
                             + getInstanceManager().getInstanceName()
                             + "] The field type ["
                             + className
                             + "] and the needed service interface ["
                             + dep.getSpecification()
                             + "] are not the same");
+                    }
                 }
-            }
-            try {
-                dep.setSpecification(getInstanceManager().getContext().getBundle().loadClass(className));
-            } catch (ClassNotFoundException e) {
-                throw new ConfigurationException("The required service interface cannot be loaded : " + e.getMessage());
+            
+                try {
+                    dep.setSpecification(getInstanceManager().getContext().getBundle().loadClass(className));
+                } catch (ClassNotFoundException e) {
+                    throw new ConfigurationException("The required service interface cannot be loaded : " + e.getMessage());
+                }
             }
         }
     }
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/ServiceUsage.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/ServiceUsage.java
index 7d289f1..5a8d5c5 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/ServiceUsage.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/ServiceUsage.java
@@ -36,12 +36,12 @@
          */

         int m_stack = 0;

         /**

-         * List of used objects.

+         * Object to inject.

          */

-        Object[] m_objects;

+        Object m_object;

         

         /**

-         * Increment the statck level.

+         * Increment the stack level.

          */

         public void inc() {

             m_stack++;

@@ -60,7 +60,7 @@
          * Clear the service object array.

          */

         public void clear() {

-            m_objects = null;

+            m_object = null;

         }

         

     }

diff --git a/ipojo/pom.xml b/ipojo/pom.xml
index 962a68a..474adc1 100644
--- a/ipojo/pom.xml
+++ b/ipojo/pom.xml
@@ -80,4 +80,17 @@
 		</modules>
 	</profile>
   </profiles>
+  
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <configuration>
+          <aggregate>true</aggregate>
+        </configuration>
+      </plugin>
+    </plugins>
+  </reporting>
+
 </project>
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ListCheckService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ListCheckService.java
new file mode 100644
index 0000000..52d9f5f
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/ListCheckService.java
@@ -0,0 +1,159 @@
+/* 

+ * 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.ipojo.test.scenarios.component;

+

+import java.util.List;

+import java.util.Properties;

+

+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;

+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;

+import org.osgi.framework.ServiceReference;

+

+public class ListCheckService implements CheckService {

+

+    List fs;

+

+    int simpleB = 0;

+

+    int objectB = 0;

+

+    int refB = 0;

+

+    int bothB = 0;

+

+    int simpleU = 0;

+

+    int objectU = 0;

+

+    int refU = 0;

+

+    int bothU = 0;

+

+    public boolean check() {

+        boolean r = fs.size() != 0;

+        for (int i = 0; i < fs.size(); i++) {

+            r = r & ((FooService) fs.get(i)).foo();

+        }

+        return r;

+    }

+

+    private boolean getBoolean() {

+        return check();

+    }

+

+    private int getInt() {

+        int r = 0;

+        for (int i = 0; i < fs.size(); i++) {

+            r = r + ((FooService) fs.get(i)).getInt();

+        }

+        return r;

+    }

+

+    private long getLong() {

+        long r = 0;

+        for (int i = 0; i < fs.size(); i++) {

+            r = r + ((FooService) fs.get(i)).getLong();

+        }

+        return r;

+    }

+

+    private double getDouble() {

+        double r = 0.0;

+        for (int i = 0; i < fs.size(); i++) {

+            r = r + ((FooService) fs.get(i)).getDouble();

+        }

+        return r;

+    }

+

+    protected Object doNothing(Object o, String s) {

+        return null;

+    }

+

+    // private Object getObject() {

+    // boolean r = true;

+    // for(int i = 0; i < fs.length; i++) {

+    // r = r && ((Boolean) fs[i].getObject()).booleanValue();

+    // }

+    // return new Boolean(r);

+    // }

+

+    public Properties getProps() {

+        Properties props = new Properties();

+        props.put("result", new Boolean(check()));

+        props.put("voidB", new Integer(simpleB));

+        props.put("objectB", new Integer(objectB));

+        props.put("refB", new Integer(refB));

+        props.put("bothB", new Integer(bothB));

+        props.put("voidU", new Integer(simpleU));

+        props.put("objectU", new Integer(objectU));

+        props.put("refU", new Integer(refU));

+        props.put("bothU", new Integer(bothU));

+        props.put("boolean", new Boolean(getBoolean()));

+        props.put("int", new Integer(getInt()));

+        props.put("long", new Long(getLong()));

+        props.put("double", new Double(getDouble()));

+

+        return props;

+    }

+

+    public void voidBind() {

+        simpleB++;

+    }

+

+    public void voidUnbind() {

+        simpleU++;

+    }

+

+    public void objectBind(FooService o) {

+        if (o != null && o instanceof FooService) {

+            objectB++;

+        }

+    }

+

+    public void objectUnbind(FooService o) {

+        if (o != null && o instanceof FooService) {

+            objectU++;

+        }

+    }

+

+    public void refBind(ServiceReference sr) {

+        if (sr != null) {

+            refB++;

+        }

+    }

+

+    public void refUnbind(ServiceReference sr) {

+        if (sr != null) {

+            refU++;

+        }

+    }

+

+    public void bothBind(FooService o, ServiceReference sr) {

+        if (o != null && o instanceof FooService && sr != null) {

+            bothB++;

+        }

+    }

+

+    public void bothUnbind(FooService o, ServiceReference sr) {

+        if (o != null && o instanceof FooService && sr != null) {

+            bothU++;

+        }

+    }

+

+}

diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/VectorCheckService.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/VectorCheckService.java
new file mode 100644
index 0000000..6c7011f
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/VectorCheckService.java
@@ -0,0 +1,159 @@
+/* 

+ * 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.ipojo.test.scenarios.component;

+

+import java.util.Properties;

+import java.util.Vector;

+

+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;

+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService;

+import org.osgi.framework.ServiceReference;

+

+public class VectorCheckService implements CheckService {

+

+    Vector fs;

+

+    int simpleB = 0;

+

+    int objectB = 0;

+

+    int refB = 0;

+

+    int bothB = 0;

+

+    int simpleU = 0;

+

+    int objectU = 0;

+

+    int refU = 0;

+

+    int bothU = 0;

+

+    public boolean check() {

+        boolean r = fs.size() != 0;

+        for (int i = 0; i < fs.size(); i++) {

+            r = r & ((FooService) fs.get(i)).foo();

+        }

+        return r;

+    }

+

+    private boolean getBoolean() {

+        return check();

+    }

+

+    private int getInt() {

+        int r = 0;

+        for (int i = 0; i < fs.size(); i++) {

+            r = r + ((FooService) fs.get(i)).getInt();

+        }

+        return r;

+    }

+

+    private long getLong() {

+        long r = 0;

+        for (int i = 0; i < fs.size(); i++) {

+            r = r + ((FooService) fs.get(i)).getLong();

+        }

+        return r;

+    }

+

+    private double getDouble() {

+        double r = 0.0;

+        for (int i = 0; i < fs.size(); i++) {

+            r = r + ((FooService) fs.get(i)).getDouble();

+        }

+        return r;

+    }

+

+    protected Object doNothing(Object o, String s) {

+        return null;

+    }

+

+    // private Object getObject() {

+    // boolean r = true;

+    // for(int i = 0; i < fs.length; i++) {

+    // r = r && ((Boolean) fs[i].getObject()).booleanValue();

+    // }

+    // return new Boolean(r);

+    // }

+

+    public Properties getProps() {

+        Properties props = new Properties();

+        props.put("result", new Boolean(check()));

+        props.put("voidB", new Integer(simpleB));

+        props.put("objectB", new Integer(objectB));

+        props.put("refB", new Integer(refB));

+        props.put("bothB", new Integer(bothB));

+        props.put("voidU", new Integer(simpleU));

+        props.put("objectU", new Integer(objectU));

+        props.put("refU", new Integer(refU));

+        props.put("bothU", new Integer(bothU));

+        props.put("boolean", new Boolean(getBoolean()));

+        props.put("int", new Integer(getInt()));

+        props.put("long", new Long(getLong()));

+        props.put("double", new Double(getDouble()));

+

+        return props;

+    }

+

+    public void voidBind() {

+       // simpleB++;

+    }

+

+    public void voidUnbind() {

+       // simpleU++;

+    }

+

+    public void objectBind(FooService o) {

+        if (o != null && o instanceof FooService) {

+     //       objectB++;

+        }

+    }

+

+    public void objectUnbind(FooService o) {

+        if (o != null && o instanceof FooService) {

+    //        objectU++;

+        }

+    }

+

+    public void refBind(ServiceReference sr) {

+        if (sr != null) {

+            refB++;

+        }

+    }

+

+    public void refUnbind(ServiceReference sr) {

+        if (sr != null) {

+            refU++;

+        }

+    }

+

+    public void bothBind(FooService o, ServiceReference sr) {

+        if (o != null && o instanceof FooService && sr != null) {

+            bothB++;

+        }

+    }

+

+    public void bothUnbind(FooService o, ServiceReference sr) {

+        if (o != null && o instanceof FooService && sr != null) {

+            bothU++;

+        }

+    }

+

+}

diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyTestSuite.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyTestSuite.java
index d19c752..ae38291 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyTestSuite.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyTestSuite.java
@@ -47,6 +47,8 @@
         ots.addTestSuite(MethodDelayedOptionalMultipleDependencies.class);

         ots.addTest(DefaultImplementationTestSuite.suite(bc));

         ots.addTestSuite(DependencyArchitectureTest.class);

+        ots.addTestSuite(ListMultipleDependencies.class);

+        ots.addTestSuite(VectorMultipleDependencies.class);

 		return ots;

 	}

 

diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ListMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ListMultipleDependencies.java
new file mode 100644
index 0000000..47b11ff
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ListMultipleDependencies.java
@@ -0,0 +1,248 @@
+/* 

+ * 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.ipojo.test.scenarios.service.dependency;

+

+import java.util.Properties;

+

+import org.apache.felix.ipojo.ComponentInstance;

+import org.apache.felix.ipojo.architecture.Architecture;

+import org.apache.felix.ipojo.architecture.InstanceDescription;

+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;

+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;

+import org.apache.felix.ipojo.test.scenarios.util.Utils;

+import org.osgi.framework.ServiceReference;

+

+public class ListMultipleDependencies extends OSGiTestCase {

+

+	ComponentInstance instance1, instance2;

+	ComponentInstance fooProvider1, fooProvider2;

+	

+	public void setUp() {

+		try {

+			Properties prov = new Properties();

+			prov.put("name", "FooProvider1");

+			fooProvider1 = Utils.getFactoryByName(context, "FooProviderType-1").createComponentInstance(prov);

+			fooProvider1.stop();

+		

+			Properties prov2 = new Properties();

+			prov2.put("name", "FooProvider2");

+			fooProvider2 = Utils.getFactoryByName(context, "FooProviderType-1").createComponentInstance(prov2);

+			fooProvider2.stop();

+		

+			Properties i1 = new Properties();

+			i1.put("name", "Simple");

+			instance1 = Utils.getFactoryByName(context, "SimpleListCheckServiceProvider").createComponentInstance(i1);

+			

+			Properties i2 = new Properties();

+            i2.put("name", "Optional");

+            instance2 = Utils.getFactoryByName(context, "OptionalListCheckServiceProvider").createComponentInstance(i2);

+		} catch(Exception e) { fail(e.getMessage()); }

+		

+	}

+	

+	public void tearDown() {

+		instance1.dispose();

+		instance2.dispose();

+		fooProvider1.dispose();

+		fooProvider2.dispose();

+		instance1 = null;

+		instance2 = null;

+		fooProvider1 = null;

+		fooProvider2 = null;

+	}

+	

+	public void testSimple() {

+		ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance1.getInstanceName());

+		assertNotNull("Check architecture availability", arch_ref);

+		InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

+		

+		fooProvider1.start();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+		

+		ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+		assertNotNull("Check CheckService availability", cs_ref);

+		CheckService cs = (CheckService) context.getService(cs_ref);

+		Properties props = cs.getProps();

+		//Check properties

+		assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here

+		assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);

+		assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);

+		assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);

+		assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);

+		assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);

+		assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);

+		assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);

+		assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);

+		assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);

+		

+		fooProvider2.start();

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+		

+		cs = (CheckService) context.getService(cs_ref);

+		props = cs.getProps();

+		//Check properties

+		assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here

+		assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);

+		assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);

+		assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);

+		assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);

+		assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);

+		assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);

+		assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);

+		assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);

+		assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);

+		

+		fooProvider1.stop();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+		

+		cs = (CheckService) context.getService(cs_ref);

+		props = cs.getProps();

+		//Check properties

+		assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here

+		assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);

+		assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);

+		assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);

+		assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);

+		assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);

+		assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);

+		assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);

+		assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);

+		assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);

+		

+		fooProvider2.stop();

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);

+		

+		id = null;

+		cs = null;

+		context.ungetService(arch_ref);

+		context.ungetService(cs_ref);

+	}

+	

+	public void testOptional() {

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

+        CheckService cs = (CheckService) context.getService(cs_ref);

+        Properties props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider

+        assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);

+        assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);

+        assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);

+        assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);

+        assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);

+        assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);

+        assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);

+        assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);

+        assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);

+        

+        fooProvider1.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        

+        cs = (CheckService) context.getService(cs_ref);

+        props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here

+        assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);

+        assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);

+        assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);

+        assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);

+        assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);

+        assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);

+        assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);

+        assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);

+        assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);

+        

+        fooProvider2.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        

+        cs = (CheckService) context.getService(cs_ref);

+        props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here

+        assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);

+        assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);

+        assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);

+        assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);

+        assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);

+        assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);

+        assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);

+        assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);

+        assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        

+        cs = (CheckService) context.getService(cs_ref);

+        props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, it still one provider.

+        assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);

+        assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);

+        assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);

+        assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);

+        assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);

+        assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);

+        assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);

+        assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);

+        assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+        

+        cs = (CheckService) context.getService(cs_ref);

+        props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False, no more provider.

+        assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 0);

+        assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 0);

+        assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);

+        assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);

+        assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);

+        assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);

+        assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);

+        assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);

+        assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);

+        

+        id = null;

+        cs = null;

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);       

+    }

+	

+}

diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/VectorMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/VectorMultipleDependencies.java
new file mode 100644
index 0000000..e83c480
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/VectorMultipleDependencies.java
@@ -0,0 +1,248 @@
+/* 

+ * 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.ipojo.test.scenarios.service.dependency;

+

+import java.util.Properties;

+

+import org.apache.felix.ipojo.ComponentInstance;

+import org.apache.felix.ipojo.architecture.Architecture;

+import org.apache.felix.ipojo.architecture.InstanceDescription;

+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;

+import org.apache.felix.ipojo.test.scenarios.service.dependency.service.CheckService;

+import org.apache.felix.ipojo.test.scenarios.util.Utils;

+import org.osgi.framework.ServiceReference;

+

+public class VectorMultipleDependencies extends OSGiTestCase {

+

+	ComponentInstance instance1, instance2;

+	ComponentInstance fooProvider1, fooProvider2;

+	

+	public void setUp() {

+		try {

+			Properties prov = new Properties();

+			prov.put("name", "FooProvider1");

+			fooProvider1 = Utils.getFactoryByName(context, "FooProviderType-1").createComponentInstance(prov);

+			fooProvider1.stop();

+		

+			Properties prov2 = new Properties();

+			prov2.put("name", "FooProvider2");

+			fooProvider2 = Utils.getFactoryByName(context, "FooProviderType-1").createComponentInstance(prov2);

+			fooProvider2.stop();

+		

+			Properties i1 = new Properties();

+			i1.put("name", "Simple");

+			instance1 = Utils.getFactoryByName(context, "SimpleVectorCheckServiceProvider").createComponentInstance(i1);

+			

+			Properties i2 = new Properties();

+            i2.put("name", "Optional");

+            instance2 = Utils.getFactoryByName(context, "OptionalVectorCheckServiceProvider").createComponentInstance(i2);

+		} catch(Exception e) { fail(e.getMessage()); }

+		

+	}

+	

+	public void tearDown() {

+		instance1.dispose();

+		instance2.dispose();

+		fooProvider1.dispose();

+		fooProvider2.dispose();

+		instance1 = null;

+		instance2 = null;

+		fooProvider1 = null;

+		fooProvider2 = null;

+	}

+	

+	public void testSimple() {

+		ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance1.getInstanceName());

+		assertNotNull("Check architecture availability", arch_ref);

+		InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

+		

+		fooProvider1.start();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+		

+		ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());

+		assertNotNull("Check CheckService availability", cs_ref);

+		CheckService cs = (CheckService) context.getService(cs_ref);

+		Properties props = cs.getProps();

+		//Check properties

+		assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here

+		assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);

+		assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);

+		assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);

+		assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);

+		assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);

+		assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);

+		assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);

+		assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);

+		assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);

+		

+		fooProvider2.start();

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+		

+		cs = (CheckService) context.getService(cs_ref);

+		props = cs.getProps();

+		//Check properties

+		assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here

+		assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);

+		assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);

+		assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);

+		assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);

+		assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);

+		assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);

+		assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);

+		assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);

+		assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);

+		

+		fooProvider1.stop();

+		

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+		

+		cs = (CheckService) context.getService(cs_ref);

+		props = cs.getProps();

+		//Check properties

+		assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here

+		assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);

+		assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);

+		assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);

+		assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);

+		assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);

+		assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);

+		assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);

+		assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);

+		assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);

+		

+		fooProvider2.stop();

+		id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+		assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);

+		

+		id = null;

+		cs = null;

+		context.ungetService(arch_ref);

+		context.ungetService(cs_ref);

+	}

+	

+	public void testOptional() {

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(context, Architecture.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check architecture availability", arch_ref);

+        InstanceDescription id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance2.getInstanceName());

+        assertNotNull("Check CheckService availability", cs_ref);

+        CheckService cs = (CheckService) context.getService(cs_ref);

+        Properties props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider

+        assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);

+        assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);

+        assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);

+        assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);

+        assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);

+        assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);

+        assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);

+        assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);

+        assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0);

+        

+        fooProvider1.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);

+        

+        cs = (CheckService) context.getService(cs_ref);

+        props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here

+        assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);

+        assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);

+        assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);

+        assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);

+        assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);

+        assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);

+        assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);

+        assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);

+        assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 1.0);

+        

+        fooProvider2.start();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);

+        

+        cs = (CheckService) context.getService(cs_ref);

+        props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, two providers are here

+        assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);

+        assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);

+        assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);

+        assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);

+        assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);

+        assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);

+        assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);

+        assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);

+        assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 2.0);

+        

+        fooProvider1.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);

+        

+        cs = (CheckService) context.getService(cs_ref);

+        props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue()); // True, it still one provider.

+        assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);

+        assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);

+        assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);

+        assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);

+        assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);

+        assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);

+        assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);

+        assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);

+        assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 1.0);

+        

+        fooProvider2.stop();

+        

+        id = ((Architecture) context.getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);

+        

+        cs = (CheckService) context.getService(cs_ref);

+        props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation - 4", ((Boolean)props.get("result")).booleanValue()); // False, no more provider.

+        assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 0);

+        assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 0);

+        assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);

+        assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);

+        assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);

+        assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);

+        assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);

+        assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);

+        assertEquals("Check FS invocation (double) - 4", ((Double)props.get("double")).doubleValue(), 0.0);

+        

+        id = null;

+        cs = null;

+        context.ungetService(arch_ref);

+        context.ungetService(cs_ref);       

+    }

+	

+}

diff --git a/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml b/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
index 994afeb..b08fd6e 100644
--- a/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
+++ b/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
@@ -424,4 +424,37 @@
 		<provides />

 	</component>

 	

+	<!-- Aggregate dependency as List -->

+	<component

+		className="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"

+		name="SimpleListCheckServiceProvider" architecture="true">

+		<requires field="fs" interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>

+		<provides />

+	</component>

+	<component

+		className="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"

+		name="OptionalListCheckServiceProvider"

+		architecture="true">

+		<requires interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />

+		<provides />

+	</component>

+	

+		<!-- Aggregate dependency as Vector -->

+	<component

+		className="org.apache.felix.ipojo.test.scenarios.component.VectorCheckService"

+		name="SimpleVectorCheckServiceProvider" architecture="true">

+		<requires field="fs">

+			<callback type="bind" method="objectBind"/>

+			<callback type="unbind" method="objectUnbind"/>

+		</requires>

+		<provides />

+	</component>

+	<component

+		className="org.apache.felix.ipojo.test.scenarios.component.VectorCheckService"

+		name="OptionalVectorCheckServiceProvider"

+		architecture="true">

+		<requires interface="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />

+		<provides />

+	</component>

+	

 </ipojo>