* Fix FELIX-1427
Service dependencies are not able to be injected as smart proxies (generated in bytecode). However the proxies ensure the service object set synchronization.
By default fields now receive proxies (default behavior can be set with the ipojo.depednency.proxy-enabled|disabled system property).

* Fix an interception bug on constructors

* Fix import / package packages of composites and temporal handler as now the core embeds ASM

* Add a classloading issue in the temporal dependencies (Bad classloader)



git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@893960 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Requires.java b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Requires.java
index e65e87e..f7ea606 100644
--- a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Requires.java
+++ b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Requires.java
@@ -19,6 +19,7 @@
 package org.apache.felix.ipojo.annotations;

 

 import java.lang.annotation.ElementType;

+import java.lang.annotation.Inherited;

 import java.lang.annotation.Target;

 import java.util.Comparator;

 

@@ -27,6 +28,7 @@
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>

  */

 @Target(ElementType.FIELD)

+@Inherited

 public @interface Requires {

     

     /**

@@ -84,4 +86,11 @@
      * This attribute is required for Collection field.

      */

     String specification() default "";

+    

+    /**

+     * Set to true if the service dependency is injected

+     * as a proxy.

+     * Default: true

+     */

+    boolean proxy() default true;

 }

diff --git a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Unbind.java b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Unbind.java
index d05ddb6..b44ca3b 100644
--- a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Unbind.java
+++ b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/Unbind.java
@@ -77,5 +77,5 @@
      * Set the from attribute.

      */

     String from() default "";

-

+    

 }

diff --git a/ipojo/api/pom.xml b/ipojo/api/pom.xml
index 2b43bab..af4f11a 100644
--- a/ipojo/api/pom.xml
+++ b/ipojo/api/pom.xml
@@ -58,7 +58,8 @@
               org.apache.felix.ipojo.api.composite,
               org.apache.felix.ipojo.manipulation,
               org.apache.felix.ipojo.manipulation.annotations,
-              org.objectweb.asm.commons, org.objectweb.asm
+              org.objectweb.asm.commons;version=3.0, 
+              org.objectweb.asm;version=3.0
             </Export-Package>
             <Include-Resource> META-INF/LICENSE=LICENSE,
               META-INF/NOTICE=NOTICE, META-INF/LICENSE.asm=LICENSE.asm
diff --git a/ipojo/api/src/main/java/org/apache/felix/ipojo/api/Dependency.java b/ipojo/api/src/main/java/org/apache/felix/ipojo/api/Dependency.java
index cac71d4..724b466 100644
--- a/ipojo/api/src/main/java/org/apache/felix/ipojo/api/Dependency.java
+++ b/ipojo/api/src/main/java/org/apache/felix/ipojo/api/Dependency.java
@@ -116,6 +116,11 @@
      * Does the dependency supports nullable? 
      */
     private boolean m_nullable = true;
+    
+    /**
+     * Does the dependency enables proxy. 
+     */
+    private boolean m_proxy = true;
 
     /**
      * Gets the dependency metadata.
@@ -174,6 +179,9 @@
         if (m_aggregate) {
             dep.addAttribute(new Attribute("aggregate", "true"));
         }
+        if (! m_proxy) {
+            dep.addAttribute(new Attribute("proxy", "false"));
+        }
         if (m_policy != -1) {
             if (m_policy == DYNAMIC) {
                 dep.addAttribute(new Attribute("policy", "dynamic"));
@@ -251,6 +259,17 @@
     }
     
     /**
+     * Sets if the dependency injects proxies.
+     * @param proxy <code>false</code> if the dependency does not
+     * inject proxies but uses direct references.
+     * @return the current dependency object.
+     */
+    public Dependency setProxy(boolean proxy) {
+        m_proxy = proxy;
+        return this;
+    }
+    
+    /**
      * Sets the dependency bind method.
      * @param bind the bind method name
      * @return the current dependency object.
diff --git a/ipojo/arch/pom.xml b/ipojo/arch/pom.xml
index a1e2120..5c9e930 100644
--- a/ipojo/arch/pom.xml
+++ b/ipojo/arch/pom.xml
@@ -84,9 +84,9 @@
             <ipojo>
               <component classname="org.apache.felix.ipojo.arch.ArchCommandImpl" public="false">
                 <Provides />
-                <requires field="m_archs" optional="true" />
-                <requires field="m_factories" optional="true" />
-                <requires field="m_handlers" optional="true" />
+                <requires field="m_archs" optional="true" proxy="false"/>
+                <requires field="m_factories" optional="true" proxy="false"/>
+                <requires field="m_handlers" optional="true" proxy="false"/>
               </component>
               <instance component="org.apache.felix.ipojo.arch.ArchCommandImpl" name="ArchCommand" />
             </ipojo>
diff --git a/ipojo/composite/pom.xml b/ipojo/composite/pom.xml
index d8851a1..a368558 100644
--- a/ipojo/composite/pom.xml
+++ b/ipojo/composite/pom.xml
@@ -80,6 +80,7 @@
               org.apache.felix.ipojo.metadata,
               org.apache.felix.ipojo.parser,
               org.apache.felix.ipojo.util,
+              org.objectweb.asm*;version=3.0,
               org.osgi.framework;version=1.3 </Import-Package>
             <Private-Package>
               org.apache.felix.ipojo.composite.architecture,
@@ -90,7 +91,7 @@
             <Export-Package>
               org.apache.felix.ipojo.composite; version="${ipojo.package.version}" ,
               !org.objectweb.asm.xml*,
-              org.objectweb.asm*;-split-package:=merge-first ,
+              org.objectweb.asm*;version=3.0;-split-package:=merge-first ,
               org.apache.felix.ipojo.manipulation
             </Export-Package>
             <Include-Resource> META-INF/LICENSE=LICENSE,
diff --git a/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionMetadata.java b/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionMetadata.java
index dc1419f..69bc5bb 100644
--- a/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionMetadata.java
+++ b/ipojo/composite/src/main/java/org/apache/felix/ipojo/composite/service/provides/CompositionMetadata.java
@@ -273,6 +273,7 @@
                 Element dep = new Element("requires", "");

                 dep.addAttribute(new Attribute("field", field.getName()));

                 dep.addAttribute(new Attribute("scope", "composite"));

+                dep.addAttribute(new Attribute("proxy", "false"));

                 if (field.getSpecification().isOptional()) {

                     dep.addAttribute(new Attribute("optional", "true"));

                 }

diff --git a/ipojo/core/LICENSE.asm b/ipojo/core/LICENSE.asm
new file mode 100644
index 0000000..cc529ed
--- /dev/null
+++ b/ipojo/core/LICENSE.asm
@@ -0,0 +1,29 @@
+Copyright (c) 2000-2005 INRIA, France Telecom

+All rights reserved.

+

+Redistribution and use in source and binary forms, with or without

+modification, are permitted provided that the following conditions

+are met:

+

+1. Redistributions of source code must retain the above copyright

+   notice, this list of conditions and the following disclaimer.

+

+2. Redistributions in binary form must reproduce the above copyright

+   notice, this list of conditions and the following disclaimer in the

+   documentation and/or other materials provided with the distribution.

+

+3. Neither the name of the copyright holders nor the names of its

+   contributors may be used to endorse or promote products derived from

+   this software without specific prior written permission.

+

+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE

+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF

+THE POSSIBILITY OF SUCH DAMAGE.

diff --git a/ipojo/core/NOTICE b/ipojo/core/NOTICE
index c5f26c0..890f6ac 100644
--- a/ipojo/core/NOTICE
+++ b/ipojo/core/NOTICE
@@ -12,6 +12,10 @@
 Copyright (c) OSGi Alliance (2000, 2007).
 Licensed under the Apache License 2.0.
 
+This product includes software developed at
+Copyright (c) 2000-2005 INRIA, France Telecom
+Licensed under BSD License.
+
 II. Used Software
 
 This product uses software developed at
diff --git a/ipojo/core/pom.xml b/ipojo/core/pom.xml
index 2e41ea2..3edd353 100644
--- a/ipojo/core/pom.xml
+++ b/ipojo/core/pom.xml
@@ -57,6 +57,17 @@
       <artifactId>org.apache.felix.ipojo.metadata</artifactId>
       <version>${pom.version}</version>
     </dependency>
+    <dependency>
+      <groupId>asm</groupId>
+      <artifactId>asm-all</artifactId>
+      <version>3.0</version>
+      <exclusions>
+        <exclusion>
+          <groupId>asm</groupId>
+          <artifactId>asm-tree</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
@@ -102,11 +113,12 @@
               org.apache.felix.ipojo.handlers.configuration; version="${ipojo.package.version}",
               org.apache.felix.ipojo.context; version="${ipojo.package.version}",
               org.osgi.service.cm,
-              org.osgi.service.log
+              org.osgi.service.log,
+              org.objectweb.asm; version=3.0
             </Export-Package>
             <Include-Resource>
               META-INF/LICENSE=LICENSE,
-              META-INF/NOTICE=NOTICE
+              META-INF/NOTICE=NOTICE, META-INF/LICENSE.asm=LICENSE.asm
             </Include-Resource>
             <_donotcopy> (CVS|.svn|.+.bak|~.+|metadata.xml) </_donotcopy>
           </instructions>
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
index 277d0d0..ade79b1 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
@@ -407,6 +407,10 @@
     public String getVersion() {
         return m_version;
     }
+    
+    public ClassLoader getBundleClassLoader() {
+        return m_classLoader;
+    }
 
     /**
      * this class defines the classloader attached to a factory.
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
index 1091ad5..92cebf4 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
@@ -37,7 +37,7 @@
 import org.osgi.framework.BundleContext;
 
 /**
- * This class defines the container of primitive instances. It manages content initialization 
+ * This class defines the container of primitive instances. It manages content initialization
  * and handlers cooperation.
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
@@ -59,7 +59,7 @@
 
     /**
      * The current instance state ({@link ComponentInstance#STOPPED} at the beginning).
-     * Possible value are 
+     * Possible value are
      * <li>{@link ComponentInstance#INVALID}</li>
      * <li>{@link ComponentInstance#VALID}</li>
      * <li>{@link ComponentInstance#DISPOSED}</li>
@@ -77,7 +77,7 @@
      * The instance factory.
      */
     private final ComponentFactory m_factory;
-    
+
     /**
      * The instance description.
      */
@@ -113,7 +113,7 @@
 
     /**
      * The factory method used to create content objects.
-     * If <code>null</code>, the regular constructor is used. 
+     * If <code>null</code>, the regular constructor is used.
      * Once set, this field is immutable.
      */
     private String m_factoryMethod = null;
@@ -129,7 +129,7 @@
     private List m_stateQueue = new ArrayList();
 
     /**
-     * The map of [field, value], storing POJO managed 
+     * The map of [field, value], storing POJO managed
      * field value.
      */
     private Map m_fields = new HashMap();
@@ -167,7 +167,7 @@
 
         // Add the name
         m_name = (String) configuration.get("instance.name");
-        
+
         // Check if an object is injected in the instance
         Object obj = configuration.get("instance.object");
         if (obj != null) {
@@ -248,11 +248,11 @@
      */
     public synchronized Object getFieldValue(String fieldName, Object pojo) {
         Object setByContainer = null;
-        
+
         if (m_fields != null) {
             setByContainer = m_fields.get(fieldName);
         }
-        
+
         if (setByContainer == null && pojo != null) { // In the case of no given pojo, return null.
             // If null either the value was not already set or has the null value.
             try {
@@ -289,13 +289,13 @@
                 m_state = -2; // Temporary state.
             }
         }
-        
+
         // Plug handler descriptions
         Handler[] handlers = getRegistredHandlers();
         for (int i = 0; i < handlers.length; i++) {
             m_description.addHandler(handlers[i].getDescription());
         }
-        
+
         for (int i = 0; i < m_handlers.length; i++) {
             m_handlers[i].addInstanceStateListener(this);
             try {
@@ -306,12 +306,12 @@
                 throw e;
             }
         }
-        
+
         // Is an object already contained (i.e. injected)
         if (m_pojoObjects != null && ! m_pojoObjects.isEmpty()) {
             managedInjectedObject();
         }
-        
+
         for (int i = 0; i < m_handlers.length; i++) {
             if (m_handlers[i].getState() != VALID) {
                 setState(INVALID);
@@ -332,11 +332,11 @@
         synchronized (this) {
             if (m_state == STOPPED) { // Instance already stopped
                 return;
-            } 
+            }
             m_stateQueue.clear();
             m_inTransition = false;
         }
-        
+
         setState(INVALID); // Must be called outside a synchronized block.
 
         // Stop all the handlers
@@ -344,7 +344,7 @@
             m_handlers[i].removeInstanceStateListener(this);
             m_handlers[i].stop();
         }
-        
+
         synchronized (this) {
             m_state = STOPPED;
             if (m_listeners != null) {
@@ -379,11 +379,11 @@
             }
             m_listeners = null;
         }
-        
+
         if (state > STOPPED) { // Valid or invalid
             stop(); // Does not hold the lock.
         }
-        
+
         synchronized (this) {
             m_state = DISPOSED;
         }
@@ -406,9 +406,9 @@
     }
 
     /**
-     * Sets the state of the component instance. 
+     * Sets the state of the component instance.
      * If the state changes, calls the {@link PrimitiveHandler#stateChanged(int)} method on the attached handlers.
-     * This method has a reentrant mechanism. If in the flow of the first call the method is called another times, 
+     * This method has a reentrant mechanism. If in the flow of the first call the method is called another times,
      * the second call is stored and executed after the first one finished.
      * @param state the new state
      */
@@ -489,7 +489,7 @@
 
     /**
      * Checks if the instance is started.
-     * An instance is started if the state is either 
+     * An instance is started if the state is either
      * {@link ComponentInstance#VALID} or {@link ComponentInstance#INVALID}.
      * @return <code>true</code> if the instance is started.
      * @see org.apache.felix.ipojo.ComponentInstance#isStarted()
@@ -556,7 +556,7 @@
         }
         return m_pojoObjects.toArray(new Object[m_pojoObjects.size()]);
     }
-    
+
     /**
      * Creates a POJO objects.
      * This method is not synchronized and does require any locks.
@@ -585,9 +585,9 @@
                         cst.setAccessible(true);
                     }
                     Object[] args = new Object[] { this, m_context };
-                    onEntry(null, m_className,  new Object[] {m_context});
+                    onEntry(null, MethodMetadata.BC_CONSTRUCTOR_ID,  new Object[] {m_context});
                     instance = cst.newInstance(args);
-                    onExit(null, m_className, instance);
+                    onExit(instance, MethodMetadata.BC_CONSTRUCTOR_ID, instance);
                 } catch (NoSuchMethodException e) {
                     // Create an instance if no instance are already created with <init>()BundleContext
                     if (instance == null) {
@@ -596,9 +596,9 @@
                             cst.setAccessible(true);
                         }
                         Object[] args = new Object[] {this};
-                        onEntry(null, m_className, new Object[0]);
+                        onEntry(null, MethodMetadata.EMPTY_CONSTRUCTOR_ID, new Object[0]);
                         instance = cst.newInstance(args);
-                        onExit(null, m_className, instance);
+                        onExit(instance, MethodMetadata.EMPTY_CONSTRUCTOR_ID, instance);
                     }
                 }
             } catch (IllegalAccessException e) {
@@ -712,18 +712,18 @@
     }
 
     /**
-     * Creates an instance of the content. 
+     * Creates an instance of the content.
      * This method needs to be called once only for singleton provided service.
      * This methods call the {@link InstanceManager#createObject()} method, and adds
      * the created object to the {@link InstanceManager#m_pojoObjects} list. Then,
-     * it calls the {@link PrimitiveHandler#onCreation(Object)} methods on attached 
+     * it calls the {@link PrimitiveHandler#onCreation(Object)} methods on attached
      * handlers.
      * @return a new instance or <code>null</code> if an error occurs during the
      * creation.
      */
     public Object createPojoObject() {
         Object instance = createObject();
-        
+
         // Add the new instance in the instance list.
         synchronized (this) {
             if (m_pojoObjects == null) {
@@ -736,10 +736,10 @@
             // This methods must be call without the monitor lock.
             ((PrimitiveHandler) m_handlers[i].getHandler()).onCreation(instance);
         }
-        
+
         return instance;
     }
-    
+
     /**
      * Deletes a POJO object.
      * @param pojo the pojo to remove from the list of created pojos.
@@ -751,11 +751,11 @@
     }
 
     /**
-     * Gets the first object created by the instance. 
+     * Gets the first object created by the instance.
      * If no object created, creates and returns a POJO object.
      * This methods call the {@link InstanceManager#createObject()} method, and adds
      * the created object to the {@link InstanceManager#m_pojoObjects} list. Then,
-     * it calls the {@link PrimitiveHandler#onCreation(Object)} methods on attached 
+     * it calls the {@link PrimitiveHandler#onCreation(Object)} methods on attached
      * handlers.
      * <br/>
      * <p>
@@ -781,11 +781,11 @@
                 newPOJO = true;
             }
         }
-        
+
         // Call createInstance on Handlers :
         for (int i = 0; newPOJO && i < m_handlers.length; i++) {
             ((PrimitiveHandler) m_handlers[i].getHandler()).onCreation(pojo);
-        } 
+        }
         //NOTE this method allows returning a POJO object before calling the onCreation on handler:
         // a second thread get the created object before the first one (which created the object),
         // call onCreation.
@@ -805,52 +805,52 @@
         }
         return m_clazz;
     }
-    
+
     /**
      * Configures an injected object in this container.
      */
     private void managedInjectedObject() {
         Object obj = m_pojoObjects.get(0); // Get first object.
-   
+
         if (! (obj instanceof Pojo)) {
             // Error, the injected object is not a POJO.
             throw new RuntimeException("The injected object in " + m_name + " is not a POJO");
         }
-        
+
         load(); // Load the class.
 
         if (! m_clazz.isInstance(obj)) {
             throw new RuntimeException("The injected object in " + m_name + " is not an instance of " + m_className);
         }
-        
+
         // Call _setInstanceManager
         try {
             Method setIM = m_clazz.getDeclaredMethod("_setInstanceManager", new Class[] {this.getClass()});
             setIM.setAccessible(true); // Necessary as the method is private
             setIM.invoke(obj, new Object[] {this});
         } catch (Exception e) {
-            // If anything wrong happened... 
+            // If anything wrong happened...
             throw new RuntimeException("Cannot attach the injected object with the container of " + m_name + " : " + e.getMessage());
         }
-        
+
         // Call createInstance on Handlers :
         for (int i = 0; i < m_handlers.length; i++) {
             // This methods must be call without the monitor lock.
             ((PrimitiveHandler) m_handlers[i].getHandler()).onCreation(obj);
         }
-        
-        
+
+
     }
 
     /**
      * Registers an handler.
      * This methods is called by handler wanting to monitor
-     * fields and/or methods of the implementation class.  
+     * fields and/or methods of the implementation class.
      * @param handler the handler to register
      * @param fields the field metadata list
      * @param methods the method metadata list
      * @deprecated use {@link InstanceManager#register(FieldMetadata, FieldInterceptor)}
-     * and {@link InstanceManager#register(FieldMetadata, MethodInterceptor)} instead. 
+     * and {@link InstanceManager#register(FieldMetadata, MethodInterceptor)} instead.
      */
     public void register(PrimitiveHandler handler, FieldMetadata[] fields, MethodMetadata[] methods) {
         for (int i = 0; fields != null && i < fields.length; i++) {
@@ -861,7 +861,7 @@
         }
 
     }
-    
+
     /**
      * Registers a field interceptor.
      * A field interceptor will be notified of field access of the
@@ -890,7 +890,7 @@
             }
         }
     }
-    
+
     /**
      * Registers a method interceptor.
      * A method interceptor will be notified of method entries, exits
@@ -989,6 +989,7 @@
         }
         MethodInterceptor[] list = (MethodInterceptor[]) m_methodRegistration.get(methodId);
         Method method = getMethodById(methodId);
+        // In case of a constructor, the method is null, and the list is null too.
         for (int i = 0; list != null && i < list.length; i++) {
             list[i].onEntry(pojo, method, args); // Outside a synchronized block.
         }
@@ -999,7 +1000,7 @@
      * The given returned object is an instance of {@link Exception} if the method thrown an
      * exception. If the given object is <code>null</code>, either the method returns <code>void</code>,
      * or the method has returned <code>null</code>
-     * This method calls the {@link PrimitiveHandler#onExit(Object, Method, Object[])} and the 
+     * This method calls the {@link PrimitiveHandler#onExit(Object, Method, Object[])} and the
      * {@link PrimitiveHandler#onFinally(Object, Method)} methods on method interceptors monitoring the method.
      * @param pojo the pojo object on which method was invoked.
      * @param methodId the method id used to compute the {@link Method} object.
@@ -1022,14 +1023,14 @@
     /**
      * Dispatches error method events on registered method interceptors.
      * or the method has returned <code>null</code>
-     * This method calls the {@link PrimitiveHandler#onExit(Object, Method, Object[])} and the 
-     * {@link PrimitiveHandler#onFinally(Object, Method)} methods on method interceptors monitoring 
+     * This method calls the {@link PrimitiveHandler#onExit(Object, Method, Object[])} and the
+     * {@link PrimitiveHandler#onFinally(Object, Method)} methods on method interceptors monitoring
      * the method.
      * @param pojo the pojo object on which the method was invoked
      * @param methodId the method id used to compute the {@link Method} object.
      * @param error the Throwable object.
      */
-    public void onError(Object pojo, String methodId, Throwable error) {        
+    public void onError(Object pojo, String methodId, Throwable error) {
         if (m_methodRegistration == null) {
             return;
         }
@@ -1064,7 +1065,7 @@
                 }
             }
             // If not found, it is a constructor, return null in this case.
-            if (methodId.equals(m_clazz.getName())) {
+            if (methodId.startsWith(MethodMetadata.CONSTRUCTOR_PREFIX)) {
                 // Constructor.
                 return null;
             }
@@ -1077,7 +1078,7 @@
     }
 
     /**
-     * This method is called by the manipulated class each time that a PUTFILED instruction is executed. 
+     * This method is called by the manipulated class each time that a PUTFILED instruction is executed.
      * The method calls the {@link PrimitiveHandler#onSet(Object, String, Object)} method on each field
      * interceptors monitoring this field.
      * This method can be invoked with a <code>null</code> pojo argument when the changes comes from another
@@ -1102,7 +1103,7 @@
         }
     }
 
-    
+
     /**
      * Gets the bundle context used by this component instance.
      * @return the context of the component.
@@ -1121,8 +1122,8 @@
     public BundleContext getGlobalContext() {
         return ((IPojoContext) m_context).getGlobalContext(); // Immutable
     }
-    
-    
+
+
     /**
      * Gets the local service context. This service context gives
      * access to the 'local' service registry (the composite one).
@@ -1151,8 +1152,8 @@
      * such as the instance name.
      * This methods calls the {@link PrimitiveHandler#reconfigure(Dictionary)}
      * methods on each attached handler, and then recompute the instance
-     * state. Note that the reconfiguration process does not deactivate the 
-     * instance. 
+     * state. Note that the reconfiguration process does not deactivate the
+     * instance.
      * @param configuration the new configuration to push
      * @see org.apache.felix.ipojo.ComponentInstance#reconfigure(java.util.Dictionary)
      */
@@ -1177,7 +1178,7 @@
     /**
      * Gets the implementation class of the component type.
      * This method does not need to be synchronized as the
-     * class name is constant once set. 
+     * class name is constant once set.
      * @return the class name of the component implementation.
      */
     public String getClassName() {
@@ -1222,7 +1223,7 @@
     }
 
     /**
-     * Gets the list of registered fields (containing field names). 
+     * Gets the list of registered fields (containing field names).
      * This method is invoked by the POJO itself during
      * its initialization.
      * @return the set of registered fields.
@@ -1235,7 +1236,7 @@
     }
 
     /**
-     * Gets the list of registered methods (containing method ids). 
+     * Gets the list of registered methods (containing method ids).
      * This method is invoked by the POJO itself during its
      * initialization.
      * @return the set of registered methods.
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 3b3e4ae..b023592 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
@@ -19,6 +19,7 @@
 package org.apache.felix.ipojo.handlers.dependency;
 
 import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
@@ -111,6 +112,16 @@
      * Immutable once set.
      */
     private String m_id;
+    
+    /**
+     * Do we have to inject proxy?
+     */
+    private boolean m_isProxy;
+    
+    /**
+     * Proxy Object.
+     */
+    private Object m_proxyObject;
 
     /**
      * Dependency constructor. After the creation the dependency is not started.
@@ -122,22 +133,25 @@
      * @param isOptional : is the dependency an optional dependency ?
      * @param isAggregate : is the dependency an aggregate dependency
      * @param nullable : describe if the nullable ability is enable or disable
+     * @param isProxy : is the proxied dependency
      * @param identity : id of the dependency, may be null
      * @param context : bundle context (or service context) to use.
      * @param policy : resolution policy
      * @param cmp : comparator to sort references
      * @param defaultImplem : default-implementation class
      */
-    public Dependency(DependencyHandler handler, String field, Class spec, Filter filter, boolean isOptional, boolean isAggregate, boolean nullable, String identity, BundleContext context, int policy, Comparator cmp, String defaultImplem) {
+    public Dependency(DependencyHandler handler, String field, Class spec, Filter filter, boolean isOptional, boolean isAggregate, boolean nullable, boolean isProxy, String identity, BundleContext context, int policy, Comparator cmp, String defaultImplem) {
         super(spec, isAggregate, isOptional, filter, cmp, policy, context, handler, handler.getInstanceManager());
         m_handler = handler;
         m_field = field;
+        m_isProxy = isProxy;
+
         if (field != null) {
             m_usage = new ServiceUsage();
         } else {
             m_usage = null;
         }
-
+        
         m_supportNullable = nullable;
         m_di = defaultImplem;
 
@@ -321,6 +335,7 @@
      * Start the dependency.
      */
     public void start() {
+        
         if (isOptional() && !isAggregate()) {
             if (m_di == null) {
                 // If nullable are supported, create the nullable object.
@@ -357,6 +372,15 @@
                 }
             }
         }
+        
+        if (m_isProxy) {
+            if (isAggregate()) {
+                m_proxyObject = new ServiceCollection(this);
+            } else {
+                ProxyFactory proxyFactory = new ProxyFactory(this.getClass().getClassLoader());
+                m_proxyObject = proxyFactory.getProxy(getSpecification(), this);
+            }
+        }
 
         super.start();
         // Once the dependency is started, access to fields must be synchronized.
@@ -463,6 +487,84 @@
             return Arrays.asList(refs);
         }
     }
+    
+    /**
+     * Called by the proxy to get  service objects to delegate a method.
+     * On aggregate dependencies, it returns a list.
+     * @return a service object or a nullable/default-implementation object.
+     * For aggregate dependencies it returns a list or an empty list.
+     */
+    public Object getService() {
+        // Check that we're in proxy mode.
+        if (! m_isProxy) {
+            throw new IllegalStateException("The dependency is not a proxied dependency");
+        }
+        
+        Usage usage = (Usage) m_usage.get();
+        if (usage.m_stack == 0) { // uninitialized usage.
+            if (usage.m_componentStack > 0) {
+                // We comes from the component who didn't touch the service.
+                // So we initialize the usage.
+                createServiceObject(usage);
+                usage.inc(); // Start the caching, so set the stack level to 1
+                m_usage.set(usage);
+                if (isAggregate()) {
+                    Object obj =  usage.m_object;
+                    if (obj instanceof Set) {
+                        List list = new ArrayList();
+                        list.addAll((Set) obj);
+                        return list;
+                    } else {
+                        // We already have a list
+                        return obj;
+                    }
+                } else {
+                    return usage.m_object;
+                }
+            } else {
+                // External access => Immediate get.
+                if (isAggregate()) {
+                    ServiceReference[] refs = getServiceReferences();
+                    if (refs == null) {
+                        return new ArrayList(0); // Create an empty list.
+                    } else {
+                        List objs = new ArrayList(refs.length);
+                        for (int i = 0; refs != null && i < refs.length; i++) {
+                            ServiceReference ref = refs[i];
+                            objs.add(getService(ref));
+                        }
+                        return objs;
+                    } 
+                } else { // Scalar dependency.
+                    ServiceReference ref = getServiceReference();
+                    if (ref != null) {
+                        return getService(ref);
+                    } else {
+                        // No service available.
+                        // TODO Decide what we have to do.
+                        throw new RuntimeException("Service " + getSpecification() + " unavailable"); 
+                    }
+                }
+            }
+        } else {
+            // Use the copy.
+            // if the copy is a set, transform to a list
+            if (isAggregate()) {
+                Object obj =  usage.m_object;
+                if (obj instanceof Set) {
+                    List list = new ArrayList();
+                    list.addAll((Set) obj);
+                    return list;
+                } else {
+                    // We already have a list
+                    return obj;
+                }
+            } else {
+                return usage.m_object;
+            }
+            
+        }
+    }
 
     /**
      * This method is called by the replaced code in the component
@@ -474,6 +576,7 @@
      * @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.
         Usage usage = (Usage) m_usage.get();
         if (usage.m_stack == 0) { // uninitialized usage.
@@ -481,8 +584,11 @@
             usage.inc(); // Start the caching, so set the stack level to 1
             m_usage.set(usage);
         }
-
-        return usage.m_object;
+        if (! m_isProxy) {
+            return usage.m_object;
+        } else {
+            return m_proxyObject;
+        }
 
     }
 
@@ -584,6 +690,7 @@
     public void onEntry(Object pojo, Method method, Object[] args) {
         if (m_usage != null) {
             Usage usage = (Usage) m_usage.get();
+            usage.incComponentStack(); // Increment the number of component access.
             if (usage.m_stack > 0) {
                 usage.inc();
                 m_usage.set(usage); // Set the Thread local as value has been modified
@@ -623,6 +730,7 @@
     public void onFinally(Object pojo, Method method) {
         if (m_usage != null) {
             Usage usage = (Usage) m_usage.get();
+            usage.decComponentStack();
             if (usage.m_stack > 0) {
                 if (usage.dec()) {
                     // Exit the method flow => Release all objects
@@ -645,6 +753,14 @@
         return m_di;
     }
 
+    public boolean isProxy() {
+        return m_isProxy;
+    }
+    
+    public void setProxy(boolean proxy) {
+        m_isProxy = proxy;
+    }
+
     /**
      * Set the type to inject.
      * This method set the dependency as aggregate.
@@ -654,5 +770,74 @@
         setAggregate(true);
         m_type = type;
     }
+    
+    /**
+     * Creates proxy object for proxied scalar dependencies.
+     */
+    private class ProxyFactory extends ClassLoader {
+        
+        /**
+         * Handler classloader, used to load the temporal dependency class. 
+         */
+        private ClassLoader m_handlerCL;
+
+        /**
+         * Creates the proxy classloader.
+         * @param parent the handler classloader.
+         */
+        public ProxyFactory(ClassLoader parent) {
+            super(getHandler().getInstanceManager().getFactory().getBundleClassLoader());
+            m_handlerCL = parent;
+        }
+        
+        /**
+         * Loads a proxy class generated for the given (interface) class.
+         * @param clazz the service specification to proxy
+         * @return the Class object of the proxy.
+         */
+        protected Class getProxyClass(Class clazz) {
+            byte[] clz = ProxyGenerator.dumpProxy(clazz); // Generate the proxy.
+            return defineClass(clazz.getName() + "$$Proxy", clz, 0, clz.length);
+        }
+        
+        /**
+         * Create a proxy object for the given specification. The proxy
+         * uses the given dependency to get the service object.  
+         * @param spec the service specification (interface)
+         * @param dep the temporal dependency used to get the service
+         * @return the proxy object.
+         */
+        public Object getProxy(Class spec, Dependency dep) {
+            try {
+                Class clazz = getProxyClass(getSpecification());
+                Constructor constructor = clazz.getConstructor(
+                        new Class[]{clazz.getClassLoader().loadClass(Dependency.class.getName())});                                               
+                return constructor.newInstance(new Object[] {dep});
+            } catch (Throwable e) {
+                m_handler.error("Cannot create the proxy object", e);
+                m_handler.getInstanceManager().stop();
+                return null;
+            }
+        }
+        
+        /**
+         * Loads the given class.
+         * This class use the classloader of the specification class
+         * or the handler class loader.
+         * @param name the class name
+         * @return the class object
+         * @throws ClassNotFoundException if the class is not found by the two classloaders.
+         * @see java.lang.ClassLoader#loadClass(java.lang.String)
+         */
+        public Class loadClass(String name) throws ClassNotFoundException {
+            try {
+                return getHandler().getInstanceManager().getContext().getBundle().loadClass(name);
+            } catch (ClassNotFoundException e) {
+                return m_handlerCL.loadClass(name);
+            }
+        }
+    }
+    
+    
 
 }
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java
index 659c564..c4c4531 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyDescription.java
@@ -54,6 +54,9 @@
     
     public String getId() { return m_dependency.getId(); }
     
+    public boolean isProxy() { return m_dependency.isProxy(); }
+
+    
     /**
      * Gets <code>true</code> if the dependency uses Nullable objects.
      * @return true if the dependency is optional and supports nullable object.
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 e5862b3..cdcee18 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
@@ -49,6 +49,21 @@
 public class DependencyHandler extends PrimitiveHandler implements DependencyStateListener {
 
     /**
+     * Proxy settings property.
+     */
+    public static final String PROXY_SETTINGS_PROPERTY = "ipojo.proxy";
+    
+    /**
+     * Proxy settings value: enabled.
+     */
+    public static final String PROXY_ENABLED = "enabled";
+    
+    /**
+     * Proxy settings value: disabled.
+     */
+    public static final String PROXY_DISABLED = "disabled";
+    
+    /**
      * Dependency field type : Vector
      * The dependency will be injected as a vector.
      */
@@ -174,7 +189,7 @@
      * @return true if the dependency is valid
      * @throws ConfigurationException : the checked dependency is not correct
      */
-    private boolean checkDependency(Dependency dep, PojoMetadata manipulation) throws ConfigurationException {
+    private boolean checkDependency(Dependency dep, PojoMetadata manipulation) throws ConfigurationException {       
         // Check the internal type of dependency
         String field = dep.getField();
         DependencyCallback[] callbacks = dep.getCallbacks();
@@ -225,6 +240,10 @@
             }
             String type = meta.getFieldType();
             if (type.endsWith("[]")) {
+                if (dep.isProxy()) {
+                    warn("Arrays cannot be used for proxied dependencies - Disable the proxy mode");
+                    dep.setProxy(false);
+                }
                 // Set the dependency to multiple
                 dep.setAggregate(true);
                 type = type.substring(0, type.length() - 2);
@@ -233,6 +252,10 @@
                 type = null;
             } else if (type.equals(Vector.class.getName())) {
                 dep.setType(VECTOR);
+                if (dep.isProxy()) {
+                    warn("Vectors cannot be used for proxied dependencies - Disable the proxy mode");
+                    dep.setProxy(false);
+                }
                 type = null;
             } else if (type.equals(Set.class.getName())) {
                 dep.setType(SET);
@@ -246,6 +269,12 @@
             }
             setSpecification(dep, type, true); // Throws an exception if the field type mismatch.
         }
+        
+        // Disables proxy on null (nullable=false)
+        if (dep.isProxy()  && dep.isOptional() && ! dep.supportsNullable()) {
+            dep.setProxy(false);
+            warn("Optional Null Dependencies do not support proxying - Disable the proxy mode");
+        }
 
         // Check that all required info are set
         return dep.getSpecification() != null;
@@ -342,7 +371,29 @@
             
             String nul = deps[i].getAttribute("nullable");
             boolean nullable = nul == null || nul.equalsIgnoreCase("true");
-
+            
+            boolean isProxy = true;
+            // Detect proxy default value.
+            String setting = getInstanceManager().getContext().getProperty(PROXY_SETTINGS_PROPERTY);
+            if (setting == null || PROXY_ENABLED.equals(setting)) { // If not set => Enabled
+                isProxy = true;
+            } else if (setting != null  && PROXY_DISABLED.equals(setting)) {
+                isProxy = false;
+            }
+            
+            String proxy = deps[i].getAttribute("proxy");
+            // If proxy == null, use default value
+            if (proxy != null) {
+                if (proxy.equals("false")) {
+                    isProxy = false;
+                } else if (proxy.equals("true")) {
+                    if (! isProxy) { // The configuration overrides the system setting
+                        warn("The configuration of a service dependency overides the proxy mode");
+                    }
+                    isProxy = true;
+                }   
+            }
+            
             String scope = deps[i].getAttribute("scope");
             BundleContext context = getInstanceManager().getContext(); // Get the default bundle context.
             if (scope != null) {
@@ -401,7 +452,9 @@
 
             int policy = DependencyModel.getPolicy(deps[i]);
             Comparator cmp = DependencyModel.getComparator(deps[i], getInstanceManager().getGlobalContext());
-            Dependency dep = new Dependency(this, field, spec, fil, optional, aggregate, nullable, identitity, context, policy, cmp, defaultImplem);
+
+            
+            Dependency dep = new Dependency(this, field, spec, fil, optional, aggregate, nullable, isProxy, identitity, context, policy, cmp, defaultImplem);
 
             // Look for dependency callback :
             Element[] cbs = deps[i].getElements("Callback");
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandlerDescription.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandlerDescription.java
index 7794f2e..0e6d77d 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandlerDescription.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyHandlerDescription.java
@@ -40,7 +40,7 @@
      */
     private DependencyDescription[] m_dependencies = new DependencyDescription[0];
     
-    // TODO Definie the DependencyStateListener Interface (in ipojo utils)
+    // TODO Define the DependencyStateListener Interface (in ipojo utils)
     
     // TODO Add the list of listener.
     
@@ -123,6 +123,12 @@
                 dep.addAttribute(new Attribute("Aggregate", "false"));
             }
             
+            if (m_dependencies[i].isProxy()) {
+                dep.addAttribute(new Attribute("Proxy", "true"));
+            } else {
+                dep.addAttribute(new Attribute("Proxy", "false"));
+            }
+            
             String policy = "dynamic";
             if (m_dependencies[i].getPolicy() == DependencyModel.STATIC_BINDING_POLICY) {
                 policy = "static";
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/ProxyGenerator.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/ProxyGenerator.java
new file mode 100644
index 0000000..65c20e1
--- /dev/null
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/ProxyGenerator.java
@@ -0,0 +1,181 @@
+/* 
+ * 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.handlers.dependency;
+
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
+
+/**
+ * Generates proxy class delegating operation invocations thanks to a
+ * a dependency.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ProxyGenerator implements Opcodes {
+    
+    /**
+     * The dependency name. 
+     */
+    private static final String DEPENDENCY = "m_dependency";
+    
+    /**
+     * The dependency descriptor.
+     */
+    private static final String DEPENDENCY_DESC = Type.getDescriptor(Dependency.class);
+    
+    /**
+     * Dependency internal class name. 
+     */
+    private static final String DEPENDENCY_INTERNAL_NAME = "org/apache/felix/ipojo/handlers/dependency/Dependency";
+    
+    /**
+     * Gets the internal names of the given class objects. 
+     * @param classes the classes
+     * @return the array containing internal names of the given class array. 
+     */
+    private static String[] getInternalClassNames(Class[] classes) {
+        final String[] names = new String[classes.length];
+        for (int i = 0; i < names.length; i++) {
+            names[i] = Type.getInternalName(classes[i]);
+        }
+        return names;
+    }
+    
+    /**
+     * Generates a proxy class.
+     * @param spec the proxied service specification
+     * @return the byte[] for the generated proxy class.
+     */
+    public static byte[] dumpProxy(Class spec) {
+        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+        String internalClassName = Type.getInternalName(spec); // Specification class internal name.
+        String[] itfs = new String[] {internalClassName};  // Implemented interface.
+        String className = internalClassName + "$$Proxy"; // Unique name.
+        Method[] methods = spec.getMethods(); // Method to delegate
+        
+        cw.visit(Opcodes.V1_3, Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL, className, null, "java/lang/Object", itfs);
+        addDependencyField(cw);
+        generateConstructor(cw, className);
+        
+        // For each method, create the delegator code.
+        for (int i = 0; i < methods.length; i++) {
+            if ((methods[i].getModifiers() & (Modifier.STATIC | Modifier.FINAL)) == 0) {
+                generateDelegator(cw, methods[i], className, internalClassName);
+            }
+        }        
+        
+        cw.visitEnd();
+        
+        return cw.toByteArray();
+        
+    }
+
+    /**
+     * Generates a delegated method.
+     * @param cw the class writer
+     * @param method the method object to delegate
+     * @param className the generated class name
+     * @param itfName the internal specification class name
+     */
+    private static void generateDelegator(ClassWriter cw, Method method,
+            String className, String itfName) {
+        String methodName = method.getName();
+        String desc = Type.getMethodDescriptor(method);
+        String[] exceptions = getInternalClassNames(method.getExceptionTypes());
+        int modifiers = method.getModifiers()
+                & ~(Modifier.ABSTRACT | Modifier.NATIVE | Modifier.SYNCHRONIZED);
+        Type[] types = Type.getArgumentTypes(method);
+
+        int freeRoom = 1;
+        for (int t = 0; t < types.length; t++) {
+            freeRoom = freeRoom + types[t].getSize();
+        }
+
+        MethodVisitor mv = cw.visitMethod(modifiers, methodName, desc, null,
+                exceptions);
+        mv.visitCode();
+
+        mv.visitVarInsn(ALOAD, 0);
+        mv.visitFieldInsn(GETFIELD, className, DEPENDENCY, DEPENDENCY_DESC);  // The dependency is on the stack.
+        mv.visitMethodInsn(INVOKEVIRTUAL, DEPENDENCY_INTERNAL_NAME, "getService", // Call getService
+                "()Ljava/lang/Object;"); // The service object is on the stack.
+        int varSvc = freeRoom; 
+        freeRoom = freeRoom + 1; // Object Reference.
+        mv.visitVarInsn(ASTORE, varSvc); // Store the service object.
+        
+        // Invoke the method on the service object.
+        mv.visitVarInsn(ALOAD, varSvc);
+        // Push argument on the stack.
+        int i = 1; // Arguments. (non static method)
+        for (int t = 0; t < types.length; t++) {
+            mv.visitVarInsn(types[t].getOpcode(ILOAD), i); 
+            i = i + types[t].getSize();
+        }
+        // Invocation
+        mv.visitMethodInsn(INVOKEINTERFACE, itfName, methodName, desc);
+
+        // Return the result
+        Type returnType = Type.getReturnType(desc);
+        if (returnType.getSort() != Type.VOID) {
+            mv.visitInsn(returnType.getOpcode(IRETURN));
+        } else {
+            mv.visitInsn(RETURN);
+        }
+
+        // End of the method.
+        mv.visitMaxs(0, 0);
+        mv.visitEnd();
+    }
+
+    /**
+     * Generates the constructors. The constructor receives a dependency
+     * and set the {@link ProxyGenerator#DEPENDENCY} field.
+     * @param cw the class writer
+     * @param className the generated class name.
+     */
+    private static void generateConstructor(ClassWriter cw, String className) {
+        MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", '(' + DEPENDENCY_DESC + ")V", null, null);
+        mv.visitCode();
+
+        mv.visitVarInsn(ALOAD, 0); // Load this
+        mv.visitInsn(DUP); // Dup
+        mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V"); // Call  super
+        mv.visitVarInsn(ALOAD, 1); // Load the argument
+        mv.visitFieldInsn(PUTFIELD, className, DEPENDENCY, DEPENDENCY_DESC); // Assign the dependency field
+        mv.visitInsn(RETURN); // Return void
+
+        mv.visitMaxs(0, 0);
+        mv.visitEnd();
+    }
+
+    /**
+     * Adds the dependency field {@link ProxyGenerator#DEPENDENCY}.
+     * @param cw the class writer
+     */
+    private static void addDependencyField(ClassWriter cw) {
+        cw.visitField(Opcodes.ACC_FINAL, DEPENDENCY, DEPENDENCY_DESC, null, null);
+        cw.visitEnd();
+    }
+
+}
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/ServiceCollection.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/ServiceCollection.java
new file mode 100644
index 0000000..46451aa
--- /dev/null
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/ServiceCollection.java
@@ -0,0 +1,422 @@
+/* 
+ * 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.handlers.dependency;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Set;
+
+/**
+* Maintains a service object collection.
+* This collection wrap the temporal dependency to be accessible from a
+* {@link Collection}, that can be passed to helper objects (Collaborators).
+* 
+* 
+* The {@link Collection#iterator()} method returns an {@link Iterator} iterating
+* on a cached copy of available service objects. In the case that there are no 
+* available services, the policies act as follows:
+* <ul>
+* <li>'null' returns a null iterator</li>
+* <li>'nullable' and default-implementation returns an iterator iterating on one object (the
+*  nullable or default-implementation object</li>
+* <li>'empty' returns an empty iterator.</li>
+* </ul>
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class ServiceCollection implements Collection, List, Set {
+    
+    /**
+     * The wrapped dependency.
+     */
+    private Dependency m_dependency;
+        
+    /**
+     * Creates a Service Collection.
+     * @param dep the wrapped dependency
+     */
+    public ServiceCollection(Dependency dep) {
+        m_dependency = dep;
+    }
+
+    /**
+     * Unsupported method.
+     * @param o an object
+     * @return N/A
+     * @see java.util.Collection#add(java.lang.Object)
+     */
+    public boolean add(Object o) {
+        throw new UnsupportedOperationException("Cannot add elements inside this collection");
+    }
+
+    /**
+     * Unsupported method.
+     * @param c an object
+     * @return N/A
+     * @see java.util.Collection#addAll(java.util.Collection)
+     */
+    public boolean addAll(Collection c) {
+        throw new UnsupportedOperationException("Cannot add elements inside this collection");
+    }
+    
+    /**
+     * Unsupported method.
+     * @param index an index
+     * @param obj an object
+     * @see java.util.List#add(int, java.lang.Object)
+     */
+    public void add(int index, Object obj) {
+        throw new UnsupportedOperationException("Cannot add elements inside this collection");
+    }
+
+    /**
+     * Unsupported method.
+     * @param index an index
+     * @param c an object
+     * @return N/A
+     * @see java.util.List#addAll(int, java.util.Collection)
+     */
+    public boolean addAll(int index, Collection c) {
+        throw new UnsupportedOperationException("Cannot add elements inside this collection");
+    }
+
+    /**
+     * Unsupported method.
+     * @see java.util.Collection#clear()
+     */
+    public void clear() {
+        throw new UnsupportedOperationException("Cannot remove elements from this collection");
+    }
+
+    /**
+     * Checks if the wrapped dependency has always access to the
+     * given service object.The method allows knowing if the provider returning the
+     * service object has left. 
+     * @param o  the service object
+     * @return <code>true</code> if the object is still available,
+     * <code>false</code> otherwise.
+     * @see java.util.Collection#contains(java.lang.Object)
+     */
+    public boolean contains(Object o) {
+        List list = (List) m_dependency.getService();
+        return list.contains(o);
+    }
+
+    /**
+     * Checks if the wrapped dependencies has always access to the
+     * given service objects.The method allows knowing if providers returning the
+     * service objects have left. 
+     * @param c the set of service object
+     * @return <code>true</code> if the objects are still available,
+     * <code>false</code> otherwise.
+     * @see java.util.Collection#contains(java.lang.Object)
+     */
+    public boolean containsAll(Collection c) {
+        List list = (List) m_dependency.getService();
+        return list.containsAll(c);
+    }
+
+    /**
+     * Checks if at least one provider matching with the dependency
+     * is available.
+     * @return <code>true</code> if one provider or more satisfying the
+     * dependency are available. Otherwise, returns <code>false</code> 
+     * @see java.util.Collection#isEmpty()
+     */
+    public boolean isEmpty() {
+        return m_dependency.getSize() == 0;
+    }
+
+    /**
+     * Gets an iterator on the current list of available service objects.
+     * The returned iterator iterates on a cached copy of the service
+     * objects.
+     * @return a iterator giving access to service objects.
+     * @see java.util.Collection#iterator()
+     */
+    public Iterator iterator() {
+        List obj = (List) m_dependency.getService();
+        return new ServiceIterator(obj); // Create the service iterator with the service reference list.
+    }
+    
+    /**
+     * Unsupported method.
+     * @param o a object
+     * @return N/A
+     * @see java.util.Collection#remove(java.lang.Object)
+     */
+    public boolean remove(Object o) {
+        throw new UnsupportedOperationException("Cannot remove elements from this collection");
+    }
+
+    /**
+     * Unsupported method.
+     * @param index the index
+     * @return N/A
+     * @see java.util.Collection#remove(java.lang.Object)
+     */
+    public Object remove(int index) {
+        throw new UnsupportedOperationException("Cannot remove elements from this collection");
+    }
+
+    /**
+     * Unsupported method.
+     * @param c a set of objects
+     * @return N/A
+     * @see java.util.Collection#removeAll(java.util.Collection)
+     */
+    public boolean removeAll(Collection c) {
+        throw new UnsupportedOperationException("Cannot remove elements from this collection");
+    }
+
+    /**
+     * Unsupported method.
+     * @param c a set of objects
+     * @return N/A
+     * @see java.util.Collection#retainAll(java.util.Collection)
+     */
+    public boolean retainAll(Collection c) {
+        throw new UnsupportedOperationException("Cannot remove elements from this collection");
+    }
+
+    /**
+     * Gets the number of available providers.
+     * @return the number of matching service providers.
+     * @see java.util.Collection#size()
+     */
+    public int size() {
+        return m_dependency.getSize();
+    }
+
+    /**
+     * Returns an array containing available service objects.
+     * This method executed on timeout policies if no matching
+     * providers when the timeout is reached. 
+     * @return a array containing available service objects.
+     * @see java.util.Collection#toArray()
+     */
+    public Object[] toArray() {
+        return toArray(new Object[0]);
+    }
+    
+    /**
+     * Returns an array containing available service objects.
+     * This method executed on timeout policies if no matching
+     * providers when the timeout is reached. 
+     * @param a the array into which the elements of this collection 
+     * are to be stored, if it is big enough; otherwise, a new array
+     * of the same runtime type is allocated for this purpose. 
+     * @return a array containing available service objects.
+     * @see java.util.Collection#toArray(java.lang.Object[])
+     */
+    public Object[] toArray(Object[] a) {
+        List list = (List) m_dependency.getService();
+        return list.toArray(a);
+    }
+    
+    /**
+     * Gets the object stored at the given index.
+     * @param index the index
+     * @return the service object
+     * @see java.util.List#get(int)
+     */
+    public Object get(int index) {
+        List list = (List) m_dependency.getService();
+        return list.get(index);
+    }
+
+    /**
+     * Gets the index of the given object in the current
+     * collection.
+     * @param o the object 
+     * @return the index of the object of <code>-1</code>
+     * if not found.
+     * @see java.util.List#indexOf(java.lang.Object)
+     */
+    public int indexOf(Object o) {
+        List list = (List) m_dependency.getService();
+        return list.indexOf(o);
+    }
+
+    /**
+     * Gets the last index of the given object in the current
+     * collection.
+     * @param o the object 
+     * @return the index of the object of <code>-1</code>
+     * if not found.
+     * @see java.util.List#lastIndexOf(java.lang.Object)
+     */
+    public int lastIndexOf(Object o) {
+        List list = (List) m_dependency.getService();
+        return list.lastIndexOf(o);
+    }
+
+    /**
+     * Gets a list iterator on the current list of available service objects.
+     * The returned iterator iterates on a cached copy of the service
+     * objects.
+     * @return a iterator giving access to service objects.
+     * @see java.util.List#listIterator()
+     */
+    public ListIterator listIterator() {
+        List obj = (List) m_dependency.getService();
+        return new ServiceIterator(obj); // Create the service iterator with the service reference list.
+    }
+
+    /**
+     * Unsupported Method.
+     * @param index an index
+     * @return N/A
+     * @see java.util.List#listIterator(int)
+     */
+    public ListIterator listIterator(int index) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Unsupported Method.
+     * @param arg0 an index
+     * @param arg1 an object
+     * @return N/A
+     * @see java.util.List#set(int, E)
+     */
+    public Object set(int arg0, Object arg1) {
+        throw new UnsupportedOperationException("Cannot add elements inside this collection");
+    }
+
+    /**
+     * Returns a sublist from the current list.
+     * @param fromIndex the index of the list beginning
+     * @param toIndex the index of the list end
+     * @return the sub-list
+     * @see java.util.List#subList(int, int)
+     */
+    public List subList(int fromIndex, int toIndex) {
+        List list = (List) m_dependency.getService();
+        return list.subList(fromIndex, toIndex);
+    }
+
+    /**
+     * Iterator on a set of service objects.
+     * This iterator iterates on a cached copy of service objects.
+     */
+    private final class ServiceIterator implements ListIterator {
+        
+        /**
+         * Underlying iterator.
+         */
+        private ListIterator m_iterator;
+        
+        /**
+         * Creates a Service Iterator iterating
+         * on the given set of providers.
+         * @param list the list of service object.
+         */
+        private ServiceIterator(List list) {           
+            m_iterator = list.listIterator();
+        }
+
+        /**
+         * Returns <code>true</code> if the iteration has 
+         * more service objects. 
+         * @return <code>true</code> if the iterator has more elements.
+         * @see java.util.Iterator#hasNext()
+         */
+        public boolean hasNext() {
+            return m_iterator.hasNext();
+        }
+
+        /**
+         * Returns the next service objects in the iteration. 
+         * @return the next service object in the iteration. 
+         * @see java.util.Iterator#next()
+         */
+        public Object next() {
+            return m_iterator.next();
+        }
+
+        /**
+         * Unsupported operation.
+         * @see java.util.Iterator#remove()
+         */
+        public void remove() {
+            throw new UnsupportedOperationException();            
+        }
+
+        /**
+         * Unsupported operation.
+         * @param obj an object
+         * @see java.util.ListIterator#add(E)
+         */
+        public void add(Object obj) {
+            throw new UnsupportedOperationException();                        
+        }
+
+        /**
+         * Checks if the is an element before the currently 
+         * pointed one.
+         * @return true if there is an element before the
+         * current one.
+         * @see java.util.ListIterator#hasPrevious()
+         */
+        public boolean hasPrevious() {
+            return m_iterator.hasPrevious();
+        }
+
+        /**
+         * Gets the index of the next element.
+         * @return the index of the next element.
+         * @see java.util.ListIterator#nextIndex()
+         */
+        public int nextIndex() {
+            return m_iterator.nextIndex();
+        }
+
+        
+        /**
+         * Gets the previous elements.
+         * @return the previous element
+         * @see java.util.ListIterator#previous()
+         */
+        public Object previous() {
+            return m_iterator.previous();
+        }
+
+        /**
+         * Gets the index of the previous element.
+         * @return the index of the previous element.
+         * @see java.util.ListIterator#previousIndex()
+         */
+        public int previousIndex() {
+            return m_iterator.previousIndex();
+        }
+
+        /**
+         * Unsupported operation.
+         * @param obj an object
+         * @see java.util.ListIterator#set(E)
+         */
+        public void set(Object obj) {
+            throw new UnsupportedOperationException();  
+        }
+                  
+    }
+
+}
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 b681f59..3757e77 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
@@ -41,13 +41,27 @@
         Object m_object;

         

         /**

-         * Increment the stack level.

+         * Tracks the number of component method called

+         * in the current thread.

+         */

+        int m_componentStack = 0;

+        

+        /**

+         * Increment the stack level from the first

+         * service get.

          */

         public void inc() {

             m_stack++;

         }

         

         /**

+         * Increment the component stack level.

+         */

+        public void incComponentStack() {

+            m_componentStack++;

+        }

+        

+        /**

          * Decrement the stack level.

          * @return  true if the stack is 0 after the decrement.

          */

@@ -57,6 +71,15 @@
         }

         

         /**

+         * Decrement the component stack level.

+         * @return  true if the stack is 0 after the decrement.

+         */

+        public boolean decComponentStack() {

+            m_componentStack--;

+            return m_componentStack == 0;

+        }

+        

+        /**

          * Clear the service object array.

          */

         public void clear() {

diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/MethodMetadata.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/MethodMetadata.java
index e92363c..ab8eb76 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/MethodMetadata.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/MethodMetadata.java
@@ -28,6 +28,21 @@
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public class MethodMetadata {
+    
+    /**
+     * Empty Constructor Method Id.
+     */
+    public static final String EMPTY_CONSTRUCTOR_ID = "$init";
+
+    /**
+     * Bundle Context Constructor Method Id.
+     */
+    public static final String BC_CONSTRUCTOR_ID = "$init$org_osgi_framework_BundleContext";
+    
+    /**
+     * Constructor Prefix.
+     */
+    public static final String CONSTRUCTOR_PREFIX = "$init";
 
     /**
      * The name of the method.
@@ -125,5 +140,4 @@
         }
         return identifier.toString();
     }
-
 }
diff --git a/ipojo/core/src/main/resources/core.xsd b/ipojo/core/src/main/resources/core.xsd
index 2f3491f..5d51779 100644
--- a/ipojo/core/src/main/resources/core.xsd
+++ b/ipojo/core/src/main/resources/core.xsd
@@ -260,6 +260,13 @@
                       <xs:documentation>Specific service provider. The dependency can only be fulfilled by the component with the matching name, or by the service with a matching PID.</xs:documentation>
                     </xs:annotation>
         </xs:attribute>
+        
+        <xs:attribute name="proxy" type="xs:boolean"
+          use="optional">
+                    <xs:annotation>
+                      <xs:documentation>Enables or Disable the proxy injection (on field injection)</xs:documentation>
+                    </xs:annotation>
+        </xs:attribute>
 
         <xs:attribute name="scope" use="optional">
           <xs:simpleType>
diff --git a/ipojo/examples/tutorial-maven/hello.client.annotation/src/main/java/ipojo/example/hello/client/HelloClient.java b/ipojo/examples/tutorial-maven/hello.client.annotation/src/main/java/ipojo/example/hello/client/HelloClient.java
index 2c3697c..45c7574 100644
--- a/ipojo/examples/tutorial-maven/hello.client.annotation/src/main/java/ipojo/example/hello/client/HelloClient.java
+++ b/ipojo/examples/tutorial-maven/hello.client.annotation/src/main/java/ipojo/example/hello/client/HelloClient.java
@@ -20,6 +20,8 @@
 

 import ipojo.example.hello.Hello;

 

+import java.util.Set;

+

 import org.apache.felix.ipojo.annotations.Component;

 import org.apache.felix.ipojo.annotations.Invalidate;

 import org.apache.felix.ipojo.annotations.Requires;

@@ -38,8 +40,8 @@
     /**

      * Hello services. Injected by the container.

      */

-    @Requires

-    private Hello[] m_hello;

+    @Requires(specification="ipojo.example.hello.Hello", optional=true, defaultimplementation=MyDummyHello.class)

+    private Hello m_hello;

 

     /**

      *  End flag.

@@ -65,9 +67,11 @@
      * Invoke hello services.

      */

     public void invokeHelloServices() {

-        for (int i = 0; i < m_hello.length; i++) {

-            System.out.println(i + " :" + m_hello[i].sayHello("Clement"));

-        }

+        System.out.println(m_hello);

+        Hello hello = m_hello;

+        //for (Hello hello : m_hello) {

+            System.out.println(hello.sayHello("Clement ") + hello);

+        //}

     }

 

     /**

diff --git a/ipojo/examples/tutorial-maven/hello.client.annotation/src/main/java/ipojo/example/hello/client/MyDummyHello.java b/ipojo/examples/tutorial-maven/hello.client.annotation/src/main/java/ipojo/example/hello/client/MyDummyHello.java
new file mode 100644
index 0000000..e59db8a
--- /dev/null
+++ b/ipojo/examples/tutorial-maven/hello.client.annotation/src/main/java/ipojo/example/hello/client/MyDummyHello.java
@@ -0,0 +1,11 @@
+package ipojo.example.hello.client;
+
+import ipojo.example.hello.Hello;
+
+public class MyDummyHello implements Hello {
+
+    public String sayHello(String name) {
+        return "Bonjour";
+    }
+
+}
diff --git a/ipojo/handler/temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalDependency.java b/ipojo/handler/temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalDependency.java
index d821ed1..44767d6 100644
--- a/ipojo/handler/temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalDependency.java
+++ b/ipojo/handler/temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalDependency.java
@@ -125,7 +125,7 @@
         if (! proxy) { // No proxy => initialize the Thread local.
             m_usage = new ServiceUsage();
         } else if (proxy && ! agg) { // Scalar proxy => Create the proxy.
-            ProxyFactory proxyFactory = new ProxyFactory(this.getSpecification().getClassLoader(), this.getClass().getClassLoader());
+            ProxyFactory proxyFactory = new ProxyFactory(this.getClass().getClassLoader());
             m_proxyObject = proxyFactory.getProxy(getSpecification(), this);
         }
     }
@@ -495,23 +495,16 @@
     private class ProxyFactory extends ClassLoader {
         
         /**
-         * Instance classloader, used to load specification and dependent classes.
-         */
-        private ClassLoader m_instanceCL;
-        
-        /**
          * Handler classloader, used to load the temporal dependency class. 
          */
         private ClassLoader m_handlerCL;
         
         /**
          * Creates the proxy classloader.
-         * @param parent1 the instance classloader.
-         * @param parent2 the handler classloader.
+         * @param parent the handler classloader.
          */
-        public ProxyFactory(ClassLoader parent1, ClassLoader parent2) {
-            this.m_instanceCL = parent1;
-            this.m_handlerCL = parent2;
+        public ProxyFactory(ClassLoader parent) {
+            this.m_handlerCL = parent;
         }
         
         /**
@@ -554,7 +547,7 @@
          */
         public Class loadClass(String name) throws ClassNotFoundException {
             try {
-                return m_instanceCL.loadClass(name);
+                return m_handler.getInstanceManager().getContext().getBundle().loadClass(name);
             } catch (ClassNotFoundException e) {
                 return m_handlerCL.loadClass(name);
             }
diff --git a/ipojo/junit4osgi/junit4osgi/metadata.xml b/ipojo/junit4osgi/junit4osgi/metadata.xml
index 7d59467..6497c6e 100644
--- a/ipojo/junit4osgi/junit4osgi/metadata.xml
+++ b/ipojo/junit4osgi/junit4osgi/metadata.xml
@@ -1,36 +1,36 @@
 <!--

-	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.

+  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.

 -->

 <ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

-	xsi:schemaLocation="org.apache.felix.ipojo http://people.apache.org/~clement/ipojo/schemas/core.xsd 

-	    org.apache.felix.ipojo.extender http://people.apache.org/~clement/ipojo/schemas/extender-pattern.xsd"

-	xmlns="org.apache.felix.ipojo"

-	xmlns:extender="org.apache.felix.ipojo.extender">

-	<component

-		classname="org.apache.felix.ipojo.junit4osgi.impl.JunitExtender">

-		<extender:extender extension="Test-Suite"

-			onArrival="onBundleArrival" onDeparture="onBundleDeparture" />

-		<callback transition="invalidate" method="stopping" />

-		<callback transition="validate" method="starting" />

-		<requires field="m_log" optional="true" 

-			default-implementation="org.apache.felix.ipojo.junit4osgi.impl.LogServiceImpl"/>

-		<provides />

-	</component>

-	<instance

-		component="org.apache.felix.ipojo.junit4osgi.impl.JunitExtender" />

-</ipojo>
\ No newline at end of file
+  xsi:schemaLocation="org.apache.felix.ipojo http://people.apache.org/~clement/ipojo/schemas/core.xsd 

+      org.apache.felix.ipojo.extender http://people.apache.org/~clement/ipojo/schemas/extender-pattern.xsd"

+  xmlns="org.apache.felix.ipojo"

+  xmlns:extender="org.apache.felix.ipojo.extender">

+  <component

+    classname="org.apache.felix.ipojo.junit4osgi.impl.JunitExtender">

+    <extender:extender extension="Test-Suite"

+      onArrival="onBundleArrival" onDeparture="onBundleDeparture" />

+    <callback transition="invalidate" method="stopping" />

+    <callback transition="validate" method="starting" />

+    <requires field="m_log" optional="true" 

+      default-implementation="org.apache.felix.ipojo.junit4osgi.impl.LogServiceImpl"/>

+    <provides />

+  </component>

+  <instance

+    component="org.apache.felix.ipojo.junit4osgi.impl.JunitExtender" />

+</ipojo>

diff --git a/ipojo/junit4osgi/maven-junit4osgi-plugin/pom.xml b/ipojo/junit4osgi/maven-junit4osgi-plugin/pom.xml
index 6870a28..8072721 100644
--- a/ipojo/junit4osgi/maven-junit4osgi-plugin/pom.xml
+++ b/ipojo/junit4osgi/maven-junit4osgi-plugin/pom.xml
@@ -67,7 +67,6 @@
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.ipojo.handler.extender</artifactId>
       <version>1.5.0-SNAPSHOT</version>
-      <scope>runtime</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.felix</groupId>
diff --git a/ipojo/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Junit4osgiPlugin.java b/ipojo/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Junit4osgiPlugin.java
index 953926b..3557e8a 100644
--- a/ipojo/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Junit4osgiPlugin.java
+++ b/ipojo/junit4osgi/maven-junit4osgi-plugin/src/main/java/org/apache/felix/ipojo/junit4osgi/plugin/Junit4osgiPlugin.java
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -24,6 +24,7 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -34,11 +35,13 @@
 
 import junit.framework.AssertionFailedError;
 import junit.framework.Test;
+import junit.framework.TestCase;
 import junit.framework.TestFailure;
 import junit.framework.TestListener;
 import junit.framework.TestResult;
 
 import org.apache.felix.framework.Felix;
+import org.apache.felix.ipojo.junit4osgi.OSGiJunitRunner;
 import org.apache.felix.ipojo.junit4osgi.plugin.log.LogServiceImpl;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.AbstractMojo;
@@ -52,153 +55,153 @@
 
 /**
  * Goal starting Felix and executing junit4osgi tests.
- *  
+ *
  * @goal test
  * @phase integration-test
  * @requiresDependencyResolution runtime
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- * 
+ *
  */
 public class Junit4osgiPlugin extends AbstractMojo {
 
     /**
      * The Maven project.
-     * 
+     *
      * @parameter expression="${project}"
      * @required
      * @readonly
      */
     private MavenProject m_project;
-    
+
     /**
-     * Dependencies of the current plugin. 
+     * Dependencies of the current plugin.
      * @parameter expression="${plugin.artifacts}"
      */
     private java.util.List m_pluginArtifacts;
-    
+
     /**
      * Base directory where all reports are written to.
-     * 
+     *
      * @parameter expression="${project.build.directory}/surefire-reports"
      */
     private File m_reportsDirectory;
-    
+
     /**
      * Base directory where all reports are written to.
-     * 
+     *
      * @parameter expression="${project.build.directory}"
      */
     private File m_targetDir;
-    
+
     /**
      * Must the current artifact be deployed?
-     * 
+     *
      * @parameter expression="${deployProjectArtifact}" default-value="true"
      */
     private boolean m_deployProjectArtifact;
-    
+
     /**
      * Required bundles.
-     * 
+     *
      * @parameter
      */
     private List bundles;
-    
+
     /**
      * Felix configuration.
-     * 
+     *
      * @parameter
      */
     private Map configuration;
-    
+
     /**
      * Enables / Disables the log service provided by the plugin.
-     * 
+     *
      * @parameter expression="${logService}" default-value="true"
      */
     private boolean m_logEnable;
-    
+
     /**
      * Number of executed test case.
      */
     private int m_total;
-    
+
     /**
      * Number of failing test case.
      */
     private int m_totalFailures;
-    
+
     /**
      * Number of test case in error .
      */
     private int m_totalErrors;
-    
+
     /**
      * Test results in error.
      */
     private List m_errors = new ArrayList();
-    
+
     /**
-     * Failing test results. 
+     * Failing test results.
      */
     private List m_failures = new ArrayList();
-    
+
     /**
      * Test results.
      */
     private List m_results = new ArrayList();
-    
+
     /**
      * Log Service exposed by the plug-in framework.
      */
     private LogServiceImpl m_logService;
-    
+
     /**
      * Set this to 'true' to bypass unit tests entirely. Its use is NOT RECOMMENDED, especially if you
      * enable it using the "maven.test.skip" property, because maven.test.skip disables both running the
      * tests and compiling the tests.  Consider using the skipTests parameter instead.
-     * 
+     *
      * @parameter expression="${maven.test.skip}"
      */
     private boolean skip;
-    
+
     /**
      * Set this to true to ignore a failure during testing. Its use is NOT RECOMMENDED, but quite convenient on
      * occasion.
-     * 
+     *
      * @parameter expression="${maven.test.failure.ignore}"
      */
     private boolean testFailureIgnore;
-    
+
     /**
      * Set this to avoid printing test execution trace on System.out and System.err. This will be written in the
      * reports.
-     * @parameter 
+     * @parameter
      */
     private boolean hideOutputs;
-    
+
     /**
      * Felix configuration.
      */
     private Map felixConf;
-    
-   
+
+
     /**
      * Executes the plug-in.
      * @throws MojoFailureException when the test execution failed.
      * @see org.apache.maven.plugin.AbstractMojo#execute()
      */
     public void execute() throws MojoFailureException {
-        
+
         if (skip) {
             getLog().info("Tests are skipped");
             return;
         }
-       
-        
+
+
         List bundles = parseBundleList();
         bundles.addAll(getTestBundle());
-        
+
         List activators = new ArrayList();
         m_logService = new LogServiceImpl();
         if (m_logEnable) { // Starts the log service if enabled
@@ -213,13 +216,13 @@
         felixConf.put("ipojo.log.level", "WARNING");
         // Use a boot delagation to share classes between the host and the embedded Felix.
         // The cobertura package is used during code coverage collection
-        //felixConf.put("org.osgi.framework.bootdelegation", "net.sourceforge.cobertura.coveragedata"); 
+        //felixConf.put("org.osgi.framework.bootdelegation", "net.sourceforge.cobertura.coveragedata");
         felixConf.put("org.osgi.framework.system.packages.extra", "org.osgi.service.log;version=1.3, junit.framework;version=1.3");
 
         //felixConf.put("org.osgi.framework.system.packages.extra", "org.osgi.service.log, junit.framework");
-        
-        felixConf.put("org.osgi.framework.storage", m_targetDir.getAbsolutePath() + "/felix-cache"); 
-        
+
+        felixConf.put("org.osgi.framework.storage", m_targetDir.getAbsolutePath() + "/felix-cache");
+
         felixConf.put(Constants.FRAMEWORK_BUNDLE_PARENT, Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK);
 
         if (configuration != null) {
@@ -236,25 +239,35 @@
 //                bd.concat(", net.sourceforge.cobertura.coveragedata");
 //            }
         }
-        
+
         System.out.println("");
         System.out.println("-------------------------------------------------------");
-        System.out.println(" T E S T S");        
+        System.out.println(" T E S T S");
         System.out.println("-------------------------------------------------------");
-        
+
         Felix felix = new Felix(felixConf);
         try {
             felix.start();
         } catch (BundleException e) {
             e.printStackTrace();
         }
-        
+
+        getLog().info("Felix started - Waiting for stability");
+
         waitForStability(felix.getBundleContext());
-        
+
+        getLog().info("Bundle Stability Reached - Waiting for runner service");
 
         Object runner = waitForRunnerService(felix.getBundleContext());
+
+        if (runner == null) {
+            throw new MojoFailureException("Cannot intialize the testing framework");
+        }
+
+        getLog().info("Runner Service available");
+
         invokeRun(runner, felix.getBundleContext());
-                
+
         try {
             felix.stop();
             felix.waitForStop(5000);
@@ -264,7 +277,7 @@
         } catch (Exception e) {
             getLog().error(e);
         }
-        
+
         if (m_totalErrors > 0 || m_totalFailures > 0) {
             if (! testFailureIgnore) {
             throw new MojoFailureException("There are test failures. \n\n"
@@ -278,7 +291,7 @@
         }
 
     }
-    
+
     /**
      * Waits for stability:
      * <ul>
@@ -303,13 +316,22 @@
             count++;
             bundleStability = getBundleStability(context);
         }
-        
+
         if (count == 500) {
             getLog().error("Bundle stability isn't reached after 500 tries");
             dumpBundles(context);
             throw new MojoFailureException("Cannot reach the bundle stability");
         }
-        
+
+        //DEBUG
+        Bundle[] bundles = context.getBundles();
+        getLog().debug("Bundles List");
+        for (int i = 0; i < bundles.length; i++) {
+            getLog().debug(bundles[i].getSymbolicName() + " - " + bundles[i].getVersion() + " - " + bundles[i].getState());
+        }
+        getLog().debug("--------------");
+        // END DEBUG
+
         boolean serviceStability = false;
         count = 0;
         int count1 = 0;
@@ -329,15 +351,30 @@
             }
             count++;
         }
-        
+
         if (count == 500) {
             getLog().error("Service stability isn't reached after 500 tries (" + count1 + " != " + count2);
             dumpBundles(context);
             throw new MojoFailureException("Cannot reach the service stability");
         }
-        
+
+        try {
+            ServiceReference[] refs = context.getServiceReferences(null, null);
+            getLog().debug("Service List");
+            for (int i = 0; i < refs.length; i++) {
+                String[] itfs = (String[]) refs[i].getProperty(Constants.OBJECTCLASS);
+                List list = Arrays.asList(itfs); 
+                if (list.contains("org.apache.felix.ipojo.architecture.Architecture")) {
+                    getLog().debug(list.toString() + " - " + refs[i].getProperty("architecture.instance"));
+                } else {
+                    getLog().debug(list.toString());
+                }
+            }
+            getLog().debug("--------------");
+        } catch (Exception e) {}
+
     }
-    
+
     /**
      * Are bundle stables.
      * @param bc the bundle context
@@ -362,7 +399,6 @@
         if (bundles == null) {
             return toDeploy;
         }
-        System.out.println("Deploy URL bundles " + bundles); // TODO
         for (int i = 0; i < bundles.size(); i++) {
             String bundle = (String) bundles.get(i);
             try {
@@ -373,12 +409,12 @@
                 getLog().error(bundle + " is not a valid url, bundle ignored");
             }
         }
-        
+
         return toDeploy;
     }
-    
+
     /**
-     * Computes the URL list of bundles to install from 
+     * Computes the URL list of bundles to install from
      * <code>test</code> scoped dependencies.
      * @return the list of url of bundles to install.
      */
@@ -394,7 +430,7 @@
                         if (file.getName().endsWith("jar")) {
                             JarFile jar = new JarFile(file);
                             if (jar.getManifest().getMainAttributes().getValue("Bundle-ManifestVersion") != null) {
-                                toDeploy.add(file.toURL());
+                                toDeploy.add(file.toURI().toURL());
                             }
                         } // else {
 //                            getLog().info("The artifact " + artifact.getFile().getName() + " is not a Jar file.");
@@ -409,7 +445,7 @@
         }
         return toDeploy;
     }
-    
+
     /**
      * Waits until the {@link OSGiJunitRunner} service
      * is published.
@@ -422,6 +458,7 @@
         while (ref == null && count < 1000) {
             try {
                 Thread.sleep(5);
+                count++;
             } catch (InterruptedException e) {
                 // Nothing to do
             }
@@ -433,7 +470,7 @@
         getLog().error("Junit Runner service unavailable");
         return null;
     }
-    
+
     /**
      * Executes tests by using reflection.
      * @param runner the {@link OSGiJunitRunner} service object
@@ -441,7 +478,7 @@
      */
     private void invokeRun(Object runner, BundleContext bc) {
         Method getTest;
-        
+
         try {
             getTest = runner.getClass().getMethod("getTests", new Class[0]);
             List tests = (List) getTest.invoke(runner, new Object[0]);
@@ -461,7 +498,7 @@
                     }
                 }
             }
-            
+
             if (m_failures.size() > 0) {
                 System.out.println("\nTests in error:");
                 for (int i = 0; i < m_errors.size(); i++) {
@@ -473,15 +510,15 @@
                     }
                 }
             }
-            
-            System.out.println("\nTests run: " + m_total + ", Failures: " + m_totalFailures + ", Errors:" + m_totalErrors + "\n");          
+
+            System.out.println("\nTests run: " + m_total + ", Failures: " + m_totalFailures + ", Errors:" + m_totalErrors + "\n");
         } catch (Exception e) {
             getLog().error(e);
-        } 
+        }
     }
-    
+
     /**
-     * Gets the {@link OSGiJunitRunner#run(long)} method from the 
+     * Gets the {@link OSGiJunitRunner#run(long)} method from the
      * {@link OSGiJunitRunner} service object.
      * @param runner the {@link OSGiJunitRunner} service object.
      * @return the Method object for the <code>run</code> method.
@@ -489,7 +526,7 @@
     private Method getRunMethod(Object runner) {
         Method[] methods = runner.getClass().getMethods();
         for (int i = 0; i < methods.length; i++) {
-            if (methods[i].getName().equals("run") 
+            if (methods[i].getName().equals("run")
                     && methods[i].getParameterTypes().length == 1
                     && ! methods[i].getParameterTypes()[0].equals(Long.TYPE)) {
                 return methods[i];
@@ -498,7 +535,7 @@
         getLog().error("Cannot find the run method");
         return null;
     }
-    
+
     /**
      * Computes the name of the given test.
      * This method calls the {@link TestCase#getName()}
@@ -519,9 +556,9 @@
             getLog().error(e);
             return null;
         }
-            
+
     }
-    
+
     /**
      * Executes the given test.
      * @param runner the {@link OSGiJunitRunner} service object
@@ -580,7 +617,7 @@
         }
 
     }
-    
+
     /**
      * Prints the bundle list.
      * @param bc the bundle context.
@@ -592,45 +629,45 @@
             getLog().info(bundles[i].getSymbolicName() + " - " + bundles[i].getState());
         }
     }
-    
+
     public LogServiceImpl getLogService() {
         return m_logService;
     }
-    
-    
+
+
     private class ResultListener implements TestListener {
-        
+
         /**
          * The XML Report.
          */
         private XMLReport m_report;
-        
+
         /**
          * Check if the test has failed or thrown an
          * error.
          */
         private boolean m_abort;
-        
+
         /**
          * Backup of the {@link System#out} stream.
          */
         private PrintStream m_outBackup = System.out;
-        
+
         /**
          * Backup of the {@link System#err} stream.
          */
         private PrintStream m_errBackup = System.err;
-        
+
         /**
-         * The output stream used during the test execution. 
+         * The output stream used during the test execution.
          */
         private StringOutputStream m_out = new StringOutputStream();
-        
+
         /**
-         * The error stream used during the test execution. 
+         * The error stream used during the test execution.
          */
         private StringOutputStream m_err = new StringOutputStream();;
-        
+
         /**
          * Creates a ResultListener.
          * @param report the XML report
@@ -660,7 +697,7 @@
                 AssertionFailedError assertionfailederror) {
             m_report.testFailed(test, assertionfailederror, m_out.toString(), m_err.toString(), getLogService().getLoggedMessages());
             m_abort = true;
-            
+
         }
 
         /**
@@ -689,7 +726,7 @@
             System.setOut(new ReportPrintStream(m_out, m_outBackup, hideOutputs));
             getLogService().enableOutputStream();
         }
-        
+
     }
-    
+
 }
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCreator.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCreator.java
index 4d0b960..a80105d 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCreator.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/MethodCreator.java
@@ -316,7 +316,6 @@
             }

         }

         

-        

         mv.visitMaxs(0, 0);

         mv.visitEnd();

     }

@@ -348,7 +347,7 @@
                 ad.visit(mv);

             }

         }

-        

+

         mv.visitMaxs(0, 0);

         mv.visitEnd();

     }

@@ -657,7 +656,6 @@
         }

 

         mv.visitLabel(endif2);

-

         mv.visitInsn(RETURN);

 

         mv.visitMaxs(0, 0);

diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java
index 6dc24c7..3bd0fb5 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java
@@ -157,6 +157,11 @@
         private String m_from;

         

         /**

+         * Proxy attribute.

+         */

+        private String m_proxy;

+        

+        /**

          * Constructor.

          * @param name : field name.

          */

@@ -209,6 +214,10 @@
                 m_from = arg1.toString();

                 return;

             }

+            if (arg0.equals("proxy")) {

+                m_proxy = arg1.toString();

+                return;

+            }

         }

 

         /**

@@ -256,6 +265,9 @@
             if (m_from != null) {

                 req.addAttribute(new Attribute("from", m_from));

             }

+            if (m_proxy != null) {

+                req.addAttribute(new Attribute("proxy", m_proxy));

+            }

             

             if (m_id != null) { 

                 m_collector.getIds().put(m_id, req);

diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
index 856218e..d288b94 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/MethodCollector.java
@@ -211,7 +211,7 @@
          * From attribute.
          */
         private String m_from;
-
+        
         /**
          * Constructor.
          * @param bind : method name.
@@ -379,7 +379,6 @@
                         System.err.println("The from attribute is not always the same");
                         return;
                     }
-                    
                 }
                 
             }
diff --git a/ipojo/manipulator/src/main/resources/core.xsd b/ipojo/manipulator/src/main/resources/core.xsd
index 2f3491f..5d51779 100644
--- a/ipojo/manipulator/src/main/resources/core.xsd
+++ b/ipojo/manipulator/src/main/resources/core.xsd
@@ -260,6 +260,13 @@
                       <xs:documentation>Specific service provider. The dependency can only be fulfilled by the component with the matching name, or by the service with a matching PID.</xs:documentation>
                     </xs:annotation>
         </xs:attribute>
+        
+        <xs:attribute name="proxy" type="xs:boolean"
+          use="optional">
+                    <xs:annotation>
+                      <xs:documentation>Enables or Disable the proxy injection (on field injection)</xs:documentation>
+                    </xs:annotation>
+        </xs:attribute>
 
         <xs:attribute name="scope" use="optional">
           <xs:simpleType>
diff --git a/ipojo/metadata/pom.xml b/ipojo/metadata/pom.xml
index d8ee7f8..0426e44 100644
--- a/ipojo/metadata/pom.xml
+++ b/ipojo/metadata/pom.xml
@@ -43,6 +43,7 @@
         <extensions>true</extensions>
         <configuration>
           <instructions>
+            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
             <Bundle-Name>iPOJO Metadata</Bundle-Name>
             <Bundle-Vendor> The Apache Software Foundation </Bundle-Vendor>
             <Bundle-Description> iPOJO Metadata </Bundle-Description>
diff --git a/ipojo/tests/bundleAsiPOJO/helpers/pom.xml b/ipojo/tests/bundleAsiPOJO/helpers/pom.xml
index 906263f..647d632 100644
--- a/ipojo/tests/bundleAsiPOJO/helpers/pom.xml
+++ b/ipojo/tests/bundleAsiPOJO/helpers/pom.xml
@@ -7,11 +7,13 @@
   <version>1.5.0-SNAPSHOT</version>
   <name>iPOJO Test Helpers</name>
 
+  
+
   <dependencies>
     <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.ipojo</artifactId>
-      <version>${pom.version}</version>
+      <version>1.4.0</version>
     </dependency>
     <dependency>
       <groupId>org.osgi</groupId>
@@ -26,6 +28,11 @@
       <scope>compile</scope>
     </dependency>
   </dependencies>
+  <parent>
+    <artifactId>felix-parent</artifactId>
+    <groupId>org.apache.felix</groupId>
+    <version>1.2.0</version>
+  </parent>
 
   <build>
     <plugins>
diff --git a/ipojo/tests/bundleAsiPOJO/helpers/src/main/java/org/apache/felix/ipojo/test/helpers/IPOJOHelper.java b/ipojo/tests/bundleAsiPOJO/helpers/src/main/java/org/apache/felix/ipojo/test/helpers/IPOJOHelper.java
index bb1cd4d..e723f9f 100644
--- a/ipojo/tests/bundleAsiPOJO/helpers/src/main/java/org/apache/felix/ipojo/test/helpers/IPOJOHelper.java
+++ b/ipojo/tests/bundleAsiPOJO/helpers/src/main/java/org/apache/felix/ipojo/test/helpers/IPOJOHelper.java
@@ -347,6 +347,17 @@
     public Element getMetadata(String component) {
         return getMetadata(m_context.getBundle(), component);
     }
+    
+    /**
+     * Returns the instance metadata of a component defined in this bundle.
+     * 
+     * @param component the name of the locally defined component.
+     * @return the list of instance metadata of the component with the given name,
+     *         defined in this given bundle, or {@code null} if not found.
+     */
+    public Element[] getInstanceMetadata(String component) {
+        return getInstanceMetadata(m_context.getBundle(), component);
+    }
 
     /**
      * Returns the component factory with the given name in the given bundle.
@@ -483,6 +494,53 @@
                             + bundle.getSymbolicName() + "): " + e.getMessage());
         }
     }
+    
+    /**
+     * Returns the instance metadatas of the component with the given name,
+     * defined in the given bundle.
+     * 
+     * @param bundle the bundle from which the component is defined.
+     * @param component the name of the defined component.
+     * @return the list of instance metadata of the component with the given name,
+     *         defined in the given bundle, or {@code null} if not found.
+     */
+    public static Element[] getInstanceMetadata(Bundle bundle, String component) {
+
+        // Retrieves the component description from the bundle's manifest.
+        String elem = (String) bundle.getHeaders().get("iPOJO-Components");
+        if (elem == null) {
+            throw new IllegalArgumentException(
+                    "Cannot find iPOJO-Components descriptor in the specified bundle ("
+                            + bundle.getSymbolicName()
+                            + "). Not an iPOJO bundle.");
+        }
+
+        // Parses the retrieved description and find the component with the
+        // given name.
+        List list = new ArrayList();
+        try {
+            Element element = ManifestMetadataParser.parseHeaderMetadata(elem);
+            Element[] childs = element.getElements("instance");
+            for (int i = 0; i < childs.length; i++) {
+                String name = childs[i].getAttribute("component");
+                if (name != null && name.equalsIgnoreCase(component)) {
+                    list.add(childs[i]);
+                }
+            }
+            
+            if (list.isEmpty()) {
+                // Component not found...
+                return null;
+            } else {
+                return (Element[]) list.toArray(new Element[list.size()]);
+            }
+
+        } catch (ParseException e) {
+            throw new IllegalStateException(
+                    "Cannot parse the components from specified bundle ("
+                            + bundle.getSymbolicName() + "): " + e.getMessage());
+        }
+    }
 
     /**
      * Returns the service object of a service registered in the specified
diff --git a/ipojo/tests/bundleAsiPOJO/pom.xml b/ipojo/tests/bundleAsiPOJO/pom.xml
index f2ddfac..f9b0f10 100644
--- a/ipojo/tests/bundleAsiPOJO/pom.xml
+++ b/ipojo/tests/bundleAsiPOJO/pom.xml
@@ -24,7 +24,7 @@
   <name>Apache Felix iPOJO TinyBundles Extension</name>

   <packaging>pom</packaging>

   

-   <profiles>

+  <profiles>

   <profile>

     <id>java5</id>

     <activation>

diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Dependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Dependency.java
index f69e76d..2bd64dc 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Dependency.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/Dependency.java
@@ -83,6 +83,10 @@
         assertEquals("Check mod unbind", "unbindMod", unbind);

         assertEquals("Check mod modified", "modifiedMod", mod);

         assertEquals("Check mod id", "mod", id);

+        

+        // Check not proxied

+        dep = getDependencyById(deps, "notproxied");

+        assertEquals("Check not proxied", "false", dep.getAttribute("proxy"));

     }

     

     private Element getDependencyById(Element[] deps, String name) {

diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Dependency.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Dependency.java
index 906fa4f..17d8d19 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Dependency.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/Dependency.java
@@ -76,5 +76,8 @@
     }

     

     

+    @Requires(proxy=false, id="notproxied")

+    FooService myFoo;

+    

     

 }

diff --git a/ipojo/tests/core/service-dependency-filter/src/main/resources/metadata.xml b/ipojo/tests/core/service-dependency-filter/src/main/resources/metadata.xml
index 9918326..5cdf205 100644
--- a/ipojo/tests/core/service-dependency-filter/src/main/resources/metadata.xml
+++ b/ipojo/tests/core/service-dependency-filter/src/main/resources/metadata.xml
@@ -3,120 +3,120 @@
     xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"

     xmlns="org.apache.felix.ipojo">

 

-	<!--  Simple Filter Dependencies -->

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckProvider"

-		name="SimpleFilterCheckServiceProvider" architecture="true">

-		<provides>

-			<property field="m_toto" name="toto" value="A" />

-		</provides>

-	</component>

+  <!--  Simple Filter Dependencies -->

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckProvider"

+    name="SimpleFilterCheckServiceProvider" architecture="true">

+    <provides>

+      <property field="m_toto" name="toto" value="A" />

+    </provides>

+  </component>

 

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"

-		name="SimpleFilterCheckServiceSubscriber" architecture="true">

-		<requires field="m_foo" filter="(toto=B)" id="id1">

-			<callback type="bind" method="Bind" />

-			<callback type="unbind" method="Unbind" />

-		</requires>

-		<provides />

-	</component>

-	

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"

-		name="SimpleFromCheckServiceSubscriber" architecture="true">

-		<requires field="m_foo" from="A" id="id1">

-			<callback type="bind" method="Bind" />

-			<callback type="unbind" method="Unbind" />

-		</requires>

-		<provides />

-	</component>

-	

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckProvider"

-		name="SimplePIDCheckServiceProvider" architecture="true">

-		<provides>

-			<property type="String" name="service.pid" />

-		</provides>

-	</component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"

+    name="SimpleFilterCheckServiceSubscriber" architecture="true">

+    <requires field="m_foo" filter="(toto=B)" id="id1" proxy="false">

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

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

+    </requires>

+    <provides />

+  </component>

+  

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"

+    name="SimpleFromCheckServiceSubscriber" architecture="true">

+    <requires field="m_foo" from="A" id="id1" proxy="false">

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

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

+    </requires>

+    <provides />

+  </component>

+  

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckProvider"

+    name="SimplePIDCheckServiceProvider" architecture="true">

+    <provides>

+      <property type="String" name="service.pid" />

+    </provides>

+  </component>

 

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"

-		name="SimpleFilterCheckServiceSubscriber2" architecture="true">

-		<requires field="m_foo" id="id2">

-			<callback type="bind" method="Bind" />

-			<callback type="unbind" method="Unbind" />

-		</requires>

-		<provides />

-	</component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"

+    name="SimpleFilterCheckServiceSubscriber2" architecture="true">

+    <requires field="m_foo" id="id2" proxy="false">

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

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

+    </requires>

+    <provides />

+  </component>

 

-	<!--  Optional Simple Filter Dependencies -->

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"

-		name="OptionalSimpleFilterCheckServiceSubscriber"

-		architecture="true">

-		<requires field="m_foo" filter="(toto=B)" id="id1"

-			optional="true">

-			<callback type="bind" method="Bind" />

-			<callback type="unbind" method="Unbind" />

-		</requires>

-		<provides />

-	</component>

+  <!--  Optional Simple Filter Dependencies -->

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"

+    name="OptionalSimpleFilterCheckServiceSubscriber"

+    architecture="true">

+    <requires field="m_foo" filter="(toto=B)" id="id1"

+      optional="true" proxy="false">

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

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

+    </requires>

+    <provides />

+  </component>

 

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"

-		name="OptionalSimpleFilterCheckServiceSubscriber2"

-		architecture="true">

-		<requires field="m_foo" id="id2" optional="true">

-			<callback type="bind" method="Bind" />

-			<callback type="unbind" method="Unbind" />

-		</requires>

-		<provides />

-	</component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.FilterCheckSubscriber"

+    name="OptionalSimpleFilterCheckServiceSubscriber2"

+    architecture="true">

+    <requires field="m_foo" id="id2" optional="true" proxy="false">

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

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

+    </requires>

+    <provides />

+  </component>

 

-	<!-- Aggregate filter Dependencies-->

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"

-		name="MultipleFilterCheckServiceSubscriber" architecture="true">

-		<requires field="m_foo" filter="(toto=B)" id="id1">

-			<callback type="bind" method="Bind" />

-			<callback type="unbind" method="Unbind" />

-		</requires>

-		<provides />

-	</component>

+  <!-- Aggregate filter Dependencies-->

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"

+    name="MultipleFilterCheckServiceSubscriber" architecture="true">

+    <requires field="m_foo" filter="(toto=B)" id="id1" proxy="false">

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

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

+    </requires>

+    <provides />

+  </component>

 

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"

-		name="MultipleFilterCheckServiceSubscriber2" architecture="true">

-		<requires field="m_foo" id="id2">

-			<callback type="bind" method="Bind" />

-			<callback type="unbind" method="Unbind" />

-		</requires>

-		<provides />

-	</component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"

+    name="MultipleFilterCheckServiceSubscriber2" architecture="true">

+    <requires field="m_foo" id="id2" proxy="false">

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

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

+    </requires>

+    <provides />

+  </component>

 

-	<!--  Optional Aggregate Filter Dependencies -->

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"

-		name="OptionalMultipleFilterCheckServiceSubscriber"

-		architecture="true">

-		<requires field="m_foo" filter="(toto=B)" id="id1"

-			optional="true">

-			<callback type="bind" method="Bind" />

-			<callback type="unbind" method="Unbind" />

-		</requires>

-		<provides />

-	</component>

+  <!--  Optional Aggregate Filter Dependencies -->

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"

+    name="OptionalMultipleFilterCheckServiceSubscriber"

+    architecture="true">

+    <requires field="m_foo" filter="(toto=B)" id="id1" proxy="false"

+      optional="true">

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

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

+    </requires>

+    <provides />

+  </component>

 

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"

-		name="OptionalMultipleFilterCheckServiceSubscriber2"

-		architecture="true">

-		<requires field="m_foo" id="id2" optional="true">

-			<callback type="bind" method="Bind" />

-			<callback type="unbind" method="Unbind" />

-		</requires>

-		<provides />

-	</component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.service.dependency.filter.component.MultipleFilterCheckSubscriber"

+    name="OptionalMultipleFilterCheckServiceSubscriber2"

+    architecture="true">

+    <requires field="m_foo" id="id2" optional="true" proxy="false">

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

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

+    </requires>

+    <provides />

+  </component>

 

 </ipojo>

diff --git a/ipojo/tests/core/service-dependency/pom.xml b/ipojo/tests/core/service-dependency/pom.xml
index 3b112f9..ce5a943 100644
--- a/ipojo/tests/core/service-dependency/pom.xml
+++ b/ipojo/tests/core/service-dependency/pom.xml
@@ -35,9 +35,9 @@
       <version>${pom.version}</version>

     </dependency>

     <dependency>

-      <groupId>org.apache.felix</groupId>

-      <artifactId>org.osgi.core</artifactId>

-      <version>1.0.1</version>

+        <groupId>org.osgi</groupId>

+       <artifactId>org.osgi.core</artifactId>

+        <version>4.2.0</version>

     </dependency>

     <dependency>

       <groupId>junit</groupId>

@@ -98,7 +98,6 @@
         </configuration>

       </plugin>

       

-      <!--

       <plugin>

         <groupId>org.apache.felix</groupId>

         <artifactId>maven-junit4osgi-plugin</artifactId>

@@ -116,7 +115,6 @@
           </execution>

         </executions>

       </plugin>

-      -->

       </plugins>

   </build>

 </project>

diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java
index 8ace55d..4130ea0 100644
--- a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/DependencyArchitectureTest.java
@@ -35,586 +35,686 @@
 import org.osgi.framework.ServiceReference;

 

 public class DependencyArchitectureTest extends OSGiTestCase {

-	

-	ComponentInstance fooProvider1, fooProvider2;

-	

-	ComponentInstance instance1, instance2, instance3, instance4;

-	

-	public void setUp() {

-		try {

-			Properties prov = new Properties();

-			prov.put("instance.name","FooProvider");

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

-			fooProvider1.stop();

-		

-			Properties prov2 = new Properties();

-			prov2.put("instance.name","FooProvider2");

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

-			fooProvider2.stop();

-		

-			Properties i1 = new Properties();

-			i1.put("instance.name","Simple");

-			instance1 = Utils.getFactoryByName(getContext(), "SimpleCheckServiceProvider").createComponentInstance(i1);

-		

-			Properties i2 = new Properties();

-			i2.put("instance.name","Optional");

-			instance2 = Utils.getFactoryByName(getContext(), "SimpleOptionalCheckServiceProvider").createComponentInstance(i2);

-		

-			Properties i3 = new Properties();

-			i3.put("instance.name","Multiple");

-			instance3 = Utils.getFactoryByName(getContext(), "SimpleMultipleCheckServiceProvider").createComponentInstance(i3);

-		

-			Properties i4 = new Properties();

-			i4.put("instance.name","OptionalMultiple");

-			instance4 = Utils.getFactoryByName(getContext(), "SimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i4);

-		} catch(Exception e) {

-			throw new RuntimeException(e.getMessage());

-		}

-	}

-	

-	public void tearDown() {

-		instance1.dispose();

-		instance2.dispose();

-		instance3.dispose();

-		instance4.dispose();

-		fooProvider1.dispose();

-		fooProvider2.dispose();

-		instance1 = null;

-		instance2 = null;

-		instance3 = null;

-		instance4 = null;

-		fooProvider1 = null;

-		fooProvider2 = null;

-	}

-	

-	private DependencyHandlerDescription getDependencyDesc(InstanceDescription id) {

-	    DependencyHandlerDescription handler = (DependencyHandlerDescription) id.getHandlerDescription("org.apache.felix.ipojo:requires");

-		if (handler == null) {

-		    fail("Dependency Handler not found");

-		    return null;

-		} else {

-		    return handler;

-		}

-	}

-	

-	private DependencyDescription getDependencyDescBySpecification(

+    

+    ComponentInstance fooProvider1, fooProvider2;

+    

+    ComponentInstance instance1, instance2, instance3, instance4, instance5;

+    

+    public void setUp() {

+        try {

+            Properties prov = new Properties();

+            prov.put("instance.name","FooProvider");

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

+            fooProvider1.stop();

+        

+            Properties prov2 = new Properties();

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

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

+            fooProvider2.stop();

+        

+            Properties i1 = new Properties();

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

+            instance1 = Utils.getFactoryByName(getContext(), "SimpleCheckServiceProvider").createComponentInstance(i1);

+            

+            Properties i5 = new Properties();

+            i5.put("instance.name","ProxiedSimple");

+            instance5 = Utils.getFactoryByName(getContext(), "ProxiedSimpleCheckServiceProvider").createComponentInstance(i5);

+        

+            Properties i2 = new Properties();

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

+            instance2 = Utils.getFactoryByName(getContext(), "SimpleOptionalCheckServiceProvider").createComponentInstance(i2);

+        

+            Properties i3 = new Properties();

+            i3.put("instance.name","Multiple");

+            instance3 = Utils.getFactoryByName(getContext(), "SimpleMultipleCheckServiceProvider").createComponentInstance(i3);

+            

+            Properties i4 = new Properties();

+            i4.put("instance.name","OptionalMultiple");

+            instance4 = Utils.getFactoryByName(getContext(), "SimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i4);

+        } catch(Exception e) {

+            throw new RuntimeException(e.getMessage());

+        }

+    }

+    

+    public void tearDown() {

+        instance1.dispose();

+        instance2.dispose();

+        instance3.dispose();

+        instance4.dispose();

+        instance5.dispose();

+        fooProvider1.dispose();

+        fooProvider2.dispose();

+        instance1 = null;

+        instance2 = null;

+        instance3 = null;

+        instance4 = null;

+        instance5 = null;

+        fooProvider1 = null;

+        fooProvider2 = null;

+    }

+    

+    private DependencyHandlerDescription getDependencyDesc(InstanceDescription id) {

+        DependencyHandlerDescription handler = (DependencyHandlerDescription) id.getHandlerDescription("org.apache.felix.ipojo:requires");

+        if (handler == null) {

+            fail("Dependency Handler not found");

+            return null;

+        } else {

+            return handler;

+        }

+    }

+    

+    private DependencyDescription getDependencyDescBySpecification(

             PrimitiveInstanceDescription id, String spec) {

         return id.getDependency(spec);

     }

-	

-	private ProvidedServiceHandlerDescription getPSDesc(InstanceDescription id) {

-	    ProvidedServiceHandlerDescription handler = (ProvidedServiceHandlerDescription) id.getHandlerDescription("org.apache.felix.ipojo:provides");

+    

+    private ProvidedServiceHandlerDescription getPSDesc(InstanceDescription id) {

+        ProvidedServiceHandlerDescription handler = (ProvidedServiceHandlerDescription) id.getHandlerDescription("org.apache.felix.ipojo:provides");

         if (handler == null) {

             fail("Provided Service Handler not found");

             return null;

         } else {

             return handler;

         }

-	}

-	

-	public void testSimpleDependency() {

-		ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());

-		assertNotNull("Check architecture availability", arch_dep);

-		PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

-		

-		// Check dependency handler invalidity

-		DependencyHandlerDescription dhd = getDependencyDesc(id_dep);

-		assertFalse("Check dependency handler invalidity", dhd.isValid());

-		

-		// Check dependency metadata

-		assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());

-		assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), FooService.class.getName());

-		assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());

-		assertFalse("Check dependency optionality", dhd.getDependencies()[0].isOptional());

-		assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());

-		

-		fooProvider1.start();

-		

-		ServiceReference arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

-		assertNotNull("Check architecture availability", arch_ps);

-		PrimitiveInstanceDescription id_ps = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);				

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

-		dhd = getDependencyDesc(id_dep);

-		assertTrue("Check dependency handler validity", dhd.isValid());

-		assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);

-		

-		ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());

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

-		CheckService cs = (CheckService) getContext().getService(cs_ref);

-		assertTrue("check CheckService invocation", cs.check());

-		

-		// Check object graph

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		//id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

-		ProvidedServiceHandlerDescription psh = getPSDesc(id_ps);

-		assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

-		assertEquals("Check POJO creation", id_ps.getCreatedObjects().length, 1);

-		assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

-		

-		fooProvider1.stop();

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);

-		dhd = getDependencyDesc(id_dep);

-		assertFalse("Check dependency handler invalidity", dhd.isValid());

-		

-		fooProvider1.start();

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

-		assertNotNull("Check architecture availability", arch_ps);

-		//id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);

-		psh = getPSDesc(id_ps);

-		assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

-		assertTrue("Check dependency handler validity", dhd.isValid());

-		

-		assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);

-		

-		cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance1.getInstanceName());

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

-		cs = (CheckService) getContext().getService(cs_ref);

-		assertTrue("check CheckService invocation", cs.check());

-		

-		// Check object graph 

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		//id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

-		psh = getPSDesc(id_ps);

-		assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

-		assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

-		

-		fooProvider1.stop();

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.INVALID);

-		dhd = getDependencyDesc(id_dep);

-		assertFalse("Check dependency handler invalidity", dhd.isValid());

-		

-		id_dep = null;

-		cs = null;

-		getContext().ungetService(arch_dep);

-		getContext().ungetService(cs_ref);

-	}

-	

-	public void testOptionalDependency() {

-		ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());

-		assertNotNull("Check architecture availability", arch_dep);

-		PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.VALID);

-		

-		// Check dependency handler invalidity

-		DependencyHandlerDescription dhd = getDependencyDesc(id_dep);

-		assertTrue("Check dependency handler invalidity", dhd.isValid());

-		

-		// Check dependency metadata

-		assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());

-	    assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), "FooService");

-		assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());

-		assertTrue("Check dependency optionality", dhd.getDependencies()[0].isOptional());

-		assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());

-		

-		fooProvider1.start();

-		

-		ServiceReference arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

-		assertNotNull("Check architecture availability", arch_ps);

-		PrimitiveInstanceDescription id_ps = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);				

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

-		dhd = getDependencyDesc(id_dep);

-		assertTrue("Check dependency handler validity", dhd.isValid());

-		assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);

-		

-		ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());

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

-		CheckService cs = (CheckService) getContext().getService(cs_ref);

-		assertTrue("check CheckService invocation", cs.check());

-		

-		// Check object graph

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		//id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

-		ProvidedServiceHandlerDescription psh = getPSDesc(id_ps);

-		assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

-		assertEquals("Check POJO creation", id_ps.getCreatedObjects().length, 1);

-		assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

-		

-		fooProvider1.stop();

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);

-		dhd = getDependencyDesc(id_dep);

-		assertTrue("Check dependency handler invalidity", dhd.isValid());

-		

-		fooProvider1.start();

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

-		assertNotNull("Check architecture availability", arch_ps);

-		//id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 1", id_ps.getState() == ComponentInstance.VALID);

-		psh = getPSDesc(id_ps);

-		assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

-		assertTrue("Check dependency handler validity", dhd.isValid());

-		

-		assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);

-		

-		cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance2.getInstanceName());

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

-		cs = (CheckService) getContext().getService(cs_ref);

-		assertTrue("check CheckService invocation", cs.check());

-		

-		// Check object graph 

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		//id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

-		psh = getPSDesc(id_ps);

-		assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

-		assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

-		

-		fooProvider1.stop();

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);

-		dhd = getDependencyDesc(id_dep);

-		assertTrue("Check dependency handler invalidity", dhd.isValid());

-		

-		id_dep = null;

-		cs = null;

-		getContext().ungetService(arch_dep);

-		getContext().ungetService(cs_ref);

-	}

-	

-	public void testMultipleDependency() {

-		ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());

-		assertNotNull("Check architecture availability", arch_dep);

-		PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

-		

-		// Check dependency handler invalidity

-		DependencyHandlerDescription dhd = getDependencyDesc(id_dep);

-		DependencyDescription dd = getDependencyDescBySpecification(id_dep, FooService.class.getName());

-		assertFalse("Check dependency handler invalidity", dhd.isValid());

-	    assertTrue("Check dependency invalidity", dd.getState() == Dependency.UNRESOLVED);

+    }

+    

+    public void testSimpleDependency() {

+        ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance1.getInstanceName());

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

+        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

+        

+        // Check dependency handler invalidity

+        DependencyHandlerDescription dhd = getDependencyDesc(id_dep);

+        assertFalse("Check dependency handler invalidity", dhd.isValid());

+        

+        // Check dependency metadata

+        assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());

+        assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), FooService.class.getName());

+        assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());

+        assertFalse("Check dependency optionality", dhd.getDependencies()[0].isOptional());

+        assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());

+        assertFalse("Check dependency proxy", dhd.getDependencies()[0].isProxy());

 

-		

-		// Check dependency metadata

-		assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());

-		assertTrue("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());

-		assertFalse("Check dependency optionality", dhd.getDependencies()[0].isOptional());

-		assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());

-		

-		assertEquals("Check dependency interface", dd.getSpecification(), FooService.class.getName());

+        fooProvider1.start();

+        

+        ServiceReference arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

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

+        PrimitiveInstanceDescription id_ps = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

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

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

+        dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler validity", dhd.isValid());

+        assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);

+        

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

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        // Check object graph

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

+        ProvidedServiceHandlerDescription psh = getPSDesc(id_ps);

+        assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

+        assertEquals("Check POJO creation", id_ps.getCreatedObjects().length, 1);

+        assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

+        

+        fooProvider1.stop();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

+        dhd = getDependencyDesc(id_dep);

+        assertFalse("Check dependency handler invalidity", dhd.isValid());

+        

+        fooProvider1.start();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

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

+        //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

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

+        psh = getPSDesc(id_ps);

+        assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

+        assertTrue("Check dependency handler validity", dhd.isValid());

+        

+        assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);

+        

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

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        // Check object graph 

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

+        psh = getPSDesc(id_ps);

+        assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

+        assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

+        

+        fooProvider1.stop();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

+        dhd = getDependencyDesc(id_dep);

+        assertFalse("Check dependency handler invalidity", dhd.isValid());

+        

+        id_dep = null;

+        cs = null;

+        getContext().ungetService(arch_dep);

+        getContext().ungetService(cs_ref);

+    }

+    

+    public void testProxiedSimpleDependency() {

+        ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());

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

+        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

+        

+        // Check dependency handler invalidity

+        DependencyHandlerDescription dhd = getDependencyDesc(id_dep);

+        assertFalse("Check dependency handler invalidity", dhd.isValid());

+        

+        // Check dependency metadata

+        assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());

+        assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), FooService.class.getName());

+        assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());

+        assertFalse("Check dependency optionality", dhd.getDependencies()[0].isOptional());

+        assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());

+        assertTrue("Check dependency proxy", dhd.getDependencies()[0].isProxy());

+        

+        fooProvider1.start();

+        

+        ServiceReference arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

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

+        PrimitiveInstanceDescription id_ps = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

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

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

+        dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler validity", dhd.isValid());

+        assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        // Check object graph

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

+        ProvidedServiceHandlerDescription psh = getPSDesc(id_ps);

+        assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

+        assertEquals("Check POJO creation", id_ps.getCreatedObjects().length, 1);

+        assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

+        

+        fooProvider1.stop();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

+        dhd = getDependencyDesc(id_dep);

+        assertFalse("Check dependency handler invalidity", dhd.isValid());

+        

+        fooProvider1.start();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

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

+        //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

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

+        psh = getPSDesc(id_ps);

+        assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

+        assertTrue("Check dependency handler validity", dhd.isValid());

+        

+        assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);

+        

+        cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        // Check object graph 

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

+        psh = getPSDesc(id_ps);

+        assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

+        assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

+        

+        fooProvider1.stop();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

+        dhd = getDependencyDesc(id_dep);

+        assertFalse("Check dependency handler invalidity", dhd.isValid());

+        

+        id_dep = null;

+        cs = null;

+        getContext().ungetService(arch_dep);

+        getContext().ungetService(cs_ref);

+    }

+    

+    public void testOptionalDependency() {

+        ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance2.getInstanceName());

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

+        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

+        

+        // Check dependency handler invalidity

+        DependencyHandlerDescription dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler invalidity", dhd.isValid());

+        

+        // Check dependency metadata

+        assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());

+        assertEquals("Check dependency id", dhd.getDependencies()[0].getId(), "FooService");

+        assertFalse("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());

+        assertTrue("Check dependency optionality", dhd.getDependencies()[0].isOptional());

+        assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());

+        

+        fooProvider1.start();

+        

+        ServiceReference arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

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

+        PrimitiveInstanceDescription id_ps = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

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

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

+        dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler validity", dhd.isValid());

+        assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);

+        

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

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        // Check object graph

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

+        ProvidedServiceHandlerDescription psh = getPSDesc(id_ps);

+        assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

+        assertEquals("Check POJO creation", id_ps.getCreatedObjects().length, 1);

+        assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

+        

+        fooProvider1.stop();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

+        dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler invalidity", dhd.isValid());

+        

+        fooProvider1.start();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        arch_ps = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

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

+        //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

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

+        psh = getPSDesc(id_ps);

+        assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

+        assertTrue("Check dependency handler validity", dhd.isValid());

+        

+        assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);

+        

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

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        // Check object graph 

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        //id_ps = ((Architecture) getContext().getService(arch_ps)).getInstanceDescription();

+        psh = getPSDesc(id_ps);

+        assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

+        assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

+        

+        fooProvider1.stop();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

+        dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler invalidity", dhd.isValid());

+        

+        id_dep = null;

+        cs = null;

+        getContext().ungetService(arch_dep);

+        getContext().ungetService(cs_ref);

+    }

+    

+    public void testMultipleDependency() {

+        ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());

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

+        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

+        

+        // Check dependency handler invalidity

+        DependencyHandlerDescription dhd = getDependencyDesc(id_dep);

+        DependencyDescription dd = getDependencyDescBySpecification(id_dep, FooService.class.getName());

+        assertFalse("Check dependency handler invalidity", dhd.isValid());

+        assertTrue("Check dependency invalidity", dd.getState() == Dependency.UNRESOLVED);

+

+        

+        // Check dependency metadata

+        assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());

+        assertTrue("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());

+        assertFalse("Check dependency optionality", dhd.getDependencies()[0].isOptional());

+        assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());

+        

+        assertEquals("Check dependency interface", dd.getSpecification(), FooService.class.getName());

         assertTrue("Check dependency cardinality", dd.isMultiple());

         assertFalse("Check dependency optionality", dd.isOptional());

         assertNull("Check dependency ref -1", dd.getServiceReferences());

-		

-		fooProvider1.start();

-		

-		ServiceReference arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

-		assertNotNull("Check architecture availability", arch_ps1);

-		PrimitiveInstanceDescription id_ps1 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

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

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

-		dhd = getDependencyDesc(id_dep);

-		assertTrue("Check dependency handler validity", dhd.isValid());

-		assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);

-		assertEquals("Check used ref - 1 (" + dhd.getDependencies()[0].getUsedServices().size() + ")", dhd.getDependencies()[0].getUsedServices().size(), 0);

-		

-		ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());

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

-		CheckService cs = (CheckService) getContext().getService(cs_ref);

-		assertTrue("check CheckService invocation", cs.check());

-		

-		// Check object graph

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		//id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		ProvidedServiceHandlerDescription psh = getPSDesc(id_ps1);

-		assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

-		assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);

-		assertTrue("Check service reference - 2", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

-		

-		// Start a second foo service provider

-		fooProvider2.start();

-		

-		arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

-		ServiceReference arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());

-		assertNotNull("Check architecture availability", arch_ps1);

-		assertNotNull("Check architecture 2 availability", arch_ps2);

-		//id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		PrimitiveInstanceDescription id_ps2 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps2)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);

-		assertTrue("Check instance 2 invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

-		dhd = getDependencyDesc(id_dep);

-		assertTrue("Check dependency handler validity", dhd.isValid());

-		assertEquals("Check dependency ref - 3 ", dhd.getDependencies()[0].getServiceReferences().size(), 2);

-		assertEquals("Check used ref - 2 ", dhd.getDependencies()[0].getUsedServices().size(), 1); // provider 2 not already used

-		

-		cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());

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

-		cs = (CheckService) getContext().getService(cs_ref);

-		assertTrue("check CheckService invocation", cs.check());

-		

-		// Check object graph

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		//id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		//id_ps2 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		ProvidedServiceHandlerDescription psh1 = getPSDesc(id_ps1);

-		ProvidedServiceHandlerDescription psh2 = getPSDesc(id_ps2);

-		assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);

-		assertEquals("Check POJO creation", id_ps2.getCreatedObjects().length, 1);

-		assertTrue("Check service reference - 3.1", dhd.getDependencies()[0].getUsedServices().contains(psh1.getProvidedServices()[0].getServiceReference()));

-		assertTrue("Check service reference - 3.2", dhd.getDependencies()[0].getUsedServices().contains(psh2.getProvidedServices()[0].getServiceReference()));

-		assertEquals("Check used ref - 3 ("+dhd.getDependencies()[0].getUsedServices().size()+")", dhd.getDependencies()[0].getUsedServices().size(), 2);

-		

-		fooProvider2.stop();

-		

-		arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

-		assertNotNull("Check architecture availability", arch_ps1);

-		//id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

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

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

-		dhd = getDependencyDesc(id_dep);

-		assertTrue("Check dependency handler validity", dhd.isValid());

-		assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);

-		assertEquals("Check used ref - 4 ", dhd.getDependencies()[0].getUsedServices().size(), 1);

-		

-		cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());

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

-		cs = (CheckService) getContext().getService(cs_ref);

-		assertTrue("check CheckService invocation", cs.check());

-		

-		// Check object graph

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		//id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		psh = getPSDesc(id_ps1);

-		assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

-		assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);

-		assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

-		assertEquals("Check used ref - 5 ", dhd.getDependencies()[0].getUsedServices().size(), 1);

-		

-		fooProvider1.stop();

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertFalse("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);

-		dhd = getDependencyDesc(id_dep);

-		assertFalse("Check dependency handler invalidity", dhd.isValid());

-		

-		fooProvider2.start();

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());

-		assertNotNull("Check architecture availability", arch_ps1);

-		//id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		

-		assertTrue("Check instance invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);

-		

-		psh = getPSDesc(id_ps2);

-		assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

-		assertTrue("Check dependency handler validity", dhd.isValid());

-		

-		assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);

-		assertEquals("Check used ref - 6 ", dhd.getDependencies()[0].getUsedServices().size(), 0);

-		

-		cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());

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

-		cs = (CheckService) getContext().getService(cs_ref);

-		assertTrue("check CheckService invocation", cs.check());

-		

-		// Check object graph 

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		//id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		psh = getPSDesc(id_ps2);

-		assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

-		assertTrue("Check service reference - 4", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

-		assertEquals("Check used ref - 7 ", dhd.getDependencies()[0].getUsedServices().size(), 1);

-		

-		fooProvider2.stop();

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertFalse("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);

-		dhd = getDependencyDesc(id_dep);

-		assertFalse("Check dependency handler invalidity", dhd.isValid());

-		

-		id_dep = null;

-		cs = null;

-		getContext().ungetService(arch_dep);

-		getContext().ungetService(cs_ref);

-	}

-	

-	public void testMultipleOptionalDependency() {

-		ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());

-		assertNotNull("Check architecture availability", arch_dep);

-		PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 1", id_dep.getState() == ComponentInstance.VALID);

-		

-		// Check dependency handler invalidity

-		DependencyHandlerDescription dhd = getDependencyDesc(id_dep);

-		assertTrue("Check dependency handler invalidity", dhd.isValid());

-		

-		// Check dependency metadata

-		assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());

-		assertTrue("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());

-		assertTrue("Check dependency optionality", dhd.getDependencies()[0].isOptional());

-		assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());

-		

-		fooProvider1.start();

-		

-		ServiceReference arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

-		assertNotNull("Check architecture availability", arch_ps1);

-		PrimitiveInstanceDescription id_ps1 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);				

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

-		dhd = getDependencyDesc(id_dep);

-		assertTrue("Check dependency handler validity", dhd.isValid());

-		assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);

-		

-		ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());

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

-		CheckService cs = (CheckService) getContext().getService(cs_ref);

-		assertTrue("check CheckService invocation", cs.check());

-		

-		// Check object graph

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		//id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		ProvidedServiceHandlerDescription psh = getPSDesc(id_ps1);

-		assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

-		assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);

-		assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

-		

-		// Start a second foo service provider

-		fooProvider2.start();

-		

-		arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

-		ServiceReference arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());

-		assertNotNull("Check architecture availability", arch_ps1);

-		assertNotNull("Check architecture 2 availability", arch_ps2);

-		//id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		PrimitiveInstanceDescription id_ps2 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps2)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);

-		assertTrue("Check instance 2 invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

-		dhd = getDependencyDesc(id_dep);

-		assertTrue("Check dependency handler validity", dhd.isValid());

-		assertEquals("Check dependency ref - 3 ", dhd.getDependencies()[0].getServiceReferences().size(), 2);

-		

-		cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());

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

-		cs = (CheckService) getContext().getService(cs_ref);

-		assertTrue("check CheckService invocation", cs.check());

-		

-		// Check object graph

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		//id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		//id_ps2 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		ProvidedServiceHandlerDescription psh1 = getPSDesc(id_ps1);

-		ProvidedServiceHandlerDescription psh2 = getPSDesc(id_ps2);

-		assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);

-		assertEquals("Check POJO creation", id_ps2.getCreatedObjects().length, 1);

-		assertTrue("Check service reference - 2.1", dhd.getDependencies()[0].getUsedServices().contains(psh1.getProvidedServices()[0].getServiceReference()));

-		assertTrue("Check service reference - 2.2", dhd.getDependencies()[0].getUsedServices().contains(psh2.getProvidedServices()[0].getServiceReference()));

-		

-		fooProvider2.stop();

-		

-		arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

-		assertNotNull("Check architecture availability", arch_ps1);

-		//id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 1", id_ps1.getState() == ComponentInstance.VALID);				

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

-		dhd = getDependencyDesc(id_dep);

-		assertTrue("Check dependency handler validity", dhd.isValid());

-		assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);

-		

-		cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());

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

-		cs = (CheckService) getContext().getService(cs_ref);

-		assertTrue("check CheckService invocation", cs.check());

-		

-		// Check object graph

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		//id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		psh = getPSDesc(id_ps1);

-		assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

-		assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);

-		assertTrue("Check service reference - 3", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

+        assertFalse("Check dependency proxy", dhd.getDependencies()[0].isProxy());

 

-		fooProvider1.stop();

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);

-		dhd = getDependencyDesc(id_dep);

-		assertTrue("Check dependency handler invalidity", dhd.isValid());

-		

-		fooProvider2.start();

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());

-		assertNotNull("Check architecture availability", arch_ps2);

-		//id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);

-		psh = getPSDesc(id_ps2);

-		assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

-		assertTrue("Check dependency handler validity", dhd.isValid());

-		

-		assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);

-		

-		cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());

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

-		cs = (CheckService) getContext().getService(cs_ref);

-		assertTrue("check CheckService invocation", cs.check());

-		

-		// Check object graph 

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		dhd = getDependencyDesc(id_dep);

-		//id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

-		psh = getPSDesc(id_ps2);

-		assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

-		assertTrue("Check service reference - 4", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

+        fooProvider1.start();

+        

+        ServiceReference arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

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

+        PrimitiveInstanceDescription id_ps1 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

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

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

+        dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler validity", dhd.isValid());

+        assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);

+        assertEquals("Check used ref - 1 (" + dhd.getDependencies()[0].getUsedServices().size() + ")", dhd.getDependencies()[0].getUsedServices().size(), 0);

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        // Check object graph

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

+        ProvidedServiceHandlerDescription psh = getPSDesc(id_ps1);

+        assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

+        assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);

+        assertTrue("Check service reference - 2", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

+        

+        // Start a second foo service provider

+        fooProvider2.start();

+        

+        arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

+        ServiceReference arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());

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

+        assertNotNull("Check architecture 2 availability", arch_ps2);

+        //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

+        PrimitiveInstanceDescription id_ps2 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps2)).getInstanceDescription();

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

+        assertTrue("Check instance 2 invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

+        dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler validity", dhd.isValid());

+        assertEquals("Check dependency ref - 3 ", dhd.getDependencies()[0].getServiceReferences().size(), 2);

+        assertEquals("Check used ref - 2 ", dhd.getDependencies()[0].getUsedServices().size(), 1); // provider 2 not already used

+        

+        cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        // Check object graph

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

+        //id_ps2 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

+        ProvidedServiceHandlerDescription psh1 = getPSDesc(id_ps1);

+        ProvidedServiceHandlerDescription psh2 = getPSDesc(id_ps2);

+        assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);

+        assertEquals("Check POJO creation", id_ps2.getCreatedObjects().length, 1);

+        assertTrue("Check service reference - 3.1", dhd.getDependencies()[0].getUsedServices().contains(psh1.getProvidedServices()[0].getServiceReference()));

+        assertTrue("Check service reference - 3.2", dhd.getDependencies()[0].getUsedServices().contains(psh2.getProvidedServices()[0].getServiceReference()));

+        assertEquals("Check used ref - 3 ("+dhd.getDependencies()[0].getUsedServices().size()+")", dhd.getDependencies()[0].getUsedServices().size(), 2);

+        

+        fooProvider2.stop();

+        

+        arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

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

+        //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

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

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

+        dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler validity", dhd.isValid());

+        assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);

+        assertEquals("Check used ref - 4 ", dhd.getDependencies()[0].getUsedServices().size(), 1);

+        

+        cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        // Check object graph

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

+        psh = getPSDesc(id_ps1);

+        assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

+        assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);

+        assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

+        assertEquals("Check used ref - 5 ", dhd.getDependencies()[0].getUsedServices().size(), 1);

+        

+        fooProvider1.stop();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        assertFalse("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);

+        dhd = getDependencyDesc(id_dep);

+        assertFalse("Check dependency handler invalidity", dhd.isValid());

+        

+        fooProvider2.start();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());

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

+        //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

+        

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

+        

+        psh = getPSDesc(id_ps2);

+        assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

+        assertTrue("Check dependency handler validity", dhd.isValid());

+        

+        assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);

+        assertEquals("Check used ref - 6 ", dhd.getDependencies()[0].getUsedServices().size(), 0);

+        

+        cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        // Check object graph 

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

+        psh = getPSDesc(id_ps2);

+        assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

+        assertTrue("Check service reference - 4", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

+        assertEquals("Check used ref - 7 ", dhd.getDependencies()[0].getUsedServices().size(), 1);

+        

+        fooProvider2.stop();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        assertFalse("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);

+        dhd = getDependencyDesc(id_dep);

+        assertFalse("Check dependency handler invalidity", dhd.isValid());

+        

+        id_dep = null;

+        cs = null;

+        getContext().ungetService(arch_dep);

+        getContext().ungetService(cs_ref);

+    }

+    

+    public void testMultipleOptionalDependency() {

+        ServiceReference arch_dep = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());

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

+        PrimitiveInstanceDescription id_dep = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

+        

+        // Check dependency handler invalidity

+        DependencyHandlerDescription dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler invalidity", dhd.isValid());

+        

+        // Check dependency metadata

+        assertEquals("Check dependency interface", dhd.getDependencies()[0].getInterface(), FooService.class.getName());

+        assertTrue("Check dependency cardinality", dhd.getDependencies()[0].isMultiple());

+        assertTrue("Check dependency optionality", dhd.getDependencies()[0].isOptional());

+        assertNull("Check dependency ref -1", dhd.getDependencies()[0].getServiceReferences());

+        

+        fooProvider1.start();

+        

+        ServiceReference arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

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

+        PrimitiveInstanceDescription id_ps1 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

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

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

+        dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler validity", dhd.isValid());

+        assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        // Check object graph

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

+        ProvidedServiceHandlerDescription psh = getPSDesc(id_ps1);

+        assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

+        assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);

+        assertTrue("Check service reference - 1", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

+        

+        // Start a second foo service provider

+        fooProvider2.start();

+        

+        arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

+        ServiceReference arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());

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

+        assertNotNull("Check architecture 2 availability", arch_ps2);

+        //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

+        PrimitiveInstanceDescription id_ps2 = (PrimitiveInstanceDescription) ((Architecture) getContext().getService(arch_ps2)).getInstanceDescription();

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

+        assertTrue("Check instance 2 invalidity - 1", id_ps2.getState() == ComponentInstance.VALID);

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

+        dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler validity", dhd.isValid());

+        assertEquals("Check dependency ref - 3 ", dhd.getDependencies()[0].getServiceReferences().size(), 2);

+        

+        cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        // Check object graph

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

+        //id_ps2 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

+        ProvidedServiceHandlerDescription psh1 = getPSDesc(id_ps1);

+        ProvidedServiceHandlerDescription psh2 = getPSDesc(id_ps2);

+        assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);

+        assertEquals("Check POJO creation", id_ps2.getCreatedObjects().length, 1);

+        assertTrue("Check service reference - 2.1", dhd.getDependencies()[0].getUsedServices().contains(psh1.getProvidedServices()[0].getServiceReference()));

+        assertTrue("Check service reference - 2.2", dhd.getDependencies()[0].getUsedServices().contains(psh2.getProvidedServices()[0].getServiceReference()));

+        

+        fooProvider2.stop();

+        

+        arch_ps1 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider1.getInstanceName());

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

+        //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

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

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

+        dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler validity", dhd.isValid());

+        assertEquals("Check dependency ref - 2 ", dhd.getDependencies()[0].getServiceReferences().size(), 1);

+        

+        cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        // Check object graph

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

+        psh = getPSDesc(id_ps1);

+        assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

+        assertEquals("Check POJO creation", id_ps1.getCreatedObjects().length, 1);

+        assertTrue("Check service reference - 3", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

 

-		fooProvider2.stop();

-		

-		//id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

-		assertTrue("Check instance invalidity - 2", id_dep.getState() == ComponentInstance.VALID);

-		dhd = getDependencyDesc(id_dep);

-		assertTrue("Check dependency handler invalidity", dhd.isValid());

-		

-		id_dep = null;

-		cs = null;

-		getContext().ungetService(arch_dep);

-		getContext().ungetService(cs_ref);

-	}

-	

-	

-	

+        fooProvider1.stop();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

+        dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler invalidity", dhd.isValid());

+        

+        fooProvider2.start();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        arch_ps2 = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), fooProvider2.getInstanceName());

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

+        //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

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

+        psh = getPSDesc(id_ps2);

+        assertTrue("Check instance validity", id_dep.getState() == ComponentInstance.VALID);

+        assertTrue("Check dependency handler validity", dhd.isValid());

+        

+        assertEquals("Check dependency ref -3", dhd.getDependencies()[0].getServiceReferences().size(), 1);

+        

+        cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        // Check object graph 

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

+        dhd = getDependencyDesc(id_dep);

+        //id_ps1 = ((Architecture) getContext().getService(arch_ps1)).getInstanceDescription();

+        psh = getPSDesc(id_ps2);

+        assertEquals("Check Service Reference equality", psh.getProvidedServices()[0].getServiceReference(), dhd.getDependencies()[0].getServiceReference());

+        assertTrue("Check service reference - 4", dhd.getDependencies()[0].getUsedServices().contains(psh.getProvidedServices()[0].getServiceReference()));

+

+        fooProvider2.stop();

+        

+        //id_dep = ((Architecture) getContext().getService(arch_dep)).getInstanceDescription();

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

+        dhd = getDependencyDesc(id_dep);

+        assertTrue("Check dependency handler invalidity", dhd.isValid());

+        

+        id_dep = null;

+        cs = null;

+        getContext().ungetService(arch_dep);

+        getContext().ungetService(cs_ref);

+    }

+    

+    

+    

 }

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 fb6eb1c..a318fdc 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
@@ -29,14 +29,20 @@
     public static Test suite(BundleContext bc) {

         OSGiTestSuite ots = new OSGiTestSuite("Service Dependencies Test Suite", bc);

         ots.addTestSuite(SimpleDependencies.class);

+        ots.addTestSuite(ProxiedSimpleDependencies.class);

         ots.addTestSuite(OptionalDependencies.class);

+        ots.addTestSuite(ProxiedOptionalDependencies.class);

         ots.addTestSuite(OptionalNoNullableDependencies.class);

         ots.addTestSuite(MultipleDependencies.class);

         ots.addTestSuite(OptionalMultipleDependencies.class);

         ots.addTestSuite(DelayedSimpleDependencies.class);

+        ots.addTestSuite(ProxiedDelayedSimpleDependencies.class);

         ots.addTestSuite(DelayedOptionalDependencies.class);

+        ots.addTestSuite(ProxiedDelayedOptionalDependencies.class);

         ots.addTestSuite(DelayedMultipleDependencies.class);

+        ots.addTestSuite(ProxiedDelayedMultipleDependencies.class);

         ots.addTestSuite(DelayedOptionalMultipleDependencies.class);

+        ots.addTestSuite(ProxiedDelayedOptionalMultipleDependencies.class);

         ots.addTestSuite(MethodSimpleDependencies.class);

         ots.addTestSuite(MethodOptionalDependencies.class);

         ots.addTestSuite(MethodMultipleDependencies.class);

@@ -48,10 +54,14 @@
         ots.addTest(DefaultImplementationTestSuite.suite(bc));

         ots.addTestSuite(DependencyArchitectureTest.class);

         ots.addTestSuite(ListMultipleDependencies.class);

+        ots.addTestSuite(ProxiedListMultipleDependencies.class);

         ots.addTestSuite(VectorMultipleDependencies.class);

         ots.addTestSuite(SetMultipleDependencies.class);

+        ots.addTestSuite(ProxiedSetMultipleDependencies.class);

         ots.addTestSuite(CollectionMultipleDependencies.class);

+        ots.addTestSuite(ProxiedCollectionMultipleDependencies.class);

         ots.addTestSuite(ModifyDependencies.class);

+        ots.addTestSuite(ProxyTest.class);

         return ots;

     }

 

diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedCollectionMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedCollectionMultipleDependencies.java
new file mode 100644
index 0000000..79943853
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedCollectionMultipleDependencies.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 ProxiedCollectionMultipleDependencies extends OSGiTestCase {

+

+    ComponentInstance instance1, instance2;

+    ComponentInstance fooProvider1, fooProvider2;

+    

+    public void setUp() {

+        try {

+            Properties prov = new Properties();

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

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

+            fooProvider1.stop();

+        

+            Properties prov2 = new Properties();

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

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

+            fooProvider2.stop();

+        

+            Properties i1 = new Properties();

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

+            instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleCollectionCheckServiceProvider").createComponentInstance(i1);

+            

+            Properties i2 = new Properties();

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

+            instance2 = Utils.getFactoryByName(getContext(), "ProxiedOptionalCollectionCheckServiceProvider").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(getContext(), Architecture.class.getName(), instance1.getInstanceName());

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

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

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

+        

+        fooProvider1.start();

+        

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

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

+        

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

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

+        CheckService cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+    }

+    

+    public void testOptional() {

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

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

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

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

+        

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

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

+        CheckService cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);       

+    }

+    

+}

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

+ * 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.util.Utils;

+import org.osgi.framework.ServiceReference;

+

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

+

+public class ProxiedDelayedMultipleDependencies extends OSGiTestCase {

+

+    ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;

+    ComponentInstance fooProvider1, fooProvider2;

+    

+    public void setUp() {

+        try {

+            Properties i1 = new Properties();

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

+            instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleMultipleCheckServiceProvider").createComponentInstance(i1);

+            instance1.stop();

+        

+            Properties i2 = new Properties();

+            i2.put("instance.name","Void");

+            instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidMultipleCheckServiceProvider").createComponentInstance(i2);

+            instance2.stop();

+        

+            Properties i3 = new Properties();

+            i3.put("instance.name","Object");

+            instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectMultipleCheckServiceProvider").createComponentInstance(i3);

+            instance3.stop();

+        

+            Properties i4 = new Properties();

+            i4.put("instance.name","Ref");

+            instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefMultipleCheckServiceProvider").createComponentInstance(i4);

+            instance4.stop();

+            

+             Properties i5 = new Properties();

+             i5.put("instance.name","Both");

+             instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothMultipleCheckServiceProvider").createComponentInstance(i5);

+             instance5.stop();

+             

+             Properties i6 = new Properties();

+             i6.put("instance.name","Map");

+             instance6 = Utils.getFactoryByName(getContext(), "ProxiedMapMultipleCheckServiceProvider").createComponentInstance(i6);

+             instance6.stop();

+             

+             Properties i7 = new Properties();

+             i7.put("instance.name","Dict");

+             instance7 = Utils.getFactoryByName(getContext(), "ProxiedDictMultipleCheckServiceProvider").createComponentInstance(i7);

+             instance7.stop();

+        

+            Properties prov = new Properties();

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

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

+        

+            Properties prov2 = new Properties();

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

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

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

+    }

+    

+    public void tearDown() {

+        instance1.dispose();

+        instance2.dispose();

+        instance3.dispose();

+        instance4.dispose();

+        instance5.dispose();

+        instance6.dispose();

+        instance7.dispose();

+        fooProvider1.dispose();

+        fooProvider2.dispose();

+        instance1 = null;

+        instance2 = null;

+        instance3 = null;

+        instance4 = null;

+        instance5 = null;

+        instance6 = null;

+        instance7 = null;

+        fooProvider1 = null;

+        fooProvider2 = null;

+    }

+    

+    public void testSimple() {

+        instance1.start();

+        

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

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

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

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

+        

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

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

+        CheckService cs = (CheckService) getContext().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(), 2);

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

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

+        

+        fooProvider2.stop();

+        

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

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

+        

+        cs = (CheckService) getContext().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(), 1);

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

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

+        

+        fooProvider1.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+        

+        instance1.stop();

+    }

+    

+    public void testVoid() {

+        instance2.start();

+        

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

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

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

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

+        

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

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

+        CheckService cs = (CheckService) getContext().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(), 2);

+        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(), 2);

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

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

+        

+        fooProvider1.stop();

+        

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

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

+        

+        cs = (CheckService) getContext().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(), 2);

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

+        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, 0);

+        

+        fooProvider2.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);	

+        instance2.stop();

+    }

+    

+    public void testObject() {

+        instance3.start();

+        

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());

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

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

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

+        

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());

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

+        CheckService cs = (CheckService) getContext().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(), 2);

+        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(), 2);

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

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

+        

+        fooProvider1.stop();

+        

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

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

+        

+        cs = (CheckService) getContext().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(), 2);

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

+        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, 0);

+        

+        fooProvider2.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+        instance3.stop();

+    }

+    

+    public void testRef() {

+        instance4.start();

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());

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

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());

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

+        CheckService cs = (CheckService) getContext().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(), 2);

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

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

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

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

+        

+        fooProvider1.stop();

+        

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

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

+        

+        cs = (CheckService) getContext().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(), 2);

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

+        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, 0);

+        

+        fooProvider2.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        instance4.stop();

+        getContext().ungetService(cs_ref);

+    }

+    

+    public void testBoth() {

+        instance5.start();

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());

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

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());

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

+        CheckService cs = (CheckService) getContext().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 both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 2);

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

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

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

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

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

+        

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

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

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

+        

+        fooProvider1.stop();

+        

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

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

+        

+        cs = (CheckService) getContext().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 both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 2);

+        assertEquals("check both unbind callback invocation - 3", ((Integer)props.get("bothU")).intValue(), 1);

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

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

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

+        assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).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, 0);

+        

+        fooProvider2.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        instance5.stop();

+        getContext().ungetService(cs_ref);

+    }

+    

+    public void testMap() {

+            instance6.start();

+            ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());

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

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

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

+            

+            ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());

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

+            CheckService cs = (CheckService) getContext().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 both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);

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

+            assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 2);

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

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

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

+            

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

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

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

+            

+            fooProvider1.stop();

+            

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

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

+            

+            cs = (CheckService) getContext().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 both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);

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

+            assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 2);

+            assertEquals("check map unbind callback invocation - 1", ((Integer)props.get("mapU")).intValue(), 1);

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

+            assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).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, 0);

+            

+            fooProvider2.stop();

+            

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

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

+            

+            id = null;

+            cs = null;

+            getContext().ungetService(arch_ref);

+            instance6.stop();

+            getContext().ungetService(cs_ref);

+    }

+    

+    public void testDict() {

+        instance7.start();

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());

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

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());

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

+        CheckService cs = (CheckService) getContext().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 both bind callback invocation - 1", ((Integer)props.get("bothB")).intValue(), 0);

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

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

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

+        assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 2);

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

+        

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

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

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

+        

+        fooProvider1.stop();

+        

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

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

+        

+        cs = (CheckService) getContext().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 both bind callback invocation - 3", ((Integer)props.get("bothB")).intValue(), 0);

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

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

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

+        assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 2);

+        assertEquals("check dict unbind callback invocation - 1", ((Integer)props.get("dictU")).intValue(), 1);

+        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, 0);

+        

+        fooProvider2.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        instance7.stop();

+        getContext().ungetService(cs_ref);

+    }

+

+    

+}

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

+ * 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 ProxiedDelayedOptionalDependencies extends OSGiTestCase {

+

+    ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;

+

+    ComponentInstance fooProvider;

+

+    public void setUp() {

+        try {

+            Properties prov = new Properties();

+            prov.put("instance.name","FooProvider");

+            fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);

+

+            Properties i1 = new Properties();

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

+            instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleOptionalCheckServiceProvider").createComponentInstance(i1);

+            instance1.stop();

+

+            Properties i2 = new Properties();

+            i2.put("instance.name","Void");

+            instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidOptionalCheckServiceProvider").createComponentInstance(i2);

+            instance2.stop();

+

+            Properties i3 = new Properties();

+            i3.put("instance.name","Object");

+            instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectOptionalCheckServiceProvider").createComponentInstance(i3);

+            instance3.stop();

+

+            Properties i4 = new Properties();

+            i4.put("instance.name","Ref");

+            instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefOptionalCheckServiceProvider").createComponentInstance(i4);

+            instance4.stop();

+

+            Properties i5 = new Properties();

+            i5.put("instance.name","Both");

+            instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothOptionalCheckServiceProvider").createComponentInstance(i5);

+            instance5.stop();

+            

+            Properties i6 = new Properties();

+            i6.put("instance.name","Map");

+            instance6 = Utils.getFactoryByName(getContext(), "ProxiedMapOptionalCheckServiceProvider").createComponentInstance(i6);

+            instance6.stop();

+            

+            Properties i7 = new Properties();

+            i7.put("instance.name","Dict");

+            instance7 = Utils.getFactoryByName(getContext(), "ProxiedDictOptionalCheckServiceProvider").createComponentInstance(i7);

+            instance7.stop();

+        } catch (Exception e) {

+            fail(e.getMessage());

+        }

+

+    }

+

+    public void tearDown() {

+        instance1.dispose();

+        instance2.dispose();

+        instance3.dispose();

+        instance4.dispose();

+        instance5.dispose();

+        instance6.dispose();

+        instance7.dispose();

+        fooProvider.dispose();

+        instance1 = null;

+        instance2 = null;

+        instance3 = null;

+        instance4 = null;

+        instance5 = null;

+        instance6 = null;

+        instance7 = null;

+        fooProvider = null;

+    }

+

+    public void testSimple() {

+        instance1.start();

+

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

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

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

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

+

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

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

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

+        Properties props = cs.getProps();

+

+        // Check properties

+        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());

+        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 both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);

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

+        assertNotNull("Check FS invocation (object) - 1", props.get("object"));

+        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);

+

+        fooProvider.stop();

+

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

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

+

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

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

+        props = cs.getProps();

+        // Check properties

+        assertFalse("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is 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 both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);

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

+        assertNull("Check FS invocation (object) - 2", props.get("object"));

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

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

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

+

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+

+        instance1.stop();

+    }

+

+    public void testVoid() {

+        instance2.start();

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

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

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

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

+

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

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

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

+        Properties props = cs.getProps();

+        // Check properties

+        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());

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

+        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 both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);

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

+        assertNotNull("Check FS invocation (object) - 1", props.get("object"));

+        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);

+

+        fooProvider.stop();

+

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

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

+

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

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

+        props = cs.getProps();

+        // Check properties

+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());

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

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

+        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 both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);

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

+        assertNull("Check FS invocation (object) - 2", props.get("object"));

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

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

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

+

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+

+        instance2.stop();

+    }

+

+    public void testObject() {

+        instance3.start();

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());

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

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

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

+

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        // Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());

+        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(), 1);

+        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 both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);

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

+

+        fooProvider.stop();

+

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

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

+

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

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

+        props = cs.getProps();

+        // Check properties

+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());

+        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(), 1);

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

+        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 both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);

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

+

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+

+        instance3.stop();

+    }

+

+    public void testRef() {

+        instance4.start();

+

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());

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

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

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

+

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        // Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());

+        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(), 1);

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

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

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

+

+        fooProvider.stop();

+

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

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

+

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

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

+        props = cs.getProps();

+        // Check properties

+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());

+        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(), 1);

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

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

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

+

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+

+        instance4.stop();

+    }

+

+    public void testBoth() {

+        instance5.start();

+

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());

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

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

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

+

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        // Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());

+        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 both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 1);

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

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

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

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

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

+

+        fooProvider.stop();

+

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

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

+

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

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

+        props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());

+        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 both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 1);

+        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 1);

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

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

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

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

+

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+

+        instance5.stop();

+    }

+    

+    public void testMap() {

+        instance6.start();

+

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());

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

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

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

+

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        // Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());

+        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 both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);

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

+        assertEquals("check map bind callback invocation - 1", ((Integer)props.get("mapB")).intValue(), 1);

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

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

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

+

+        fooProvider.stop();

+

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

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

+

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

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

+        props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());

+        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 both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);

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

+        assertEquals("check map bind callback invocation - 2", ((Integer)props.get("mapB")).intValue(), 1);

+        assertEquals("check map unbind callback invocation - 2", ((Integer)props.get("mapU")).intValue(), 1);

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

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

+

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+

+        instance6.stop();

+    }

+    

+    public void testDict() {

+        instance7.start();

+

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());

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

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

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

+

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        // Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());

+        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 both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);

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

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

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

+        assertEquals("check dict bind callback invocation - 1", ((Integer)props.get("dictB")).intValue(), 1);

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

+

+        fooProvider.stop();

+

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

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

+

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

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

+        props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());

+        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 both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);

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

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

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

+        assertEquals("check dict bind callback invocation - 2", ((Integer)props.get("dictB")).intValue(), 1);

+        assertEquals("check dict unbind callback invocation - 2", ((Integer)props.get("dictU")).intValue(), 1);

+

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+

+        instance7.stop();

+    }

+

+}

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

+ * 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 ProxiedDelayedOptionalMultipleDependencies extends OSGiTestCase {

+

+    ComponentInstance instance1, instance2, instance3, instance4;

+    ComponentInstance fooProvider1, fooProvider2;

+    

+    public void setUp() {		

+        try {

+            Properties i1 = new Properties();

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

+            instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i1);

+            instance1.stop();

+        

+            Properties i2 = new Properties();

+            i2.put("instance.name","Void");

+            instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidOptionalMultipleCheckServiceProvider").createComponentInstance(i2);

+            instance2.stop();

+        

+            Properties i3 = new Properties();

+            i3.put("instance.name","Object");

+            instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);

+            instance3.stop();

+        

+            Properties i4 = new Properties();

+            i4.put("instance.name","Ref");

+            instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);

+            instance4.stop();

+        

+            Properties prov = new Properties();

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

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

+        

+            Properties prov2 = new Properties();

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

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

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

+    }

+    

+    public void tearDown() {

+        instance1.dispose();

+        instance2.dispose();

+        instance3.dispose();

+        instance4.dispose();

+        fooProvider1.dispose();

+        fooProvider2.dispose();

+        instance1 = null;

+        instance2 = null;

+        instance3 = null;

+        instance4 = null;

+        fooProvider1 = null;

+        fooProvider2 = null;

+    }

+    

+    public void testSimple() {

+        instance1.start();

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

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

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

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

+        

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

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue());

+        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(), 2);

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

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

+        

+        fooProvider1.stop();

+        

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

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);		

+        instance1.stop();

+    }

+    

+    public void testVoid() {

+        instance2.start();

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

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

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

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

+        

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

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue());

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

+        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(), 2);

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

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

+        

+        fooProvider1.stop();

+        

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

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

+        

+        cs = (CheckService) getContext().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(), 2);

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

+        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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

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

+        props = cs.getProps();

+        //Check properties

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

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

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

+        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;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+        instance2.stop();

+    }

+    

+    public void testObject() {

+        instance3.start();

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());

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

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue());

+        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(), 2);

+        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(), 2);

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

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

+        

+        fooProvider1.stop();

+        

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

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

+        

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

+        props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue());

+        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(), 2);

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

+        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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

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

+        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(), 2);

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

+        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);

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);		

+        instance3.stop();

+    }

+    

+    public void testRef() {

+        instance4.start();

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());

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

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue());

+        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(), 2);

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

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

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

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

+        

+        fooProvider1.stop();

+        

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

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

+        

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

+        props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation - 3", ((Boolean)props.get("result")).booleanValue());

+        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(), 2);

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

+        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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

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

+        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(), 2);

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

+        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);

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+        instance4.stop();

+    }

+

+    

+}

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

+ * 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 ProxiedDelayedSimpleDependencies extends OSGiTestCase {

+    

+    ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;

+    ComponentInstance fooProvider;

+    

+    

+    public void setUp() {

+        try {

+            Properties prov = new Properties();

+            prov.put("instance.name","FooProvider");

+            fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);

+        

+            Properties i1 = new Properties();

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

+            instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleCheckServiceProvider").createComponentInstance(i1);

+            instance1.stop();

+        

+            Properties i2 = new Properties();

+            i2.put("instance.name","Void");

+            instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidCheckServiceProvider").createComponentInstance(i2);

+            instance2.stop();

+        

+            Properties i3 = new Properties();

+            i3.put("instance.name","Object");

+            instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectCheckServiceProvider").createComponentInstance(i3);

+            instance3.stop();

+        

+            Properties i4 = new Properties();

+            i4.put("instance.name","Ref");

+            instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefCheckServiceProvider").createComponentInstance(i4);

+            instance4.stop();

+            

+            Properties i5 = new Properties();

+            i5.put("instance.name","Both");

+            instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothCheckServiceProvider").createComponentInstance(i5);

+            instance5.stop();

+            

+            Properties i6 = new Properties();

+            i6.put("instance.name","Map");

+            instance6 = Utils.getFactoryByName(getContext(), "ProxiedMapCheckServiceProvider").createComponentInstance(i6);

+            instance6.stop();

+            

+            Properties i7 = new Properties();

+            i7.put("instance.name","Dict");

+            instance7 = Utils.getFactoryByName(getContext(), "ProxiedDictCheckServiceProvider").createComponentInstance(i7);

+            instance7.stop();

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

+        

+    }

+    

+    public void tearDown() {

+        instance1.dispose();

+        instance2.dispose();

+        instance3.dispose();

+        instance4.dispose();

+        instance5.dispose();

+        instance5.dispose();

+        instance6.dispose();

+        instance7.dispose();

+        fooProvider.dispose();

+        instance1 = null;

+        instance2 = null;

+        instance3 = null;

+        instance4 = null;

+        instance4 = null;

+        instance5 = null;

+        instance6 = null;

+        instance7 = null;

+        fooProvider = null;

+    }

+    

+    public void testSimple() {

+        instance1.start();

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

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

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

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

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

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        fooProvider.stop();

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

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

+        fooProvider.start();

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

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

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

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        fooProvider.stop();

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

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

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+        instance1.stop();

+    }

+    

+    public void testVoid() {

+        instance2.start();

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

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

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

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

+        

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

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());

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

+        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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);

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

+            

+        fooProvider.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+        

+        instance2.stop();

+    }

+    

+    public void testObject() {

+        instance3.start();

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());

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

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

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());

+        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(), 1);

+        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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);

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

+            

+        fooProvider.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+        

+        instance3.stop();

+    }

+    

+    public void testRef() {

+        instance4.start();

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());

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

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

+        

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());

+        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(), 1);

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

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

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

+        

+        fooProvider.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+        

+        instance4.stop();

+    }

+    

+    public void testBoth() {

+        instance5.start();

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());

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

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

+        

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());

+        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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 1);

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

+        

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

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

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

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

+        

+        fooProvider.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+        

+        instance5.stop();

+    }

+    

+    public void testMap() {

+        instance6.start();

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());

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

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

+        

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());

+        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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);

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

+       

+        assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);

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

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

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

+        

+        fooProvider.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+        

+        instance6.stop();

+    }

+       public void testDict() {

+            instance7.start();

+            ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());

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

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

+            

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

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

+            

+            ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());

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

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

+            Properties props = cs.getProps();

+            //Check properties

+            assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());

+            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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);

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

+           

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

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

+            assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);

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

+            

+            fooProvider.stop();

+            

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

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

+            

+            id = null;

+            cs = null;

+            getContext().ungetService(arch_ref);

+            getContext().ungetService(cs_ref);

+            

+            instance7.stop();

+        }

+

+}

diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedListMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedListMultipleDependencies.java
new file mode 100644
index 0000000..9365c1c
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedListMultipleDependencies.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 ProxiedListMultipleDependencies extends OSGiTestCase {

+

+    ComponentInstance instance1, instance2;

+    ComponentInstance fooProvider1, fooProvider2;

+    

+    public void setUp() {

+        try {

+            Properties prov = new Properties();

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

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

+            fooProvider1.stop();

+        

+            Properties prov2 = new Properties();

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

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

+            fooProvider2.stop();

+        

+            Properties i1 = new Properties();

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

+            instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleListCheckServiceProvider").createComponentInstance(i1);

+            

+            Properties i2 = new Properties();

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

+            instance2 = Utils.getFactoryByName(getContext(), "ProxiedOptionalListCheckServiceProvider").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(getContext(), Architecture.class.getName(), instance1.getInstanceName());

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

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

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

+        

+        fooProvider1.start();

+        

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

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

+        

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

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

+        CheckService cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+    }

+    

+    public void testOptional() {

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

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

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

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

+        

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

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

+        CheckService cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);       

+    }

+    

+}

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

+ * 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.util.Utils;

+import org.osgi.framework.ServiceReference;

+

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

+

+public class ProxiedOptionalDependencies extends OSGiTestCase {

+    

+    ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;

+    ComponentInstance fooProvider;

+    

+    public void setUp() {

+        try {

+            Properties prov = new Properties();

+            prov.put("instance.name","FooProvider");

+            fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);

+            fooProvider.stop();

+            

+            Properties i1 = new Properties();

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

+            instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleOptionalCheckServiceProvider").createComponentInstance(i1);

+        

+            Properties i2 = new Properties();

+            i2.put("instance.name","Void");

+            instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidOptionalCheckServiceProvider").createComponentInstance(i2);

+        

+            Properties i3 = new Properties();

+            i3.put("instance.name","Object");

+            instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectOptionalCheckServiceProvider").createComponentInstance(i3);

+        

+            Properties i4 = new Properties();

+            i4.put("instance.name","Ref");

+            instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefOptionalCheckServiceProvider").createComponentInstance(i4);

+            

+            Properties i5 = new Properties();

+            i5.put("instance.name","Both");

+            instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothOptionalCheckServiceProvider").createComponentInstance(i5);

+            

+            Properties i6 = new Properties();

+            i6.put("instance.name","Map");

+            instance6 = Utils.getFactoryByName(getContext(), "ProxiedMapOptionalCheckServiceProvider").createComponentInstance(i6);

+            

+            Properties i7 = new Properties();

+            i7.put("instance.name","Dictionary");

+            instance7 = Utils.getFactoryByName(getContext(), "ProxiedDictOptionalCheckServiceProvider").createComponentInstance(i7);

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

+    }

+    

+    public void tearDown() {

+        instance1.dispose();

+        instance2.dispose();

+        instance3.dispose();

+        instance4.dispose();

+        instance5.dispose();

+        instance6.dispose();

+        instance7.dispose();

+        fooProvider.dispose();

+        instance1 = null;

+        instance2 = null;

+        instance3 = null;

+        instance4 = null;

+        instance5 = null;

+        instance6 = null;

+        instance7 = null;

+        fooProvider = null;

+    }

+    

+    public void testSimple() {

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

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

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

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

+        

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

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

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

+        Properties props = cs.getProps();

+        

+        //Check properties

+        assertFalse("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)

+        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);

+        assertNull("Check FS invocation (object) - 1 ("+props.get("object")+")", props.get("object"));

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

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

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

+        

+        fooProvider.start();

+        

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

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

+        

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

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

+        props = cs.getProps();

+        

+        //Check properties

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

+        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);

+        assertNotNull("Check FS invocation (object) - 2", props.get("object"));

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

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

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

+        

+        fooProvider.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);		

+    }

+    

+    public void testVoid() {

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

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

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

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

+        

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

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)

+        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);

+        assertNull("Check FS invocation (object) - 1", props.get("object"));

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

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

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

+        

+        fooProvider.start();

+        

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

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

+        

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

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

+        props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());

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

+        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);

+        assertNotNull("Check FS invocation (object) - 2", props.get("object"));

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

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

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

+        

+        fooProvider.stop();

+        

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

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

+        

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

+        props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());

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

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

+        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);

+        assertNull("Check FS invocation (object) - 3", props.get("object"));

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

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);	

+    }

+    

+    public void testObject() {

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());

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

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)

+        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);

+        

+        fooProvider.start();

+        

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

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

+        

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

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

+        props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());

+        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() + ")", ((Integer)props.get("objectB")).intValue(), 1);

+        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);

+        

+        fooProvider.stop();

+        

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

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

+        

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

+        props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue()); // Nullable object.

+        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(), 1);

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

+        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);

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);		

+    }

+    

+    public void testRef() {

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());

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

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)

+        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);

+        

+        fooProvider.start();

+        

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

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

+        

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

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

+        props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());

+        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(), 1);

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

+        

+        fooProvider.stop();

+        

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

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

+        

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

+        props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());

+        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(), 1);

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+    }

+    

+    public void testBoth() {

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());

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

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)

+        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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);

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

+        

+        fooProvider.start();

+        

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

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

+        

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

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

+        props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());

+        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 both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 1);

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

+        

+        fooProvider.stop();

+        

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

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

+        

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

+        props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());

+        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 both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 1);

+        assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 1);

+  

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+    }

+    

+    public void testMap() {

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());

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

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)

+        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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);

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

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

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

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

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

+        

+        fooProvider.start();

+        

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

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

+        

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

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

+        props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());

+        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 both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 0);

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

+        assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 1);

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

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

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

+        

+        fooProvider.stop();

+        

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

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

+        

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

+        props = cs.getProps();

+        //Check properties

+        assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());

+        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 both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 0);

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

+        assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 1);

+        assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 1);

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

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

+  

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+    }

+    

+       public void testDict() {

+            ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());

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

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

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

+            

+            ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());

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

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

+            Properties props = cs.getProps();

+            //Check properties

+            assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)

+            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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);

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

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

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

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

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

+            

+            fooProvider.start();

+            

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

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

+            

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

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

+            props = cs.getProps();

+            //Check properties

+            assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());

+            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 both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 0);

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

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

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

+            assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 1);

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

+            

+            fooProvider.stop();

+            

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

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

+            

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

+            props = cs.getProps();

+            //Check properties

+            assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());

+            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 both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 0);

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

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

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

+            assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 1);

+            assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 1);

+      

+            id = null;

+            cs = null;

+            getContext().ungetService(arch_ref);

+            getContext().ungetService(cs_ref);

+        }

+

+

+}

diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSetMultipleDependencies.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSetMultipleDependencies.java
new file mode 100644
index 0000000..002d57f
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxiedSetMultipleDependencies.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 ProxiedSetMultipleDependencies extends OSGiTestCase {

+

+    ComponentInstance instance1, instance2;

+    ComponentInstance fooProvider1, fooProvider2;

+    

+    public void setUp() {

+        try {

+            Properties prov = new Properties();

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

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

+            fooProvider1.stop();

+        

+            Properties prov2 = new Properties();

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

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

+            fooProvider2.stop();

+        

+            Properties i1 = new Properties();

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

+            instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleSetCheckServiceProvider").createComponentInstance(i1);

+            

+            Properties i2 = new Properties();

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

+            instance2 = Utils.getFactoryByName(getContext(), "ProxiedOptionalSetCheckServiceProvider").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(getContext(), Architecture.class.getName(), instance1.getInstanceName());

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

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

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

+        

+        fooProvider1.start();

+        

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

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

+        

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

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

+        CheckService cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+    }

+    

+    public void testOptional() {

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

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

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

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

+        

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

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

+        CheckService cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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) getContext().getService(arch_ref)).getInstanceDescription();

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

+        

+        cs = (CheckService) getContext().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;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);       

+    }

+    

+}

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

+ * 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.util.Utils;

+import org.osgi.framework.ServiceReference;

+

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

+

+public class ProxiedSimpleDependencies extends OSGiTestCase {

+    

+    ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7, instance8;

+    ComponentInstance fooProvider;

+    

+    public void setUp() {

+        try {

+            Properties prov = new Properties();

+            prov.put("instance.name","FooProvider");

+            fooProvider = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);

+            fooProvider.stop();

+        

+            Properties i1 = new Properties();

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

+            instance1 = Utils.getFactoryByName(getContext(), "ProxiedSimpleCheckServiceProvider").createComponentInstance(i1);

+        

+            Properties i2 = new Properties();

+            i2.put("instance.name","Void");

+            instance2 = Utils.getFactoryByName(getContext(), "ProxiedVoidCheckServiceProvider").createComponentInstance(i2);

+        

+            Properties i3 = new Properties();

+            i3.put("instance.name","Object");

+            instance3 = Utils.getFactoryByName(getContext(), "ProxiedObjectCheckServiceProvider").createComponentInstance(i3);

+        

+            Properties i4 = new Properties();

+            i4.put("instance.name","Ref");

+            instance4 = Utils.getFactoryByName(getContext(), "ProxiedRefCheckServiceProvider").createComponentInstance(i4);

+            

+            Properties i5 = new Properties();

+            i5.put("instance.name","Both");

+            instance5 = Utils.getFactoryByName(getContext(), "ProxiedBothCheckServiceProvider").createComponentInstance(i5);

+            

+            Properties i6 = new Properties();

+            i6.put("instance.name","Double");

+            instance6 = Utils.getFactoryByName(getContext(), "ProxiedDoubleCheckServiceProvider").createComponentInstance(i6);

+            

+            Properties i7 = new Properties();

+            i7.put("instance.name","Map");

+            instance7 = Utils.getFactoryByName(getContext(), "ProxiedMapCheckServiceProvider").createComponentInstance(i7);

+            

+            Properties i8 = new Properties();

+            i8.put("instance.name","Dictionary");

+            instance8 = Utils.getFactoryByName(getContext(), "ProxiedDictCheckServiceProvider").createComponentInstance(i8);

+        } catch(Exception e) { 

+            e.printStackTrace();

+            fail(e.getMessage()); }

+        

+    }

+    

+    public void tearDown() {

+        instance1.dispose();

+        instance2.dispose();

+        instance3.dispose();

+        instance4.dispose();

+        instance5.dispose();

+        instance6.dispose();

+        instance7.dispose();

+        instance8.dispose();

+        fooProvider.dispose();

+        instance1 = null;

+        instance2 = null;

+        instance3 = null;

+        instance4 = null;

+        instance5 = null;

+        instance6 = null;

+        instance7 = null;

+        instance8 = null;

+        fooProvider = null;

+    }

+    

+    public void testSimple() {

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

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

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

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

+        

+        fooProvider.start();

+        

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

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

+        

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

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        fooProvider.stop();

+        

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

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

+        

+        fooProvider.start();

+        

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

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

+        

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

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

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

+        assertTrue("check CheckService invocation", cs.check());

+        

+        fooProvider.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);		

+    }

+    

+    public void testVoid() {

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

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

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

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

+        

+        fooProvider.start();

+        

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

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

+        

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

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

+        Object o = getContext().getService(cs_ref);

+        CheckService cs = (CheckService) o;

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());

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

+        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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);

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

+        

+        fooProvider.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);		

+    }

+    

+    public void testObject() {

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance3.getInstanceName());

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

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

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

+        

+        fooProvider.start();

+        

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance3.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());

+        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(), 1);

+        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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);

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

+        

+        fooProvider.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);		

+    }

+    

+    public void testRef() {

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance4.getInstanceName());

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

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

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

+        

+        fooProvider.start();

+        

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance4.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());

+        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(), 1);

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

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

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

+        

+        fooProvider.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+    }

+    

+    public void testBoth() {

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance5.getInstanceName());

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

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

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

+        

+        fooProvider.start();

+        

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance5.getInstanceName());

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

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

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());

+        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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 1);

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

+        

+        fooProvider.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+    }

+    

+    public void testDouble() {

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance6.getInstanceName());

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

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

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

+        

+        fooProvider.start();

+        

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance6.getInstanceName());

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

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

+        assertNotNull("Check cs", cs);

+        cs.check();

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());

+        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(), 1);

+        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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);

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

+        

+        fooProvider.stop();

+        

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

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

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);       

+    }

+    

+    public void testMap() {

+        ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance7.getInstanceName());

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

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

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

+        

+        fooProvider.start();

+        

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

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

+        

+        ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance7.getInstanceName());

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

+        CheckService cs = (CheckService) getContext().getService(cs_ref);

+        Properties props = cs.getProps();

+        //Check properties

+        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());

+        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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);

+        assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);

+        assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);

+        assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);

+        assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);

+        assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);

+        

+        fooProvider.stop();

+        

+        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

+        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);

+        

+        id = null;

+        cs = null;

+        getContext().ungetService(arch_ref);

+        getContext().ungetService(cs_ref);

+    }

+    

+       public void testDict() {

+            ServiceReference arch_ref = Utils.getServiceReferenceByName(getContext(), Architecture.class.getName(), instance8.getInstanceName());

+            assertNotNull("Check architecture availability", arch_ref);

+            InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

+            assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);

+            

+            fooProvider.start();

+            

+            id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

+            assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);

+            

+            ServiceReference cs_ref = Utils.getServiceReferenceByName(getContext(), CheckService.class.getName(), instance8.getInstanceName());

+            assertNotNull("Check CheckService availability", cs_ref);

+            CheckService cs = (CheckService) getContext().getService(cs_ref);

+            Properties props = cs.getProps();

+            //Check properties

+            assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());

+            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 both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);

+            assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);

+            assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);

+            assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);

+            assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);

+            assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);

+            

+            fooProvider.stop();

+            

+            id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();

+            assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);

+            

+            id = null;

+            cs = null;

+            getContext().ungetService(arch_ref);

+            getContext().ungetService(cs_ref);

+        }

+

+}

diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxyTest.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxyTest.java
new file mode 100644
index 0000000..5e9af89
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/ProxyTest.java
@@ -0,0 +1,196 @@
+package org.apache.felix.ipojo.test.scenarios.service.dependency;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.ConfigurationException;
+import org.apache.felix.ipojo.MissingHandlerException;
+import org.apache.felix.ipojo.UnacceptableConfiguration;
+import org.apache.felix.ipojo.handlers.dependency.DependencyHandler;
+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.service.dependency.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class ProxyTest extends OSGiTestCase {
+
+
+    public void testDelegation() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+        Properties prov = new Properties();
+        prov.put("instance.name","FooProvider1-Proxy");
+        ComponentInstance fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+        
+        
+        Properties i1 = new Properties();
+        i1.put("instance.name","Delegator");
+        ComponentInstance instance1 = Utils.getFactoryByName(getContext(), 
+                "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceDelegator").createComponentInstance(i1);
+        
+        
+        ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+        assertNotNull(ref);
+        CheckService cs = (CheckService) context.getService(ref);
+        
+        Properties props = cs.getProps();
+        FooService helper = (FooService) props.get("helper.fs");
+        assertNotNull(helper);
+        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
+        
+        assertTrue(cs.check());
+        
+        fooProvider1.dispose();
+        instance1.dispose();
+    }
+    
+    public void testDelegationOnNullable() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+        Properties i1 = new Properties();
+        i1.put("instance.name","DelegatorNullable");
+        ComponentInstance instance1 = Utils.getFactoryByName(getContext(), 
+                "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceDelegator").createComponentInstance(i1);
+        
+        
+        ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+        assertNotNull(ref);
+        CheckService cs = (CheckService) context.getService(ref);
+        
+        Properties props = cs.getProps();
+        FooService helper = (FooService) props.get("helper.fs");
+        assertNotNull(helper);
+        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
+        
+        assertFalse(cs.check()); // Nullable.
+        
+        instance1.dispose();
+    }
+    
+    
+    public void testGetAndDelegation() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+        Properties prov = new Properties();
+        prov.put("instance.name","FooProvider1-Proxy");
+        ComponentInstance fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+        
+        
+        Properties i1 = new Properties();
+        i1.put("instance.name","Delegator");
+        ComponentInstance instance1 = Utils.getFactoryByName(getContext(), 
+                "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceGetAndDelegate").createComponentInstance(i1);
+        
+        
+        ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+        assertNotNull(ref);
+        CheckService cs = (CheckService) context.getService(ref);
+        
+        Properties props = cs.getProps();
+        FooService helper = (FooService) props.get("helper.fs");
+        assertNotNull(helper);
+        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
+
+        
+        assertTrue(cs.check());
+        
+        fooProvider1.dispose();
+        instance1.dispose();
+    }
+    
+    public void testGetAndDelegationOnNullable() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+        Properties i1 = new Properties();
+        i1.put("instance.name","DelegatorNullable");
+        ComponentInstance instance1 = Utils.getFactoryByName(getContext(), 
+                "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceGetAndDelegate").createComponentInstance(i1);
+        
+        
+        ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+        assertNotNull(ref);
+        CheckService cs = (CheckService) context.getService(ref);
+        
+        Properties props = cs.getProps();
+        FooService helper = (FooService) props.get("helper.fs");
+        assertNotNull(helper);
+        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
+
+        assertFalse(cs.check()); // Nullable.
+        
+        
+        instance1.dispose();
+    }
+    
+    public void testImmediate() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+        Properties prov = new Properties();
+        prov.put("instance.name","FooProvider1-Proxy");
+        ComponentInstance fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+        
+        
+        Properties i1 = new Properties();
+        i1.put("instance.name","Delegator");
+        ComponentInstance instance1 = Utils.getFactoryByName(getContext(), 
+                "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceNoDelegate").createComponentInstance(i1);
+        
+        ServiceReference ref = Utils.getServiceReference(context, CheckService.class.getName(), "(service.pid=Helper)");
+        assertNotNull(ref);
+        CheckService cs = (CheckService) context.getService(ref);
+        
+        Properties props = cs.getProps();
+        FooService helper = (FooService) props.get("helper.fs");
+        assertNotNull(helper);
+        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
+
+        assertTrue(cs.check());
+        
+        fooProvider1.dispose();
+        instance1.dispose();
+    }
+    
+    public void testImmediateNoService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+        
+        Properties i1 = new Properties();
+        i1.put("instance.name","Delegator");
+        ComponentInstance instance1 = Utils.getFactoryByName(getContext(), 
+                "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceNoDelegate").createComponentInstance(i1);
+        
+        ServiceReference ref = Utils.getServiceReference(context, CheckService.class.getName(), "(service.pid=Helper)");
+        assertNotNull(ref);
+        CheckService cs = (CheckService) context.getService(ref);
+        
+        try {
+            cs.getProps();
+            fail("Exception expected");
+        } catch(RuntimeException e) {
+            //OK
+        }
+        
+        instance1.dispose();
+    }
+    
+    public void testProxyDisabled() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
+        // Disable proxy
+        System.setProperty(DependencyHandler.PROXY_SETTINGS_PROPERTY, DependencyHandler.PROXY_DISABLED);
+        Properties prov = new Properties();
+        prov.put("instance.name","FooProvider1-Proxy");
+        ComponentInstance fooProvider1 = Utils.getFactoryByName(getContext(), "FooProviderType-1").createComponentInstance(prov);
+        
+        
+        Properties i1 = new Properties();
+        i1.put("instance.name","Delegator");
+        ComponentInstance instance1 = Utils.getFactoryByName(getContext(), 
+                "org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceDelegator").createComponentInstance(i1);
+        
+        
+        ServiceReference ref = Utils.getServiceReferenceByName(context, CheckService.class.getName(), instance1.getInstanceName());
+        assertNotNull(ref);
+        CheckService cs = (CheckService) context.getService(ref);
+        
+        Properties props = cs.getProps();
+        FooService helper = (FooService) props.get("helper.fs");
+        assertNotNull(helper);
+        assertFalse(helper.toString().contains("$$Proxy")); // Not a proxy.
+        
+        assertTrue(cs.check());
+        
+        fooProvider1.dispose();
+        instance1.dispose();
+        System.setProperty(DependencyHandler.PROXY_SETTINGS_PROPERTY, DependencyHandler.PROXY_ENABLED);
+
+    }
+
+}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceDelegator.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceDelegator.java
new file mode 100644
index 0000000..9d2c736
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceDelegator.java
@@ -0,0 +1,31 @@
+package org.apache.felix.ipojo.test.scenarios.service.dependency.proxy;
+
+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.BundleContext;
+
+public class CheckServiceDelegator implements CheckService {
+
+    private FooService fs;
+    
+    private Helper helper;
+    
+    public CheckServiceDelegator(BundleContext bc) {
+        helper = new Helper(bc, fs);
+    }
+    
+    public boolean check() {
+        // Don't access the service
+        // Just delegate
+        return helper.check();
+    }
+
+    public Properties getProps() {
+        // Don't access the service
+        // Just delegate
+        return helper.getProps();
+    }
+
+}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceGetAndDelegate.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceGetAndDelegate.java
new file mode 100644
index 0000000..7f8be1e
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceGetAndDelegate.java
@@ -0,0 +1,29 @@
+package org.apache.felix.ipojo.test.scenarios.service.dependency.proxy;
+
+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.BundleContext;
+
+public class CheckServiceGetAndDelegate implements CheckService {
+
+    private FooService fs;
+    
+    private Helper helper;
+    
+    public CheckServiceGetAndDelegate(BundleContext bc) {
+        helper = new Helper(bc, fs);
+    }
+    
+    public boolean check() {
+        fs.foo();
+        return helper.check();
+    }
+
+    public Properties getProps() {
+        fs.getBoolean();
+        return helper.getProps();
+    }
+
+}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceNoDelegate.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceNoDelegate.java
new file mode 100644
index 0000000..a72e313
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/CheckServiceNoDelegate.java
@@ -0,0 +1,42 @@
+package org.apache.felix.ipojo.test.scenarios.service.dependency.proxy;
+
+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.BundleContext;
+
+public class CheckServiceNoDelegate implements CheckService {
+
+    private FooService fs;
+    
+    private Helper helper;
+    
+    private BundleContext context;
+    
+    public CheckServiceNoDelegate(BundleContext bc) {
+       context = bc;
+       helper = new Helper(context, fs);
+    }
+    
+    public void start() {
+        helper.publish();
+    }
+    
+    public void stop() {
+        helper.unpublish();
+    }
+    
+    public boolean check() {
+        // Don't access the service
+        // Just delegate
+        return helper.check();
+    }
+
+    public Properties getProps() {
+        // Don't access the service
+        // Just delegate
+        return helper.getProps();
+    }
+
+}
diff --git a/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/Helper.java b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/Helper.java
new file mode 100644
index 0000000..c2f0f29
--- /dev/null
+++ b/ipojo/tests/core/service-dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/service/dependency/proxy/Helper.java
@@ -0,0 +1,47 @@
+package org.apache.felix.ipojo.test.scenarios.service.dependency.proxy;
+
+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.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+
+public class Helper implements CheckService {
+    
+    
+    private FooService fs;
+    private BundleContext context;
+    private ServiceRegistration reg;
+    
+    public Helper(BundleContext bc, FooService svc) {
+        fs = svc;
+        context = bc;    
+    }
+    
+    public void publish() {
+        Properties props = new Properties();
+        props.put(Constants.SERVICE_PID, "Helper");
+        reg = context.registerService(CheckService.class.getName(), this, props);
+    }
+    
+    public void unpublish() {
+        if (reg != null) {
+            reg.unregister();
+        }
+        reg = null;
+    }
+
+    public boolean check() {
+        return fs.foo();
+    }
+
+    public Properties getProps() {
+        Properties props = new Properties();
+        fs.getBoolean();
+        props.put("helper.fs", fs);
+        return props;
+    }
+
+}
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 d490139..83fd97b 100644
--- a/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
+++ b/ipojo/tests/core/service-dependency/src/main/resources/metadata.xml
@@ -1,8 +1,8 @@
-<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

-  xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"

-  xmlns="org.apache.felix.ipojo">

+<ipojo>

 <!-- 

-

+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+  xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"

+  xmlns="org.apache.felix.ipojo"

  -->

   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"

@@ -14,13 +14,13 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

     name="SimpleCheckServiceProvider" architecture="true">

-    <requires field="fs" />

+    <requires field="fs" proxy="false"/>

     <provides />

   </component>

   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

     name="VoidCheckServiceProvider" architecture="true">

-    <requires field="fs">

+    <requires field="fs" proxy="false">

       <callback type="bind" method="voidBind" />

       <callback type="unbind" method="voidUnbind" />

     </requires>

@@ -29,7 +29,7 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

     name="ObjectCheckServiceProvider" architecture="true">

-    <requires field="fs">

+    <requires field="fs" proxy="false">

       <callback type="bind" method="objectBind" />

       <callback type="unbind" method="objectUnbind" />

     </requires>

@@ -38,7 +38,7 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

     name="RefCheckServiceProvider" architecture="true">

-    <requires field="fs">

+    <requires field="fs" proxy="false">

       <callback type="bind" method="refBind" />

       <callback type="unbind" method="refUnbind" />

     </requires>

@@ -47,7 +47,7 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

     name="BothCheckServiceProvider" architecture="true">

-    <requires field="fs">

+    <requires field="fs" proxy="false">

       <callback type="bind" method="bothBind" />

       <callback type="unbind" method="bothUnbind" />

     </requires>

@@ -56,7 +56,7 @@
     <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

     name="MapCheckServiceProvider" architecture="true">

-    <requires field="fs">

+    <requires field="fs" proxy="false">

       <callback type="bind" method="propertiesMapBind" />

       <callback type="unbind" method="propertiesMapUnbind" />

     </requires>

@@ -65,12 +65,74 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

     name="DictCheckServiceProvider" architecture="true">

+    <requires field="fs" proxy="false">

+      <callback type="bind" method="propertiesDictionaryBind" />

+      <callback type="unbind" method="propertiesDictionaryUnbind" />

+    </requires>

+    <provides />

+  </component>

+  

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

+    name="ProxiedSimpleCheckServiceProvider" architecture="true">

+    <requires field="fs" />

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

+    name="ProxiedVoidCheckServiceProvider" architecture="true">

+    <requires field="fs">

+      <callback type="bind" method="voidBind" />

+      <callback type="unbind" method="voidUnbind" />

+    </requires>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

+    name="ProxiedObjectCheckServiceProvider" 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.CheckServiceProvider"

+    name="ProxiedRefCheckServiceProvider" architecture="true">

+    <requires field="fs">

+      <callback type="bind" method="refBind" />

+      <callback type="unbind" method="refUnbind" />

+    </requires>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

+    name="ProxiedBothCheckServiceProvider" architecture="true">

+    <requires field="fs">

+      <callback type="bind" method="bothBind" />

+      <callback type="unbind" method="bothUnbind" />

+    </requires>

+    <provides />

+  </component>

+    <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

+    name="ProxiedMapCheckServiceProvider" architecture="true">

+    <requires field="fs">

+      <callback type="bind" method="propertiesMapBind" />

+      <callback type="unbind" method="propertiesMapUnbind" />

+    </requires>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

+    name="ProxiedDictCheckServiceProvider" architecture="true">

     <requires field="fs">

       <callback type="bind" method="propertiesDictionaryBind" />

       <callback type="unbind" method="propertiesDictionaryUnbind" />

     </requires>

     <provides />

   </component>

+  

 

   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

@@ -79,6 +141,16 @@
       <callback type="bind" method="objectBind" />

       <callback type="unbind" method="objectUnbind" />

     </requires>

+    <requires field="fs" proxy="true"/>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

+    name="ProxiedDoubleCheckServiceProvider" architecture="true">

+    <requires>

+      <callback type="bind" method="objectBind" />

+      <callback type="unbind" method="objectUnbind" />

+    </requires>

     <requires field="fs" />

     <provides />

   </component>

@@ -134,7 +206,7 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

     name="SimpleOptionalCheckServiceProvider" architecture="true">

-    <requires field="fs" optional="true" id="FooService"/>

+    <requires field="fs" optional="true" id="FooService" proxy="false"/>

     <provides />

   </component>

   <component

@@ -146,7 +218,7 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

     name="VoidOptionalCheckServiceProvider" architecture="true">

-    <requires field="fs" optional="true">

+    <requires field="fs" optional="true" proxy="false">

       <callback type="bind" method="voidBind" />

       <callback type="unbind" method="voidUnbind" />

     </requires>

@@ -164,7 +236,7 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

     name="ObjectOptionalCheckServiceProvider" architecture="true">

-    <requires field="fs" optional="true">

+    <requires field="fs" optional="true" proxy="false">

       <callback type="bind" method="objectBind" />

       <callback type="unbind" method="objectUnbind" />

     </requires>

@@ -182,7 +254,7 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

     name="RefOptionalCheckServiceProvider" architecture="true">

-    <requires field="fs" optional="true">

+    <requires field="fs" optional="true" proxy="false">

       <callback type="bind" method="refBind" />

       <callback type="unbind" method="refUnbind" />

     </requires>

@@ -200,7 +272,7 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

     name="BothOptionalCheckServiceProvider" architecture="true">

-    <requires field="fs" optional="true">

+    <requires field="fs" optional="true" proxy="false">

       <callback type="bind" method="bothBind" />

       <callback type="unbind" method="bothUnbind" />

     </requires>

@@ -209,7 +281,7 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

     name="MapOptionalCheckServiceProvider" architecture="true">

-    <requires field="fs" optional="true">

+    <requires field="fs" optional="true" proxy="false">

       <callback type="bind" method="propertiesMapBind" />

       <callback type="unbind" method="propertiesMapUnbind" />

     </requires>

@@ -218,6 +290,67 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

     name="DictOptionalCheckServiceProvider" architecture="true">

+    <requires field="fs" optional="true" proxy="false">

+      <callback type="bind" method="propertiesDictionaryBind" />

+      <callback type="unbind" method="propertiesDictionaryUnbind" />

+    </requires>

+    <provides />

+  </component>

+  

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

+    name="ProxiedSimpleOptionalCheckServiceProvider" architecture="true">

+    <requires field="fs" optional="true" id="FooService"/>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

+    name="ProxiedVoidOptionalCheckServiceProvider" architecture="true">

+    <requires field="fs" optional="true">

+      <callback type="bind" method="voidBind" />

+      <callback type="unbind" method="voidUnbind" />

+    </requires>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

+    name="ProxiedObjectOptionalCheckServiceProvider" architecture="true">

+    <requires field="fs" optional="true">

+      <callback type="bind" method="objectBind" />

+      <callback type="unbind" method="objectUnbind" />

+    </requires>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

+    name="ProxiedRefOptionalCheckServiceProvider" architecture="true">

+    <requires field="fs" optional="true">

+      <callback type="bind" method="refBind" />

+      <callback type="unbind" method="refUnbind" />

+    </requires>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

+    name="ProxiedBothOptionalCheckServiceProvider" architecture="true">

+    <requires field="fs" optional="true">

+      <callback type="bind" method="bothBind" />

+      <callback type="unbind" method="bothUnbind" />

+    </requires>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

+    name="ProxiedMapOptionalCheckServiceProvider" architecture="true">

+    <requires field="fs" optional="true">

+      <callback type="bind" method="propertiesMapBind" />

+      <callback type="unbind" method="propertiesMapUnbind" />

+    </requires>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider"

+    name="ProxiedDictOptionalCheckServiceProvider" architecture="true">

     <requires field="fs" optional="true">

       <callback type="bind" method="propertiesDictionaryBind" />

       <callback type="unbind" method="propertiesDictionaryUnbind" />

@@ -440,12 +573,28 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

     name="SimpleMultipleCheckServiceProvider" architecture="true">

-    <requires field="fs" />

+    <requires field="fs" proxy="false"/>

     <provides />

   </component>

   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

+    name="ProxiedSimpleMultipleCheckServiceProvider" architecture="true">

+    <requires field="fs" />

+    <provides />

+  </component>

+  

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

     name="VoidMultipleCheckServiceProvider" architecture="true">

+    <requires field="fs" proxy="false">

+      <callback type="bind" method="voidBind" />

+      <callback type="unbind" method="voidUnbind" />

+    </requires>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

+    name="ProxiedVoidMultipleCheckServiceProvider" architecture="true">

     <requires field="fs">

       <callback type="bind" method="voidBind" />

       <callback type="unbind" method="voidUnbind" />

@@ -455,6 +604,15 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

     name="ObjectMultipleCheckServiceProvider" architecture="true">

+    <requires field="fs" proxy="false">

+      <callback type="bind" method="objectBind" />

+      <callback type="unbind" method="objectUnbind" />

+    </requires>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

+    name="ProxiedObjectMultipleCheckServiceProvider" architecture="true">

     <requires field="fs">

       <callback type="bind" method="objectBind" />

       <callback type="unbind" method="objectUnbind" />

@@ -464,7 +622,7 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

     name="RefMultipleCheckServiceProvider" architecture="true">

-    <requires field="fs">

+    <requires field="fs" proxy="false">

       <callback type="bind" method="refBind" />

       <callback type="unbind" method="refUnbind" />

     </requires>

@@ -472,7 +630,26 @@
   </component>

   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

+    name="ProxiedRefMultipleCheckServiceProvider" architecture="true">

+    <requires field="fs">

+      <callback type="bind" method="refBind" />

+      <callback type="unbind" method="refUnbind" />

+    </requires>

+    <provides />

+  </component>

+  

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

     name="BothMultipleCheckServiceProvider" architecture="true">

+    <requires field="fs" proxy="false">

+      <callback type="bind" method="bothBind" />

+      <callback type="unbind" method="bothUnbind" />

+    </requires>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

+    name="ProxiedBothMultipleCheckServiceProvider" architecture="true">

     <requires field="fs">

       <callback type="bind" method="bothBind" />

       <callback type="unbind" method="bothUnbind" />

@@ -482,7 +659,7 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

     name="MapMultipleCheckServiceProvider" architecture="true">

-    <requires field="fs">

+    <requires field="fs" proxy="false">

       <callback type="bind" method="propertiesMapBind" />

       <callback type="unbind" method="propertiesMapUnbind" />

     </requires>

@@ -490,7 +667,26 @@
   </component>

   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

-    name="DictMultipleCheckServiceProvider" architecture="true">

+    name="ProxiedMapMultipleCheckServiceProvider" architecture="true">

+    <requires field="fs">

+      <callback type="bind" method="propertiesMapBind" />

+      <callback type="unbind" method="propertiesMapUnbind" />

+    </requires>

+    <provides />

+  </component>

+  

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

+    name="DictMultipleCheckServiceProvider" architecture="true" >

+    <requires field="fs" proxy="false">

+      <callback type="bind" method="propertiesDictionaryBind" />

+      <callback type="unbind" method="propertiesDictionaryUnbind" />

+    </requires>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

+    name="ProxiedDictMultipleCheckServiceProvider" architecture="true">

     <requires field="fs">

       <callback type="bind" method="propertiesDictionaryBind" />

       <callback type="unbind" method="propertiesDictionaryUnbind" />

@@ -551,14 +747,14 @@
     classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

     name="SimpleOptionalMultipleCheckServiceProvider"

     architecture="true">

-    <requires field="fs" optional="true" />

+    <requires field="fs" optional="true" proxy="false"/>

     <provides />

   </component>

   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

     name="VoidOptionalMultipleCheckServiceProvider"

     architecture="true">

-    <requires field="fs" optional="true">

+    <requires field="fs" optional="true" proxy="false">

       <callback type="bind" method="voidBind" />

       <callback type="unbind" method="voidUnbind" />

     </requires>

@@ -568,7 +764,7 @@
     classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

     name="ObjectOptionalMultipleCheckServiceProvider"

     architecture="true">

-    <requires field="fs" optional="true">

+    <requires field="fs" optional="true" proxy="false">

       <callback type="bind" method="objectBind" />

       <callback type="unbind" method="objectUnbind" />

     </requires>

@@ -578,12 +774,51 @@
     classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

     name="RefOptionalMultipleCheckServiceProvider"

     architecture="true">

+    <requires field="fs" optional="true" proxy="false">

+      <callback type="bind" method="refBind" />

+      <callback type="unbind" method="refUnbind" />

+    </requires>

+    <provides />

+  </component>

+  

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

+    name="ProxiedSimpleOptionalMultipleCheckServiceProvider"

+    architecture="true">

+    <requires field="fs" optional="true" />

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

+    name="ProxiedVoidOptionalMultipleCheckServiceProvider"

+    architecture="true">

+    <requires field="fs" optional="true">

+      <callback type="bind" method="voidBind" />

+      <callback type="unbind" method="voidUnbind" />

+    </requires>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

+    name="ProxiedObjectOptionalMultipleCheckServiceProvider"

+    architecture="true">

+    <requires field="fs" optional="true">

+      <callback type="bind" method="objectBind" />

+      <callback type="unbind" method="objectUnbind" />

+    </requires>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckService"

+    name="ProxiedRefOptionalMultipleCheckServiceProvider"

+    architecture="true">

     <requires field="fs" optional="true">

       <callback type="bind" method="refBind" />

       <callback type="unbind" method="refUnbind" />

     </requires>

     <provides />

   </component>

+  

   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.MethodMultipleCheckService"

     name="MObjectOptionalMultipleCheckServiceProvider"

@@ -611,13 +846,28 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"

     name="SimpleListCheckServiceProvider" architecture="true">

-    <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>

+    <requires proxy="false"

+      field="fs" specification="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 proxy="false" 

+      specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />

+    <provides />

+  </component>

+   <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"

+    name="ProxiedSimpleListCheckServiceProvider" architecture="true">

+    <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.ListCheckService"

+    name="ProxiedOptionalListCheckServiceProvider"

+    architecture="true">

     <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />

     <provides />

   </component>

@@ -644,13 +894,26 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.SetCheckService"

     name="SimpleSetCheckServiceProvider" architecture="true">

-    <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>

+    <requires proxy="false" field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>

     <provides />

   </component>

   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.SetCheckService"

     name="OptionalSetCheckServiceProvider"

     architecture="true">

+    <requires proxy="false" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.SetCheckService"

+    name="ProxiedSimpleSetCheckServiceProvider" architecture="true">

+    <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.SetCheckService"

+    name="ProxiedOptionalSetCheckServiceProvider"

+    architecture="true">

     <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />

     <provides />

   </component>

@@ -659,6 +922,12 @@
   <component

     classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckService"

     name="SimpleCollectionCheckServiceProvider" architecture="true">

+    <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" proxy="false"/>

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckService"

+    name="ProxiedSimpleCollectionCheckServiceProvider" architecture="true">

     <requires field="fs" specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService"/>

     <provides />

   </component>

@@ -666,7 +935,18 @@
     classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckService"

     name="OptionalCollectionCheckServiceProvider"

     architecture="true">

-    <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" />

+    <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" 

+      proxy="false"

+    />

+    <provides />

+  </component>

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.CollectionCheckService"

+    name="ProxiedOptionalCollectionCheckServiceProvider"

+    architecture="true">

+    <requires specification="org.apache.felix.ipojo.test.scenarios.service.dependency.service.FooService" field="fs" optional="true" 

+      proxy="false"

+    />

     <provides />

   </component>

   

@@ -740,5 +1020,21 @@
     </requires>

     <provides />

   </component>

+

+  <!--  Proxy Tests -->

+  <component classname="org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceDelegator">

+    <provides/>

+    <requires field="fs" optional="true"/>

+  </component>

+  <component classname="org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceGetAndDelegate">

+    <provides/>

+    <requires field="fs" optional="true"/>

+  </component>

+  <component classname="org.apache.felix.ipojo.test.scenarios.service.dependency.proxy.CheckServiceNoDelegate">

+      <provides/>

+      <requires field="fs" optional="true"/>

+      <callback transition="validate" method="start"/>

+    <callback transition="invalidate" method="stop"/>  

+  </component>

   

 </ipojo>

diff --git a/ipojo/tests/core/service-providing-strategies/src/main/resources/metadata.xml b/ipojo/tests/core/service-providing-strategies/src/main/resources/metadata.xml
index 901cede..bb892b3 100755
--- a/ipojo/tests/core/service-providing-strategies/src/main/resources/metadata.xml
+++ b/ipojo/tests/core/service-providing-strategies/src/main/resources/metadata.xml
@@ -3,33 +3,33 @@
     xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/SNAPSHOT/core.xsd"

     xmlns="org.apache.felix.ipojo"

 >

-	<!-- Simple provider  -->

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooProviderType1"

-		name="PSS-FooProviderType-Instance" architecture="true">

-		<provides strategy="instance"/>

-	</component>

-	

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.component.strategies.Consumer"

-		name="PSS-Cons" architecture="true">

-		<requires field="fs"/>

-		<provides/>

-	</component>

-	

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.component.strategies.BarConsumer"

-		name="PSS-ConsBar" architecture="true">

-		<requires field="bs"/>

-		<provides/>

-	</component>

-	

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooBarProviderType1"

-		name="PSS-FooBarProviderType-Instance" architecture="true">

-		<provides strategy="instance"/>

-	</component>

-	

+  <!-- Simple provider  -->

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooProviderType1"

+    name="PSS-FooProviderType-Instance" architecture="true">

+    <provides strategy="instance"/>

+  </component>

+  

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.strategies.Consumer"

+    name="PSS-Cons" architecture="true">

+    <requires field="fs" proxy="false"/>

+    <provides/>

+  </component>

+  

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.strategies.BarConsumer"

+    name="PSS-ConsBar" architecture="true">

+    <requires field="bs" proxy="false"/>

+    <provides/>

+  </component>

+  

+  <component

+    classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooBarProviderType1"

+    name="PSS-FooBarProviderType-Instance" architecture="true">

+    <provides strategy="instance"/>

+  </component>

+  

     <component

         classname="org.apache.felix.ipojo.test.scenarios.component.strategies.FooProviderType1"

         name="PSS-FooProviderType-Custom" architecture="true">