FELIX-3093 - migrate composite test to pax exam 3

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1450158 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/runtime/composite-it/pom.xml b/ipojo/runtime/composite-it/pom.xml
new file mode 100644
index 0000000..bf0c638
--- /dev/null
+++ b/ipojo/runtime/composite-it/pom.xml
@@ -0,0 +1,455 @@
+<!--
+  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.
+-->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>felix-parent</artifactId>
+        <version>1.2.1</version>
+        <relativePath>../../../pom/pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>org.apache.felix.ipojo.runtime.composite-it</artifactId>
+    <version>1.9.0-SNAPSHOT</version>
+    <name>Apache Felix iPOJO Runtime Project ~ Composite Integration Tests</name>
+    <packaging>pom</packaging>
+
+    <build>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+            </resource>
+            <resource>
+                <directory>.</directory>
+                <targetPath>META-INF</targetPath>
+                <includes>
+                    <include>LICENSE*</include>
+                    <include>NOTICE*</include>
+                    <include>DEPENDENCIES*</include>
+                </includes>
+            </resource>
+        </resources>
+
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.5.1</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.servicemix.tooling</groupId>
+                <artifactId>depends-maven-plugin</artifactId>
+                <version>1.2</version>
+                <executions>
+                    <execution>
+                        <id>generate-config</id>
+                        <goals>
+                            <goal>generate-depends-file</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+
+    </build>
+
+    <properties>
+        <exam.version>3.0.0</exam.version>
+        <url.version>1.5.1</url.version>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-native</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit4</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-aether</artifactId>
+            <version>${url.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.framework</artifactId>
+            <version>4.2.0</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-core</artifactId>
+            <version>0.9.6</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>0.9.6</version>
+            <scope>test</scope>
+        </dependency>
+
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.9</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.9.5</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ops4j.pax.tinybundles</groupId>
+            <artifactId>tinybundles</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.ipojo</artifactId>
+            <version>1.9.0-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.ipojo.composite</artifactId>
+            <version>1.9.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.ipojo.manipulator</artifactId>
+            <version>1.9.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.configadmin</artifactId>
+            <version>1.6.0</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ow2.chameleon.testing</groupId>
+            <artifactId>osgi-helpers</artifactId>
+            <version>0.6.0</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ow2.chameleon.testing</groupId>
+            <artifactId>tinybundles-ipojo</artifactId>
+            <version>0.3.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.ipojo.handler.eventadmin</artifactId>
+            <!--
+            We use the released version as we don't really have to do any behavioral test on the handler in the core
+            test.
+            -->
+            <version>1.8.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.log</artifactId>
+            <version>1.0.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-wrap</artifactId>
+            <version>1.5.2</version>
+        </dependency>
+    </dependencies>
+
+    <profiles>
+        <profile>
+            <id>release</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-assembly-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>make-assembly</id>
+                                <phase>package</phase>
+                                <goals>
+                                    <goal>single</goal>
+                                </goals>
+                                <configuration>
+                                    <descriptorRefs>
+                                        <descriptorRef>project</descriptorRef>
+                                    </descriptorRefs>
+                                    <!-- we don't want to attach all the assemblies, such as bz2 -->
+                                    <attach>false</attach>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <!-- only attach the project and bin assemblies, in tar.gz and zip flavors -->
+                        <groupId>org.codehaus.mojo</groupId>
+                        <artifactId>build-helper-maven-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>attach-assemblies</id>
+                                <phase>package</phase>
+                                <goals>
+                                    <goal>attach-artifact</goal>
+                                </goals>
+                                <configuration>
+                                    <artifacts>
+                                        <artifact>
+                                            <file>
+                                                ${project.build.directory}/${project.artifactId}-${project.version}-project.tar.gz
+                                            </file>
+                                            <classifier>project</classifier>
+                                            <type>tar.gz</type>
+                                        </artifact>
+                                        <artifact>
+                                            <file>
+                                                ${project.build.directory}/${project.artifactId}-${project.version}-project.zip
+                                            </file>
+                                            <classifier>project</classifier>
+                                            <type>zip</type>
+                                        </artifact>
+                                    </artifacts>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
+        <profile>
+            <id>knopflerfish</id>
+            <activation>
+                <activeByDefault>false</activeByDefault>
+                <property>
+                    <name>pax.exam.framework</name>
+                    <value>knopflerfish</value>
+                </property>
+            </activation>
+            <properties>
+                <pax.exam.framework>knopflerfish</pax.exam.framework>
+            </properties>
+            <repositories>
+                <repository>
+                    <id>knopflerfish-releases</id>
+                    <url>http://www.knopflerfish.org/maven2</url>
+                </repository>
+            </repositories>
+            <dependencies>
+                <dependency>
+                    <groupId>org.knopflerfish</groupId>
+                    <artifactId>framework</artifactId>
+                    <version>5.2.0</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+
+        <profile>
+            <id>equinox</id>
+            <activation>
+                <activeByDefault>false</activeByDefault>
+                <property>
+                    <name>pax.exam.framework</name>
+                    <value>equinox</value>
+                </property>
+            </activation>
+            <properties>
+                <pax.exam.framework>equinox</pax.exam.framework>
+            </properties>
+            <dependencies>
+                <dependency>
+                    <groupId>org.eclipse.tycho</groupId>
+                    <artifactId>org.eclipse.osgi</artifactId>
+                    <version>3.8.1.v20120830-144521</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+
+        <profile>
+            <id>felix</id>
+            <activation>
+                <activeByDefault>false</activeByDefault>
+                <property>
+                    <name>pax.exam.framework</name>
+                    <value>felix</value>
+                </property>
+            </activation>
+            <properties>
+                <pax.exam.framework>felix</pax.exam.framework>
+            </properties>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.felix</groupId>
+                    <artifactId>org.apache.felix.framework</artifactId>
+                    <version>4.2.0</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+
+        <profile>
+            <id>test</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-invoker-plugin</artifactId>
+                        <version>1.8</version>
+                        <configuration>
+                            <streamLogs>true</streamLogs>
+                            <goals>
+                                <goal>clean</goal>
+                                <goal>test</goal>
+                            </goals>
+                            <cloneClean>true</cloneClean>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>regular</id>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                                <configuration>
+                                    <profiles>
+                                        <profile>felix</profile>
+                                    </profiles>
+                                    <cloneProjectsTo>${project.build.directory}/regular</cloneProjectsTo>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+
+        <profile>
+            <id>test-all</id>
+            <activation>
+                <activeByDefault>false</activeByDefault>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-invoker-plugin</artifactId>
+                        <version>1.8</version>
+                        <configuration>
+                            <streamLogs>true</streamLogs>
+                            <goals>
+                                <goal>clean</goal>
+                                <goal>test</goal>
+                            </goals>
+                            <cloneClean>true</cloneClean>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>equinox-native</id>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                                <configuration>
+                                    <profiles>
+                                        <profile>equinox</profile>
+                                    </profiles>
+                                    <cloneProjectsTo>${project.build.directory}/equinox-native</cloneProjectsTo>
+
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>felix-native</id>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                                <configuration>
+                                    <profiles>
+                                        <profile>felix</profile>
+                                    </profiles>
+                                    <cloneProjectsTo>${project.build.directory}/felix-native</cloneProjectsTo>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>knopflerfish-native</id>
+                                <goals>
+                                    <goal>run</goal>
+                                </goals>
+                                <configuration>
+                                    <profiles>
+                                        <profile>knopflerfish</profile>
+                                    </profiles>
+                                    <cloneProjectsTo>${project.build.directory}/knopflerfish-native</cloneProjectsTo>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+</project>
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/pom.xml b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/pom.xml
new file mode 100644
index 0000000..c27cf16
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/pom.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.ipojo.runtime.composite-it</artifactId>
+        <version>1.9.0-SNAPSHOT</version>
+        <relativePath>../../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.felix</groupId>
+    <artifactId>ipojo-composite-import-export-test</artifactId>
+
+    <name>${project.artifactId}</name>
+    
+</project>
\ No newline at end of file
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Baz2CheckProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Baz2CheckProvider.java
new file mode 100644
index 0000000..7e5d145
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Baz2CheckProvider.java
@@ -0,0 +1,81 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.BazService;

+import org.apache.felix.ipojo.runtime.core.services.CheckService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+public class Baz2CheckProvider implements CheckService {

+	

+	BazService fs;

+	

+	int simpleB = 0;

+	int objectB = 0;

+	int refB = 0;

+	int simpleU = 0;

+	int objectU = 0;

+	int refU = 0;

+

+	public boolean check() {

+		return fs.foo();

+	}

+

+	public Properties getProps() {

+		Properties props = new Properties();

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

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

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

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

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

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

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

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

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

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

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

+		if(fs.getObject() != null) { props.put("object", fs.getObject()); }

+		

+		return props;

+	}

+	

+	private void voidBind() {

+		simpleB++;

+	}

+	private void voidUnbind() {

+		simpleU++;

+	}

+	

+	protected void objectBind(Object o) {

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

+	}

+	protected void objectUnbind(Object o) {

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

+	}

+	

+	public void refBind(ServiceReference sr) {

+		if(sr != null) { refB++; }

+	}

+	public void refUnbind(ServiceReference sr) {

+		if(sr != null) { refU++; }

+	}

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/BazProviderType1.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/BazProviderType1.java
new file mode 100644
index 0000000..5ac64d3
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/BazProviderType1.java
@@ -0,0 +1,51 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.BazService;

+

+import java.util.Properties;

+

+public class BazProviderType1 implements BazService {

+	

+	private int m_bar;

+	private String m_foo;

+

+	public boolean foo() {

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("bar", new Integer(m_bar));

+		p.put("foo", m_foo);

+		return p;

+	}

+	

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckProviderParentClass.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckProviderParentClass.java
new file mode 100644
index 0000000..7d18712
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckProviderParentClass.java
@@ -0,0 +1,51 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.ServiceReference;

+

+public abstract class CheckProviderParentClass {

+    

+    int simpleU = 0;

+    int objectU = 0;

+    int refU = 0;

+    int bothU = 0;

+    

+    

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

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

+    }

+    

+    public void refUnbind(ServiceReference sr) {

+        if(sr != null) { refU++; }

+    }

+    

+    public void objectUnbind(FooService o) {

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

+        else {

+            System.err.println("Unbind null : " + o);

+        }

+    }

+    

+    public void voidUnbind() {

+        simpleU++;

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java
new file mode 100644
index 0000000..eee88a2
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java
@@ -0,0 +1,83 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.CheckService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+public class CheckServiceProvider extends CheckProviderParentClass implements CheckService {

+    

+	FooService fs;

+	

+	int simpleB = 0;

+	int objectB = 0;

+	int refB = 0;

+	int bothB = 0;

+

+	public boolean check() {

+		return fs.foo();

+	}

+

+	public Properties getProps() {

+		Properties props = new Properties();

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

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

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

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

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

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

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

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

+		if (fs != null) {

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

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

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

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

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

+		    if(fs.getObject() != null) { props.put("object", fs.getObject()); }

+		}

+        props.put("static", CheckService.foo);

+        props.put("class", CheckService.class.getName());

+		return props;

+	}

+	

+	private void voidBind() {

+		simpleB++;

+	}

+	

+	protected void objectBind(FooService o) {

+	    if (o == null) {

+	        System.err.println("Bind receive null !!! ");

+	        return;

+	    }

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

+	}

+	

+	public void refBind(ServiceReference sr) {

+		if(sr != null) { refB++; }

+	}

+	

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

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

+	}

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java
new file mode 100644
index 0000000..03016d3
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java
@@ -0,0 +1,54 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.BarService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+

+import java.util.Properties;

+

+public class FooBarProviderType1 implements FooService, BarService {

+

+	public boolean foo() {

+		return true;

+	}

+

+	public Properties fooProps() {

+		return new Properties();

+	}

+

+	public boolean bar() {

+		return true;

+	}

+

+	public Properties getProps() {

+		return new Properties();

+	}

+

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
new file mode 100644
index 0000000..b9eda2d
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
@@ -0,0 +1,92 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.BundleContext;

+

+import java.util.Properties;

+

+public class FooProviderType1 implements FooService {

+	

+	private int m_bar;

+	private String m_foo;

+    

+    private BundleContext m_context;

+    

+    private static FooProviderType1 singleton;

+    private static int count = 0;

+    

+    public FooProviderType1(BundleContext bc) {

+        if (bc ==null) {

+            throw new RuntimeException("Injected bundle context null");

+        }

+        m_context = bc;

+    }

+

+	public boolean foo() {

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("bar", new Integer(m_bar));

+        if(m_foo != null) {

+            p.put("foo", m_foo);

+        }

+        p.put("context", m_context);

+        

+        p.put("count", new Integer(count));

+		return p;

+	}

+    

+	public void testException() throws Exception {

+        String a = "foobarbaz";

+	    throw new Exception("foo"+a);

+    }

+    

+    public void testTry() {

+            String a = "foo";

+            a.charAt(0);

+    }

+    

+    public void testTry2(String s) {

+            String a = "foo";

+            a.charAt(0);

+    }

+    

+    private void nexttry(String  s) {

+        try {

+            s += "foo";

+        } catch(RuntimeException e) {

+            

+        }

+    }

+    

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java
new file mode 100644
index 0000000..47f6ae5
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java
@@ -0,0 +1,63 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+

+import java.util.Properties;

+

+public class FooProviderTypeDyn implements FooService {

+	

+	private int intProp;	

+	private String strProp;

+	private String[] strAProp;

+	private int[] intAProp;

+	private boolean boolProp;

+

+	public boolean foo() {

+		intProp = 3;

+		boolProp = true;

+		if(strProp.equals("foo")) { strProp = "bar"; }

+		else { strProp = "foo"; }

+		strAProp = new String[] {"foo", "bar", "baz"};

+		intAProp = new int[] {3, 2, 1};

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("intProp", new Integer(intProp));

+		p.put("boolProp", new Boolean(boolProp));

+		p.put("strProp", strProp);

+		p.put("strAProp", strAProp);

+		p.put("intAProp", intAProp);

+		return p;

+	}

+	

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java
new file mode 100644
index 0000000..efec5f0
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java
@@ -0,0 +1,58 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+

+import java.util.Properties;

+

+public class FooProviderTypeDyn2 implements FooService {

+	

+	private int intProp = 2;

+	private boolean boolProp = true;

+	private String strProp = "foo";

+	private String[] strAProp = new String[] {"foo", "bar"};

+	private int[] intAProp = new int[] {1, 2, 3};

+

+	public boolean foo() {

+		intAProp = null;

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("intProp", new Integer(intProp));

+		p.put("boolProp", new Boolean(boolProp));

+		p.put("strProp", strProp);

+		p.put("strAProp", strAProp);

+		p.put("intAProp", intAProp);

+		return p;

+	}

+	

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java
new file mode 100644
index 0000000..c3ade01
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java
@@ -0,0 +1,222 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.Tata;

+

+import java.util.Properties;

+

+

+public class TataProvider implements Tata {

+    

+    int tata = 0;

+    int tataStr = 0;

+    int tataStrs = 0;

+    int tata_2 = 0;

+    int tata_3 = 0;

+    int tata1 = 0;

+    int tata1_1 = 0;

+    int tata5 = 0;

+    int tata5_1 = 0;

+    int tata5_2 = 0;

+    int tataBoolean = 0;

+    int tataBooleans = 0;

+    int tataByte = 0;

+    int tataBytes = 0;

+    private int add;

+    private int tataShorts;

+    private int tataShort;

+    private int tataLongs;

+    private int tataLong;

+    private int tataInts;

+    private int tataInt;

+    private int tataFloat;

+    private int tataFloats;

+    private int tataDoubles;

+    private int tataDouble;

+    private int tataChars;

+    private int tataChar;

+    

+    public Properties getPropsTata() {

+        Properties props = new Properties();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+        return props;

+    }

+

+    public void tata() {

+        tata++;

+    }

+

+    public String tataStr() {

+        tataStr++;

+        return "Tata";

+    }

+

+    public String[] tataStrs() {

+        tataStrs++;

+        return new String[] {"T", "A", "T", "A"};

+    }

+

+    public void tata(int i, int j) {

+        tata_2++;        

+    }

+

+    public void tata(String s) {

+        tata_3++;

+    }

+

+    public String tata1(String a) {

+        tata1++;

+       return a;

+    }

+

+    public String tata1(char[] a) {

+        tata1_1++;

+        String s = new String(a);

+        return s;

+    }

+

+    public String tata5(String a, int i) {

+       tata5++;

+       return a+i;

+    }

+

+    public String tata5(String[] a, int i) {

+       tata5_1++;

+       return ""+a.length + i;

+    }

+

+    public String tata5(String a, int[] i) {

+        tata5_2++;

+        return a + i.length;

+    }

+

+    public boolean tataBoolean(boolean b) {

+        tataBoolean++;

+        return b;

+    }

+

+    public boolean[] tataBooleans(boolean[] b) {

+        tataBooleans++;

+       return b;

+    }

+

+    public byte tataByte(byte b) {

+        tataByte++;

+        return b;

+    }

+

+    public byte[] tataBytes(byte[] b) {

+        tataBytes++;

+        return b;

+    }

+

+    public char tataChar(char c) {

+       tataChar++;

+       return c;

+    }

+

+    public char[] tataChars(char[] c) {

+        tataChars++;

+        return c;

+    }

+

+    public double tataDouble(double d) {

+        tataDouble++;

+        return d;

+    }

+

+    public double[] tataDoubles(double[] d) {

+        tataDoubles++;

+        return d;

+    }

+

+    public float tataFloat(float f) {

+        tataFloat++;

+        return f;

+    }

+

+    public float[] tataFloats(float[] f) {

+        tataFloats++;

+        return f;

+    }

+

+    public int tataInt(int i) {

+        tataInt++;

+        return i;

+    }

+

+    public int[] tataInts(int[] its) {

+        tataInts++;

+        return its;

+    }

+

+    public long tataLong(long l) {

+        tataLong++;

+        return l;

+    }

+

+    public long[] tataLongs(long[] l) {

+        tataLongs++;

+        return l;

+    }

+

+    public short tataShort(short s) {

+        tataShort++;

+        return s;

+    }

+

+    public short[] tataShorts(short[] s) {

+        tataShorts++;

+        return s;

+    }

+

+    public long add(int i, int j, int k) {

+        add++;

+        return i + j + k;

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java
new file mode 100644
index 0000000..d230c2d
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java
@@ -0,0 +1,73 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.Toto;

+

+import java.util.Properties;

+

+

+public class TotoProvider implements Toto {

+    

+    private int i = 0;

+    public static int toto = 0;

+    public static int toto_2 = 0;

+    public static int toto_3 = 0;

+    public static int toto_4 = 0;

+    public static int toto1 = 0;

+    

+    public int count() {

+        return i;

+    }

+    

+    public void toto() {

+        toto++;        

+    }

+

+    public void toto(int i, int j) {

+        toto_2++;

+    }

+

+    public String toto(String a) {

+        toto_3++;

+        return a;

+    }

+

+    public String toto(String[] a) {

+        toto_4++;

+        return "toto";

+    }

+

+    public void toto1(String j) {

+        i++;

+        toto1++;        

+    }

+

+    public Properties getProps() {

+        Properties props = new Properties();

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

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

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

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

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

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

+        return props;

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java
new file mode 100644
index 0000000..f90460c
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java
@@ -0,0 +1,81 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.Toto;

+

+import java.util.Properties;

+

+

+public class TotoProviderGlue implements Toto {

+    

+    Toto m_toto;

+    

+    private int i = 0;

+    public static int toto = 0;

+    public static int toto_2 = 0;

+    public static int toto_3 = 0;

+    public static int toto_4 = 0;

+    public static int toto1 = 0;

+    

+    public int count() {

+        return i;

+    }

+    

+    public void toto() {

+        toto++;

+        m_toto.toto();

+    }

+

+    public void toto(int i, int j) {

+        toto_2++;

+        m_toto.toto(i, j);

+    }

+

+    public String toto(String a) {

+        toto_3++;

+        return a;

+    }

+

+    public String toto(String[] a) {

+        toto_4++;

+        return "toto";

+    }

+

+    public void toto1(String j) {

+        i++;

+        toto1++;

+        m_toto.toto1(j);

+    }

+

+    public Properties getProps() {

+        Properties props = new Properties();

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

+        props.put("gtoto", new Integer(toto));

+        props.put("gtoto_2", new Integer(toto_2));

+        props.put("gtoto_3", new Integer(toto_3));

+        props.put("gtoto_4", new Integer(toto_4));

+        props.put("gtoto1", new Integer(toto1));

+        props.put("glue", "glue");

+        Properties p2 = m_toto.getProps();

+        props.putAll(p2);

+        return props;

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java
new file mode 100644
index 0000000..e31a24a
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java
@@ -0,0 +1,25 @@
+/* 

+ * 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.runtime.core.services.A123;

+

+public interface CheckService2 {

+	

+	public boolean check();

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java
new file mode 100644
index 0000000..f704138
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java
@@ -0,0 +1,29 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface BarService {

+	

+	public boolean bar();

+	

+	public Properties getProps();

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java
new file mode 100644
index 0000000..a4c4854
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java
@@ -0,0 +1,39 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface BazService {

+

+	boolean foo();

+	

+	Properties fooProps();

+	

+	Boolean getObject();

+	

+	boolean getBoolean();

+	

+	int getInt();

+	

+	long getLong();

+	

+	double getDouble();

+	

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
new file mode 100644
index 0000000..eca0faa
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
@@ -0,0 +1,31 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface CheckService {

+    

+    public static final String foo = "foo";

+	

+	public boolean check();

+	

+	public Properties getProps();

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
new file mode 100644
index 0000000..37c1a65
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
@@ -0,0 +1,39 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface FooService {

+

+	boolean foo();

+	

+	Properties fooProps();

+	

+	Boolean getObject();

+	

+	boolean getBoolean();

+	

+	int getInt();

+	

+	long getLong();

+	

+	double getDouble();

+	

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java
new file mode 100644
index 0000000..ba526f5
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java
@@ -0,0 +1,62 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface Tata {

+    

+    public Properties getPropsTata();

+    

+    public void tata();

+    

+    public int tataInt(int i);

+    public long tataLong(long l);

+    public double tataDouble(double d);

+    public char tataChar(char c);

+    public boolean tataBoolean(boolean b);

+    public short tataShort(short s);

+    public float tataFloat(float f);

+    public byte tataByte(byte b);

+    

+    public int[] tataInts(int[] its);

+    public long[] tataLongs(long[] l);

+    public double[] tataDoubles(double[] d);

+    public char[] tataChars(char[] c);

+    public boolean[] tataBooleans(boolean[] b);

+    public short[] tataShorts(short[] s);

+    public float[] tataFloats(float[] f);

+    public byte[] tataBytes(byte[] b);

+    

+    public String tataStr();

+    public String[] tataStrs();

+    

+    public void tata(int i, int j);

+    public void tata(String s);

+    

+    public String tata1(String a);

+    public String tata1(char[] a);

+    

+    public String tata5(String a, int i);

+    public String tata5(String[] a, int i);

+    public String tata5(String a, int[] i);

+    

+    public long add(int i, int j, int k);

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java
new file mode 100644
index 0000000..19bd528
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java
@@ -0,0 +1,78 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface Tota {

+    

+    public static final String specification="specification { " +

+    		"requires { " +

+    		    "$specification=\"org.apache.felix.ipojo.test.composite.service.Toto\" " +

+    		    "$optional=\"true\" " +

+    		    "$aggregate=\"true\" " +

+    		    "$type=\"service\" " +

+    		"} }"; 

+    

+    public Properties getProps() throws UnsupportedOperationException;;

+    public Properties getPropsTata();

+    

+    public void tata();

+    

+    public int tataInt(int i);

+    public long tataLong(long l);

+    public double tataDouble(double d);

+    public char tataChar(char c);

+    public boolean tataBoolean(boolean b);

+    public short tataShort(short s);

+    public float tataFloat(float f);

+    public byte tataByte(byte b);

+    

+    public int[] tataInts(int[] its);

+    public long[] tataLongs(long[] l);

+    public double[] tataDoubles(double[] d);

+    public char[] tataChars(char[] c);

+    public boolean[] tataBooleans(boolean[] b);

+    public short[] tataShorts(short[] s);

+    public float[] tataFloats(float[] f);

+    public byte[] tataBytes(byte[] b);

+    

+    public String tataStr();

+    public String[] tataStrs();

+    

+    public void tata(int i, int j);

+    public void tata(String s);

+    

+    public String tata1(String a);

+    public String tata1(char[] a);

+    

+    public String tata5(String a, int i);

+    public String tata5(String[] a, int i);

+    public String tata5(String a, int[] i);

+    

+    public long add(int i, int j, int k);

+    

+    public void toto() throws UnsupportedOperationException;    

+    public void toto(int i, int j) throws UnsupportedOperationException;

+    public String toto(String a) throws UnsupportedOperationException;

+    

+    public void toto1(String j) throws UnsupportedOperationException;

+    

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java
new file mode 100644
index 0000000..8ed22ec
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java
@@ -0,0 +1,37 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface Toto {

+    

+    public Properties getProps();

+    

+    public void toto();    

+    public void toto(int i, int j);

+    public String toto(String a);

+    public String toto(String[] a);

+    

+    public void toto1(String j);

+    

+    public int count();

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/resources/metadata-import-export.xml b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/resources/metadata-import-export.xml
new file mode 100644
index 0000000..059c8b7
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/resources/metadata-import-export.xml
@@ -0,0 +1,87 @@
+<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 

+	    org.apache.felix.composite http://felix.apache.org/ipojo/schemas/SNAPSHOT/composite.xsd"

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

+	xmlns:comp="org.apache.felix.ipojo.composite"

+	xmlns:cs="org.apache.felix.ipojo.test.composite.handler.CheckServiceHandler">

+	<comp:composite name="composite.requires.1" architecture="true">

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.FooService"

+			scope="composite" />

+	</comp:composite>

+

+	<comp:composite name="composite.requires.2" architecture="true">

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.FooService"

+			aggregate="true" scope="composite" />

+	</comp:composite>

+

+	<comp:composite name="composite.requires.3" architecture="true">

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.FooService"

+			optional="true" scope="composite" />

+	</comp:composite>

+

+	<comp:composite name="composite.requires.4" architecture="true">

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.FooService"

+			optional="true" aggregate="true" scope="composite" />

+	</comp:composite>

+

+	<comp:composite name="composite.requires.5" architecture="true">

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.FooService"

+			filter="(&amp;(int=2)(long=40))" scope="composite" />

+	</comp:composite>

+

+	<comp:composite name="composite.export.1" architecture="true">

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService"

+			aggregate="true" optional="true" filter="(!(instance.name=export))"

+			scope="composite" />

+		<comp:provides action="export"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService" />

+	</comp:composite>

+

+	<comp:composite name="composite.export.2" architecture="true">

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService"

+			scope="composite" aggregate="true" optional="true"

+			filter="(!(instance.name=export))" />

+		<comp:provides action="export"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService"

+			optional="true" />

+	</comp:composite>

+

+	<comp:composite name="composite.export.3" architecture="true">

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService"

+			scope="composite" aggregate="true" optional="true"

+			filter="(!(instance.name=export))" />

+		<comp:provides action="export"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService"

+			aggregate="true" />

+	</comp:composite>

+

+	<comp:composite name="composite.export.4" architecture="true">

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService"

+			aggregate="true" optional="true" filter="(!(instance.name=export))"

+			scope="composite" />

+		<comp:provides action="export"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService"

+			aggregate="true" optional="true" />

+	</comp:composite>

+

+	<comp:composite name="composite.export.5" architecture="true">

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService"

+			aggregate="true" optional="true" filter="(!(instance.name=export))"

+			scope="composite" />

+		<comp:provides action="export"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService"

+			filter="(instance.name=foo1)" />

+	</comp:composite>

+

+</ipojo>

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/resources/metadata.xml b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/resources/metadata.xml
new file mode 100644
index 0000000..6143ff9
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/main/resources/metadata.xml
@@ -0,0 +1,112 @@
+<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

+	    org.apache.felix.composite http://felix.apache.org/ipojo/schemas/SNAPSHOT/composite.xsd"

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

+	xmlns:comp="org.apache.felix.ipojo.composite">

+	<!-- Used component type -->

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"

+		name="COMPO-FooProviderType-1" architecture="true">

+		<provides />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"

+		name="COMPO-FooProviderType-2" architecture="true">

+		<provides>

+			<property name="int" type="int" value="2" />

+			<property name="long" type="long" value="40" />

+			<property name="string" type="java.lang.String" value="foo" />

+			<property name="strAProp" type="java.lang.String[]"

+				value="{foo, bar}" />

+			<property name="intAProp" type="int[]" value="{1,2,3}" />

+		</provides>

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderTypeDyn"

+		name="COMPO-FooProviderType-Dyn" architecture="true">

+		<provides>

+			<property name="int" field="intProp" value="2" />

+			<property name="boolean" field="boolProp" value="false" />

+			<property name="string" field="strProp" value="foo" />

+			<property name="strAProp" field="strAProp"

+				value="{foo, bar}" />

+			<property name="intAProp" field="intAProp" value="{ 1,2,3}" />

+		</provides>

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderTypeDyn2"

+		name="COMPO-FooProviderType-Dyn2" architecture="true">

+		<provides>

+			<property name="int" field="intProp" value="4" />

+			<property name="boolean" field="boolProp" />

+			<property name="string" field="strProp" />

+			<property name="strAProp" field="strAProp" />

+			<property name="intAProp" field="intAProp"

+				value="{1, 2,3 }" />

+		</provides>

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.CheckServiceProvider"

+		name="COMPO-SimpleCheckServiceProvider" architecture="true">

+		<requires field="fs" />

+		<provides />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"

+		name="COMPO-FooBarProviderType-1" architecture="true">

+		<provides />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"

+		name="COMPO-FooBarProviderType-2" architecture="true">

+		<provides

+			specifications="{org.apache.felix.ipojo.runtime.core.services.FooService, org.apache.felix.ipojo.runtime.core.services.BarService }" />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"

+		name="COMPO-FooBarProviderType-3" architecture="true">

+		<provides

+			specifications="{org.apache.felix.ipojo.runtime.core.services.FooService}">

+			<property name="baz" type="java.lang.String" value="foo" />

+		</provides>

+		<provides

+			specifications="{org.apache.felix.ipojo.runtime.core.services.BarService}">

+			<property name="baz" type="java.lang.String" value="bar" />

+		</provides>

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.BazProviderType1"

+		name="BazProviderType">

+		<provides />

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.TataProvider"

+		name="tata">

+		<provides />

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.TotoProvider"

+		name="toto" architecture="true">

+		<provides />

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.TotoProviderGlue"

+		name="totoglue">

+		<requires field="m_toto" scope="composite" />

+	</component>

+

+	<!--  Composite -->

+	<comp:composite name="composite.empty" architecture="true">

+	</comp:composite>

+

+	<component classname="org.apache.felix.ipojo.runtime.core.components.Baz2CheckProvider" name="Baz2CheckProvider" architecture="true">

+		<requires field="fs" scope="composite"/>

+		<provides/>

+	</component>

+

+</ipojo>

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
new file mode 100644
index 0000000..b242001
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
@@ -0,0 +1,225 @@
+package org.apache.felix.ipojo.runtime.core;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.ServiceContext;
+import org.apache.felix.ipojo.composite.CompositeManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.CompositeOption;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+import org.ops4j.pax.tinybundles.core.TinyBundle;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.ow2.chameleon.testing.helpers.IPOJOHelper;
+import org.ow2.chameleon.testing.helpers.OSGiHelper;
+import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static junit.framework.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.*;
+
+/**
+ * Bootstrap the test from this project
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class Common {
+
+    @Inject
+    protected
+    BundleContext bc;
+
+    protected OSGiHelper osgiHelper;
+    protected IPOJOHelper ipojoHelper;
+
+    protected boolean deployTestedBundle = true;
+
+    @Configuration
+    public Option[] config() throws IOException {
+        Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+        root.setLevel(Level.INFO);
+
+        if (deployTestedBundle) {
+            return options(
+                    cleanCaches(),
+                    ipojoBundles(),
+                    junitBundles(),
+                    testedBundle(),
+                    systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+            );
+        } else {
+            return options(
+                    cleanCaches(),
+                    ipojoBundles(),
+                    junitBundles(),
+                    systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+            );
+        }
+    }
+
+    public static Option junitAndMockitoBundles() {
+        return new DefaultCompositeOption(
+                // Repository required to load harmcrest (OSGi-fied version).
+                repository("http://repository.springsource.com/maven/bundles/external").id(
+                        "com.springsource.repository.bundles.external"),
+
+                // Mockito without Hamcrest and Objenesis
+                mavenBundle("org.mockito", "mockito-core", "1.9.5"),
+
+                // Hamcrest with a version matching the range expected by Mockito
+                mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
+
+                // Objenesis with a version matching the range expected by Mockito
+                wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
+                        .exports("*;version=1.2"),
+
+                // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
+                // 4.9 which does not match the Mockito import.
+                CoreOptions.junitBundles(),
+
+                /*
+                 * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
+                 * java.lang.LinkageError: loader constraint violation in interface itable initialization:
+                 * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
+                 * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
+                 * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
+                 * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
+                 * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
+                 * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
+                 * proxy/Callback used in the signature
+                 *
+                 * So we disable the bootdelegation.
+                 */
+                frameworkProperty("felix.bootdelegation.implicit").value("false")
+        );
+    }
+
+
+    @Before
+    public void commonSetUp() {
+        osgiHelper = new OSGiHelper(bc);
+        ipojoHelper = new IPOJOHelper(bc);
+
+        // Dump OSGi Framework information
+        String vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VENDOR);
+        if (vendor == null) {
+            vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
+        }
+        String version = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VERSION);
+        System.out.println("OSGi Framework : " + vendor + " - " + version);
+    }
+
+    @After
+    public void commonTearDown() {
+        ipojoHelper.dispose();
+        osgiHelper.dispose();
+    }
+
+    public BundleContext getContext() {
+        return bc;
+    }
+
+    public static ServiceContext getServiceContext(ComponentInstance ci) {
+        if (ci instanceof CompositeManager) {
+            return ((CompositeManager) ci).getServiceContext();
+        } else {
+            throw new RuntimeException("Cannot get the service context from a non composite instance");
+        }
+    }
+
+    public CompositeOption ipojoBundles() {
+        return new DefaultCompositeOption(
+                mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
+                mavenBundle("org.apache.felix", "org.apache.felix.ipojo.composite").versionAsInProject(),
+                mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
+                // configuration admin
+                mavenBundle("org.apache.felix",  "org.apache.felix.configadmin").versionAsInProject()
+        );
+    }
+
+    public Option testedBundle() throws MalformedURLException {
+        File out = new File("target/tested/bundle.jar");
+        if (out.exists()) {
+            return bundle(out.toURI().toURL().toExternalForm());
+        }
+
+        TinyBundle tested = TinyBundles.bundle();
+
+        // We look inside target/classes to find the class and resources
+        File classes = new File("target/classes");
+        Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
+        List<File> services = new ArrayList<File>();
+        for (File file : files) {
+            if (file.isDirectory()) {
+                // By convention we export of .services and .service package
+                if (file.getName().endsWith("services")  || file.getName().endsWith("service")) {
+                    services.add(file);
+                }
+            } else {
+                // We need to compute the path
+                String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+                tested.add(path, file.toURI().toURL());
+                System.out.println(file.getName() + " added to " + path);
+            }
+        }
+
+        // Export the inherited package, components and strategies
+        String export = "";
+        for (File file : services) {
+            if (export.length() > 0) { export += ", "; }
+            String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+            String packageName = path.replace('/', '.');
+            export += packageName;
+        }
+
+        System.out.println("Exported packages : " + export);
+
+        InputStream inputStream = tested
+                .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
+                .set(Constants.IMPORT_PACKAGE, "*")
+                .set(Constants.EXPORT_PACKAGE, export)
+                .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));
+
+        try {
+            org.apache.commons.io.FileUtils.copyInputStreamToFile(inputStream, out);
+            return bundle(out.toURI().toURL().toExternalForm());
+        } catch (MalformedURLException e) {
+            throw new RuntimeException("Cannot compute the url of the manipulated bundle");
+        } catch (IOException e) {
+            throw new RuntimeException("Cannot write of the manipulated bundle");
+        }
+    }
+
+    public void assertContains(String s, String[] arrays, String object) {
+        for (String suspect : arrays) {
+            if (object.equals(suspect)) {
+                return;
+            }
+        }
+        fail("Assertion failed : " + s);
+    }
+
+
+}
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestFilteredExport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestFilteredExport.java
new file mode 100644
index 0000000..09f3fca
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestFilteredExport.java
@@ -0,0 +1,237 @@
+/* 

+ * 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.runtime.core.exporter;

+

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.BazService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestFilteredExport extends Common {

+

+    ComponentInstance export1;

+    Factory fooProvider;

+    ComponentInstance foo1 = null, foo2 = null;

+

+    @Before

+    public void setUp() {

+        fooProvider = ipojoHelper.getFactory("BazProviderType");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        Properties p1 = new Properties();

+        p1.put("instance.name", "foo1");

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+

+        try {

+            foo1 = fooProvider.createComponentInstance(p1);

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Fail to create foos : " + e.getMessage());

+        }

+

+        foo1.stop();

+        foo2.stop();

+

+        Factory factory = ipojoHelper.getFactory("composite.export.5");

+        Properties props = new Properties();

+        props.put("instance.name", "export");

+        try {

+            export1 = factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Fail to instantiate exporter " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        foo1.dispose();

+        foo2.dispose();

+        export1.dispose();

+        foo1 = null;

+        foo2 = null;

+        export1 = null;

+    }

+

+    @Test

+    public void test1() {

+        export1.start();

+

+        // Check that no foo service are available

+        assertEquals("Check no foo service", osgiHelper.getServiceReferences(FooService.class.getName(), null).length, 0);

+

+        // Test invalidity

+        assertTrue("Check invalidity - 0", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 0", isFooServiceProvided());

+        assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke());

+

+        foo2.start();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke());

+

+        foo1.stop();

+        assertTrue("Check invalidity - 3", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);

+

+        foo2.stop();

+        assertTrue("Check invalidity - 4", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);

+

+        foo2.start();

+        assertTrue("Check invalidity - 5", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 5", isFooServiceProvided());

+        assertEquals("Check number of provides - 5", countFooServiceProvided(), 0);

+    }

+

+    @Test

+    public void test2() {

+        export1.start();

+

+        // Test invalidity

+        assertTrue("Check invalidity - 0", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 0", isFooServiceProvided());

+        assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke());

+

+        foo2.start();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke());

+

+        foo2.stop();

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

+        assertTrue("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 3", invoke());

+

+        foo1.stop();

+        assertTrue("Check invalidity - 4", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 5", isFooServiceProvided());

+        assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 5", invoke());

+    }

+

+    @Test

+    public void test3() {

+        foo1.start();

+        foo2.start();

+

+        export1.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke());

+

+        foo1.stop();

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

+        assertFalse("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 0);

+

+        foo2.stop();

+        assertTrue("Check invalidity - 3", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 4", invoke());

+    }

+

+    @Test

+    public void test4() {

+        foo1.start();

+        foo2.start();

+

+        export1.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke());

+

+        foo2.stop();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke());

+

+        foo1.stop();

+        assertTrue("Check invalidity - 3", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);

+

+        foo2.start();

+        assertTrue("Check invalidity - 4", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);

+    }

+

+

+    private boolean isFooServiceProvided() {

+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), export1.getInstanceName());

+        return ref != null;

+    }

+

+    private int countFooServiceProvided() {

+        ServiceReference[] refs = osgiHelper.getServiceReferences(BazService.class.getName(), "(instance.name=" + export1.getInstanceName() + ")");

+        return refs.length;

+    }

+

+    private boolean invoke() {

+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), export1.getInstanceName());

+        if (ref == null) {

+            return false;

+        }

+        BazService fs = (BazService) getContext().getService(ref);

+        return fs.foo();

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestMultipleExport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestMultipleExport.java
new file mode 100644
index 0000000..e7871b1
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestMultipleExport.java
@@ -0,0 +1,260 @@
+/* 

+ * 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.runtime.core.exporter;

+

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.BazService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestMultipleExport extends Common {

+

+    ComponentInstance export3;

+    Factory fooProvider;

+    ComponentInstance foo1 = null, foo2 = null;

+

+    @Before

+    public void setUp() {

+        fooProvider = ipojoHelper.getFactory("BazProviderType");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        Properties p1 = new Properties();

+        p1.put("instance.name", "foo1");

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+

+        try {

+            foo1 = fooProvider.createComponentInstance(p1);

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Fail to create foos : " + e.getMessage());

+        }

+

+        foo1.stop();

+        foo2.stop();

+

+        Factory factory = ipojoHelper.getFactory("composite.export.3");

+        Properties props = new Properties();

+        props.put("instance.name", "export");

+        try {

+            export3 = factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Fail to instantiate exporter " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        foo1.dispose();

+        foo2.dispose();

+        export3.dispose();

+        foo1 = null;

+        foo2 = null;

+        export3 = null;

+    }

+

+    @Test

+    public void test1() {

+        export3.start();

+

+        // Check that no foo service are available

+        assertEquals("Check no foo service", osgiHelper.getServiceReferences(FooService.class.getName(), null).length, 0);

+

+        // Test invalidity

+        assertTrue("Check invalidity - 0", export3.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 0", isFooServiceProvided());

+        assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke(1));

+

+        foo2.start();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 2);

+        assertTrue("Check invocation - 2", invoke(2));

+

+        foo1.stop();

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

+        assertTrue("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3 (" + countFooServiceProvided() + ")", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 3", invoke(1));

+

+        foo2.stop();

+        assertTrue("Check invalidity - 4", export3.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);

+

+        foo2.start();

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

+        assertTrue("Check providing - 5", isFooServiceProvided());

+        assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 5", invoke(1));

+    }

+

+    @Test

+    public void test2() {

+        export3.start();

+

+        // Test invalidity

+        assertTrue("Check invalidity - 0", export3.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 0", isFooServiceProvided());

+        assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke());

+

+        foo2.start();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 2);

+        assertTrue("Check invocation - 2", invoke(2));

+

+        foo2.stop();

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

+        assertTrue("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 3", invoke(1));

+

+        foo1.stop();

+        assertTrue("Check invalidity - 4", export3.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 5", isFooServiceProvided());

+        assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 5", invoke(1));

+    }

+

+    @Test

+    public void test3() {

+        foo1.start();

+        foo2.start();

+

+        export3.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 2);

+        assertTrue("Check invocation - 1", invoke(2));

+

+        foo1.stop();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke(1));

+

+        foo2.stop();

+        assertTrue("Check invalidity - 3", export3.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 4", invoke(1));

+    }

+

+    @Test

+    public void test4() {

+        foo1.start();

+        foo2.start();

+

+        export3.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 2);

+        assertTrue("Check invocation - 1", invoke(2));

+

+        foo2.stop();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke(1));

+

+        foo1.stop();

+        assertTrue("Check invalidity - 3", export3.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);

+

+        foo2.start();

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

+        assertTrue("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 4", invoke(1));

+    }

+

+

+    private boolean isFooServiceProvided() {

+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), export3.getInstanceName());

+        return ref != null;

+    }

+

+    private int countFooServiceProvided() {

+        ServiceReference[] refs = osgiHelper.getServiceReferences(BazService.class.getName(), "(instance.name=" + export3.getInstanceName() + ")");

+        return refs.length;

+    }

+

+    private boolean invoke() {

+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), export3.getInstanceName());

+        if (ref == null) {

+            return false;

+        }

+        BazService fs = (BazService) getContext().getService(ref);

+        getContext().ungetService(ref);

+        return fs.foo();

+    }

+

+    private boolean invoke(int nb) {

+        ServiceReference[] refs = osgiHelper.getServiceReferences(BazService.class.getName(), "(instance.name=" + export3.getInstanceName() + ")");

+        if (refs == null) {

+            return false;

+        }

+        if (nb > refs.length) {

+            return false;

+        }

+        for (int i = 0; i < nb; i++) {

+            BazService fs = (BazService) getContext().getService(refs[i]);

+            getContext().ungetService(refs[i]);

+            if (!fs.foo()) {

+                return false;

+            }

+        }

+        return true;

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestOptionalExport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestOptionalExport.java
new file mode 100644
index 0000000..2b3975e
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestOptionalExport.java
@@ -0,0 +1,241 @@
+/* 

+ * 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.runtime.core.exporter;

+

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.BazService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestOptionalExport extends Common {

+

+    ComponentInstance export2;

+    Factory fooProvider;

+    ComponentInstance foo1 = null, foo2 = null;

+

+    @Before

+    public void setUp() {

+        fooProvider = ipojoHelper.getFactory("BazProviderType");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        Properties p1 = new Properties();

+        p1.put("instance.name", "foo1");

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+

+        try {

+            foo1 = fooProvider.createComponentInstance(p1);

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Fail to create foos : " + e.getMessage());

+        }

+

+        foo1.stop();

+        foo2.stop();

+

+        Factory factory = ipojoHelper.getFactory("composite.export.2");

+        Properties props = new Properties();

+        props.put("instance.name", "export");

+        try {

+            export2 = factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Fail to instantiate exporter " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        foo1.dispose();

+        foo2.dispose();

+        export2.dispose();

+        foo1 = null;

+        foo2 = null;

+        export2 = null;

+    }

+

+    @Test

+    public void test1() {

+        export2.start();

+

+        // Check that no foo service are available

+        assertEquals("Check no foo service", osgiHelper.getServiceReferences(FooService.class.getName(), null).length, 0);

+

+        // Test validity

+        assertTrue("Check validity - 0", export2.getState() == ComponentInstance.VALID);

+        assertFalse("Check providing - 0", isFooServiceProvided());

+        assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke());

+

+        foo2.start();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke());

+

+        foo1.stop();

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

+        assertTrue("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3 (" + countFooServiceProvided() + ")", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 3", invoke());

+

+        foo2.stop();

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

+        assertFalse("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);

+

+        foo2.start();

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

+        assertTrue("Check providing - 5", isFooServiceProvided());

+        assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 5", invoke());

+    }

+

+    @Test

+    public void test2() {

+        export2.start();

+

+        // Test invalidity

+        assertTrue("Check validity - 0", export2.getState() == ComponentInstance.VALID);

+        assertFalse("Check providing - 0", isFooServiceProvided());

+        assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke());

+

+        foo2.start();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke());

+

+        foo2.stop();

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

+        assertTrue("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 3", invoke());

+

+        foo1.stop();

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

+        assertFalse("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 5", isFooServiceProvided());

+        assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 5", invoke());

+    }

+

+    @Test

+    public void test3() {

+        foo1.start();

+        foo2.start();

+

+        export2.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke());

+

+        foo1.stop();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke());

+

+        foo2.stop();

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

+        assertFalse("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 4", invoke());

+    }

+

+    @Test

+    public void test4() {

+        foo1.start();

+        foo2.start();

+

+        export2.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke());

+

+        foo2.stop();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke());

+

+        foo1.stop();

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

+        assertFalse("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);

+

+        foo2.start();

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

+        assertTrue("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 4", invoke());

+    }

+

+

+    private boolean isFooServiceProvided() {

+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), export2.getInstanceName());

+        return ref != null;

+    }

+

+    private int countFooServiceProvided() {

+        ServiceReference[] refs = osgiHelper.getServiceReferences(BazService.class.getName(), "(instance.name=" + export2.getInstanceName() + ")");

+        return refs.length;

+    }

+

+    private boolean invoke() {

+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), export2.getInstanceName());

+        if (ref == null) {

+            return false;

+        }

+        BazService fs = (BazService) getContext().getService(ref);

+        return fs.foo();

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestOptionalMultipleExport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestOptionalMultipleExport.java
new file mode 100644
index 0000000..40c0d5d
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestOptionalMultipleExport.java
@@ -0,0 +1,260 @@
+/* 

+ * 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.runtime.core.exporter;

+

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.BazService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestOptionalMultipleExport extends Common {

+

+    ComponentInstance export3;

+    Factory fooProvider;

+    ComponentInstance foo1 = null, foo2 = null;

+

+    @Before

+    public void setUp() {

+        fooProvider = ipojoHelper.getFactory("BazProviderType");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        Properties p1 = new Properties();

+        p1.put("instance.name", "foo1");

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+

+        try {

+            foo1 = fooProvider.createComponentInstance(p1);

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Fail to create foos : " + e.getMessage());

+        }

+

+        foo1.stop();

+        foo2.stop();

+

+        Factory factory = ipojoHelper.getFactory("composite.export.4");

+        Properties props = new Properties();

+        props.put("instance.name", "export");

+        try {

+            export3 = factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Fail to instantiate exporter " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        foo1.dispose();

+        foo2.dispose();

+        export3.dispose();

+        foo1 = null;

+        foo2 = null;

+        export3 = null;

+    }

+

+    @Test

+    public void test1() {

+        export3.start();

+

+        // Check that no foo service are available

+        assertEquals("Check no foo service", osgiHelper.getServiceReferences(FooService.class.getName(), null).length, 0);

+

+        // Test invalidity

+        assertTrue("Check validity - 0", export3.getState() == ComponentInstance.VALID);

+        assertFalse("Check providing - 0", isFooServiceProvided());

+        assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke(1));

+

+        foo2.start();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 2);

+        assertTrue("Check invocation - 2", invoke(2));

+

+        foo1.stop();

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

+        assertTrue("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3 (" + countFooServiceProvided() + ")", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 3", invoke(1));

+

+        foo2.stop();

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

+        assertFalse("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);

+

+        foo2.start();

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

+        assertTrue("Check providing - 5", isFooServiceProvided());

+        assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 5", invoke(1));

+    }

+

+    @Test

+    public void test2() {

+        export3.start();

+

+        // Test invalidity

+        assertTrue("Check validity - 0", export3.getState() == ComponentInstance.VALID);

+        assertFalse("Check providing - 0", isFooServiceProvided());

+        assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke());

+

+        foo2.start();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 2);

+        assertTrue("Check invocation - 2", invoke(2));

+

+        foo2.stop();

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

+        assertTrue("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 3", invoke(1));

+

+        foo1.stop();

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

+        assertFalse("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 5", isFooServiceProvided());

+        assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 5", invoke(1));

+    }

+

+    @Test

+    public void test3() {

+        foo1.start();

+        foo2.start();

+

+        export3.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 2);

+        assertTrue("Check invocation - 1", invoke(2));

+

+        foo1.stop();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke(1));

+

+        foo2.stop();

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

+        assertFalse("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 4", invoke(1));

+    }

+

+    @Test

+    public void test4() {

+        foo1.start();

+        foo2.start();

+

+        export3.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 2);

+        assertTrue("Check invocation - 1", invoke(2));

+

+        foo2.stop();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke(1));

+

+        foo1.stop();

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

+        assertFalse("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);

+

+        foo2.start();

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

+        assertTrue("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 4", invoke(1));

+    }

+

+

+    private boolean isFooServiceProvided() {

+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), export3.getInstanceName());

+        return ref != null;

+    }

+

+    private int countFooServiceProvided() {

+        ServiceReference[] refs = osgiHelper.getServiceReferences(BazService.class.getName(), "(instance.name=" + export3.getInstanceName() + ")");

+        return refs.length;

+    }

+

+    private boolean invoke() {

+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), export3.getInstanceName());

+        if (ref == null) {

+            return false;

+        }

+        BazService fs = (BazService) getContext().getService(ref);

+        getContext().ungetService(ref);

+        return fs.foo();

+    }

+

+    private boolean invoke(int nb) {

+        ServiceReference[] refs = osgiHelper.getServiceReferences(BazService.class.getName(), "(instance.name=" + export3.getInstanceName() + ")");

+        if (refs == null) {

+            return false;

+        }

+        if (nb > refs.length) {

+            return false;

+        }

+        for (int i = 0; i < nb; i++) {

+            BazService fs = (BazService) getContext().getService(refs[i]);

+            getContext().ungetService(refs[i]);

+            if (!fs.foo()) {

+                return false;

+            }

+        }

+        return true;

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestSimpleExport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestSimpleExport.java
new file mode 100644
index 0000000..a8af21b
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/exporter/TestSimpleExport.java
@@ -0,0 +1,241 @@
+/* 

+ * 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.runtime.core.exporter;

+

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.BazService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestSimpleExport extends Common {

+

+    ComponentInstance export1;

+    Factory fooProvider;

+    ComponentInstance foo1 = null, foo2 = null;

+

+    @Before

+    public void setUp() {

+        fooProvider = ipojoHelper.getFactory("BazProviderType");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        Properties p1 = new Properties();

+        p1.put("instance.name", "foo1");

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+

+        try {

+            foo1 = fooProvider.createComponentInstance(p1);

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Fail to create foos : " + e.getMessage());

+        }

+

+        foo1.stop();

+        foo2.stop();

+

+        Factory factory = ipojoHelper.getFactory("composite.export.1");

+        Properties props = new Properties();

+        props.put("instance.name", "export");

+        try {

+            export1 = factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Fail to instantiate exporter " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        foo1.dispose();

+        foo2.dispose();

+        export1.dispose();

+        foo1 = null;

+        foo2 = null;

+        export1 = null;

+    }

+

+    @Test

+    public void test1() {

+        export1.start();

+

+        // Check that no foo service are available

+        assertEquals("Check no foo service", osgiHelper.getServiceReferences(FooService.class.getName(), null).length, 0);

+

+        // Test invalidity

+        assertTrue("Check invalidity - 0", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 0", isFooServiceProvided());

+        assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke());

+

+        foo2.start();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke());

+

+        foo1.stop();

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

+        assertTrue("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3 (" + countFooServiceProvided() + ")", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 3", invoke());

+

+        foo2.stop();

+        assertTrue("Check invalidity - 4", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);

+

+        foo2.start();

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

+        assertTrue("Check providing - 5", isFooServiceProvided());

+        assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 5", invoke());

+    }

+

+    @Test

+    public void test2() {

+        export1.start();

+

+        // Test invalidity

+        assertTrue("Check invalidity - 0", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 0", isFooServiceProvided());

+        assertEquals("Check number of provides - 0", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke());

+

+        foo2.start();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke());

+

+        foo2.stop();

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

+        assertTrue("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 3", invoke());

+

+        foo1.stop();

+        assertTrue("Check invalidity - 4", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 5", isFooServiceProvided());

+        assertEquals("Check number of provides - 5", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 5", invoke());

+    }

+

+    @Test

+    public void test3() {

+        foo1.start();

+        foo2.start();

+

+        export1.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke());

+

+        foo1.stop();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke());

+

+        foo2.stop();

+        assertTrue("Check invalidity - 3", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);

+

+        foo1.start();

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

+        assertTrue("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 4", invoke());

+    }

+

+    @Test

+    public void test4() {

+        foo1.start();

+        foo2.start();

+

+        export1.start();

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

+        assertTrue("Check providing - 1", isFooServiceProvided());

+        assertEquals("Check number of provides - 1", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 1", invoke());

+

+        foo2.stop();

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

+        assertTrue("Check providing - 2", isFooServiceProvided());

+        assertEquals("Check number of provides - 2", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 2", invoke());

+

+        foo1.stop();

+        assertTrue("Check invalidity - 3", export1.getState() == ComponentInstance.INVALID);

+        assertFalse("Check providing - 3", isFooServiceProvided());

+        assertEquals("Check number of provides - 3", countFooServiceProvided(), 0);

+

+        foo2.start();

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

+        assertTrue("Check providing - 4", isFooServiceProvided());

+        assertEquals("Check number of provides - 4", countFooServiceProvided(), 1);

+        assertTrue("Check invocation - 4", invoke());

+    }

+

+

+    private boolean isFooServiceProvided() {

+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), export1.getInstanceName());

+        return ref != null;

+    }

+

+    private int countFooServiceProvided() {

+        ServiceReference[] refs = osgiHelper.getServiceReferences(BazService.class.getName(), "(instance.name=" + export1.getInstanceName() + ")");

+        return refs.length;

+    }

+

+    private boolean invoke() {

+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), export1.getInstanceName());

+        if (ref == null) {

+            return false;

+        }

+        BazService fs = (BazService) getContext().getService(ref);

+        return fs.foo();

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedFilteredImport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedFilteredImport.java
new file mode 100644
index 0000000..fe15caf
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedFilteredImport.java
@@ -0,0 +1,157 @@
+/* 

+ * 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.runtime.core.importer;

+

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestDelayedFilteredImport extends Common {

+

+    ComponentInstance import1;

+    Factory fooProvider;

+    ComponentInstance foo1, foo2;

+

+    @Before

+    public void setUp() {

+

+        Properties p = new Properties();

+        p.put("instance.name", "importer");

+        Factory compFact = ipojoHelper.getFactory("composite.requires.1");

+        try {

+            import1 = compFact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate the component : " + e.getMessage());

+        }

+

+        import1.stop();

+

+        fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        Properties p1 = new Properties();

+        p1.put("instance.name", "foo1");

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+        try {

+            foo1 = fooProvider.createComponentInstance(p1);

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Cannot instantiate foo providers : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        foo1.dispose();

+        foo2.dispose();

+        import1.dispose();

+        foo1 = null;

+        foo2 = null;

+        import1 = null;

+    }

+

+    @Test

+    public void testSimple() {

+        import1.start();

+        //Two providers

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import1);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo1.stop();

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the second provider

+        foo2.stop();

+        assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);

+

+        foo2.start();

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+    }

+

+    @Test

+    public void testSimple2() {

+        import1.start();

+        //Two providers

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import1);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo2.stop();

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the second provider

+        foo1.stop();

+        assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);

+

+        foo1.start();

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedMultipleImport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedMultipleImport.java
new file mode 100644
index 0000000..9fa1877
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedMultipleImport.java
@@ -0,0 +1,163 @@
+/* 

+ * 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.runtime.core.importer;

+

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestDelayedMultipleImport extends Common {

+

+    ComponentInstance import2;

+    Factory fooProvider;

+    ComponentInstance foo1, foo2;

+

+    @Before

+    public void setUp() {

+

+        Properties p = new Properties();

+        p.put("instance.name", "importer");

+        Factory compFact = ipojoHelper.getFactory("composite.requires.2");

+        try {

+            import2 = compFact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate the component : " + e.getMessage());

+        }

+

+        import2.stop();

+

+        fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        Properties p1 = new Properties();

+        p1.put("instance.name", "foo1");

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+        try {

+            foo1 = fooProvider.createComponentInstance(p1);

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Cannot instantiate foo providers : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        foo1.dispose();

+        foo2.dispose();

+        import2.dispose();

+        foo1 = null;

+        foo2 = null;

+        import2 = null;

+    }

+

+    @Test

+    public void testSimple() {

+        import2.start();

+        //Two providers

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import2);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 2);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+        fs = (FooService) sc.getService(refs[1]);

+        assertTrue("Test foo invocation (2)", fs.foo());

+        sc.ungetService(refs[1]);

+

+        foo1.stop();

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the second provider

+        foo2.stop();

+        assertTrue("Test component invalidity - 2", import2.getState() == ComponentInstance.INVALID);

+

+        foo2.start();

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+    }

+

+    @Test

+    public void testSimple2() {

+        import2.start();

+        //Two providers

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import2);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 2);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+        fs = (FooService) sc.getService(refs[1]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[1]);

+

+        foo2.stop();

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the second provider

+        foo1.stop();

+        assertTrue("Test component invalidity - 2", import2.getState() == ComponentInstance.INVALID);

+

+        foo1.start();

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedOptionalImport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedOptionalImport.java
new file mode 100644
index 0000000..d1aafa9
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedOptionalImport.java
@@ -0,0 +1,163 @@
+/* 

+ * 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.runtime.core.importer;

+

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestDelayedOptionalImport extends Common {

+

+    ComponentInstance import3;

+    Factory fooProvider;

+    ComponentInstance foo1, foo2;

+

+    @Before

+    public void setUp() {

+

+        Properties p = new Properties();

+        p.put("instance.name", "importer");

+        Factory compFact = ipojoHelper.getFactory("composite.requires.3");

+        try {

+            import3 = compFact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate the component : " + e.getMessage());

+        }

+

+        import3.stop();

+

+        fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        Properties p1 = new Properties();

+        p1.put("instance.name", "foo1");

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+        try {

+            foo1 = fooProvider.createComponentInstance(p1);

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Cannot instantiate foo providers : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        foo1.dispose();

+        foo2.dispose();

+        import3.dispose();

+        foo1 = null;

+        foo2 = null;

+        import3 = null;

+    }

+

+    @Test

+    public void testSimple() {

+        import3.start();

+        //Two providers

+        assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import3);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo1.stop();

+        assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import3);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the second provider

+        foo2.stop();

+        assertTrue("Test component validity - 2", import3.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import3);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertEquals("Test foo non-availability inside the composite - 3.1", refs.length, 0);

+

+        foo2.start();

+        assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import3);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+    }

+

+    @Test

+    public void testSimple2() {

+        import3.start();

+        //Two providers

+        assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import3);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo2.stop();

+        assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import3);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the second provider

+        foo1.stop();

+        assertTrue("Test component validity - 2", import3.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import3);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 0);

+

+        foo1.start();

+        assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import3);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedOptionalMultipleImport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedOptionalMultipleImport.java
new file mode 100644
index 0000000..18644b7
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedOptionalMultipleImport.java
@@ -0,0 +1,169 @@
+/* 

+ * 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.runtime.core.importer;

+

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestDelayedOptionalMultipleImport extends Common {

+

+    ComponentInstance import4;

+    Factory fooProvider;

+    ComponentInstance foo1, foo2;

+

+    @Before

+    public void setUp() {

+

+        Properties p = new Properties();

+        p.put("instance.name", "importer");

+        Factory compFact = ipojoHelper.getFactory("composite.requires.4");

+        try {

+            import4 = compFact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate the component : " + e.getMessage());

+        }

+

+        import4.stop();

+

+        fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        Properties p1 = new Properties();

+        p1.put("instance.name", "foo1");

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+        try {

+            foo1 = fooProvider.createComponentInstance(p1);

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Cannot instantiate foo providers : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        foo1.dispose();

+        foo2.dispose();

+        import4.dispose();

+        foo1 = null;

+        foo2 = null;

+        import4 = null;

+    }

+

+    @Test

+    public void testSimple() {

+        import4.start();

+        //Two providers

+        assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import4);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 2);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+        fs = (FooService) sc.getService(refs[1]);

+        assertTrue("Test foo invocation (2)", fs.foo());

+        sc.ungetService(refs[1]);

+

+        foo1.stop();

+        assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import4);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the second provider

+        foo2.stop();

+        assertTrue("Test component validity - 2", import4.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import4);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertEquals("Test foo availability inside the composite - 1", refs.length, 0);

+

+        foo2.start();

+        assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import4);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+    }

+

+    @Test

+    public void testSimple2() {

+        import4.start();

+        //Two providers

+        assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import4);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 2);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+        fs = (FooService) sc.getService(refs[1]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[1]);

+

+        foo2.stop();

+        assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import4);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the second provider

+        foo1.stop();

+        assertTrue("Test component validity - 2", import4.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import4);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertEquals("Test foo availability inside the composite - 1", refs.length, 0);

+

+        foo1.start();

+        assertTrue("Test component validity", import4.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import4);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedSimpleImport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedSimpleImport.java
new file mode 100644
index 0000000..8da4190
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestDelayedSimpleImport.java
@@ -0,0 +1,158 @@
+/* 

+ * 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.runtime.core.importer;

+

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestDelayedSimpleImport extends Common {

+

+    ComponentInstance import1;

+    Factory fooProvider;

+    ComponentInstance foo1, foo2;

+

+    @Before

+    public void setUp() {

+

+        Properties p = new Properties();

+        p.put("instance.name", "importer");

+        Factory compFact = ipojoHelper.getFactory("composite.requires.1");

+        try {

+            import1 = compFact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate the component : " + e.getMessage());

+        }

+

+        import1.stop();

+

+        fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        Properties p1 = new Properties();

+        p1.put("instance.name", "foo1");

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+        try {

+            foo1 = fooProvider.createComponentInstance(p1);

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Cannot instantiate foo providers : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        foo1.dispose();

+        foo2.dispose();

+        import1.dispose();

+        foo1 = null;

+        foo2 = null;

+        import1 = null;

+    }

+

+    @Test

+    public void testSimple() {

+        import1.start();

+

+        //Two providers

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import1);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo1.stop();

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 2", refs);

+        assertEquals("Test foo availability inside the composite - 2.2", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the second provider

+        foo2.stop();

+        assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);

+

+        foo2.start();

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+    }

+

+    @Test

+    public void testSimple2() {

+        import1.start();

+        //Two providers

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import1);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo2.stop();

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the second provider

+        foo1.stop();

+        assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);

+

+        foo1.start();

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestFilteredImport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestFilteredImport.java
new file mode 100644
index 0000000..e8dc250
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestFilteredImport.java
@@ -0,0 +1,155 @@
+/* 

+ * 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.runtime.core.importer;

+

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestFilteredImport extends Common {

+

+    ComponentInstance import1;

+    Factory fooProvider;

+    Factory fooProvider2;

+

+    ComponentInstance foo1, foo2;

+

+    @Before

+    public void setUp() {

+        Properties p = new Properties();

+        p.put("instance.name", "importer");

+        Factory compFact = ipojoHelper.getFactory("composite.requires.5");

+        try {

+            import1 = compFact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate the component : " + e.getMessage());

+        }

+        import1.stop();

+

+        fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        fooProvider2 = ipojoHelper.getFactory("COMPO-FooProviderType-2");

+        assertNotNull("Check fooProvider availability", fooProvider2);

+

+        Properties p1 = new Properties();

+        p1.put("instance.name", "foo1");

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+        try {

+            foo1 = fooProvider.createComponentInstance(p1);

+            foo2 = fooProvider2.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Cannot instantiate foo providers : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        foo1.dispose();

+        foo2.dispose();

+        import1.dispose();

+        foo1 = null;

+        foo2 = null;

+        import1 = null;

+    }

+

+    @Test

+    public void testSimple() {

+        import1.start();

+        //Two providers

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import1);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo1.stop();

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the second provider

+        foo2.stop();

+        assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);

+

+        foo2.start();

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+    }

+

+    @Test

+    public void testSimple2() {

+        import1.start();

+        //Two providers

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import1);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo2.stop();

+        assertTrue("Test component invalidity - 1", import1.getState() == ComponentInstance.INVALID);

+

+        // Stop the second provider

+        foo1.stop();

+        assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);

+

+        foo1.start();

+        assertTrue("Test component invalidity - 3", import1.getState() == ComponentInstance.INVALID);

+

+        foo2.start();

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestMultipleImport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestMultipleImport.java
new file mode 100644
index 0000000..298f2ba
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestMultipleImport.java
@@ -0,0 +1,198 @@
+/* 

+ * 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.runtime.core.importer;

+

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestMultipleImport extends Common {

+

+    ComponentInstance import2;

+    Factory fooProvider;

+

+    @Before

+    public void setUp() {

+        fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        Properties p = new Properties();

+        p.put("instance.name", "importer");

+        Factory compFact = ipojoHelper.getFactory("composite.requires.2");

+        try {

+            import2 = compFact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate the component : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        import2.dispose();

+        import2 = null;

+    }

+

+    @Test

+    public void testSimple() {

+        // No provider -> Invalid

+        assertTrue("Test component invalidity", import2.getState() == ComponentInstance.INVALID);

+

+        ComponentInstance foo = null;

+        Properties p = new Properties();

+        p.put("instance.name", "foo");

+        try {

+            foo = fooProvider.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo component " + e.getMessage());

+        }

+

+        ComponentInstance foo2 = null;

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+        try {

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo2 component " + e.getMessage());

+        }

+

+        // The foo service is available => import1 must be valid

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import2);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2 (" + refs.length + ")", refs.length, 2);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        FooService fs2 = (FooService) sc.getService(refs[1]);

+        assertTrue("Test foo invocation", fs2.foo());

+        sc.ungetService(refs[0]);

+        sc.ungetService(refs[1]);

+

+        // Stop the second provider

+        foo2.dispose();

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 2", refs);

+        assertEquals("Test foo availability inside the composite - 2.1 (" + refs.length + ")", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // stop the foo provider

+        foo.stop();

+

+        // No provider -> Invalid

+        assertTrue("Test component invalidity - 2", import2.getState() == ComponentInstance.INVALID);

+

+        foo.start();

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo.dispose();

+        // No provider -> Invalid

+        assertTrue("Test component invalidity - 3", import2.getState() == ComponentInstance.INVALID);

+    }

+

+    @Test

+    public void testSimple2() {

+        // No provider -> Invalid

+        assertTrue("Test component invalidity", import2.getState() == ComponentInstance.INVALID);

+

+        ComponentInstance foo1 = null;

+        Properties p = new Properties();

+        p.put("instance.name", "foo");

+        try {

+            foo1 = fooProvider.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo component " + e.getMessage());

+        }

+

+        ComponentInstance foo2 = null;

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+        try {

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo2 component " + e.getMessage());

+        }

+

+        // The foo service is available => import1 must be valid

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import2);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2 (" + refs.length + ")", refs.length, 2);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        FooService fs2 = (FooService) sc.getService(refs[1]);

+        assertTrue("Test foo invocation", fs2.foo());

+        sc.ungetService(refs[0]);

+        sc.ungetService(refs[1]);

+

+        // Stop the first provider

+        foo1.stop();

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 2", refs);

+        assertEquals("Test foo availability inside the composite - 2.1 (" + refs.length + ")", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // stop the second foo provider

+        foo2.dispose();

+

+        // No provider -> Invalid

+        assertTrue("Test component invalidity - 2", import2.getState() == ComponentInstance.INVALID);

+

+        foo1.start();

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo1.dispose();

+        // No provider -> Invalid

+        assertTrue("Test component invalidity - 3", import2.getState() == ComponentInstance.INVALID);

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestOptionalImport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestOptionalImport.java
new file mode 100644
index 0000000..b9b0482
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestOptionalImport.java
@@ -0,0 +1,192 @@
+/* 

+ * 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.runtime.core.importer;

+

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestOptionalImport extends Common {

+

+    ComponentInstance import3;

+    Factory fooProvider;

+

+    @Before

+    public void setUp() {

+        fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        Properties p = new Properties();

+        p.put("instance.name", "importer");

+        Factory compFact = ipojoHelper.getFactory("composite.requires.3");

+        try {

+            import3 = compFact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate the component : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        import3.dispose();

+        import3 = null;

+    }

+

+    @Test

+    public void testSimple() {

+        // No provider -> valid

+        assertTrue("Test component invalidity", import3.getState() == ComponentInstance.VALID);

+

+        ComponentInstance foo = null;

+        Properties p = new Properties();

+        p.put("instance.name", "foo");

+        try {

+            foo = fooProvider.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo component " + e.getMessage());

+        }

+

+        ComponentInstance foo2 = null;

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+        try {

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo2 component " + e.getMessage());

+        }

+

+        // The foo service is available => import1 must be valid

+        assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import3);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the second provider

+        foo2.dispose();

+        assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import3);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 2", refs);

+        assertEquals("Test foo availability inside the composite - 2.1 (" + refs.length + ")", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // stop the foo provider

+        foo.stop();

+

+        // No provider -> Invalid

+        assertTrue("Test component invalidity - 2", import3.getState() == ComponentInstance.VALID);

+

+        foo.start();

+        assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import3);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo.dispose();

+        // No provider -> Invalid

+        assertTrue("Test component invalidity - 3", import3.getState() == ComponentInstance.VALID);

+    }

+

+    @Test

+    public void testSimple2() {

+        // No provider -> valid

+        assertTrue("Test component invalidity", import3.getState() == ComponentInstance.VALID);

+

+        ComponentInstance foo1 = null;

+        Properties p = new Properties();

+        p.put("instance.name", "foo");

+        try {

+            foo1 = fooProvider.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo component " + e.getMessage());

+        }

+

+        ComponentInstance foo2 = null;

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+        try {

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo2 component " + e.getMessage());

+        }

+

+        // The foo service is available => import1 must be valid

+        assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import3);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the second provider

+        foo1.stop();

+        assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import3);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 2", refs);

+        assertEquals("Test foo availability inside the composite - 2.1 (" + refs.length + ")", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // stop the foo provider

+        foo2.dispose();

+

+        // No provider -> Invalid

+        assertTrue("Test component invalidity - 2", import3.getState() == ComponentInstance.VALID);

+

+        foo1.start();

+        assertTrue("Test component validity", import3.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import3);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo1.dispose();

+        // No provider -> Invalid

+        assertTrue("Test component invalidity - 3", import3.getState() == ComponentInstance.VALID);

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestOptionalMultipleImport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestOptionalMultipleImport.java
new file mode 100644
index 0000000..0ac8a52
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestOptionalMultipleImport.java
@@ -0,0 +1,209 @@
+/* 

+ * 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.runtime.core.importer;

+

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestOptionalMultipleImport extends Common {

+

+    ComponentInstance import2;

+    Factory fooProvider;

+

+    @Before

+    public void setUp() {

+        fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        Properties p = new Properties();

+        p.put("instance.name", "importer");

+        Factory compFact = ipojoHelper.getFactory("composite.requires.4");

+        try {

+            import2 = compFact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate the component : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        import2.dispose();

+        import2 = null;

+    }

+

+    @Test

+    public void testSimple() {

+        // No provider -> valid

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+

+        ComponentInstance foo = null;

+        Properties p = new Properties();

+        p.put("instance.name", "foo");

+        try {

+            foo = fooProvider.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo component " + e.getMessage());

+        }

+

+        ComponentInstance foo2 = null;

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+        try {

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo2 component " + e.getMessage());

+        }

+

+        // The foo service is available => import1 must be valid

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import2);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2 (" + refs.length + ")", refs.length, 2);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        FooService fs2 = (FooService) sc.getService(refs[1]);

+        assertTrue("Test foo invocation", fs2.foo());

+        sc.ungetService(refs[0]);

+        sc.ungetService(refs[1]);

+

+        // Stop the second provider

+        foo2.dispose();

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 2", refs);

+        assertEquals("Test foo availability inside the composite - 2.1 (" + refs.length + ")", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // stop the foo provider

+        foo.stop();

+

+        // No provider -> valid

+        assertTrue("Test component validity - 2", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertEquals("Test foo non-availability inside the composite - 1", refs.length, 0);

+

+        foo.start();

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo.dispose();

+        // No provider -> Invalid

+        assertTrue("Test component validity - 3", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertEquals("Test foo non-availability inside the composite - 2", refs.length, 0);

+    }

+

+    @Test

+    public void testSimple2() {

+        // No provider -> Invalid

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+

+        ComponentInstance foo1 = null;

+        Properties p = new Properties();

+        p.put("instance.name", "foo");

+        try {

+            foo1 = fooProvider.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo component " + e.getMessage());

+        }

+

+        ComponentInstance foo2 = null;

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+        try {

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo2 component " + e.getMessage());

+        }

+

+        // The foo service is available => import1 must be valid

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import2);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2 (" + refs.length + ")", refs.length, 2);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        FooService fs2 = (FooService) sc.getService(refs[1]);

+        assertTrue("Test foo invocation", fs2.foo());

+        sc.ungetService(refs[0]);

+        sc.ungetService(refs[1]);

+

+        // Stop the first provider

+        foo1.stop();

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 2", refs);

+        assertEquals("Test foo availability inside the composite - 2.1 (" + refs.length + ")", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // stop the second foo provider

+        foo2.dispose();

+

+        // No provider -> Invalid

+        assertTrue("Test component validity - 2", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertEquals("Test foo non-availability inside the composite - 1", refs.length, 0);

+

+        foo1.start();

+        assertTrue("Test component validity", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo1.dispose();

+        // No provider -> Invalid

+        assertTrue("Test component invalidity - 3", import2.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import2);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertEquals("Test foo non-availability inside the composite - 2", refs.length, 0);

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestSimpleImport.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestSimpleImport.java
new file mode 100644
index 0000000..0bec7c9
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-import-export-test/src/test/java/org/apache/felix/ipojo/runtime/core/importer/TestSimpleImport.java
@@ -0,0 +1,192 @@
+/* 

+ * 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.runtime.core.importer;

+

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestSimpleImport extends Common {

+

+    ComponentInstance import1;

+    Factory fooProvider;

+

+    @Before

+    public void setUp() {

+        fooProvider = ipojoHelper.getFactory("COMPO-FooProviderType-1");

+        assertNotNull("Check fooProvider availability", fooProvider);

+

+        Properties p = new Properties();

+        p.put("instance.name", "importer");

+        Factory compFact = ipojoHelper.getFactory("composite.requires.1");

+        try {

+            import1 = compFact.createComponentInstance(p);

+        } catch (Exception e) {

+            e.printStackTrace();

+            fail("Cannot instantiate the component : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        import1.dispose();

+        import1 = null;

+    }

+

+    @Test

+    public void testSimple() {

+        // No provider -> Invalid

+        assertTrue("Test component invalidity - 0 (" + import1.getState() + ")", import1.getState() == ComponentInstance.INVALID);

+

+        ComponentInstance foo = null;

+        Properties p = new Properties();

+        p.put("instance.name", "foo");

+        try {

+            foo = fooProvider.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo component " + e.getMessage());

+        }

+

+        ComponentInstance foo2 = null;

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+        try {

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo2 component " + e.getMessage());

+        }

+

+        // The foo service is available => import1 must be valid

+        assertTrue("Test component validity - 1", import1.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import1);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the second provider

+        foo2.dispose();

+        assertTrue("Test component validity - 2", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 2", refs);

+        assertEquals("Test foo availability inside the composite - 2.1 (" + refs.length + ")", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // stop the foo provider

+        foo.stop();

+

+        // No provider -> Invalid

+        assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);

+

+        foo.start();

+        assertTrue("Test component validity - 3", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo.dispose();

+        // No provider -> Invalid

+        assertTrue("Test component invalidity - 3", import1.getState() == ComponentInstance.INVALID);

+    }

+

+    @Test

+    public void testSimple2() {

+        // No provider -> Invalid

+        assertTrue("Test component invalidity", import1.getState() == ComponentInstance.INVALID);

+

+        ComponentInstance foo1 = null;

+        Properties p = new Properties();

+        p.put("instance.name", "foo");

+        try {

+            foo1 = fooProvider.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo component " + e.getMessage());

+        }

+

+        ComponentInstance foo2 = null;

+        Properties p2 = new Properties();

+        p2.put("instance.name", "foo2");

+        try {

+            foo2 = fooProvider.createComponentInstance(p2);

+        } catch (Exception e) {

+            fail("Fail to instantiate the foo2 component " + e.getMessage());

+        }

+

+        // The foo service is available => import1 must be valid

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        ServiceContext sc = getServiceContext(import1);

+        ServiceReference[] refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 1", refs);

+        assertEquals("Test foo availability inside the composite - 1.2", refs.length, 1);

+        FooService fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // Stop the first provider

+        foo1.stop();

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 2", refs);

+        assertEquals("Test foo availability inside the composite - 2.1 (" + refs.length + ")", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        // stop the second foo provider

+        foo2.dispose();

+

+        // No provider -> Invalid

+        assertTrue("Test component invalidity - 2", import1.getState() == ComponentInstance.INVALID);

+

+        foo1.start();

+        assertTrue("Test component validity", import1.getState() == ComponentInstance.VALID);

+        sc = getServiceContext(import1);

+        refs = ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null);

+        assertNotNull("Test foo availability inside the composite - 3", refs);

+        assertEquals("Test foo availability inside the composite - 3.1", refs.length, 1);

+        fs = (FooService) sc.getService(refs[0]);

+        assertTrue("Test foo invocation", fs.foo());

+        sc.ungetService(refs[0]);

+

+        foo1.dispose();

+        // No provider -> Invalid

+        assertTrue("Test component invalidity - 3", import1.getState() == ComponentInstance.INVALID);

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/pom.xml b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/pom.xml
new file mode 100644
index 0000000..06d1540
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/pom.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.ipojo.runtime.composite-it</artifactId>
+        <version>1.9.0-SNAPSHOT</version>
+        <relativePath>../../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.felix</groupId>
+    <artifactId>ipojo-composite-instance-test</artifactId>
+
+    <name>${project.artifactId}</name>
+    
+</project>
\ No newline at end of file
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Baz2CheckProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Baz2CheckProvider.java
new file mode 100644
index 0000000..7e5d145
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Baz2CheckProvider.java
@@ -0,0 +1,81 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.BazService;

+import org.apache.felix.ipojo.runtime.core.services.CheckService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+public class Baz2CheckProvider implements CheckService {

+	

+	BazService fs;

+	

+	int simpleB = 0;

+	int objectB = 0;

+	int refB = 0;

+	int simpleU = 0;

+	int objectU = 0;

+	int refU = 0;

+

+	public boolean check() {

+		return fs.foo();

+	}

+

+	public Properties getProps() {

+		Properties props = new Properties();

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

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

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

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

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

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

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

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

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

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

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

+		if(fs.getObject() != null) { props.put("object", fs.getObject()); }

+		

+		return props;

+	}

+	

+	private void voidBind() {

+		simpleB++;

+	}

+	private void voidUnbind() {

+		simpleU++;

+	}

+	

+	protected void objectBind(Object o) {

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

+	}

+	protected void objectUnbind(Object o) {

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

+	}

+	

+	public void refBind(ServiceReference sr) {

+		if(sr != null) { refB++; }

+	}

+	public void refUnbind(ServiceReference sr) {

+		if(sr != null) { refU++; }

+	}

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/BazProviderType1.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/BazProviderType1.java
new file mode 100644
index 0000000..5ac64d3
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/BazProviderType1.java
@@ -0,0 +1,51 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.BazService;

+

+import java.util.Properties;

+

+public class BazProviderType1 implements BazService {

+	

+	private int m_bar;

+	private String m_foo;

+

+	public boolean foo() {

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("bar", new Integer(m_bar));

+		p.put("foo", m_foo);

+		return p;

+	}

+	

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckProviderParentClass.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckProviderParentClass.java
new file mode 100644
index 0000000..7d18712
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckProviderParentClass.java
@@ -0,0 +1,51 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.ServiceReference;

+

+public abstract class CheckProviderParentClass {

+    

+    int simpleU = 0;

+    int objectU = 0;

+    int refU = 0;

+    int bothU = 0;

+    

+    

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

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

+    }

+    

+    public void refUnbind(ServiceReference sr) {

+        if(sr != null) { refU++; }

+    }

+    

+    public void objectUnbind(FooService o) {

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

+        else {

+            System.err.println("Unbind null : " + o);

+        }

+    }

+    

+    public void voidUnbind() {

+        simpleU++;

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java
new file mode 100644
index 0000000..eee88a2
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java
@@ -0,0 +1,83 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.CheckService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+public class CheckServiceProvider extends CheckProviderParentClass implements CheckService {

+    

+	FooService fs;

+	

+	int simpleB = 0;

+	int objectB = 0;

+	int refB = 0;

+	int bothB = 0;

+

+	public boolean check() {

+		return fs.foo();

+	}

+

+	public Properties getProps() {

+		Properties props = new Properties();

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

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

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

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

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

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

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

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

+		if (fs != null) {

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

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

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

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

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

+		    if(fs.getObject() != null) { props.put("object", fs.getObject()); }

+		}

+        props.put("static", CheckService.foo);

+        props.put("class", CheckService.class.getName());

+		return props;

+	}

+	

+	private void voidBind() {

+		simpleB++;

+	}

+	

+	protected void objectBind(FooService o) {

+	    if (o == null) {

+	        System.err.println("Bind receive null !!! ");

+	        return;

+	    }

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

+	}

+	

+	public void refBind(ServiceReference sr) {

+		if(sr != null) { refB++; }

+	}

+	

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

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

+	}

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java
new file mode 100644
index 0000000..03016d3
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java
@@ -0,0 +1,54 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.BarService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+

+import java.util.Properties;

+

+public class FooBarProviderType1 implements FooService, BarService {

+

+	public boolean foo() {

+		return true;

+	}

+

+	public Properties fooProps() {

+		return new Properties();

+	}

+

+	public boolean bar() {

+		return true;

+	}

+

+	public Properties getProps() {

+		return new Properties();

+	}

+

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
new file mode 100644
index 0000000..b9eda2d
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
@@ -0,0 +1,92 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.BundleContext;

+

+import java.util.Properties;

+

+public class FooProviderType1 implements FooService {

+	

+	private int m_bar;

+	private String m_foo;

+    

+    private BundleContext m_context;

+    

+    private static FooProviderType1 singleton;

+    private static int count = 0;

+    

+    public FooProviderType1(BundleContext bc) {

+        if (bc ==null) {

+            throw new RuntimeException("Injected bundle context null");

+        }

+        m_context = bc;

+    }

+

+	public boolean foo() {

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("bar", new Integer(m_bar));

+        if(m_foo != null) {

+            p.put("foo", m_foo);

+        }

+        p.put("context", m_context);

+        

+        p.put("count", new Integer(count));

+		return p;

+	}

+    

+	public void testException() throws Exception {

+        String a = "foobarbaz";

+	    throw new Exception("foo"+a);

+    }

+    

+    public void testTry() {

+            String a = "foo";

+            a.charAt(0);

+    }

+    

+    public void testTry2(String s) {

+            String a = "foo";

+            a.charAt(0);

+    }

+    

+    private void nexttry(String  s) {

+        try {

+            s += "foo";

+        } catch(RuntimeException e) {

+            

+        }

+    }

+    

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java
new file mode 100644
index 0000000..47f6ae5
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java
@@ -0,0 +1,63 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+

+import java.util.Properties;

+

+public class FooProviderTypeDyn implements FooService {

+	

+	private int intProp;	

+	private String strProp;

+	private String[] strAProp;

+	private int[] intAProp;

+	private boolean boolProp;

+

+	public boolean foo() {

+		intProp = 3;

+		boolProp = true;

+		if(strProp.equals("foo")) { strProp = "bar"; }

+		else { strProp = "foo"; }

+		strAProp = new String[] {"foo", "bar", "baz"};

+		intAProp = new int[] {3, 2, 1};

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("intProp", new Integer(intProp));

+		p.put("boolProp", new Boolean(boolProp));

+		p.put("strProp", strProp);

+		p.put("strAProp", strAProp);

+		p.put("intAProp", intAProp);

+		return p;

+	}

+	

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java
new file mode 100644
index 0000000..efec5f0
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java
@@ -0,0 +1,58 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+

+import java.util.Properties;

+

+public class FooProviderTypeDyn2 implements FooService {

+	

+	private int intProp = 2;

+	private boolean boolProp = true;

+	private String strProp = "foo";

+	private String[] strAProp = new String[] {"foo", "bar"};

+	private int[] intAProp = new int[] {1, 2, 3};

+

+	public boolean foo() {

+		intAProp = null;

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("intProp", new Integer(intProp));

+		p.put("boolProp", new Boolean(boolProp));

+		p.put("strProp", strProp);

+		p.put("strAProp", strAProp);

+		p.put("intAProp", intAProp);

+		return p;

+	}

+	

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ServiceConsumer.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ServiceConsumer.java
new file mode 100644
index 0000000..65295b7
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ServiceConsumer.java
@@ -0,0 +1,27 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.apache.felix.ipojo.runtime.core.services.Service;
+
+import java.util.Properties;
+
+public class ServiceConsumer implements CheckService {
+
+    private Service service;
+    private Properties props = new Properties();
+
+    public ServiceConsumer() {
+        props.put("1", new Integer(service.count()));
+        props.put("2", new Integer(service.count()));
+        props.put("3", new Integer(service.count()));
+    }
+
+    public boolean check() {
+        return service.count() > 0;
+    }
+
+    public Properties getProps() {
+        return props;
+    }
+
+}
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ServiceProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ServiceProvider.java
new file mode 100644
index 0000000..702899f
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ServiceProvider.java
@@ -0,0 +1,15 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.Service;
+
+
+public class ServiceProvider implements Service {
+
+    private int i = 0;
+
+    public int count() {
+        i++;
+        return i;
+    }
+
+}
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java
new file mode 100644
index 0000000..c3ade01
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java
@@ -0,0 +1,222 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.Tata;

+

+import java.util.Properties;

+

+

+public class TataProvider implements Tata {

+    

+    int tata = 0;

+    int tataStr = 0;

+    int tataStrs = 0;

+    int tata_2 = 0;

+    int tata_3 = 0;

+    int tata1 = 0;

+    int tata1_1 = 0;

+    int tata5 = 0;

+    int tata5_1 = 0;

+    int tata5_2 = 0;

+    int tataBoolean = 0;

+    int tataBooleans = 0;

+    int tataByte = 0;

+    int tataBytes = 0;

+    private int add;

+    private int tataShorts;

+    private int tataShort;

+    private int tataLongs;

+    private int tataLong;

+    private int tataInts;

+    private int tataInt;

+    private int tataFloat;

+    private int tataFloats;

+    private int tataDoubles;

+    private int tataDouble;

+    private int tataChars;

+    private int tataChar;

+    

+    public Properties getPropsTata() {

+        Properties props = new Properties();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+        return props;

+    }

+

+    public void tata() {

+        tata++;

+    }

+

+    public String tataStr() {

+        tataStr++;

+        return "Tata";

+    }

+

+    public String[] tataStrs() {

+        tataStrs++;

+        return new String[] {"T", "A", "T", "A"};

+    }

+

+    public void tata(int i, int j) {

+        tata_2++;        

+    }

+

+    public void tata(String s) {

+        tata_3++;

+    }

+

+    public String tata1(String a) {

+        tata1++;

+       return a;

+    }

+

+    public String tata1(char[] a) {

+        tata1_1++;

+        String s = new String(a);

+        return s;

+    }

+

+    public String tata5(String a, int i) {

+       tata5++;

+       return a+i;

+    }

+

+    public String tata5(String[] a, int i) {

+       tata5_1++;

+       return ""+a.length + i;

+    }

+

+    public String tata5(String a, int[] i) {

+        tata5_2++;

+        return a + i.length;

+    }

+

+    public boolean tataBoolean(boolean b) {

+        tataBoolean++;

+        return b;

+    }

+

+    public boolean[] tataBooleans(boolean[] b) {

+        tataBooleans++;

+       return b;

+    }

+

+    public byte tataByte(byte b) {

+        tataByte++;

+        return b;

+    }

+

+    public byte[] tataBytes(byte[] b) {

+        tataBytes++;

+        return b;

+    }

+

+    public char tataChar(char c) {

+       tataChar++;

+       return c;

+    }

+

+    public char[] tataChars(char[] c) {

+        tataChars++;

+        return c;

+    }

+

+    public double tataDouble(double d) {

+        tataDouble++;

+        return d;

+    }

+

+    public double[] tataDoubles(double[] d) {

+        tataDoubles++;

+        return d;

+    }

+

+    public float tataFloat(float f) {

+        tataFloat++;

+        return f;

+    }

+

+    public float[] tataFloats(float[] f) {

+        tataFloats++;

+        return f;

+    }

+

+    public int tataInt(int i) {

+        tataInt++;

+        return i;

+    }

+

+    public int[] tataInts(int[] its) {

+        tataInts++;

+        return its;

+    }

+

+    public long tataLong(long l) {

+        tataLong++;

+        return l;

+    }

+

+    public long[] tataLongs(long[] l) {

+        tataLongs++;

+        return l;

+    }

+

+    public short tataShort(short s) {

+        tataShort++;

+        return s;

+    }

+

+    public short[] tataShorts(short[] s) {

+        tataShorts++;

+        return s;

+    }

+

+    public long add(int i, int j, int k) {

+        add++;

+        return i + j + k;

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java
new file mode 100644
index 0000000..d230c2d
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java
@@ -0,0 +1,73 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.Toto;

+

+import java.util.Properties;

+

+

+public class TotoProvider implements Toto {

+    

+    private int i = 0;

+    public static int toto = 0;

+    public static int toto_2 = 0;

+    public static int toto_3 = 0;

+    public static int toto_4 = 0;

+    public static int toto1 = 0;

+    

+    public int count() {

+        return i;

+    }

+    

+    public void toto() {

+        toto++;        

+    }

+

+    public void toto(int i, int j) {

+        toto_2++;

+    }

+

+    public String toto(String a) {

+        toto_3++;

+        return a;

+    }

+

+    public String toto(String[] a) {

+        toto_4++;

+        return "toto";

+    }

+

+    public void toto1(String j) {

+        i++;

+        toto1++;        

+    }

+

+    public Properties getProps() {

+        Properties props = new Properties();

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

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

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

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

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

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

+        return props;

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java
new file mode 100644
index 0000000..f90460c
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java
@@ -0,0 +1,81 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.Toto;

+

+import java.util.Properties;

+

+

+public class TotoProviderGlue implements Toto {

+    

+    Toto m_toto;

+    

+    private int i = 0;

+    public static int toto = 0;

+    public static int toto_2 = 0;

+    public static int toto_3 = 0;

+    public static int toto_4 = 0;

+    public static int toto1 = 0;

+    

+    public int count() {

+        return i;

+    }

+    

+    public void toto() {

+        toto++;

+        m_toto.toto();

+    }

+

+    public void toto(int i, int j) {

+        toto_2++;

+        m_toto.toto(i, j);

+    }

+

+    public String toto(String a) {

+        toto_3++;

+        return a;

+    }

+

+    public String toto(String[] a) {

+        toto_4++;

+        return "toto";

+    }

+

+    public void toto1(String j) {

+        i++;

+        toto1++;

+        m_toto.toto1(j);

+    }

+

+    public Properties getProps() {

+        Properties props = new Properties();

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

+        props.put("gtoto", new Integer(toto));

+        props.put("gtoto_2", new Integer(toto_2));

+        props.put("gtoto_3", new Integer(toto_3));

+        props.put("gtoto_4", new Integer(toto_4));

+        props.put("gtoto1", new Integer(toto1));

+        props.put("glue", "glue");

+        Properties p2 = m_toto.getProps();

+        props.putAll(p2);

+        return props;

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java
new file mode 100644
index 0000000..e31a24a
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java
@@ -0,0 +1,25 @@
+/* 

+ * 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.runtime.core.services.A123;

+

+public interface CheckService2 {

+	

+	public boolean check();

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java
new file mode 100644
index 0000000..f704138
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java
@@ -0,0 +1,29 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface BarService {

+	

+	public boolean bar();

+	

+	public Properties getProps();

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java
new file mode 100644
index 0000000..a4c4854
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java
@@ -0,0 +1,39 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface BazService {

+

+	boolean foo();

+	

+	Properties fooProps();

+	

+	Boolean getObject();

+	

+	boolean getBoolean();

+	

+	int getInt();

+	

+	long getLong();

+	

+	double getDouble();

+	

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
new file mode 100644
index 0000000..eca0faa
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
@@ -0,0 +1,31 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface CheckService {

+    

+    public static final String foo = "foo";

+	

+	public boolean check();

+	

+	public Properties getProps();

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
new file mode 100644
index 0000000..37c1a65
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
@@ -0,0 +1,39 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface FooService {

+

+	boolean foo();

+	

+	Properties fooProps();

+	

+	Boolean getObject();

+	

+	boolean getBoolean();

+	

+	int getInt();

+	

+	long getLong();

+	

+	double getDouble();

+	

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Service.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Service.java
new file mode 100644
index 0000000..7b85548
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Service.java
@@ -0,0 +1,7 @@
+package org.apache.felix.ipojo.runtime.core.services;
+
+public interface Service {
+    
+    public int count();
+
+}
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java
new file mode 100644
index 0000000..ba526f5
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java
@@ -0,0 +1,62 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface Tata {

+    

+    public Properties getPropsTata();

+    

+    public void tata();

+    

+    public int tataInt(int i);

+    public long tataLong(long l);

+    public double tataDouble(double d);

+    public char tataChar(char c);

+    public boolean tataBoolean(boolean b);

+    public short tataShort(short s);

+    public float tataFloat(float f);

+    public byte tataByte(byte b);

+    

+    public int[] tataInts(int[] its);

+    public long[] tataLongs(long[] l);

+    public double[] tataDoubles(double[] d);

+    public char[] tataChars(char[] c);

+    public boolean[] tataBooleans(boolean[] b);

+    public short[] tataShorts(short[] s);

+    public float[] tataFloats(float[] f);

+    public byte[] tataBytes(byte[] b);

+    

+    public String tataStr();

+    public String[] tataStrs();

+    

+    public void tata(int i, int j);

+    public void tata(String s);

+    

+    public String tata1(String a);

+    public String tata1(char[] a);

+    

+    public String tata5(String a, int i);

+    public String tata5(String[] a, int i);

+    public String tata5(String a, int[] i);

+    

+    public long add(int i, int j, int k);

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java
new file mode 100644
index 0000000..19bd528
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java
@@ -0,0 +1,78 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface Tota {

+    

+    public static final String specification="specification { " +

+    		"requires { " +

+    		    "$specification=\"org.apache.felix.ipojo.test.composite.service.Toto\" " +

+    		    "$optional=\"true\" " +

+    		    "$aggregate=\"true\" " +

+    		    "$type=\"service\" " +

+    		"} }"; 

+    

+    public Properties getProps() throws UnsupportedOperationException;;

+    public Properties getPropsTata();

+    

+    public void tata();

+    

+    public int tataInt(int i);

+    public long tataLong(long l);

+    public double tataDouble(double d);

+    public char tataChar(char c);

+    public boolean tataBoolean(boolean b);

+    public short tataShort(short s);

+    public float tataFloat(float f);

+    public byte tataByte(byte b);

+    

+    public int[] tataInts(int[] its);

+    public long[] tataLongs(long[] l);

+    public double[] tataDoubles(double[] d);

+    public char[] tataChars(char[] c);

+    public boolean[] tataBooleans(boolean[] b);

+    public short[] tataShorts(short[] s);

+    public float[] tataFloats(float[] f);

+    public byte[] tataBytes(byte[] b);

+    

+    public String tataStr();

+    public String[] tataStrs();

+    

+    public void tata(int i, int j);

+    public void tata(String s);

+    

+    public String tata1(String a);

+    public String tata1(char[] a);

+    

+    public String tata5(String a, int i);

+    public String tata5(String[] a, int i);

+    public String tata5(String a, int[] i);

+    

+    public long add(int i, int j, int k);

+    

+    public void toto() throws UnsupportedOperationException;    

+    public void toto(int i, int j) throws UnsupportedOperationException;

+    public String toto(String a) throws UnsupportedOperationException;

+    

+    public void toto1(String j) throws UnsupportedOperationException;

+    

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java
new file mode 100644
index 0000000..8ed22ec
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java
@@ -0,0 +1,37 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface Toto {

+    

+    public Properties getProps();

+    

+    public void toto();    

+    public void toto(int i, int j);

+    public String toto(String a);

+    public String toto(String[] a);

+    

+    public void toto1(String j);

+    

+    public int count();

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/resources/metadata-instance.xml b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/resources/metadata-instance.xml
new file mode 100644
index 0000000..9857648
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/resources/metadata-instance.xml
@@ -0,0 +1,89 @@
+<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

+	    org.apache.felix.composite http://felix.apache.org/ipojo/schemas/SNAPSHOT/composite.xsd"

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

+	xmlns:comp="org.apache.felix.ipojo.composite"

+	xmlns:cs="org.apache.felix.ipojo.test.composite.handler.CheckServiceHandler">

+	<comp:composite name="composite.bar.1" architecture="true">

+		<subservice action="instantiate" specification="org.apache.felix.ipojo.runtime.core.services.BarService"/>

+	</comp:composite>

+

+	<comp:composite name="composite.bar.2" architecture="true">

+		<subservice action="instantiate" specification="org.apache.felix.ipojo.runtime.core.services.BarService" aggregate="true"/>

+	</comp:composite>

+

+	<comp:composite name="composite.bar.3" architecture="true">

+		<subservice action="instantiate" specification="org.apache.felix.ipojo.runtime.core.services.BarService" optional="true"/>

+	</comp:composite>

+

+	<comp:composite name="composite.bar.4" architecture="true">

+		<subservice action="instantiate" specification="org.apache.felix.ipojo.runtime.core.services.FooService" aggregate="true" optional="true"/>

+	</comp:composite>

+

+	<comp:composite name="composite.bar.5-accept" architecture="true">

+		<subservice action="instantiate" specification="org.apache.felix.ipojo.runtime.core.services.FooService">

+			<property name="boolean" value="true"/>

+			<property name="string" value="foo"/>

+			<property name="strAprop" value="{foo, bar, baz}"/>

+			<property name="int" value="5"/>

+		</subservice>

+	</comp:composite>

+

+	<comp:composite name="composite.bar.5-refuse1" architecture="true">

+		<subservice action="instantiate" specification="org.apache.felix.ipojo.runtime.core.services.BarService">

+			<property name="foo" value="bar"/>

+			<property name="boolean" value="true"/>

+			<property name="string" value="foo"/>

+			<property name="strAprop" value="{foo, bar, baz}"/>

+			<property name="int" value="5"/>

+		</subservice>

+	</comp:composite>

+

+	<comp:composite name="composite.bar.5-refuse2" architecture="true">

+		<subservice action="instantiate" specification="org.apache.felix.ipojo.runtime.core.services.BarService">

+			<property name="string" value="foo"/>

+			<property name="strAprop" value="{foo, bar, baz}"/>

+		</subservice>

+	</comp:composite>

+

+    <!-- Instance of a specified component -->

+	<comp:composite name="composite.inst.1" architecture="true">

+		<instance component="COMPO-FooProviderType-1" /> <!-- name="FooProv"  -->

+		<instance component="COMPO-FooProviderType-Dyn2">

+			<property name="boolean" value="true"/>

+			<property name="string" value="foo"/>

+			<property name="strAProp" value="{a,b,c}"/>

+		</instance>

+	</comp:composite>

+

+	<!-- Scope test -->

+	<component name="SCOPE-provider" classname="org.apache.felix.ipojo.runtime.core.components.ServiceProvider">

+		<provides/>

+	</component>

+	<component name="SCOPE-cons" classname="org.apache.felix.ipojo.runtime.core.components.ServiceConsumer">

+		<provides/>

+		<requires field="service"/>

+	</component>

+	<comp:composite name="SCOPE-scope">

+		<instance component="SCOPE-provider"/>

+		<instance component="SCOPE-cons"/>

+	</comp:composite>

+	<comp:composite name="SCOPE-badscope">

+		<instance component="SCOPE-cons"/>

+	</comp:composite>

+

+	<!-- Instance configuration  -->

+	<comp:composite name="CONF-MySuperComposite">

+                <instance component="COMPO-FooProviderType-2">

+                               <property name="int" value="3"/>

+                </instance>

+                <subservice action="instantiate"

+					specification="org.apache.felix.ipojo.runtime.core.services.FooService">

+					<property name="boolean" value="true"/>

+					<property name="string" value="foo"/>

+					<property name="strAprop" value="{foo, bar, baz}"/>

+					<property name="int" value="3"/>

+				</subservice>

+	</comp:composite>

+</ipojo>

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/resources/metadata.xml b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/resources/metadata.xml
new file mode 100644
index 0000000..6143ff9
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/main/resources/metadata.xml
@@ -0,0 +1,112 @@
+<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

+	    org.apache.felix.composite http://felix.apache.org/ipojo/schemas/SNAPSHOT/composite.xsd"

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

+	xmlns:comp="org.apache.felix.ipojo.composite">

+	<!-- Used component type -->

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"

+		name="COMPO-FooProviderType-1" architecture="true">

+		<provides />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"

+		name="COMPO-FooProviderType-2" architecture="true">

+		<provides>

+			<property name="int" type="int" value="2" />

+			<property name="long" type="long" value="40" />

+			<property name="string" type="java.lang.String" value="foo" />

+			<property name="strAProp" type="java.lang.String[]"

+				value="{foo, bar}" />

+			<property name="intAProp" type="int[]" value="{1,2,3}" />

+		</provides>

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderTypeDyn"

+		name="COMPO-FooProviderType-Dyn" architecture="true">

+		<provides>

+			<property name="int" field="intProp" value="2" />

+			<property name="boolean" field="boolProp" value="false" />

+			<property name="string" field="strProp" value="foo" />

+			<property name="strAProp" field="strAProp"

+				value="{foo, bar}" />

+			<property name="intAProp" field="intAProp" value="{ 1,2,3}" />

+		</provides>

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderTypeDyn2"

+		name="COMPO-FooProviderType-Dyn2" architecture="true">

+		<provides>

+			<property name="int" field="intProp" value="4" />

+			<property name="boolean" field="boolProp" />

+			<property name="string" field="strProp" />

+			<property name="strAProp" field="strAProp" />

+			<property name="intAProp" field="intAProp"

+				value="{1, 2,3 }" />

+		</provides>

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.CheckServiceProvider"

+		name="COMPO-SimpleCheckServiceProvider" architecture="true">

+		<requires field="fs" />

+		<provides />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"

+		name="COMPO-FooBarProviderType-1" architecture="true">

+		<provides />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"

+		name="COMPO-FooBarProviderType-2" architecture="true">

+		<provides

+			specifications="{org.apache.felix.ipojo.runtime.core.services.FooService, org.apache.felix.ipojo.runtime.core.services.BarService }" />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"

+		name="COMPO-FooBarProviderType-3" architecture="true">

+		<provides

+			specifications="{org.apache.felix.ipojo.runtime.core.services.FooService}">

+			<property name="baz" type="java.lang.String" value="foo" />

+		</provides>

+		<provides

+			specifications="{org.apache.felix.ipojo.runtime.core.services.BarService}">

+			<property name="baz" type="java.lang.String" value="bar" />

+		</provides>

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.BazProviderType1"

+		name="BazProviderType">

+		<provides />

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.TataProvider"

+		name="tata">

+		<provides />

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.TotoProvider"

+		name="toto" architecture="true">

+		<provides />

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.TotoProviderGlue"

+		name="totoglue">

+		<requires field="m_toto" scope="composite" />

+	</component>

+

+	<!--  Composite -->

+	<comp:composite name="composite.empty" architecture="true">

+	</comp:composite>

+

+	<component classname="org.apache.felix.ipojo.runtime.core.components.Baz2CheckProvider" name="Baz2CheckProvider" architecture="true">

+		<requires field="fs" scope="composite"/>

+		<provides/>

+	</component>

+

+</ipojo>

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
new file mode 100644
index 0000000..b242001
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
@@ -0,0 +1,225 @@
+package org.apache.felix.ipojo.runtime.core;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.ServiceContext;
+import org.apache.felix.ipojo.composite.CompositeManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.CompositeOption;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+import org.ops4j.pax.tinybundles.core.TinyBundle;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.ow2.chameleon.testing.helpers.IPOJOHelper;
+import org.ow2.chameleon.testing.helpers.OSGiHelper;
+import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static junit.framework.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.*;
+
+/**
+ * Bootstrap the test from this project
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class Common {
+
+    @Inject
+    protected
+    BundleContext bc;
+
+    protected OSGiHelper osgiHelper;
+    protected IPOJOHelper ipojoHelper;
+
+    protected boolean deployTestedBundle = true;
+
+    @Configuration
+    public Option[] config() throws IOException {
+        Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+        root.setLevel(Level.INFO);
+
+        if (deployTestedBundle) {
+            return options(
+                    cleanCaches(),
+                    ipojoBundles(),
+                    junitBundles(),
+                    testedBundle(),
+                    systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+            );
+        } else {
+            return options(
+                    cleanCaches(),
+                    ipojoBundles(),
+                    junitBundles(),
+                    systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+            );
+        }
+    }
+
+    public static Option junitAndMockitoBundles() {
+        return new DefaultCompositeOption(
+                // Repository required to load harmcrest (OSGi-fied version).
+                repository("http://repository.springsource.com/maven/bundles/external").id(
+                        "com.springsource.repository.bundles.external"),
+
+                // Mockito without Hamcrest and Objenesis
+                mavenBundle("org.mockito", "mockito-core", "1.9.5"),
+
+                // Hamcrest with a version matching the range expected by Mockito
+                mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
+
+                // Objenesis with a version matching the range expected by Mockito
+                wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
+                        .exports("*;version=1.2"),
+
+                // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
+                // 4.9 which does not match the Mockito import.
+                CoreOptions.junitBundles(),
+
+                /*
+                 * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
+                 * java.lang.LinkageError: loader constraint violation in interface itable initialization:
+                 * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
+                 * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
+                 * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
+                 * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
+                 * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
+                 * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
+                 * proxy/Callback used in the signature
+                 *
+                 * So we disable the bootdelegation.
+                 */
+                frameworkProperty("felix.bootdelegation.implicit").value("false")
+        );
+    }
+
+
+    @Before
+    public void commonSetUp() {
+        osgiHelper = new OSGiHelper(bc);
+        ipojoHelper = new IPOJOHelper(bc);
+
+        // Dump OSGi Framework information
+        String vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VENDOR);
+        if (vendor == null) {
+            vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
+        }
+        String version = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VERSION);
+        System.out.println("OSGi Framework : " + vendor + " - " + version);
+    }
+
+    @After
+    public void commonTearDown() {
+        ipojoHelper.dispose();
+        osgiHelper.dispose();
+    }
+
+    public BundleContext getContext() {
+        return bc;
+    }
+
+    public static ServiceContext getServiceContext(ComponentInstance ci) {
+        if (ci instanceof CompositeManager) {
+            return ((CompositeManager) ci).getServiceContext();
+        } else {
+            throw new RuntimeException("Cannot get the service context from a non composite instance");
+        }
+    }
+
+    public CompositeOption ipojoBundles() {
+        return new DefaultCompositeOption(
+                mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
+                mavenBundle("org.apache.felix", "org.apache.felix.ipojo.composite").versionAsInProject(),
+                mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
+                // configuration admin
+                mavenBundle("org.apache.felix",  "org.apache.felix.configadmin").versionAsInProject()
+        );
+    }
+
+    public Option testedBundle() throws MalformedURLException {
+        File out = new File("target/tested/bundle.jar");
+        if (out.exists()) {
+            return bundle(out.toURI().toURL().toExternalForm());
+        }
+
+        TinyBundle tested = TinyBundles.bundle();
+
+        // We look inside target/classes to find the class and resources
+        File classes = new File("target/classes");
+        Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
+        List<File> services = new ArrayList<File>();
+        for (File file : files) {
+            if (file.isDirectory()) {
+                // By convention we export of .services and .service package
+                if (file.getName().endsWith("services")  || file.getName().endsWith("service")) {
+                    services.add(file);
+                }
+            } else {
+                // We need to compute the path
+                String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+                tested.add(path, file.toURI().toURL());
+                System.out.println(file.getName() + " added to " + path);
+            }
+        }
+
+        // Export the inherited package, components and strategies
+        String export = "";
+        for (File file : services) {
+            if (export.length() > 0) { export += ", "; }
+            String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+            String packageName = path.replace('/', '.');
+            export += packageName;
+        }
+
+        System.out.println("Exported packages : " + export);
+
+        InputStream inputStream = tested
+                .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
+                .set(Constants.IMPORT_PACKAGE, "*")
+                .set(Constants.EXPORT_PACKAGE, export)
+                .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));
+
+        try {
+            org.apache.commons.io.FileUtils.copyInputStreamToFile(inputStream, out);
+            return bundle(out.toURI().toURL().toExternalForm());
+        } catch (MalformedURLException e) {
+            throw new RuntimeException("Cannot compute the url of the manipulated bundle");
+        } catch (IOException e) {
+            throw new RuntimeException("Cannot write of the manipulated bundle");
+        }
+    }
+
+    public void assertContains(String s, String[] arrays, String object) {
+        for (String suspect : arrays) {
+            if (object.equals(suspect)) {
+                return;
+            }
+        }
+        fail("Assertion failed : " + s);
+    }
+
+
+}
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instance/TestInstanceScope.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instance/TestInstanceScope.java
new file mode 100644
index 0000000..9a3ce08
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instance/TestInstanceScope.java
@@ -0,0 +1,86 @@
+package org.apache.felix.ipojo.runtime.core.instance;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.ServiceContext;
+import org.apache.felix.ipojo.architecture.Architecture;
+import org.apache.felix.ipojo.composite.CompositeFactory;
+import org.apache.felix.ipojo.runtime.core.Common;
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.apache.felix.ipojo.runtime.core.services.Service;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+
+import java.util.Properties;
+
+import static org.junit.Assert.*;
+
+public class TestInstanceScope extends Common {
+
+    CompositeFactory factory;
+    ComponentInstance instance;
+
+    @Before
+    public void setUp() {
+        factory = (CompositeFactory) ipojoHelper.getFactory("SCOPE-scope");
+        assertNotNull("Factory", factory);
+        try {
+            instance = factory.createComponentInstance(null);
+        } catch (Exception e) {
+            fail("Fail instantiation : " + e.getMessage());
+        }
+
+
+    }
+
+    @After
+    public void tearDown() {
+        instance.dispose();
+        instance = null;
+    }
+
+    @Test
+    public void testScope() {
+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance.getInstanceName());
+        assertNotNull("Check architecture availability", ref);
+        Architecture arch = (Architecture) getContext().getService(ref);
+        assertTrue("Validity", arch.getInstanceDescription().getState() == ComponentInstance.VALID);
+
+        // Get internal service
+        ServiceContext sc = getServiceContext(instance);
+        ServiceReference ref2 = ipojoHelper.getServiceReference(sc, CheckService.class.getName(), null);
+        assertNotNull("Check CheckService availability", ref2);
+        CheckService svc = (CheckService) sc.getService(ref2);
+        Properties props = svc.getProps();
+        assertEquals("Check props - 1", 1, ((Integer) props.get("1")).intValue());
+        assertEquals("Check props - 2", 2, ((Integer) props.get("2")).intValue());
+        assertEquals("Check props - 3", 3, ((Integer) props.get("3")).intValue());
+
+    }
+
+    @Test
+    public void testGlobalUnavailability() {
+        ServiceReference ref2 = osgiHelper.getServiceReference(Service.class.getName(), null);
+        assertNull("Check Service unavailability", ref2);
+    }
+
+    @Test
+    public void testScopeUnvailability() {
+        CompositeFactory factory2 = (CompositeFactory) ipojoHelper.getFactory("SCOPE-badscope");
+        assertNotNull("Factory", factory2);
+        ComponentInstance instance2 = null;
+        try {
+            instance2 = factory2.createComponentInstance(null);
+        } catch (Exception e) {
+            fail("Fail instantiation : " + e.getMessage());
+        }
+        //System.out.println(instance2.getInstanceDescription().getDescription());
+
+        assertEquals("Check invalidity", ComponentInstance.INVALID, instance2.getState());
+        instance2.dispose();
+
+    }
+
+
+}
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instance/TestSimpleInstance.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instance/TestSimpleInstance.java
new file mode 100644
index 0000000..b1f0ee0
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instance/TestSimpleInstance.java
@@ -0,0 +1,279 @@
+/* 

+ * 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.runtime.core.instance;

+

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

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

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

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

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

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

+import org.apache.felix.ipojo.composite.CompositeInstanceDescription;

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static junit.framework.Assert.assertEquals;

+import static org.junit.Assert.*;

+

+public class TestSimpleInstance extends Common {

+

+    private ComponentFactory fooFactory1, fooFactory2;

+    private ComponentFactory compoFactory;

+    private ComponentInstance empty;

+

+    @Before

+    public void setUp() {

+        fooFactory1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooProviderType-1");

+        fooFactory2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooProviderType-Dyn2");

+        compoFactory = (ComponentFactory) ipojoHelper.getFactory("composite.inst.1");

+        Factory fact = ipojoHelper.getFactory("composite.empty");

+        Properties props = new Properties();

+        props.put("instance.name", "empty-X");

+        try {

+            empty = fact.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot create the empty composite : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        empty.dispose();

+        empty = null;

+    }

+

+    @Test

+    public void testCreation() {

+        Properties props = new Properties();

+        props.put("instance.name", "under-A");

+        ComponentInstance under = null;

+        try {

+            under = compoFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            e.printStackTrace();

+            fail("Cannot instantiate under from " + compoFactory.getName() + " -> " + e.getMessage());

+        }

+

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

+        under.dispose();

+    }

+

+    @Test

+    public void testServiceAvailability() {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = compoFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        ServiceContext sc = getServiceContext(under);

+

+        assertNotNull("Check service availability", sc.getServiceReference(FooService.class.getName()));

+        assertEquals("Check service provider", ipojoHelper.getServiceReferences(sc, FooService.class.getName(), null).length,

+                2);

+

+        under.dispose();

+    }

+

+    @Test

+    public void testCreationLevel2() {

+        ServiceContext sc = getServiceContext(empty);

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = compoFactory.createComponentInstance(props, sc);

+        } catch (Exception e) {

+            e.printStackTrace();

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        under.dispose();

+    }

+

+    @Test

+    public void testServiceAvailabilityLevel2() {

+        ServiceContext sc = getServiceContext(empty);

+        Properties props = new Properties();

+        props.put("instance.name", "under-X");

+        ComponentInstance under = null;

+        try {

+            under = compoFactory.createComponentInstance(props, sc);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        ServiceContext sc2 = getServiceContext(under);

+

+        assertNotNull("Check service availability", sc2.getServiceReference(FooService.class.getName()));

+        assertEquals("Check service providers", ipojoHelper.getServiceReferences(sc2, FooService.class.getName(),

+                null).length, 2);

+

+        under.dispose();

+    }

+

+    @Test

+    public void testFactoryManagement() {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = compoFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+

+        fooFactory1.stop();

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

+

+        fooFactory1.start();

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

+

+        fooFactory2.stop();

+        assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);

+

+        fooFactory2.start();

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

+

+        under.dispose();

+        fooFactory1.start();

+        fooFactory2.start();

+    }

+

+    @Test

+    public void testFactoryManagementLevel2() {

+        ServiceContext sc = getServiceContext(empty);

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = compoFactory.createComponentInstance(props, sc);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+

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

+

+        fooFactory1.stop();

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

+

+        fooFactory1.start();

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

+

+        fooFactory2.stop();

+        assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);

+

+        fooFactory2.start();

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

+

+        under.dispose();

+        fooFactory1.start();

+        fooFactory2.start();

+    }

+

+    public void atestArchitecture() { // TODO fix and reactivate the method.

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = compoFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

+        ServiceReference ref = osgiHelper.getServiceReference(Architecture.class.getName(),

+                "(architecture.instance=under)");

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

+        Architecture arch = (Architecture) getContext().getService(ref);

+        CompositeInstanceDescription id = (CompositeInstanceDescription) arch.getInstanceDescription();

+

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

+        InstanceDescription[] contained = id.getContainedInstances();

+        assertEquals("Check contained instances count (" + contained.length + ")", contained.length, 1);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

+

+        ComponentFactory fact1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-1");

+        ComponentFactory fact2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-2");

+        ComponentFactory fact3 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-3");

+

+        fact1.stop();

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

+        ref = osgiHelper.getServiceReference(Architecture.class.getName(), "(architecture.instance=under)");

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

+        arch = (Architecture) getContext().getService(ref);

+        //id = arch.getInstanceDescription();

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

+        contained = id.getContainedInstances();

+        assertEquals("Check contained instances count", contained.length, 1);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

+

+        fact2.stop();

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

+        ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");

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

+        arch = (Architecture) getContext().getService(ref);

+        //id = arch.getInstanceDescription();

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

+        contained = id.getContainedInstances();

+        assertEquals("Check contained instances count", contained.length, 1);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

+

+        fact3.stop();

+        assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);

+        ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");

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

+        arch = (Architecture) getContext().getService(ref);

+        //id = arch.getInstanceDescription();

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

+        contained = id.getContainedInstances();

+        assertEquals("Check contained instances count", contained.length, 0);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

+

+        fact1.start();

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

+        ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");

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

+        arch = (Architecture) getContext().getService(ref);

+        //id = arch.getInstanceDescription();

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

+        contained = id.getContainedInstances();

+        assertEquals("Check contained instances count", contained.length, 1);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

+

+        under.dispose();

+        fact2.start();

+        fact3.start();

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestConfigurableInstantiation.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestConfigurableInstantiation.java
new file mode 100644
index 0000000..b55d8f1
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestConfigurableInstantiation.java
@@ -0,0 +1,112 @@
+/* 

+ * 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.runtime.core.instantiator;

+

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestConfigurableInstantiation extends Common {

+

+    private ComponentFactory acceptF;

+    private ComponentFactory refuse1F;

+    private ComponentFactory refuse2F;

+

+    @Before

+    public void setUp() {

+        acceptF = (ComponentFactory) ipojoHelper.getFactory("composite.bar.5-accept");

+        refuse1F = (ComponentFactory) ipojoHelper.getFactory("composite.bar.5-refuse1");

+        refuse2F = (ComponentFactory) ipojoHelper.getFactory("composite.bar.5-refuse2");

+

+    }

+

+    @After

+    public void tearDown() {

+    }

+

+    @Test

+    public void testAccept() {

+        Properties props = new Properties();

+        props.put("instance.name", "under-A");

+        ComponentInstance under = null;

+        try {

+            under = acceptF.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

+

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

+        ServiceContext sc = getServiceContext(under);

+        ServiceReference ref = sc.getServiceReference(FooService.class.getName());

+        assertNotNull("Check refs not null", ref);

+        FooService foo = (FooService) sc.getService(ref);

+        Properties p = foo.fooProps();

+        boolean b = ((Boolean) p.get("boolProp")).booleanValue();

+        String s = (String) p.get("strProp");

+        int i = ((Integer) p.get("intProp")).intValue();

+        assertTrue("Test boolean", b);

+        assertEquals("Test string", s, "foo");

+        //TODO See why it fails...

+        //assertEquals("Test int", i, 5); // The code fix to 5.

+        under.dispose();

+    }

+

+    @Test

+    public void testRefuse1() {

+        Properties props = new Properties();

+        props.put("instance.name", "under-ref1");

+        ComponentInstance under = null;

+        try {

+            under = refuse1F.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

+

+        assertTrue("Check that under is not valid", under.getState() == ComponentInstance.INVALID);

+

+        under.dispose();

+    }

+

+    @Test

+    public void testRefuse2() {

+        Properties props = new Properties();

+        props.put("instance.name", "under-ref2");

+        ComponentInstance under = null;

+        try {

+            under = refuse2F.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

+

+        assertTrue("Check that under is not valid", under.getState() == ComponentInstance.INVALID);

+

+        under.dispose();

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestConfiguration.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestConfiguration.java
new file mode 100644
index 0000000..4e757cb
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestConfiguration.java
@@ -0,0 +1,97 @@
+/*

+ * 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.runtime.core.instantiator;

+

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.InvalidSyntaxException;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestConfiguration extends Common {

+

+    private ComponentFactory compositeFactory;

+

+    @Before

+    public void setUp() {

+        compositeFactory = (ComponentFactory) ipojoHelper.getFactory("CONF-MySuperComposite");

+    }

+

+    @After

+    public void tearDown() {

+

+    }

+

+    @Test

+    public void testDefaultInstantiation() throws InvalidSyntaxException {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = compositeFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            e.printStackTrace();

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        ServiceContext sc = getServiceContext(under);

+        ServiceReference[] refs = sc.getServiceReferences(FooService.class.getName(), null);

+        assertEquals(2, refs.length);

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

+            assertEquals(3, ((Integer) refs[i].getProperty("int")).intValue());

+            assertEquals("foo", (String) refs[i].getProperty("string"));

+        }

+        under.dispose();

+    }

+

+    @Test

+    public void testConfiguredInstantiation() throws InvalidSyntaxException {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        props.put("string", "bar");

+        props.put("int", "25");

+        ComponentInstance under = null;

+        try {

+            under = compositeFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            e.printStackTrace();

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        ServiceContext sc = getServiceContext(under);

+        ServiceReference[] refs = sc.getServiceReferences(FooService.class.getName(), null);

+        assertEquals(2, refs.length);

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

+            assertEquals(25, ((Integer) refs[i].getProperty("int")).intValue());

+            assertEquals("bar", (String) refs[i].getProperty("string"));

+        }

+        under.dispose();

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestMultipleInstantiation.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestMultipleInstantiation.java
new file mode 100644
index 0000000..be3f4fe
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestMultipleInstantiation.java
@@ -0,0 +1,287 @@
+/* 

+ * 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.runtime.core.instantiator;

+

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

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

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

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

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

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

+import org.apache.felix.ipojo.composite.CompositeInstanceDescription;

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.BarService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestMultipleInstantiation extends Common {

+

+    private ComponentFactory bar2Factory;

+    private ComponentInstance empty;

+

+    @Before

+    public void setUp() {

+        bar2Factory = (ComponentFactory) ipojoHelper.getFactory("composite.bar.2");

+        Factory fact = ipojoHelper.getFactory("composite.empty");

+        Properties props = new Properties();

+        props.put("instance.name", "empty");

+        try {

+            empty = fact.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot create the empty composite : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        empty.dispose();

+        empty = null;

+    }

+

+    @Test

+    public void testCreation() {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar2Factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        under.dispose();

+    }

+

+    @Test

+    public void testServiceAvailability() {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar2Factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        ServiceContext sc = getServiceContext(under);

+        assertNotNull("Check service availability", sc.getServiceReference(BarService.class.getName()));

+        int count = ipojoHelper.getServiceReferences(sc, BarService.class.getName(), null).length;

+        assertEquals("Check service provider number : " + count, count, 3);

+

+        under.dispose();

+    }

+

+    @Test

+    public void testCreationLevel2() {

+        ServiceContext sc = getServiceContext(empty);

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar2Factory.createComponentInstance(props, sc);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        under.dispose();

+    }

+

+    @Test

+    public void testServiceAvailabilityLevel2() {

+        ServiceContext sc = getServiceContext(empty);

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar2Factory.createComponentInstance(props, sc);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        ServiceContext sc2 = getServiceContext(under);

+        assertNotNull("Check service availability", sc2.getServiceReference(BarService.class.getName()));

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc2, BarService.class.getName(), null).length, 3);

+

+        under.dispose();

+    }

+

+    @Test

+    public void testFactoryManagement() {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar2Factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

+        ServiceContext sc = getServiceContext(under);

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

+

+        ComponentFactory fact1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-1");

+        ComponentFactory fact2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-2");

+        ComponentFactory fact3 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-3");

+

+        fact1.stop();

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

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc, BarService.class.getName(), null).length, 2);

+

+        fact2.stop();

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

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc, BarService.class.getName(), null).length, 1);

+

+        fact3.stop();

+        assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc, BarService.class.getName(), null).length, 0);

+

+        fact1.start();

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc, BarService.class.getName(), null).length, 1);

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

+

+        under.dispose();

+        fact2.start();

+        fact3.start();

+    }

+

+    @Test

+    public void testFactoryManagementLevel2() {

+        ServiceContext sc = getServiceContext(empty);

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar2Factory.createComponentInstance(props, sc);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        ServiceContext sc2 = getServiceContext(under);

+

+        ComponentFactory fact1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-1");

+        ComponentFactory fact2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-2");

+        ComponentFactory fact3 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-3");

+

+        fact1.stop();

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

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc2, BarService.class.getName(), null).length, 2);

+

+        fact2.stop();

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

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc2, BarService.class.getName(), null).length, 1);

+

+        fact3.stop();

+        assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc2, BarService.class.getName(), null).length, 0);

+

+        fact1.start();

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

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc2, BarService.class.getName(), null).length, 1);

+

+        under.dispose();

+        fact2.start();

+        fact3.start();

+    }

+

+    @Test

+    public void testArchitecture() {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar2Factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");

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

+        Architecture arch = (Architecture) getContext().getService(ref);

+        CompositeInstanceDescription id = (CompositeInstanceDescription) arch.getInstanceDescription();

+

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

+        InstanceDescription[] contained = id.getContainedInstances();

+        assertEquals("Check contained instances count", contained.length, 3);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.2");

+

+        ComponentFactory fact1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-1");

+        ComponentFactory fact2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-2");

+        ComponentFactory fact3 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-3");

+

+        fact1.stop();

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

+        ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");

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

+        arch = (Architecture) getContext().getService(ref);

+        //id = arch.getInstanceDescription();

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

+        contained = id.getContainedInstances();

+        assertEquals("Check contained instances count", contained.length, 2);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.2");

+

+        fact2.stop();

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

+        ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");

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

+        arch = (Architecture) getContext().getService(ref);

+        //id = arch.getInstanceDescription();

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

+        contained = id.getContainedInstances();

+        assertEquals("Check contained instances count", contained.length, 1);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.2");

+

+        fact3.stop();

+        assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);

+        ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");

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

+        arch = (Architecture) getContext().getService(ref);

+        //id = arch.getInstanceDescription();

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

+        contained = id.getContainedInstances();

+        assertEquals("Check contained instances count", contained.length, 0);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.2");

+

+        fact1.start();

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

+        ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");

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

+        arch = (Architecture) getContext().getService(ref);

+        //id = arch.getInstanceDescription();

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

+        contained = id.getContainedInstances();

+        assertEquals("Check contained instances count", contained.length, 1);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.2");

+

+        getContext().ungetService(ref);

+        under.dispose();

+        fact2.start();

+        fact3.start();

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestOptionalInstantiation.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestOptionalInstantiation.java
new file mode 100644
index 0000000..4829107
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestOptionalInstantiation.java
@@ -0,0 +1,273 @@
+/* 

+ * 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.runtime.core.instantiator;

+

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

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

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

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

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

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

+import org.apache.felix.ipojo.composite.CompositeInstanceDescription;

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.BarService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestOptionalInstantiation extends Common {

+

+	private ComponentFactory bar1Factory;

+	private ComponentInstance empty;

+	

+	@Before

+    public void setUp() {

+		bar1Factory = (ComponentFactory) ipojoHelper.getFactory("composite.bar.3");

+		Factory fact = ipojoHelper.getFactory("composite.empty");

+		Properties props = new Properties();

+		props.put("instance.name","empty");

+		try {

+			empty = fact.createComponentInstance(props);

+		} catch(Exception e) {

+			fail("Cannot create the empty composite : " + e.getMessage());

+		}

+	}

+	

+	@After

+    public void tearDown() {

+		empty.dispose();

+		empty = null;

+	}

+	

+	@Test

+    public void testCreation() {

+		Properties props = new Properties();

+		props.put("instance.name","under");

+		ComponentInstance under = null;

+		try {

+			under = bar1Factory.createComponentInstance(props);

+		} catch(Exception e) {

+			fail("Cannot instantiate under : " + e.getMessage());

+		}

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

+		under.dispose();

+	}

+	

+	@Test public void testServiceAvailability() {

+		Properties props = new Properties();

+		props.put("instance.name","under");

+		ComponentInstance under = null;

+		try {

+			under = bar1Factory.createComponentInstance(props);

+		} catch(Exception e) {

+			fail("Cannot instantiate under : " + e.getMessage());

+		}	

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

+		ServiceContext sc = getServiceContext(under);

+		assertNotNull("Check service availability", sc.getServiceReference(BarService.class.getName()));

+		

+		under.dispose();

+	}

+	

+	@Test public void testCreationLevel2() {

+		ServiceContext sc = getServiceContext(empty);

+		Properties props = new Properties();

+		props.put("instance.name","under");

+		ComponentInstance under = null;

+		try {

+			under = bar1Factory.createComponentInstance(props, sc);

+		} catch(Exception e) {

+			fail("Cannot instantiate under : " + e.getMessage());

+		}

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

+		under.dispose();

+	}

+	

+	@Test public void testServiceAvailabilityLevel2() {

+		ServiceContext sc = getServiceContext(empty);

+		Properties props = new Properties();

+		props.put("instance.name","under");

+		ComponentInstance under = null;

+		try {

+			under = bar1Factory.createComponentInstance(props, sc);

+		} catch(Exception e) {

+			fail("Cannot instantiate under : " + e.getMessage());

+		}	

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

+		ServiceContext sc2 = getServiceContext(under);

+		assertNotNull("Check service availability", sc2.getServiceReference(BarService.class.getName()));

+		

+		under.dispose();

+	}

+	

+	@Test public void testFactoryManagement() {

+		Properties props = new Properties();

+		props.put("instance.name","under");

+		ComponentInstance under = null;

+		try {

+			under = bar1Factory.createComponentInstance(props);

+		} catch(Exception e) {

+			fail("Cannot instantiate under : " + e.getMessage());

+		}

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

+		

+		ComponentFactory fact1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-1");

+		ComponentFactory fact2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-2");

+		ComponentFactory fact3 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-3");

+		

+		fact1.stop();

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

+		

+		fact2.stop();

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

+		

+		fact3.stop();

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

+		ServiceContext sc = getServiceContext(under);

+		assertNull("Check that no Bar Service is available", sc.getServiceReference(BarService.class.getName()));

+		

+		fact1.start();

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

+		

+		under.dispose();

+		fact2.start();

+		fact3.start();

+	}

+	

+	@Test public void testFactoryManagementLevel2() {

+		ServiceContext sc = getServiceContext(empty);

+		Properties props = new Properties();

+		props.put("instance.name","under");

+		ComponentInstance under = null;

+		try {

+			under = bar1Factory.createComponentInstance(props, sc);

+		} catch(Exception e) {

+			fail("Cannot instantiate under : " + e.getMessage());

+		}

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

+		

+		ComponentFactory fact1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-1");

+		ComponentFactory fact2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-2");

+		ComponentFactory fact3 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-3");

+		

+		fact1.stop();

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

+		

+		fact2.stop();

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

+		

+		fact3.stop();

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

+		

+		fact1.start();

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

+		

+		under.dispose();

+		fact2.start();

+		fact3.start();

+	}

+	

+	@Test public void testArchitecture() {

+		Properties props = new Properties();

+		props.put("instance.name","under");

+		ComponentInstance under = null;

+		try {

+			under = bar1Factory.createComponentInstance(props);

+		} catch(Exception e) {

+			fail("Cannot instantiate under : " + e.getMessage());

+		}

+		

+		ServiceReference ref = ipojoHelper.getServiceReferenceByName( Architecture.class.getName(), "under");

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

+		Architecture arch = (Architecture) getContext().getService(ref);

+		assertNotNull("Check architecture", arch);

+        CompositeInstanceDescription id = (CompositeInstanceDescription) arch.getInstanceDescription();

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

+		InstanceDescription[] contained = id.getContainedInstances();

+		assertNotNull("Check contained not null", contained);

+		assertEquals("Check contained instances count ("+contained.length+") - 1", contained.length, 1);

+		assertEquals("Check instance name" , id.getName(), "under");

+		assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");

+		

+		ComponentFactory fact1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-1");

+		ComponentFactory fact2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-2");

+		ComponentFactory fact3 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-3");

+		

+		

+		fact1.stop();

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

+		ref = ipojoHelper.getServiceReferenceByName( Architecture.class.getName(), "under");

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

+		arch = (Architecture) getContext().getService(ref);

+		//id = arch.getInstanceDescription();

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

+		contained = id.getContainedInstances();

+		assertEquals("Check contained instances count", contained.length, 1);

+		assertEquals("Check instance name" , id.getName(), "under");

+		assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");

+		

+		fact2.stop();

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

+		ref = ipojoHelper.getServiceReferenceByName( Architecture.class.getName(), "under");

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

+		arch = (Architecture) getContext().getService(ref);

+		//id = arch.getInstanceDescription();

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

+		contained = id.getContainedInstances();

+		assertEquals("Check contained instances count", contained.length, 1);

+		assertEquals("Check instance name" , id.getName(), "under");

+		assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");

+

+		fact3.stop();

+		assertTrue("Check instance invalidity", under.getState() == ComponentInstance.VALID);

+		ref = ipojoHelper.getServiceReferenceByName( Architecture.class.getName(), "under");

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

+		arch = (Architecture) getContext().getService(ref);

+		//id = arch.getInstanceDescription();

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

+		contained = id.getContainedInstances();

+		assertEquals("Check contained instances count", contained.length, 0);

+		assertEquals("Check instance name" , id.getName(), "under");

+		assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");

+

+		fact1.start();

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

+		ref = ipojoHelper.getServiceReferenceByName( Architecture.class.getName(), "under");

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

+		arch = (Architecture) getContext().getService(ref);

+		//id = arch.getInstanceDescription();

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

+		contained = id.getContainedInstances();

+		assertEquals("Check contained instances count", contained.length, 1);

+		assertEquals("Check instance name" , id.getName(), "under");

+		assertEquals("Check component type name" , id.getComponentDescription().getName(), "composite.bar.3");

+

+		getContext().ungetService(ref);

+		under.dispose();

+		fact2.start();

+		fact3.start();

+	}

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestOptionalMultipleInstantiation.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestOptionalMultipleInstantiation.java
new file mode 100644
index 0000000..29eb2f6
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestOptionalMultipleInstantiation.java
@@ -0,0 +1,214 @@
+/* 

+ * 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.runtime.core.instantiator;

+

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

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.BarService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestOptionalMultipleInstantiation extends Common {

+

+    private ComponentFactory bar2Factory;

+    private ComponentInstance empty;

+

+    @Before

+    public void setUp() {

+        bar2Factory = (ComponentFactory) ipojoHelper.getFactory("composite.bar.4");

+        assertNotNull("Check bar2factory availability", bar2Factory);

+

+        Factory fact = ipojoHelper.getFactory("composite.empty");

+        Properties props = new Properties();

+        props.put("instance.name", "empty");

+        try {

+            empty = fact.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot create the empty composite : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        empty.dispose();

+        empty = null;

+    }

+

+    @Test

+    public void testCreation() {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar2Factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        under.dispose();

+    }

+

+    @Test

+    public void testServiceAvailability() {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar2Factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        ServiceContext sc = getServiceContext(under);

+        assertNotNull("Check service availability", sc.getServiceReference(BarService.class.getName()));

+        int count = ipojoHelper.getServiceReferences(sc, BarService.class.getName(), null).length;

+        assertEquals("Check service provider number : " + count, count, 3);

+

+        under.dispose();

+    }

+

+    @Test

+    public void testCreationLevel2() {

+        ServiceContext sc = getServiceContext(empty);

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar2Factory.createComponentInstance(props, sc);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        under.dispose();

+    }

+

+    @Test

+    public void testServiceAvailabilityLevel2() {

+        ServiceContext sc = getServiceContext(empty);

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar2Factory.createComponentInstance(props, sc);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        ServiceContext sc2 = getServiceContext(under);

+        assertNotNull("Check service availability", sc2.getServiceReference(BarService.class.getName()));

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc2,

+                BarService.class.getName(), null).length, 3);

+

+        under.dispose();

+    }

+

+    @Test

+    public void testFactoryManagement() {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar2Factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

+        ServiceContext sc = getServiceContext(under);

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

+

+        ComponentFactory fact1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-1");

+        ComponentFactory fact2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-2");

+        ComponentFactory fact3 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-3");

+

+        fact1.stop();

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

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc,

+                BarService.class.getName(), null).length, 2);

+

+        fact2.stop();

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

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc,

+                BarService.class.getName(), null).length, 1);

+

+        fact3.stop();

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

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc,

+                BarService.class.getName(), null).length, 0);

+

+        fact1.start();

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc,

+                BarService.class.getName(), null).length, 1);

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

+

+        under.dispose();

+        fact2.start();

+        fact3.start();

+    }

+

+    @Test

+    public void testFactoryManagementLevel2() {

+        ServiceContext sc = getServiceContext(empty);

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar2Factory.createComponentInstance(props, sc);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        ServiceContext sc2 = getServiceContext(under);

+

+        ComponentFactory fact1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-1");

+        ComponentFactory fact2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-2");

+        ComponentFactory fact3 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-3");

+

+        fact1.stop();

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

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc2,

+                BarService.class.getName(), null).length, 2);

+

+        fact2.stop();

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

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc2,

+                BarService.class.getName(), null).length, 1);

+

+        fact3.stop();

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

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc2,

+                BarService.class.getName(), null).length, 0);

+

+        fact1.start();

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

+        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc2,

+                BarService.class.getName(), null).length, 1);

+

+        under.dispose();

+        fact2.start();

+        fact3.start();

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestSimpleInstantiation.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestSimpleInstantiation.java
new file mode 100644
index 0000000..ff18fb3
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-instance-test/src/test/java/org/apache/felix/ipojo/runtime/core/instantiator/TestSimpleInstantiation.java
@@ -0,0 +1,274 @@
+/* 

+ * 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.runtime.core.instantiator;

+

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

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

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

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

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

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

+import org.apache.felix.ipojo.composite.CompositeInstanceDescription;

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.services.BarService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestSimpleInstantiation extends Common {

+

+    private ComponentFactory bar1Factory;

+    private ComponentInstance empty;

+

+    @Before

+    public void setUp() {

+        bar1Factory = (ComponentFactory) ipojoHelper.getFactory("composite.bar.1");

+        Factory fact = ipojoHelper.getFactory("composite.empty");

+        Properties props = new Properties();

+        props.put("instance.name", "empty-X");

+        try {

+            empty = fact.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot create the empty composite : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        empty.dispose();

+        empty = null;

+    }

+

+    @Test

+    public void testCreation() {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar1Factory.createComponentInstance(props);

+        } catch (Exception e) {

+            e.printStackTrace();

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        under.dispose();

+    }

+

+    @Test

+    public void testServiceAvailability() {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar1Factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        ServiceContext sc = getServiceContext(under);

+        assertNotNull("Check service availability", sc.getServiceReference(BarService.class.getName()));

+

+        under.dispose();

+    }

+

+    @Test

+    public void testCreationLevel2() {

+        ServiceContext sc = getServiceContext(empty);

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar1Factory.createComponentInstance(props, sc);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        under.dispose();

+    }

+

+    @Test

+    public void testServiceAvailabilityLevel2() {

+        ServiceContext sc = getServiceContext(empty);

+        Properties props = new Properties();

+        props.put("instance.name", "under-X");

+        ComponentInstance under = null;

+        try {

+            under = bar1Factory.createComponentInstance(props, sc);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+        ServiceContext sc2 = getServiceContext(under);

+        assertNotNull("Check service availability", sc2.getServiceReference(BarService.class.getName()));

+

+        under.dispose();

+    }

+

+    @Test

+    public void testFactoryManagement() {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar1Factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+

+        ComponentFactory fact1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-1");

+        ComponentFactory fact2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-2");

+        ComponentFactory fact3 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-3");

+

+

+        fact1.stop();

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

+

+        fact2.stop();

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

+

+        fact3.stop();

+        assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);

+

+        fact1.start();

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

+

+        under.dispose();

+        fact2.start();

+        fact3.start();

+    }

+

+    @Test

+    public void testFactoryManagementLevel2() {

+        ServiceContext sc = getServiceContext(empty);

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar1Factory.createComponentInstance(props, sc);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

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

+

+        ComponentFactory fact1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-1");

+        ComponentFactory fact2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-2");

+        ComponentFactory fact3 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-3");

+

+        fact1.stop();

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

+

+        fact2.stop();

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

+

+        fact3.stop();

+        assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);

+

+        fact1.start();

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

+

+        under.dispose();

+        fact2.start();

+        fact3.start();

+    }

+

+    @Test

+    public void testArchitecture() {

+        Properties props = new Properties();

+        props.put("instance.name", "under");

+        ComponentInstance under = null;

+        try {

+            under = bar1Factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate under : " + e.getMessage());

+        }

+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");

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

+        Architecture arch = (Architecture) getContext().getService(ref);

+        CompositeInstanceDescription id = (CompositeInstanceDescription) arch.getInstanceDescription();

+

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

+        InstanceDescription[] contained = id.getContainedInstances();

+        assertEquals("Check contained instances count", contained.length, 1);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

+

+        ComponentFactory fact1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-1");

+        ComponentFactory fact2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-2");

+        ComponentFactory fact3 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-3");

+

+        fact1.stop();

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

+        ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");

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

+        arch = (Architecture) getContext().getService(ref);

+        //id = arch.getInstanceDescription();

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

+        contained = id.getContainedInstances();

+        assertEquals("Check contained instances count", contained.length, 1);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

+

+        fact2.stop();

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

+        ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");

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

+        arch = (Architecture) getContext().getService(ref);

+        //id = arch.getInstanceDescription();

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

+        contained = id.getContainedInstances();

+        assertEquals("Check contained instances count", contained.length, 1);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

+

+        fact3.stop();

+        assertTrue("Check instance invalidity", under.getState() == ComponentInstance.INVALID);

+        ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");

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

+        arch = (Architecture) getContext().getService(ref);

+        //id = arch.getInstanceDescription();

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

+        contained = id.getContainedInstances();

+        assertEquals("Check contained instances count", contained.length, 0);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

+

+        fact1.start();

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

+        ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "under");

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

+        arch = (Architecture) getContext().getService(ref);

+        //id = arch.getInstanceDescription();

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

+        contained = id.getContainedInstances();

+        assertEquals("Check contained instances count", contained.length, 1);

+        assertEquals("Check instance name", id.getName(), "under");

+        assertEquals("Check component type name", id.getComponentDescription().getName(), "composite.bar.1");

+

+        under.dispose();

+        fact2.start();

+        fact3.start();

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/pom.xml b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/pom.xml
new file mode 100644
index 0000000..643df52
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/pom.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.ipojo.runtime.composite-it</artifactId>
+        <version>1.9.0-SNAPSHOT</version>
+        <relativePath>../../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.felix</groupId>
+    <artifactId>ipojo-composite-runtime-test</artifactId>
+
+    <name>${project.artifactId}</name>
+    
+</project>
\ No newline at end of file
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Baz2CheckProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Baz2CheckProvider.java
new file mode 100644
index 0000000..7e5d145
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Baz2CheckProvider.java
@@ -0,0 +1,81 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.BazService;

+import org.apache.felix.ipojo.runtime.core.services.CheckService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+public class Baz2CheckProvider implements CheckService {

+	

+	BazService fs;

+	

+	int simpleB = 0;

+	int objectB = 0;

+	int refB = 0;

+	int simpleU = 0;

+	int objectU = 0;

+	int refU = 0;

+

+	public boolean check() {

+		return fs.foo();

+	}

+

+	public Properties getProps() {

+		Properties props = new Properties();

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

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

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

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

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

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

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

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

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

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

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

+		if(fs.getObject() != null) { props.put("object", fs.getObject()); }

+		

+		return props;

+	}

+	

+	private void voidBind() {

+		simpleB++;

+	}

+	private void voidUnbind() {

+		simpleU++;

+	}

+	

+	protected void objectBind(Object o) {

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

+	}

+	protected void objectUnbind(Object o) {

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

+	}

+	

+	public void refBind(ServiceReference sr) {

+		if(sr != null) { refB++; }

+	}

+	public void refUnbind(ServiceReference sr) {

+		if(sr != null) { refU++; }

+	}

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/BazProviderType1.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/BazProviderType1.java
new file mode 100644
index 0000000..5ac64d3
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/BazProviderType1.java
@@ -0,0 +1,51 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.BazService;

+

+import java.util.Properties;

+

+public class BazProviderType1 implements BazService {

+	

+	private int m_bar;

+	private String m_foo;

+

+	public boolean foo() {

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("bar", new Integer(m_bar));

+		p.put("foo", m_foo);

+		return p;

+	}

+	

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckProviderParentClass.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckProviderParentClass.java
new file mode 100644
index 0000000..7d18712
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckProviderParentClass.java
@@ -0,0 +1,51 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.ServiceReference;

+

+public abstract class CheckProviderParentClass {

+    

+    int simpleU = 0;

+    int objectU = 0;

+    int refU = 0;

+    int bothU = 0;

+    

+    

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

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

+    }

+    

+    public void refUnbind(ServiceReference sr) {

+        if(sr != null) { refU++; }

+    }

+    

+    public void objectUnbind(FooService o) {

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

+        else {

+            System.err.println("Unbind null : " + o);

+        }

+    }

+    

+    public void voidUnbind() {

+        simpleU++;

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java
new file mode 100644
index 0000000..eee88a2
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java
@@ -0,0 +1,83 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.CheckService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+public class CheckServiceProvider extends CheckProviderParentClass implements CheckService {

+    

+	FooService fs;

+	

+	int simpleB = 0;

+	int objectB = 0;

+	int refB = 0;

+	int bothB = 0;

+

+	public boolean check() {

+		return fs.foo();

+	}

+

+	public Properties getProps() {

+		Properties props = new Properties();

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

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

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

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

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

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

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

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

+		if (fs != null) {

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

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

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

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

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

+		    if(fs.getObject() != null) { props.put("object", fs.getObject()); }

+		}

+        props.put("static", CheckService.foo);

+        props.put("class", CheckService.class.getName());

+		return props;

+	}

+	

+	private void voidBind() {

+		simpleB++;

+	}

+	

+	protected void objectBind(FooService o) {

+	    if (o == null) {

+	        System.err.println("Bind receive null !!! ");

+	        return;

+	    }

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

+	}

+	

+	public void refBind(ServiceReference sr) {

+		if(sr != null) { refB++; }

+	}

+	

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

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

+	}

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java
new file mode 100644
index 0000000..03016d3
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java
@@ -0,0 +1,54 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.BarService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+

+import java.util.Properties;

+

+public class FooBarProviderType1 implements FooService, BarService {

+

+	public boolean foo() {

+		return true;

+	}

+

+	public Properties fooProps() {

+		return new Properties();

+	}

+

+	public boolean bar() {

+		return true;

+	}

+

+	public Properties getProps() {

+		return new Properties();

+	}

+

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
new file mode 100644
index 0000000..b9eda2d
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
@@ -0,0 +1,92 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.BundleContext;

+

+import java.util.Properties;

+

+public class FooProviderType1 implements FooService {

+	

+	private int m_bar;

+	private String m_foo;

+    

+    private BundleContext m_context;

+    

+    private static FooProviderType1 singleton;

+    private static int count = 0;

+    

+    public FooProviderType1(BundleContext bc) {

+        if (bc ==null) {

+            throw new RuntimeException("Injected bundle context null");

+        }

+        m_context = bc;

+    }

+

+	public boolean foo() {

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("bar", new Integer(m_bar));

+        if(m_foo != null) {

+            p.put("foo", m_foo);

+        }

+        p.put("context", m_context);

+        

+        p.put("count", new Integer(count));

+		return p;

+	}

+    

+	public void testException() throws Exception {

+        String a = "foobarbaz";

+	    throw new Exception("foo"+a);

+    }

+    

+    public void testTry() {

+            String a = "foo";

+            a.charAt(0);

+    }

+    

+    public void testTry2(String s) {

+            String a = "foo";

+            a.charAt(0);

+    }

+    

+    private void nexttry(String  s) {

+        try {

+            s += "foo";

+        } catch(RuntimeException e) {

+            

+        }

+    }

+    

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java
new file mode 100644
index 0000000..47f6ae5
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java
@@ -0,0 +1,63 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+

+import java.util.Properties;

+

+public class FooProviderTypeDyn implements FooService {

+	

+	private int intProp;	

+	private String strProp;

+	private String[] strAProp;

+	private int[] intAProp;

+	private boolean boolProp;

+

+	public boolean foo() {

+		intProp = 3;

+		boolProp = true;

+		if(strProp.equals("foo")) { strProp = "bar"; }

+		else { strProp = "foo"; }

+		strAProp = new String[] {"foo", "bar", "baz"};

+		intAProp = new int[] {3, 2, 1};

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("intProp", new Integer(intProp));

+		p.put("boolProp", new Boolean(boolProp));

+		p.put("strProp", strProp);

+		p.put("strAProp", strAProp);

+		p.put("intAProp", intAProp);

+		return p;

+	}

+	

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java
new file mode 100644
index 0000000..efec5f0
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java
@@ -0,0 +1,58 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+

+import java.util.Properties;

+

+public class FooProviderTypeDyn2 implements FooService {

+	

+	private int intProp = 2;

+	private boolean boolProp = true;

+	private String strProp = "foo";

+	private String[] strAProp = new String[] {"foo", "bar"};

+	private int[] intAProp = new int[] {1, 2, 3};

+

+	public boolean foo() {

+		intAProp = null;

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("intProp", new Integer(intProp));

+		p.put("boolProp", new Boolean(boolProp));

+		p.put("strProp", strProp);

+		p.put("strAProp", strAProp);

+		p.put("intAProp", intAProp);

+		return p;

+	}

+	

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java
new file mode 100644
index 0000000..c3ade01
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java
@@ -0,0 +1,222 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.Tata;

+

+import java.util.Properties;

+

+

+public class TataProvider implements Tata {

+    

+    int tata = 0;

+    int tataStr = 0;

+    int tataStrs = 0;

+    int tata_2 = 0;

+    int tata_3 = 0;

+    int tata1 = 0;

+    int tata1_1 = 0;

+    int tata5 = 0;

+    int tata5_1 = 0;

+    int tata5_2 = 0;

+    int tataBoolean = 0;

+    int tataBooleans = 0;

+    int tataByte = 0;

+    int tataBytes = 0;

+    private int add;

+    private int tataShorts;

+    private int tataShort;

+    private int tataLongs;

+    private int tataLong;

+    private int tataInts;

+    private int tataInt;

+    private int tataFloat;

+    private int tataFloats;

+    private int tataDoubles;

+    private int tataDouble;

+    private int tataChars;

+    private int tataChar;

+    

+    public Properties getPropsTata() {

+        Properties props = new Properties();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+        return props;

+    }

+

+    public void tata() {

+        tata++;

+    }

+

+    public String tataStr() {

+        tataStr++;

+        return "Tata";

+    }

+

+    public String[] tataStrs() {

+        tataStrs++;

+        return new String[] {"T", "A", "T", "A"};

+    }

+

+    public void tata(int i, int j) {

+        tata_2++;        

+    }

+

+    public void tata(String s) {

+        tata_3++;

+    }

+

+    public String tata1(String a) {

+        tata1++;

+       return a;

+    }

+

+    public String tata1(char[] a) {

+        tata1_1++;

+        String s = new String(a);

+        return s;

+    }

+

+    public String tata5(String a, int i) {

+       tata5++;

+       return a+i;

+    }

+

+    public String tata5(String[] a, int i) {

+       tata5_1++;

+       return ""+a.length + i;

+    }

+

+    public String tata5(String a, int[] i) {

+        tata5_2++;

+        return a + i.length;

+    }

+

+    public boolean tataBoolean(boolean b) {

+        tataBoolean++;

+        return b;

+    }

+

+    public boolean[] tataBooleans(boolean[] b) {

+        tataBooleans++;

+       return b;

+    }

+

+    public byte tataByte(byte b) {

+        tataByte++;

+        return b;

+    }

+

+    public byte[] tataBytes(byte[] b) {

+        tataBytes++;

+        return b;

+    }

+

+    public char tataChar(char c) {

+       tataChar++;

+       return c;

+    }

+

+    public char[] tataChars(char[] c) {

+        tataChars++;

+        return c;

+    }

+

+    public double tataDouble(double d) {

+        tataDouble++;

+        return d;

+    }

+

+    public double[] tataDoubles(double[] d) {

+        tataDoubles++;

+        return d;

+    }

+

+    public float tataFloat(float f) {

+        tataFloat++;

+        return f;

+    }

+

+    public float[] tataFloats(float[] f) {

+        tataFloats++;

+        return f;

+    }

+

+    public int tataInt(int i) {

+        tataInt++;

+        return i;

+    }

+

+    public int[] tataInts(int[] its) {

+        tataInts++;

+        return its;

+    }

+

+    public long tataLong(long l) {

+        tataLong++;

+        return l;

+    }

+

+    public long[] tataLongs(long[] l) {

+        tataLongs++;

+        return l;

+    }

+

+    public short tataShort(short s) {

+        tataShort++;

+        return s;

+    }

+

+    public short[] tataShorts(short[] s) {

+        tataShorts++;

+        return s;

+    }

+

+    public long add(int i, int j, int k) {

+        add++;

+        return i + j + k;

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java
new file mode 100644
index 0000000..d230c2d
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java
@@ -0,0 +1,73 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.Toto;

+

+import java.util.Properties;

+

+

+public class TotoProvider implements Toto {

+    

+    private int i = 0;

+    public static int toto = 0;

+    public static int toto_2 = 0;

+    public static int toto_3 = 0;

+    public static int toto_4 = 0;

+    public static int toto1 = 0;

+    

+    public int count() {

+        return i;

+    }

+    

+    public void toto() {

+        toto++;        

+    }

+

+    public void toto(int i, int j) {

+        toto_2++;

+    }

+

+    public String toto(String a) {

+        toto_3++;

+        return a;

+    }

+

+    public String toto(String[] a) {

+        toto_4++;

+        return "toto";

+    }

+

+    public void toto1(String j) {

+        i++;

+        toto1++;        

+    }

+

+    public Properties getProps() {

+        Properties props = new Properties();

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

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

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

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

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

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

+        return props;

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java
new file mode 100644
index 0000000..f90460c
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java
@@ -0,0 +1,81 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.Toto;

+

+import java.util.Properties;

+

+

+public class TotoProviderGlue implements Toto {

+    

+    Toto m_toto;

+    

+    private int i = 0;

+    public static int toto = 0;

+    public static int toto_2 = 0;

+    public static int toto_3 = 0;

+    public static int toto_4 = 0;

+    public static int toto1 = 0;

+    

+    public int count() {

+        return i;

+    }

+    

+    public void toto() {

+        toto++;

+        m_toto.toto();

+    }

+

+    public void toto(int i, int j) {

+        toto_2++;

+        m_toto.toto(i, j);

+    }

+

+    public String toto(String a) {

+        toto_3++;

+        return a;

+    }

+

+    public String toto(String[] a) {

+        toto_4++;

+        return "toto";

+    }

+

+    public void toto1(String j) {

+        i++;

+        toto1++;

+        m_toto.toto1(j);

+    }

+

+    public Properties getProps() {

+        Properties props = new Properties();

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

+        props.put("gtoto", new Integer(toto));

+        props.put("gtoto_2", new Integer(toto_2));

+        props.put("gtoto_3", new Integer(toto_3));

+        props.put("gtoto_4", new Integer(toto_4));

+        props.put("gtoto1", new Integer(toto1));

+        props.put("glue", "glue");

+        Properties p2 = m_toto.getProps();

+        props.putAll(p2);

+        return props;

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java
new file mode 100644
index 0000000..e31a24a
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java
@@ -0,0 +1,25 @@
+/* 

+ * 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.runtime.core.services.A123;

+

+public interface CheckService2 {

+	

+	public boolean check();

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java
new file mode 100644
index 0000000..f704138
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java
@@ -0,0 +1,29 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface BarService {

+	

+	public boolean bar();

+	

+	public Properties getProps();

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java
new file mode 100644
index 0000000..a4c4854
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java
@@ -0,0 +1,39 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface BazService {

+

+	boolean foo();

+	

+	Properties fooProps();

+	

+	Boolean getObject();

+	

+	boolean getBoolean();

+	

+	int getInt();

+	

+	long getLong();

+	

+	double getDouble();

+	

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
new file mode 100644
index 0000000..eca0faa
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
@@ -0,0 +1,31 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface CheckService {

+    

+    public static final String foo = "foo";

+	

+	public boolean check();

+	

+	public Properties getProps();

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
new file mode 100644
index 0000000..37c1a65
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
@@ -0,0 +1,39 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface FooService {

+

+	boolean foo();

+	

+	Properties fooProps();

+	

+	Boolean getObject();

+	

+	boolean getBoolean();

+	

+	int getInt();

+	

+	long getLong();

+	

+	double getDouble();

+	

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java
new file mode 100644
index 0000000..ba526f5
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java
@@ -0,0 +1,62 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface Tata {

+    

+    public Properties getPropsTata();

+    

+    public void tata();

+    

+    public int tataInt(int i);

+    public long tataLong(long l);

+    public double tataDouble(double d);

+    public char tataChar(char c);

+    public boolean tataBoolean(boolean b);

+    public short tataShort(short s);

+    public float tataFloat(float f);

+    public byte tataByte(byte b);

+    

+    public int[] tataInts(int[] its);

+    public long[] tataLongs(long[] l);

+    public double[] tataDoubles(double[] d);

+    public char[] tataChars(char[] c);

+    public boolean[] tataBooleans(boolean[] b);

+    public short[] tataShorts(short[] s);

+    public float[] tataFloats(float[] f);

+    public byte[] tataBytes(byte[] b);

+    

+    public String tataStr();

+    public String[] tataStrs();

+    

+    public void tata(int i, int j);

+    public void tata(String s);

+    

+    public String tata1(String a);

+    public String tata1(char[] a);

+    

+    public String tata5(String a, int i);

+    public String tata5(String[] a, int i);

+    public String tata5(String a, int[] i);

+    

+    public long add(int i, int j, int k);

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java
new file mode 100644
index 0000000..19bd528
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java
@@ -0,0 +1,78 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface Tota {

+    

+    public static final String specification="specification { " +

+    		"requires { " +

+    		    "$specification=\"org.apache.felix.ipojo.test.composite.service.Toto\" " +

+    		    "$optional=\"true\" " +

+    		    "$aggregate=\"true\" " +

+    		    "$type=\"service\" " +

+    		"} }"; 

+    

+    public Properties getProps() throws UnsupportedOperationException;;

+    public Properties getPropsTata();

+    

+    public void tata();

+    

+    public int tataInt(int i);

+    public long tataLong(long l);

+    public double tataDouble(double d);

+    public char tataChar(char c);

+    public boolean tataBoolean(boolean b);

+    public short tataShort(short s);

+    public float tataFloat(float f);

+    public byte tataByte(byte b);

+    

+    public int[] tataInts(int[] its);

+    public long[] tataLongs(long[] l);

+    public double[] tataDoubles(double[] d);

+    public char[] tataChars(char[] c);

+    public boolean[] tataBooleans(boolean[] b);

+    public short[] tataShorts(short[] s);

+    public float[] tataFloats(float[] f);

+    public byte[] tataBytes(byte[] b);

+    

+    public String tataStr();

+    public String[] tataStrs();

+    

+    public void tata(int i, int j);

+    public void tata(String s);

+    

+    public String tata1(String a);

+    public String tata1(char[] a);

+    

+    public String tata5(String a, int i);

+    public String tata5(String[] a, int i);

+    public String tata5(String a, int[] i);

+    

+    public long add(int i, int j, int k);

+    

+    public void toto() throws UnsupportedOperationException;    

+    public void toto(int i, int j) throws UnsupportedOperationException;

+    public String toto(String a) throws UnsupportedOperationException;

+    

+    public void toto1(String j) throws UnsupportedOperationException;

+    

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java
new file mode 100644
index 0000000..8ed22ec
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java
@@ -0,0 +1,37 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface Toto {

+    

+    public Properties getProps();

+    

+    public void toto();    

+    public void toto(int i, int j);

+    public String toto(String a);

+    public String toto(String[] a);

+    

+    public void toto1(String j);

+    

+    public int count();

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/resources/metadata.xml b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/resources/metadata.xml
new file mode 100644
index 0000000..fc4b9de
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/main/resources/metadata.xml
@@ -0,0 +1,112 @@
+<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

+	    org.apache.felix.composite http://felix.apache.org/ipojo/schemas/SNAPSHOT/composite.xsd"

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

+	xmlns:comp="org.apache.felix.ipojo.composite">

+	<!-- Used component type -->

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"

+		name="COMPO-FooProviderType-1" architecture="true">

+		<provides />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"

+		name="COMPO-FooProviderType-2" architecture="true">

+		<provides>

+			<property name="int" type="int" value="2" />

+			<property name="long" type="long" value="40" />

+			<property name="string" type="java.lang.String" value="foo" />

+			<property name="strAProp" type="java.lang.String[]"

+				value="{foo, bar}" />

+			<property name="intAProp" type="int[]" value="{1,2,3}" />

+		</provides>

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderTypeDyn"

+		name="COMPO-FooProviderType-Dyn" architecture="true">

+		<provides>

+			<property name="int" field="intProp" value="2" />

+			<property name="boolean" field="boolProp" value="false" />

+			<property name="string" field="strProp" value="foo" />

+			<property name="strAProp" field="strAProp"

+				value="{foo, bar}" />

+			<property name="intAProp" field="intAProp" value="{ 1,2,3}" />

+		</provides>

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderTypeDyn2"

+		name="COMPO-FooProviderType-Dyn2" architecture="true">

+		<provides>

+			<property name="int" field="intProp" value="4" />

+			<property name="boolean" field="boolProp" />

+			<property name="string" field="strProp" />

+			<property name="strAProp" field="strAProp" />

+			<property name="intAProp" field="intAProp"

+				value="{1, 2,3 }" />

+		</provides>

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.CheckServiceProvider"

+		name="COMPO-SimpleCheckServiceProvider" architecture="true">

+		<requires field="fs" />

+		<provides />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"

+		name="COMPO-FooBarProviderType-1" architecture="true">

+		<provides />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"

+		name="COMPO-FooBarProviderType-2" architecture="true">

+		<provides

+			specifications="{org.apache.felix.ipojo.test.composite.service.FooService, org.apache.felix.ipojo.test.composite.service.BarService }" />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"

+		name="COMPO-FooBarProviderType-3" architecture="true">

+		<provides

+			specifications="{org.apache.felix.ipojo.test.composite.service.FooService}">

+			<property name="baz" type="java.lang.String" value="foo" />

+		</provides>

+		<provides

+			specifications="{org.apache.felix.ipojo.test.composite.service.BarService}">

+			<property name="baz" type="java.lang.String" value="bar" />

+		</provides>

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.BazProviderType1"

+		name="BazProviderType">

+		<provides />

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.TataProvider"

+		name="tata">

+		<provides />

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.TotoProvider"

+		name="toto" architecture="true">

+		<provides />

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.TotoProviderGlue"

+		name="totoglue">

+		<requires field="m_toto" scope="composite" />

+	</component>

+

+	<!--  Composite -->

+	<comp:composite name="composite.empty" architecture="true">

+	</comp:composite>

+

+	<component classname="org.apache.felix.ipojo.runtime.core.components.Baz2CheckProvider" name="Baz2CheckProvider" architecture="true">

+		<requires field="fs" scope="composite"/>

+		<provides/>

+	</component>

+

+</ipojo>

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
new file mode 100644
index 0000000..b242001
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
@@ -0,0 +1,225 @@
+package org.apache.felix.ipojo.runtime.core;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.ServiceContext;
+import org.apache.felix.ipojo.composite.CompositeManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.CompositeOption;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+import org.ops4j.pax.tinybundles.core.TinyBundle;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.ow2.chameleon.testing.helpers.IPOJOHelper;
+import org.ow2.chameleon.testing.helpers.OSGiHelper;
+import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static junit.framework.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.*;
+
+/**
+ * Bootstrap the test from this project
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class Common {
+
+    @Inject
+    protected
+    BundleContext bc;
+
+    protected OSGiHelper osgiHelper;
+    protected IPOJOHelper ipojoHelper;
+
+    protected boolean deployTestedBundle = true;
+
+    @Configuration
+    public Option[] config() throws IOException {
+        Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+        root.setLevel(Level.INFO);
+
+        if (deployTestedBundle) {
+            return options(
+                    cleanCaches(),
+                    ipojoBundles(),
+                    junitBundles(),
+                    testedBundle(),
+                    systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+            );
+        } else {
+            return options(
+                    cleanCaches(),
+                    ipojoBundles(),
+                    junitBundles(),
+                    systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+            );
+        }
+    }
+
+    public static Option junitAndMockitoBundles() {
+        return new DefaultCompositeOption(
+                // Repository required to load harmcrest (OSGi-fied version).
+                repository("http://repository.springsource.com/maven/bundles/external").id(
+                        "com.springsource.repository.bundles.external"),
+
+                // Mockito without Hamcrest and Objenesis
+                mavenBundle("org.mockito", "mockito-core", "1.9.5"),
+
+                // Hamcrest with a version matching the range expected by Mockito
+                mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
+
+                // Objenesis with a version matching the range expected by Mockito
+                wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
+                        .exports("*;version=1.2"),
+
+                // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
+                // 4.9 which does not match the Mockito import.
+                CoreOptions.junitBundles(),
+
+                /*
+                 * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
+                 * java.lang.LinkageError: loader constraint violation in interface itable initialization:
+                 * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
+                 * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
+                 * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
+                 * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
+                 * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
+                 * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
+                 * proxy/Callback used in the signature
+                 *
+                 * So we disable the bootdelegation.
+                 */
+                frameworkProperty("felix.bootdelegation.implicit").value("false")
+        );
+    }
+
+
+    @Before
+    public void commonSetUp() {
+        osgiHelper = new OSGiHelper(bc);
+        ipojoHelper = new IPOJOHelper(bc);
+
+        // Dump OSGi Framework information
+        String vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VENDOR);
+        if (vendor == null) {
+            vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
+        }
+        String version = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VERSION);
+        System.out.println("OSGi Framework : " + vendor + " - " + version);
+    }
+
+    @After
+    public void commonTearDown() {
+        ipojoHelper.dispose();
+        osgiHelper.dispose();
+    }
+
+    public BundleContext getContext() {
+        return bc;
+    }
+
+    public static ServiceContext getServiceContext(ComponentInstance ci) {
+        if (ci instanceof CompositeManager) {
+            return ((CompositeManager) ci).getServiceContext();
+        } else {
+            throw new RuntimeException("Cannot get the service context from a non composite instance");
+        }
+    }
+
+    public CompositeOption ipojoBundles() {
+        return new DefaultCompositeOption(
+                mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
+                mavenBundle("org.apache.felix", "org.apache.felix.ipojo.composite").versionAsInProject(),
+                mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
+                // configuration admin
+                mavenBundle("org.apache.felix",  "org.apache.felix.configadmin").versionAsInProject()
+        );
+    }
+
+    public Option testedBundle() throws MalformedURLException {
+        File out = new File("target/tested/bundle.jar");
+        if (out.exists()) {
+            return bundle(out.toURI().toURL().toExternalForm());
+        }
+
+        TinyBundle tested = TinyBundles.bundle();
+
+        // We look inside target/classes to find the class and resources
+        File classes = new File("target/classes");
+        Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
+        List<File> services = new ArrayList<File>();
+        for (File file : files) {
+            if (file.isDirectory()) {
+                // By convention we export of .services and .service package
+                if (file.getName().endsWith("services")  || file.getName().endsWith("service")) {
+                    services.add(file);
+                }
+            } else {
+                // We need to compute the path
+                String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+                tested.add(path, file.toURI().toURL());
+                System.out.println(file.getName() + " added to " + path);
+            }
+        }
+
+        // Export the inherited package, components and strategies
+        String export = "";
+        for (File file : services) {
+            if (export.length() > 0) { export += ", "; }
+            String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+            String packageName = path.replace('/', '.');
+            export += packageName;
+        }
+
+        System.out.println("Exported packages : " + export);
+
+        InputStream inputStream = tested
+                .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
+                .set(Constants.IMPORT_PACKAGE, "*")
+                .set(Constants.EXPORT_PACKAGE, export)
+                .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));
+
+        try {
+            org.apache.commons.io.FileUtils.copyInputStreamToFile(inputStream, out);
+            return bundle(out.toURI().toURL().toExternalForm());
+        } catch (MalformedURLException e) {
+            throw new RuntimeException("Cannot compute the url of the manipulated bundle");
+        } catch (IOException e) {
+            throw new RuntimeException("Cannot write of the manipulated bundle");
+        }
+    }
+
+    public void assertContains(String s, String[] arrays, String object) {
+        for (String suspect : arrays) {
+            if (object.equals(suspect)) {
+                return;
+            }
+        }
+        fail("Assertion failed : " + s);
+    }
+
+
+}
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/EmptyCompositeTest.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/EmptyCompositeTest.java
new file mode 100644
index 0000000..f3e2e9d
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/EmptyCompositeTest.java
@@ -0,0 +1,227 @@
+/* 

+ * 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.runtime.core;

+

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

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

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

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

+import org.apache.felix.ipojo.composite.CompositeInstanceDescription;

+import org.apache.felix.ipojo.composite.CompositeManager;

+import org.junit.Test;

+import org.osgi.framework.InvalidSyntaxException;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class EmptyCompositeTest extends Common {

+

+    @Test

+    public void testEmptyCompositeCreation() {

+        Factory factory = ipojoHelper.getFactory("composite.empty");

+        Properties props = new Properties();

+        props.put("instance.name", "empty");

+

+        ComponentInstance ci = null;

+        try {

+            ci = factory.createComponentInstance(props);

+        } catch (Exception e) {

+            e.printStackTrace();

+            fail("Unacceptable configuration : " + e.getMessage());

+        }

+

+        ComponentTypeDescription cd = ci.getFactory().getComponentDescription();

+        assertEquals("Check component type name", cd.getName(), "composite.empty");

+//		assertEquals("Check class name (" + cd.getClassName() + ")", cd.getClassName(), "composite");

+        assertEquals("Check offered service", cd.getprovidedServiceSpecification().length, 0);

+        assertEquals("Check configurable properties", cd.getProperties().length, 0);

+

+        CompositeInstanceDescription id = (CompositeInstanceDescription) ci.getInstanceDescription();

+        assertEquals("Check composite instance name", id.getName(), "empty");

+        assertEquals("Check composite instance state (" + id.getState() + ")", id.getState(), ComponentInstance.VALID);

+

+        assertEquals("Check contained instance", id.getContainedInstances().length, 0);

+

+        assertTrue("Check composite manager", ci instanceof CompositeManager);

+        CompositeManager cm = (CompositeManager) ci;

+        ServiceContext sc = cm.getServiceContext();

+        try {

+            assertEquals("Check number of factories imported", sc.getServiceReferences(Factory.class.getName(), null).length, getContext().getServiceReferences(Factory.class.getName(), null).length);

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e.getMessage());

+        }

+        ci.dispose();

+    }

+

+    @Test

+    public void testInstanceCreation1() {

+        Factory factory = ipojoHelper.getFactory("composite.empty");

+        Properties props = new Properties();

+        props.put("instance.name", "empty");

+

+        ComponentInstance ci = null;

+        try {

+            ci = factory.createComponentInstance(props);

+        } catch (Exception e) {

+            e.printStackTrace();

+            fail("Unacceptable configuration : " + e.getMessage());

+        }

+

+        assertTrue("Check composite manager", ci instanceof CompositeManager);

+        CompositeManager cm = (CompositeManager) ci;

+        ServiceContext sc = cm.getServiceContext();

+        try {

+            assertEquals("Check number of factories imported", sc.getServiceReferences(Factory.class.getName(), null).length, getContext().getServiceReferences(Factory.class.getName(), null).length);

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e.getMessage());

+        }

+

+        Properties props2 = new Properties();

+        props2.put("instance.name", "empty2");

+        ComponentInstance ci2 = null;

+        try {

+            ci2 = factory.createComponentInstance(props2, sc);

+        } catch (Exception e) {

+            e.printStackTrace();

+            fail("Unacceptable configuration : " + e.getMessage());

+        }

+

+        CompositeInstanceDescription id = (CompositeInstanceDescription) ci.getInstanceDescription();

+        assertEquals("Check composite instance name", id.getName(), "empty");

+        assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);

+        assertEquals("Check contained instance", id.getContainedInstances().length, 1);

+        CompositeInstanceDescription id2 = (CompositeInstanceDescription) id.getContainedInstances()[0];

+        assertEquals("Check composite instance name", id2.getName(), "empty2");

+        assertEquals("Check composite instance state", id2.getState(), ComponentInstance.VALID);

+        assertEquals("Check contained instance", id2.getContainedInstances().length, 0);

+

+        ci2.dispose();

+        //id = ci.getInstanceDescription();

+        assertEquals("Check composite instance name", id.getName(), "empty");

+        assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);

+        assertEquals("Check contained instance", id.getContainedInstances().length, 0);

+

+        ci.dispose();

+    }

+

+    @Test

+    public void testInstanceCreation2() {

+        Factory factory = ipojoHelper.getFactory("composite.empty");

+        Properties props = new Properties();

+        props.put("instance.name", "empty");

+

+        ComponentInstance ci = null;

+        try {

+            ci = factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Unacceptable configuration : " + e.getMessage());

+        }

+

+        assertTrue("Check composite manager", ci instanceof CompositeManager);

+        CompositeManager cm = (CompositeManager) ci;

+        ServiceContext sc = cm.getServiceContext();

+        try {

+            assertEquals("Check number of factories imported", sc.getServiceReferences(Factory.class.getName(), null).length, getContext().getServiceReferences(Factory.class.getName(), null).length);

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e.getMessage());

+        }

+

+        Factory factory2 = ipojoHelper.getFactory(sc, "composite.empty");

+        assertNotNull("Check factory2 not null", factory2);

+        Properties props2 = new Properties();

+        props2.put("instance.name", "empty2");

+        ComponentInstance ci2 = null;

+        try {

+            ci2 = factory2.createComponentInstance(props2);

+        } catch (Exception e) {

+            fail("Unacceptable configuration : " + e.getMessage());

+        }

+

+        CompositeInstanceDescription id = (CompositeInstanceDescription) ci.getInstanceDescription();

+        assertEquals("Check composite instance name", id.getName(), "empty");

+        assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);

+        assertEquals("Check contained instance", id.getContainedInstances().length, 1);

+        CompositeInstanceDescription id2 = (CompositeInstanceDescription) id.getContainedInstances()[0];

+        assertEquals("Check composite instance name", id2.getName(), "empty2");

+        assertEquals("Check composite instance state", id2.getState(), ComponentInstance.VALID);

+        assertEquals("Check contained instance", id2.getContainedInstances().length, 0);

+

+        ci2.dispose();

+        //id = ci.getInstanceDescription();

+        assertEquals("Check composite instance name", id.getName(), "empty");

+        assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);

+        assertEquals("Check contained instance", id.getContainedInstances().length, 0);

+

+        ci.dispose();

+    }

+

+    @Test

+    public void testInstanceCreation3() {

+        Factory factory = ipojoHelper.getFactory("composite.empty");

+        Properties props = new Properties();

+        props.put("instance.name", "empty");

+

+        ComponentInstance ci = null;

+        try {

+            ci = factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Unacceptable configuration : " + e.getMessage());

+        }

+

+        assertTrue("Check composite manager", ci instanceof CompositeManager);

+        CompositeManager cm = (CompositeManager) ci;

+        ServiceContext sc = cm.getServiceContext();

+        try {

+            assertEquals("Check number of factories imported", sc.getServiceReferences(Factory.class.getName(), null).length, getContext().getServiceReferences(Factory.class.getName(), null).length);

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e.getMessage());

+        }

+

+        Factory factory2 = ipojoHelper.getFactory(sc, "composite.empty");

+        assertNotNull("Check factory2 not null", factory2);

+        Properties props2 = new Properties();

+        props2.put("instance.name", "empty2");

+        ComponentInstance ci2 = null;

+        try {

+            ci2 = factory2.createComponentInstance(props2, sc);

+        } catch (Exception e) {

+            fail("Unacceptable configuration : " + e.getMessage());

+        }

+

+        CompositeInstanceDescription id = (CompositeInstanceDescription) ci.getInstanceDescription();

+        assertEquals("Check composite instance name", id.getName(), "empty");

+        assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);

+        assertEquals("Check contained instance", id.getContainedInstances().length, 1);

+        CompositeInstanceDescription id2 = (CompositeInstanceDescription) id.getContainedInstances()[0];

+        assertEquals("Check composite instance name", id2.getName(), "empty2");

+        assertEquals("Check composite instance state", id2.getState(), ComponentInstance.VALID);

+        assertEquals("Check contained instance", id2.getContainedInstances().length, 0);

+

+        ci2.dispose();

+        //id = ci.getInstanceDescription();

+        assertEquals("Check composite instance name", id.getName(), "empty");

+        assertEquals("Check composite instance state", id.getState(), ComponentInstance.VALID);

+        assertEquals("Check contained instance", id.getContainedInstances().length, 0);

+

+        ci.dispose();

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/FactoryManagementTest.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/FactoryManagementTest.java
new file mode 100644
index 0000000..24c63e9
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/FactoryManagementTest.java
@@ -0,0 +1,320 @@
+/*

+ * Licensed to the Apache Software Foundation (ASF) under one

+ * or more contributor license agreements.  See the NOTICE file

+ * distributed with this work for additional information

+ * regarding copyright ownership.  The ASF licenses this file

+ * to you under the Apache License, Version 2.0 (the

+ * "License"); you may not use this file except in compliance

+ * with the License.  You may obtain a copy of the License at

+ *

+ *   http://www.apache.org/licenses/LICENSE-2.0

+ *

+ * Unless required by applicable law or agreed to in writing,

+ * software distributed under the License is distributed on an

+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY

+ * KIND, either express or implied.  See the License for the

+ * specific language governing permissions and limitations

+ * under the License.

+ */

+package org.apache.felix.ipojo.runtime.core;

+

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

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

+import org.apache.felix.ipojo.metadata.Element;

+import org.apache.felix.ipojo.runtime.core.services.CheckService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.BundleContext;

+import org.osgi.framework.ServiceReference;

+import org.osgi.framework.ServiceRegistration;

+

+import java.util.Dictionary;

+import java.util.List;

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class FactoryManagementTest extends Common {

+

+    private FakeFactory fake1 = new FakeFactory("fake");

+    private FakeFactory fake2 = new FakeFactory("fake2");

+

+    private Factory emptyFactory;

+    private ComponentInstance empty;

+

+    private class FakeFactory implements Factory {

+

+        private String m_name;

+

+        public FakeFactory(String name) {

+            m_name = name;

+        }

+

+        public ComponentInstance createComponentInstance(Dictionary arg0) throws UnacceptableConfiguration {

+            return null;

+        }

+

+        public ComponentInstance createComponentInstance(Dictionary arg0, ServiceContext arg1) throws UnacceptableConfiguration {

+            return null;

+        }

+

+        public Element getDescription() {

+            return null;

+        }

+

+        public String getName() {

+            return m_name;

+        }

+

+        public boolean isAcceptable(Dictionary arg0) {

+            return false;

+        }

+

+        public void reconfigure(Dictionary arg0) throws UnacceptableConfiguration {

+        }

+

+        public void addFactoryStateListener(FactoryStateListener arg0) {

+        }

+

+        public List getMissingHandlers() {

+            return null;

+        }

+

+        public List getRequiredHandlers() {

+            return null;

+        }

+

+        public void removeFactoryStateListener(FactoryStateListener arg0) {

+        }

+

+        public ComponentTypeDescription getComponentDescription() {

+            return null;

+        }

+

+        public String getClassName() {

+            return "";

+        }

+

+        public int getState() {

+            return Factory.VALID;

+        }

+

+        public BundleContext getBundleContext() {

+            return getContext();

+        }

+

+        public String getVersion() {

+            return null;

+        }

+

+        public Element getComponentMetadata() {

+            return null;

+        }

+

+    }

+

+    @Before

+    public void setUp() {

+        emptyFactory = ipojoHelper.getFactory("composite.empty");

+        Properties props = new Properties();

+        props.put("instance.name", "empty-1");

+        try {

+            empty = emptyFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot create empty instance " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        empty.dispose();

+        empty = null;

+    }

+

+    @Test

+    public void testOneLevelExposition() {

+        ServiceReference[] parentsFactoryReferences = osgiHelper.getServiceReferences(Factory.class.getName(), null);

+        ServiceContext sc = getServiceContext(empty);

+        ServiceReference[] internalFactoryReferences = ipojoHelper.getServiceReferences(sc, Factory.class.getName(), null);

+

+        assertEquals("Check the number of available factories", parentsFactoryReferences.length, internalFactoryReferences.length);

+

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

+            Factory factory = (Factory) getContext().getService(parentsFactoryReferences[i]);

+            assertTrue("Check the avaibility of " + factory.getName(), isExposed(factory, internalFactoryReferences, sc));

+        }

+    }

+

+    @Test

+    public void testTwoLevelExposition() {

+        ServiceReference[] parentsFactoryReferences = osgiHelper.getServiceReferences(Factory.class.getName(), null);

+        ServiceContext sc1 = getServiceContext(empty);

+        ServiceReference[] Level1FactoryReferences = ipojoHelper.getServiceReferences(sc1, Factory.class.getName(), null);

+

+        Factory fact = ipojoHelper.getFactory(sc1, "composite.empty");

+        Properties p = new Properties();

+        p.put("instance.name", "empty2");

+        ComponentInstance empty2 = null;

+        try {

+            empty2 = fact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate empty2 instance : " + e.getMessage());

+        }

+

+        ServiceContext sc2 = getServiceContext(empty2);

+        ServiceReference[] Level2FactoryReferences = ipojoHelper.getServiceReferences(sc2, Factory.class.getName(), null);

+

+        assertEquals("Check the number of available factories - 1", parentsFactoryReferences.length, Level1FactoryReferences.length);

+        assertEquals("Check the number of available factories - 2", parentsFactoryReferences.length, Level2FactoryReferences.length);

+        assertEquals("Check the number of available factories - 3", Level1FactoryReferences.length, Level2FactoryReferences.length);

+

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

+            Factory factory = (Factory) getContext().getService(parentsFactoryReferences[i]);

+            assertTrue("Check the avaibility of " + factory.getName(), isExposed(factory, Level2FactoryReferences, sc2));

+        }

+

+        empty2.dispose();

+    }

+

+    @Test

+    public void testDynamism() {

+        ServiceReference[] parentsFactoryReferences = osgiHelper.getServiceReferences(Factory.class.getName(), null);

+        ServiceContext sc1 = getServiceContext(empty);

+        ServiceReference[] Level1FactoryReferences = ipojoHelper.getServiceReferences(sc1, Factory.class.getName(), null);

+

+        Factory fact = ipojoHelper.getFactory(sc1, "composite.empty");

+        Properties p = new Properties();

+        p.put("instance.name", "empty2");

+        ComponentInstance empty2 = null;

+        try {

+            empty2 = fact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate empty2 instance : " + e.getMessage());

+        }

+

+        ServiceContext sc2 = getServiceContext(empty2);

+        ServiceReference[] Level2FactoryReferences = ipojoHelper.getServiceReferences(sc2, Factory.class.getName(), null);

+

+        assertEquals("Check the number of available factories - 1", parentsFactoryReferences.length, Level1FactoryReferences.length);

+        assertEquals("Check the number of available factories - 2", parentsFactoryReferences.length, Level2FactoryReferences.length);

+        assertEquals("Check the number of available factories - 3", Level1FactoryReferences.length, Level2FactoryReferences.length);

+

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

+            Factory factory = (Factory) getContext().getService(parentsFactoryReferences[i]);

+            assertTrue("Check the avaibility of " + factory.getName(), isExposed(factory, Level2FactoryReferences, sc2));

+        }

+

+        // Publish fake1

+        ServiceRegistration reg1 = getContext().registerService(Factory.class.getName(), fake1, null);

+

+        parentsFactoryReferences = osgiHelper.getServiceReferences(Factory.class.getName(), null);

+        sc1 = getServiceContext(empty);

+        Level1FactoryReferences = ipojoHelper.getServiceReferences(sc1, Factory.class.getName(), null);

+        sc2 = getServiceContext(empty2);

+        Level2FactoryReferences = ipojoHelper.getServiceReferences(sc2, Factory.class.getName(), null);

+

+        assertEquals("Check the number of available factories - 1.1", parentsFactoryReferences.length, Level1FactoryReferences.length);

+        assertEquals("Check the number of available factories - 1.2", parentsFactoryReferences.length, Level2FactoryReferences.length);

+        assertEquals("Check the number of available factories - 1.3", Level1FactoryReferences.length, Level2FactoryReferences.length);

+

+        // 	Publish fake2

+        ServiceRegistration reg2 = getContext().registerService(Factory.class.getName(), fake2, null);

+

+        parentsFactoryReferences = osgiHelper.getServiceReferences(Factory.class.getName(), null);

+        sc1 = getServiceContext(empty);

+        Level1FactoryReferences = ipojoHelper.getServiceReferences(sc1, Factory.class.getName(), null);

+        sc2 = getServiceContext(empty2);

+        Level2FactoryReferences = ipojoHelper.getServiceReferences(sc2, Factory.class.getName(), null);

+

+        assertEquals("Check the number of available factories - 1.1", parentsFactoryReferences.length, Level1FactoryReferences.length);

+        assertEquals("Check the number of available factories - 1.2", parentsFactoryReferences.length, Level2FactoryReferences.length);

+        assertEquals("Check the number of available factories - 1.3", Level1FactoryReferences.length, Level2FactoryReferences.length);

+

+        reg1.unregister();

+

+        parentsFactoryReferences = osgiHelper.getServiceReferences(Factory.class.getName(), null);

+        sc1 = getServiceContext(empty);

+        Level1FactoryReferences = ipojoHelper.getServiceReferences(sc1, Factory.class.getName(), null);

+        sc2 = getServiceContext(empty2);

+        Level2FactoryReferences = ipojoHelper.getServiceReferences(sc2, Factory.class.getName(), null);

+

+        assertEquals("Check the number of available factories - 1.1", parentsFactoryReferences.length, Level1FactoryReferences.length);

+        assertEquals("Check the number of available factories - 1.2", parentsFactoryReferences.length, Level2FactoryReferences.length);

+        assertEquals("Check the number of available factories - 1.3", Level1FactoryReferences.length, Level2FactoryReferences.length);

+

+        reg2.unregister();

+

+        parentsFactoryReferences = osgiHelper.getServiceReferences(Factory.class.getName(), null);

+        sc1 = getServiceContext(empty);

+        Level1FactoryReferences = ipojoHelper.getServiceReferences(sc1, Factory.class.getName(), null);

+        sc2 = getServiceContext(empty2);

+        Level2FactoryReferences = ipojoHelper.getServiceReferences(sc2, Factory.class.getName(), null);

+

+        assertEquals("Check the number of available factories - 1.1", parentsFactoryReferences.length, Level1FactoryReferences.length);

+        assertEquals("Check the number of available factories - 1.2", parentsFactoryReferences.length, Level2FactoryReferences.length);

+        assertEquals("Check the number of available factories - 1.3", Level1FactoryReferences.length, Level2FactoryReferences.length);

+

+        empty2.dispose();

+    }

+

+    @Test

+    public void testInvocation() {

+        ServiceContext sc1 = getServiceContext(empty);

+        Factory fact = ipojoHelper.getFactory(sc1, "composite.empty");

+        Properties p = new Properties();

+        p.put("instance.name", "empty2");

+        ComponentInstance empty2 = null;

+        try {

+            empty2 = fact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate empty2 instance : " + e.getMessage());

+        }

+

+        ServiceContext sc2 = getServiceContext(empty2);

+

+        Factory fact1 = ipojoHelper.getFactory(sc2, "COMPO-SimpleCheckServiceProvider");

+        Properties props = new Properties();

+        props.put("instance.name", "client");

+        ComponentInstance client = null;

+        try {

+            client = fact1.createComponentInstance(props);

+        } catch (Exception e) {

+            e.printStackTrace();

+            fail("Cannot instantiate the client : " + e.getMessage());

+        }

+

+        Factory fact2 = ipojoHelper.getFactory(sc2, "COMPO-FooProviderType-1");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "provider");

+        ComponentInstance provider = null;

+        try {

+            provider = fact2.createComponentInstance(props2);

+        } catch (Exception e) {

+            fail("Cannot instantiate the provider : " + e.getMessage());

+        }

+

+        ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());

+        assertNotNull("Check ref existency", ref);

+        CheckService check = (CheckService) sc2.getService(ref);

+

+        assertTrue("Check invocation", check.check());

+        client.dispose();

+        provider.dispose();

+        empty2.dispose();

+    }

+

+

+    private boolean isExposed(Factory fact, ServiceReference[] refs, ServiceContext sc) {

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

+            Factory f = (Factory) sc.getService(refs[i]);

+            if (fact.getName().equals(f.getName())) {

+                sc.ungetService(refs[i]);

+                return true;

+            }

+            sc.ungetService(refs[i]);

+        }

+        return false;

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/ServiceRangeTest.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/ServiceRangeTest.java
new file mode 100644
index 0000000..0a4d6b3
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/ServiceRangeTest.java
@@ -0,0 +1,510 @@
+/* 

+ * 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.runtime.core;

+

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

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

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

+import org.apache.felix.ipojo.runtime.core.services.CheckService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.InvalidSyntaxException;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class ServiceRangeTest extends Common {

+

+    private Factory emptyFactory;

+    private ComponentInstance empty;

+

+

+    @Before

+    public void setUp() {

+        emptyFactory = ipojoHelper.getFactory("composite.empty");

+        Properties props = new Properties();

+        props.put("instance.name", "empty-1");

+        try {

+            empty = emptyFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot create empty instance " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        empty.dispose();

+        empty = null;

+    }

+

+    @Test

+    public void testLevelOne1() {

+        ServiceContext sc2 = getServiceContext(empty);

+

+        Factory fact1 = ipojoHelper.getFactory(sc2, "COMPO-SimpleCheckServiceProvider");

+        Properties props = new Properties();

+        props.put("instance.name", "client");

+        ComponentInstance client = null;

+        try {

+            client = fact1.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate the client : " + e.getMessage());

+        }

+

+        Factory fact2 = ipojoHelper.getFactory(sc2, "COMPO-FooProviderType-1");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "provider");

+        ComponentInstance provider = null;

+        try {

+            provider = fact2.createComponentInstance(props2);

+        } catch (Exception e) {

+            fail("Cannot instantiate the provider : " + e.getMessage());

+        }

+

+        ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());

+        CheckService check = (CheckService) sc2.getService(ref);

+

+        assertTrue("Check invocation", check.check());

+

+        sc2.ungetService(ref);

+

+        // Check visibility 

+        assertNotNull("Check foo service visible inside the composite", sc2.getServiceReference(FooService.class.getName()));

+        assertNotNull("Check check service visible inside the composite", sc2.getServiceReference(CheckService.class.getName()));

+        // Check invisibilty

+        assertNull("Check foo service invisible inside the context", getContext().getServiceReference(FooService.class.getName()));

+        try {

+            assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e);

+        }

+

+        provider.dispose();

+        client.dispose();

+

+        assertNull("Check foo service invisible inside the composite", sc2.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service invisible inside the composite", sc2.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible from the context", getContext().getServiceReference(FooService.class.getName()));

+        try {

+            assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e);

+        }

+    }

+

+    @Test

+    public void testLevelOne2() {

+        ServiceContext sc2 = getServiceContext(empty);

+

+        Factory fact1 = ipojoHelper.getFactory(sc2, "COMPO-SimpleCheckServiceProvider");

+        Properties props = new Properties();

+        props.put("instance.name", "client");

+        ComponentInstance client = null;

+        try {

+            client = fact1.createComponentInstance(props, sc2);

+        } catch (Exception e) {

+            fail("Cannot instantiate the client : " + e.getMessage());

+        }

+

+        Factory fact2 = ipojoHelper.getFactory(sc2, "COMPO-FooProviderType-1");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "provider");

+        ComponentInstance provider = null;

+        try {

+            provider = fact2.createComponentInstance(props2, sc2);

+        } catch (Exception e) {

+            fail("Cannot instantiate the provider : " + e.getMessage());

+        }

+

+        ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());

+        CheckService check = (CheckService) sc2.getService(ref);

+

+        assertTrue("Check invocation", check.check());

+

+        sc2.ungetService(ref);

+

+        // Check visibility 

+        assertNotNull("Check foo service visible inside the composite", sc2.getServiceReference(FooService.class.getName()));

+        assertNotNull("Check check service visible inside the composite", sc2.getServiceReference(CheckService.class.getName()));

+        // Check invisibilty

+        assertNull("Check foo service invisible inside the context", getContext().getServiceReference(FooService.class.getName()));

+        try {

+            assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e);

+        }

+

+        client.dispose();

+        provider.dispose();

+

+        assertNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));

+        try {

+            assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e);

+        }

+    }

+

+    @Test

+    public void testLevelOne3() {

+        ServiceContext sc2 = getServiceContext(empty);

+

+        Factory fact1 = ipojoHelper.getFactory("COMPO-SimpleCheckServiceProvider");

+        Properties props = new Properties();

+        props.put("instance.name", "client");

+        ComponentInstance client = null;

+        try {

+            client = fact1.createComponentInstance(props, sc2);

+        } catch (Exception e) {

+            fail("Cannot instantiate the client : " + e.getMessage());

+        }

+

+        Factory fact2 = ipojoHelper.getFactory("COMPO-FooProviderType-1");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "provider");

+        ComponentInstance provider = null;

+        try {

+            provider = fact2.createComponentInstance(props2, sc2);

+        } catch (Exception e) {

+            fail("Cannot instantiate the provider : " + e.getMessage());

+        }

+

+        ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());

+        CheckService check = (CheckService) sc2.getService(ref);

+

+        assertTrue("Check invocation", check.check());

+

+        sc2.ungetService(ref);

+

+        // Check visibility 

+        assertNotNull("Check foo service visible inside the composite", sc2.getServiceReference(FooService.class.getName()));

+        assertNotNull("Check check service visible inside the composite", sc2.getServiceReference(CheckService.class.getName()));

+        // Check invisibilty

+        assertNull("Check foo service invisible inside the context", getContext().getServiceReference(FooService.class.getName()));

+        try {

+            assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e);

+        }

+

+        client.dispose();

+        provider.dispose();

+

+        assertNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));

+        try {

+            assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e);

+        }

+    }

+

+    @Test

+    public void testLevelTwo1() {

+        ServiceContext sc1 = getServiceContext(empty);

+        Factory fact = ipojoHelper.getFactory(sc1, "composite.empty");

+        Properties p = new Properties();

+        p.put("instance.name", "empty2");

+        ComponentInstance empty2 = null;

+        try {

+            empty2 = fact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate empty2 instance : " + e.getMessage());

+        }

+

+        ServiceContext sc2 = getServiceContext(empty2);

+

+        Factory fact1 = ipojoHelper.getFactory(sc2, "COMPO-SimpleCheckServiceProvider");

+        Properties props = new Properties();

+        props.put("instance.name", "client");

+        ComponentInstance client = null;

+        try {

+            client = fact1.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate the client : " + e.getMessage());

+        }

+

+        Factory fact2 = ipojoHelper.getFactory(sc2, "COMPO-FooProviderType-1");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "provider");

+        ComponentInstance provider = null;

+        try {

+            provider = fact2.createComponentInstance(props2);

+        } catch (Exception e) {

+            fail("Cannot instantiate the provider : " + e.getMessage());

+        }

+

+        ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());

+        CheckService check = (CheckService) sc2.getService(ref);

+

+        assertTrue("Check invocation", check.check());

+

+        sc2.ungetService(ref);

+

+        //	Check visibility 

+        assertNotNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));

+        assertNotNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));

+        // Check invisibilty

+        assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));

+        try {

+            assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e);

+        }

+

+        client.dispose();

+        provider.dispose();

+

+        assertNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));

+        try {

+            assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e);

+        }

+        empty2.dispose();

+    }

+

+    @Test

+    public void testLevelTwo2() {

+        ServiceContext sc1 = getServiceContext(empty);

+        Factory fact = ipojoHelper.getFactory(sc1, "composite.empty");

+        Properties p = new Properties();

+        p.put("instance.name", "empty2");

+        ComponentInstance empty2 = null;

+        try {

+            empty2 = fact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate empty2 instance : " + e.getMessage());

+        }

+

+        ServiceContext sc2 = getServiceContext(empty2);

+

+        Factory fact1 = ipojoHelper.getFactory(sc1, "COMPO-SimpleCheckServiceProvider");

+        Properties props = new Properties();

+        props.put("instance.name", "client");

+        ComponentInstance client = null;

+        try {

+            client = fact1.createComponentInstance(props, sc2);

+        } catch (Exception e) {

+            fail("Cannot instantiate the client : " + e.getMessage());

+        }

+

+        Factory fact2 = ipojoHelper.getFactory(sc1, "COMPO-FooProviderType-1");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "provider");

+        ComponentInstance provider = null;

+        try {

+            provider = fact2.createComponentInstance(props2, sc2);

+        } catch (Exception e) {

+            fail("Cannot instantiate the provider : " + e.getMessage());

+        }

+

+        ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());

+        CheckService check = (CheckService) sc2.getService(ref);

+

+        assertTrue("Check invocation", check.check());

+

+        sc2.ungetService(ref);

+

+        //	Check visibility 

+        assertNotNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));

+        assertNotNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));

+        // Check invisibilty

+        assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));

+        try {

+            assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e);

+        }

+

+        client.dispose();

+        provider.dispose();

+

+        assertNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));

+        try {

+            assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e);

+        }

+        empty2.dispose();

+    }

+

+    @Test

+    public void testLevelTwo3() {

+        ServiceContext sc1 = getServiceContext(empty);

+        Factory fact = ipojoHelper.getFactory(sc1, "composite.empty");

+        Properties p = new Properties();

+        p.put("instance.name", "empty2");

+        ComponentInstance empty2 = null;

+        try {

+            empty2 = fact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate empty2 instance : " + e.getMessage());

+        }

+

+        ServiceContext sc2 = getServiceContext(empty2);

+

+        Factory fact1 = ipojoHelper.getFactory("COMPO-SimpleCheckServiceProvider");

+        Properties props = new Properties();

+        props.put("instance.name", "client");

+        ComponentInstance client = null;

+        try {

+            client = fact1.createComponentInstance(props, sc2);

+        } catch (Exception e) {

+            fail("Cannot instantiate the client : " + e.getMessage());

+        }

+

+        Factory fact2 = ipojoHelper.getFactory("COMPO-FooProviderType-1");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "provider");

+        ComponentInstance provider = null;

+        try {

+            provider = fact2.createComponentInstance(props2, sc2);

+        } catch (Exception e) {

+            fail("Cannot instantiate the provider : " + e.getMessage());

+        }

+

+        ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());

+        CheckService check = (CheckService) sc2.getService(ref);

+

+        assertTrue("Check invocation", check.check());

+

+        sc2.ungetService(ref);

+

+        //	Check visibility 

+        assertNotNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));

+        assertNotNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));

+        // Check invisibilty

+        assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));

+        try {

+            assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e);

+        }

+

+        client.dispose();

+        provider.dispose();

+

+        assertNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));

+        try {

+            assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e);

+        }

+        empty2.dispose();

+    }

+

+    @Test

+    public void testLevelTwo4() {

+        ServiceContext sc1 = getServiceContext(empty);

+        Factory fact = ipojoHelper.getFactory(sc1, "composite.empty");

+        Properties p = new Properties();

+        p.put("instance.name", "empty2");

+        ComponentInstance empty2 = null;

+        try {

+            empty2 = fact.createComponentInstance(p);

+        } catch (Exception e) {

+            fail("Cannot instantiate empty2 instance : " + e.getMessage());

+        }

+

+        ServiceContext sc2 = getServiceContext(empty2);

+

+        Factory fact1 = ipojoHelper.getFactory(sc2, "COMPO-SimpleCheckServiceProvider");

+        Properties props = new Properties();

+        props.put("instance.name", "client");

+        ComponentInstance client = null;

+        try {

+            client = fact1.createComponentInstance(props, sc2);

+        } catch (Exception e) {

+            fail("Cannot instantiate the client : " + e.getMessage());

+        }

+

+        Factory fact2 = ipojoHelper.getFactory(sc2, "COMPO-FooProviderType-1");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "provider");

+        ComponentInstance provider = null;

+        try {

+            provider = fact2.createComponentInstance(props2, sc2);

+        } catch (Exception e) {

+            fail("Cannot instantiate the provider : " + e.getMessage());

+        }

+

+        ServiceReference ref = sc2.getServiceReference(CheckService.class.getName());

+        CheckService check = (CheckService) sc2.getService(ref);

+

+        assertTrue("Check invocation", check.check());

+

+        sc2.ungetService(ref);

+

+        //	Check visibility 

+        assertNotNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));

+        assertNotNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));

+        // Check invisibilty

+        assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));

+        try {

+            assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e);

+        }

+

+        client.dispose();

+        provider.dispose();

+

+        assertNull("Check foo service visible inside the composite 2", sc2.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service visible inside the composite 2", sc2.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible inside the composite 1", sc1.getServiceReference(FooService.class.getName()));

+        assertNull("Check check service invisible inside the composite 1", sc1.getServiceReference(CheckService.class.getName()));

+        assertNull("Check foo service invisible inside the global", getContext().getServiceReference(FooService.class.getName()));

+        try {

+            assertNull("Check check service invisible inside the context", getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=client)"));

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e);

+        }

+        empty2.dispose();

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/ServiceRegistryTest.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/ServiceRegistryTest.java
new file mode 100644
index 0000000..c7da5ae
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-runtime-test/src/test/java/org/apache/felix/ipojo/runtime/core/ServiceRegistryTest.java
@@ -0,0 +1,282 @@
+/* 

+ * 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.runtime.core;

+

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

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

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

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

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

+import org.apache.felix.ipojo.context.ServiceRegistry;

+import org.apache.felix.ipojo.runtime.core.services.BarService;

+import org.junit.Test;

+import org.osgi.framework.*;

+

+import java.util.Dictionary;

+import java.util.Hashtable;

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class ServiceRegistryTest extends Common {

+

+    private class svcListener implements ServiceListener {

+        public int registration = 0;

+        public int unregistration = 0;

+        public int modification = 0;

+

+        public void serviceChanged(ServiceEvent ev) {

+            if (ev.getType() == ServiceEvent.REGISTERED) {

+                registration++;

+            }

+            if (ev.getType() == ServiceEvent.UNREGISTERING) {

+                unregistration++;

+            }

+            if (ev.getType() == ServiceEvent.MODIFIED) {

+                modification++;

+            }

+        }

+    }

+

+    private class barProvider implements BarService {

+

+        public boolean bar() {

+            return true;

+        }

+

+        public Properties getProps() {

+            return null;

+        }

+

+    }

+

+    private class FakeComponent implements ComponentInstance {

+

+        public ComponentTypeDescription getComponentDescription() {

+            return null;

+        }

+

+        public BundleContext getContext() {

+            return null;

+        }

+

+        public ComponentFactory getFactory() {

+            return null;

+        }

+

+        public InstanceDescription getInstanceDescription() {

+            return null;

+        }

+

+        public String getInstanceName() {

+            return null;

+        }

+

+        public int getState() {

+            return 0;

+        }

+

+        public boolean isStarted() {

+            return false;

+        }

+

+        public void reconfigure(Dictionary dictionary) {

+        }

+

+        public void start() {

+        }

+

+        public void stop() {

+        }

+

+        public void dispose() {

+        }

+

+        public void addInstanceStateListener(InstanceStateListener arg0) {

+        }

+

+        public void removeInstanceStateListener(InstanceStateListener arg0) {

+        }

+

+    }

+

+    @Test

+    public void testRegistrationAndListener() {

+        ComponentInstance im = new FakeComponent();

+        ComponentInstance im2 = new FakeComponent();

+        ServiceRegistry registry = new ServiceRegistry(getContext());

+        assertNotNull("Assert registry not null", registry);

+        svcListener all = new svcListener();

+        try {

+            assertNull("Check that there is no available service", registry.getServiceReferences(null, null));

+        } catch (InvalidSyntaxException e) {

+            fail("Cannot query the registry : " + e.getMessage());

+        }

+        registry.addServiceListener(all);

+

+        ServiceRegistration reg1 = registry.registerService(im, BarService.class.getName(), new barProvider(), null);

+

+        try {

+            assertEquals("Check number of registred service", 1, registry.getServiceReferences(null, null).length);

+        } catch (InvalidSyntaxException e) {

+            fail("Cannot query the registry : " + e.getMessage());

+        }

+

+        ServiceRegistration reg2 = registry.registerService(im2, BarService.class.getName(), new barProvider(), null);

+

+        try {

+            assertEquals("Check number of registred service", 2, registry.getServiceReferences(null, null).length);

+        } catch (InvalidSyntaxException e) {

+            fail("Cannot query the registry : " + e.getMessage());

+        }

+

+        assertEquals("Check the number of registration", 2, all.registration);

+

+        Dictionary<String, String> props = new Hashtable<String, String>();

+        props.put("foo", "bar");

+        reg1.setProperties(props);

+        assertEquals("Check the number of modification", 1, all.modification);

+

+        reg1.unregister();

+        assertEquals("Check the number of unregistration", 1, all.unregistration);

+

+        reg2.setProperties(props);

+        assertEquals("Check the number of modification", 2, all.modification);

+

+        reg2.unregister();

+        assertEquals("Check the number of unregistration", 2, all.unregistration);

+

+        registry.removeServiceListener(all);

+    }

+

+    @Test

+    public void testRegistrationAndFilter() {

+        ComponentInstance im = new FakeComponent();

+        ComponentInstance im2 = new FakeComponent();

+        ServiceRegistry registry = new ServiceRegistry(getContext());

+        svcListener filtered = new svcListener();

+

+        try {

+            assertNull("Check that there is no available service", registry.getServiceReferences(null, null));

+        } catch (InvalidSyntaxException e) {

+            fail("Cannot query the registry : " + e.getMessage());

+        }

+

+        registry.addServiceListener(filtered, "(foo=bar)");

+

+        Dictionary<String, String> props = new Hashtable<String, String>();

+        props.put("foo", "bar");

+        ServiceRegistration reg1 = registry.registerService(im, BarService.class.getName(), new barProvider(), props);

+

+        try {

+            assertEquals("Check number of registred service", 1, registry.getServiceReferences(null, null).length);

+        } catch (InvalidSyntaxException e) {

+            fail("Cannot query the registry : " + e.getMessage());

+        }

+

+        ServiceRegistration reg2 = registry.registerService(im2, BarService.class.getName(), new barProvider(), null);

+

+        try {

+            assertEquals("Check number of registred service", 2, registry.getServiceReferences(null, null).length);

+        } catch (InvalidSyntaxException e) {

+            fail("Cannot query the registry : " + e.getMessage());

+        }

+

+        assertEquals("Check the number of registration", 1, filtered.registration);

+

+        reg2.setProperties(props);

+        assertEquals("Check the number of modification", 1, filtered.modification);

+        // Follow the OSGi semantics of filters

+

+        reg1.unregister();

+        reg2.unregister();

+        assertEquals("Check the number of unregistration", 2, filtered.unregistration);

+        registry.removeServiceListener(filtered);

+    }

+

+    @Test

+    public void testGetService() {

+        ComponentInstance im = new FakeComponent();

+        ComponentInstance im2 = new FakeComponent();

+        ServiceRegistry registry = new ServiceRegistry(getContext());

+

+        try {

+            assertNull("Check that there is no available service", registry.getServiceReferences(null, null));

+        } catch (InvalidSyntaxException e) {

+            fail("Cannot query the registry : " + e.getMessage());

+        }

+

+        Properties props = new Properties();

+        props.put("foo", "bar");

+        ServiceRegistration reg1 = registry.registerService(im, BarService.class.getName(), new barProvider(), props);

+

+        ServiceReference ref = registry.getServiceReference(BarService.class.getName());

+        assertNotNull("Check ref not null", ref);

+        assertEquals("Test property", ref.getProperty("foo"), "bar");

+        BarService bar = (BarService) registry.getService(im2, ref);

+        assertTrue("Test invocation", bar.bar());

+

+        reg1.unregister();

+        ref = registry.getServiceReference(BarService.class.getName());

+        assertNull("Check ref null", ref);

+    }

+

+    @Test

+    public void testGetFilteredService() {

+        ComponentInstance im = new FakeComponent();

+        ComponentInstance im2 = new FakeComponent();

+        ServiceRegistry registry = new ServiceRegistry(getContext());

+

+        try {

+            assertNull("Check that there is no available service", registry.getServiceReferences(null, null));

+        } catch (InvalidSyntaxException e) {

+            fail("Cannot query the registry : " + e.getMessage());

+        }

+

+        Properties props = new Properties();

+        props.put("foo", "bar");

+        ServiceRegistration reg1 = registry.registerService(im, BarService.class.getName(), new barProvider(), props);

+        ServiceRegistration reg2 = registry.registerService(im2, BarService.class.getName(), new barProvider(), null);

+

+        ServiceReference[] ref = null;

+        try {

+            ref = registry.getServiceReferences(BarService.class.getName(), "(foo=bar)");

+        } catch (InvalidSyntaxException e) {

+            fail("Registry query fail : " + e.getMessage());

+        }

+        assertNotNull("Check ref not null", ref);

+        assertEquals("Check ref count", ref.length, 1);

+        assertEquals("Test property", ref[0].getProperty("foo"), "bar");

+        BarService bar = (BarService) registry.getService(im2, ref[0]);

+        assertTrue("Test invocation", bar.bar());

+

+        ref = null;

+        reg1.unregister();

+        try {

+            ref = registry.getServiceReferences(BarService.class.getName(), "(bar=foo)");

+        } catch (InvalidSyntaxException e) {

+            fail("Registry query fail : " + e.getMessage());

+        }

+        assertNull("Check ref null", ref);

+

+        reg2.unregister();

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/pom.xml b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/pom.xml
new file mode 100644
index 0000000..eb19703
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/pom.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.ipojo.runtime.composite-it</artifactId>
+        <version>1.9.0-SNAPSHOT</version>
+        <relativePath>../../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.felix</groupId>
+    <artifactId>ipojo-composite-service-providing-test</artifactId>
+
+    <name>${project.artifactId}</name>
+    
+</project>
\ No newline at end of file
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Baz2CheckProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Baz2CheckProvider.java
new file mode 100644
index 0000000..7e5d145
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/Baz2CheckProvider.java
@@ -0,0 +1,81 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.BazService;

+import org.apache.felix.ipojo.runtime.core.services.CheckService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+public class Baz2CheckProvider implements CheckService {

+	

+	BazService fs;

+	

+	int simpleB = 0;

+	int objectB = 0;

+	int refB = 0;

+	int simpleU = 0;

+	int objectU = 0;

+	int refU = 0;

+

+	public boolean check() {

+		return fs.foo();

+	}

+

+	public Properties getProps() {

+		Properties props = new Properties();

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

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

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

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

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

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

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

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

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

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

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

+		if(fs.getObject() != null) { props.put("object", fs.getObject()); }

+		

+		return props;

+	}

+	

+	private void voidBind() {

+		simpleB++;

+	}

+	private void voidUnbind() {

+		simpleU++;

+	}

+	

+	protected void objectBind(Object o) {

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

+	}

+	protected void objectUnbind(Object o) {

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

+	}

+	

+	public void refBind(ServiceReference sr) {

+		if(sr != null) { refB++; }

+	}

+	public void refUnbind(ServiceReference sr) {

+		if(sr != null) { refU++; }

+	}

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/BazProviderType1.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/BazProviderType1.java
new file mode 100644
index 0000000..5ac64d3
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/BazProviderType1.java
@@ -0,0 +1,51 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.BazService;

+

+import java.util.Properties;

+

+public class BazProviderType1 implements BazService {

+	

+	private int m_bar;

+	private String m_foo;

+

+	public boolean foo() {

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("bar", new Integer(m_bar));

+		p.put("foo", m_foo);

+		return p;

+	}

+	

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckProviderParentClass.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckProviderParentClass.java
new file mode 100644
index 0000000..7d18712
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckProviderParentClass.java
@@ -0,0 +1,51 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.ServiceReference;

+

+public abstract class CheckProviderParentClass {

+    

+    int simpleU = 0;

+    int objectU = 0;

+    int refU = 0;

+    int bothU = 0;

+    

+    

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

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

+    }

+    

+    public void refUnbind(ServiceReference sr) {

+        if(sr != null) { refU++; }

+    }

+    

+    public void objectUnbind(FooService o) {

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

+        else {

+            System.err.println("Unbind null : " + o);

+        }

+    }

+    

+    public void voidUnbind() {

+        simpleU++;

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java
new file mode 100644
index 0000000..eee88a2
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/CheckServiceProvider.java
@@ -0,0 +1,83 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.CheckService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+public class CheckServiceProvider extends CheckProviderParentClass implements CheckService {

+    

+	FooService fs;

+	

+	int simpleB = 0;

+	int objectB = 0;

+	int refB = 0;

+	int bothB = 0;

+

+	public boolean check() {

+		return fs.foo();

+	}

+

+	public Properties getProps() {

+		Properties props = new Properties();

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

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

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

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

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

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

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

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

+		if (fs != null) {

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

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

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

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

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

+		    if(fs.getObject() != null) { props.put("object", fs.getObject()); }

+		}

+        props.put("static", CheckService.foo);

+        props.put("class", CheckService.class.getName());

+		return props;

+	}

+	

+	private void voidBind() {

+		simpleB++;

+	}

+	

+	protected void objectBind(FooService o) {

+	    if (o == null) {

+	        System.err.println("Bind receive null !!! ");

+	        return;

+	    }

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

+	}

+	

+	public void refBind(ServiceReference sr) {

+		if(sr != null) { refB++; }

+	}

+	

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

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

+	}

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java
new file mode 100644
index 0000000..03016d3
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooBarProviderType1.java
@@ -0,0 +1,54 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.BarService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+

+import java.util.Properties;

+

+public class FooBarProviderType1 implements FooService, BarService {

+

+	public boolean foo() {

+		return true;

+	}

+

+	public Properties fooProps() {

+		return new Properties();

+	}

+

+	public boolean bar() {

+		return true;

+	}

+

+	public Properties getProps() {

+		return new Properties();

+	}

+

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
new file mode 100644
index 0000000..b9eda2d
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderType1.java
@@ -0,0 +1,92 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.osgi.framework.BundleContext;

+

+import java.util.Properties;

+

+public class FooProviderType1 implements FooService {

+	

+	private int m_bar;

+	private String m_foo;

+    

+    private BundleContext m_context;

+    

+    private static FooProviderType1 singleton;

+    private static int count = 0;

+    

+    public FooProviderType1(BundleContext bc) {

+        if (bc ==null) {

+            throw new RuntimeException("Injected bundle context null");

+        }

+        m_context = bc;

+    }

+

+	public boolean foo() {

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("bar", new Integer(m_bar));

+        if(m_foo != null) {

+            p.put("foo", m_foo);

+        }

+        p.put("context", m_context);

+        

+        p.put("count", new Integer(count));

+		return p;

+	}

+    

+	public void testException() throws Exception {

+        String a = "foobarbaz";

+	    throw new Exception("foo"+a);

+    }

+    

+    public void testTry() {

+            String a = "foo";

+            a.charAt(0);

+    }

+    

+    public void testTry2(String s) {

+            String a = "foo";

+            a.charAt(0);

+    }

+    

+    private void nexttry(String  s) {

+        try {

+            s += "foo";

+        } catch(RuntimeException e) {

+            

+        }

+    }

+    

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java
new file mode 100644
index 0000000..47f6ae5
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn.java
@@ -0,0 +1,63 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+

+import java.util.Properties;

+

+public class FooProviderTypeDyn implements FooService {

+	

+	private int intProp;	

+	private String strProp;

+	private String[] strAProp;

+	private int[] intAProp;

+	private boolean boolProp;

+

+	public boolean foo() {

+		intProp = 3;

+		boolProp = true;

+		if(strProp.equals("foo")) { strProp = "bar"; }

+		else { strProp = "foo"; }

+		strAProp = new String[] {"foo", "bar", "baz"};

+		intAProp = new int[] {3, 2, 1};

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("intProp", new Integer(intProp));

+		p.put("boolProp", new Boolean(boolProp));

+		p.put("strProp", strProp);

+		p.put("strAProp", strAProp);

+		p.put("intAProp", intAProp);

+		return p;

+	}

+	

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java
new file mode 100644
index 0000000..efec5f0
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/FooProviderTypeDyn2.java
@@ -0,0 +1,58 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+

+import java.util.Properties;

+

+public class FooProviderTypeDyn2 implements FooService {

+	

+	private int intProp = 2;

+	private boolean boolProp = true;

+	private String strProp = "foo";

+	private String[] strAProp = new String[] {"foo", "bar"};

+	private int[] intAProp = new int[] {1, 2, 3};

+

+	public boolean foo() {

+		intAProp = null;

+		return true;

+	}

+

+	public Properties fooProps() {

+		Properties p = new Properties();

+		p.put("intProp", new Integer(intProp));

+		p.put("boolProp", new Boolean(boolProp));

+		p.put("strProp", strProp);

+		p.put("strAProp", strAProp);

+		p.put("intAProp", intAProp);

+		return p;

+	}

+	

+	public boolean getBoolean() { return true; }

+

+	public double getDouble() { return 1.0; }

+

+	public int getInt() { return 1; }

+

+	public long getLong() { return 1; }

+

+	public Boolean getObject() { return new Boolean(true); }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ServiceConsumer.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ServiceConsumer.java
new file mode 100644
index 0000000..65295b7
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ServiceConsumer.java
@@ -0,0 +1,27 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.CheckService;
+import org.apache.felix.ipojo.runtime.core.services.Service;
+
+import java.util.Properties;
+
+public class ServiceConsumer implements CheckService {
+
+    private Service service;
+    private Properties props = new Properties();
+
+    public ServiceConsumer() {
+        props.put("1", new Integer(service.count()));
+        props.put("2", new Integer(service.count()));
+        props.put("3", new Integer(service.count()));
+    }
+
+    public boolean check() {
+        return service.count() > 0;
+    }
+
+    public Properties getProps() {
+        return props;
+    }
+
+}
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ServiceProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ServiceProvider.java
new file mode 100644
index 0000000..702899f
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/ServiceProvider.java
@@ -0,0 +1,15 @@
+package org.apache.felix.ipojo.runtime.core.components;
+
+import org.apache.felix.ipojo.runtime.core.services.Service;
+
+
+public class ServiceProvider implements Service {
+
+    private int i = 0;
+
+    public int count() {
+        i++;
+        return i;
+    }
+
+}
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java
new file mode 100644
index 0000000..c3ade01
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TataProvider.java
@@ -0,0 +1,222 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.Tata;

+

+import java.util.Properties;

+

+

+public class TataProvider implements Tata {

+    

+    int tata = 0;

+    int tataStr = 0;

+    int tataStrs = 0;

+    int tata_2 = 0;

+    int tata_3 = 0;

+    int tata1 = 0;

+    int tata1_1 = 0;

+    int tata5 = 0;

+    int tata5_1 = 0;

+    int tata5_2 = 0;

+    int tataBoolean = 0;

+    int tataBooleans = 0;

+    int tataByte = 0;

+    int tataBytes = 0;

+    private int add;

+    private int tataShorts;

+    private int tataShort;

+    private int tataLongs;

+    private int tataLong;

+    private int tataInts;

+    private int tataInt;

+    private int tataFloat;

+    private int tataFloats;

+    private int tataDoubles;

+    private int tataDouble;

+    private int tataChars;

+    private int tataChar;

+    

+    public Properties getPropsTata() {

+        Properties props = new Properties();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+        return props;

+    }

+

+    public void tata() {

+        tata++;

+    }

+

+    public String tataStr() {

+        tataStr++;

+        return "Tata";

+    }

+

+    public String[] tataStrs() {

+        tataStrs++;

+        return new String[] {"T", "A", "T", "A"};

+    }

+

+    public void tata(int i, int j) {

+        tata_2++;        

+    }

+

+    public void tata(String s) {

+        tata_3++;

+    }

+

+    public String tata1(String a) {

+        tata1++;

+       return a;

+    }

+

+    public String tata1(char[] a) {

+        tata1_1++;

+        String s = new String(a);

+        return s;

+    }

+

+    public String tata5(String a, int i) {

+       tata5++;

+       return a+i;

+    }

+

+    public String tata5(String[] a, int i) {

+       tata5_1++;

+       return ""+a.length + i;

+    }

+

+    public String tata5(String a, int[] i) {

+        tata5_2++;

+        return a + i.length;

+    }

+

+    public boolean tataBoolean(boolean b) {

+        tataBoolean++;

+        return b;

+    }

+

+    public boolean[] tataBooleans(boolean[] b) {

+        tataBooleans++;

+       return b;

+    }

+

+    public byte tataByte(byte b) {

+        tataByte++;

+        return b;

+    }

+

+    public byte[] tataBytes(byte[] b) {

+        tataBytes++;

+        return b;

+    }

+

+    public char tataChar(char c) {

+       tataChar++;

+       return c;

+    }

+

+    public char[] tataChars(char[] c) {

+        tataChars++;

+        return c;

+    }

+

+    public double tataDouble(double d) {

+        tataDouble++;

+        return d;

+    }

+

+    public double[] tataDoubles(double[] d) {

+        tataDoubles++;

+        return d;

+    }

+

+    public float tataFloat(float f) {

+        tataFloat++;

+        return f;

+    }

+

+    public float[] tataFloats(float[] f) {

+        tataFloats++;

+        return f;

+    }

+

+    public int tataInt(int i) {

+        tataInt++;

+        return i;

+    }

+

+    public int[] tataInts(int[] its) {

+        tataInts++;

+        return its;

+    }

+

+    public long tataLong(long l) {

+        tataLong++;

+        return l;

+    }

+

+    public long[] tataLongs(long[] l) {

+        tataLongs++;

+        return l;

+    }

+

+    public short tataShort(short s) {

+        tataShort++;

+        return s;

+    }

+

+    public short[] tataShorts(short[] s) {

+        tataShorts++;

+        return s;

+    }

+

+    public long add(int i, int j, int k) {

+        add++;

+        return i + j + k;

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java
new file mode 100644
index 0000000..d230c2d
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProvider.java
@@ -0,0 +1,73 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.Toto;

+

+import java.util.Properties;

+

+

+public class TotoProvider implements Toto {

+    

+    private int i = 0;

+    public static int toto = 0;

+    public static int toto_2 = 0;

+    public static int toto_3 = 0;

+    public static int toto_4 = 0;

+    public static int toto1 = 0;

+    

+    public int count() {

+        return i;

+    }

+    

+    public void toto() {

+        toto++;        

+    }

+

+    public void toto(int i, int j) {

+        toto_2++;

+    }

+

+    public String toto(String a) {

+        toto_3++;

+        return a;

+    }

+

+    public String toto(String[] a) {

+        toto_4++;

+        return "toto";

+    }

+

+    public void toto1(String j) {

+        i++;

+        toto1++;        

+    }

+

+    public Properties getProps() {

+        Properties props = new Properties();

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

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

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

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

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

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

+        return props;

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java
new file mode 100644
index 0000000..f90460c
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/TotoProviderGlue.java
@@ -0,0 +1,81 @@
+/* 

+ * 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.runtime.core.components;

+

+import org.apache.felix.ipojo.runtime.core.services.Toto;

+

+import java.util.Properties;

+

+

+public class TotoProviderGlue implements Toto {

+    

+    Toto m_toto;

+    

+    private int i = 0;

+    public static int toto = 0;

+    public static int toto_2 = 0;

+    public static int toto_3 = 0;

+    public static int toto_4 = 0;

+    public static int toto1 = 0;

+    

+    public int count() {

+        return i;

+    }

+    

+    public void toto() {

+        toto++;

+        m_toto.toto();

+    }

+

+    public void toto(int i, int j) {

+        toto_2++;

+        m_toto.toto(i, j);

+    }

+

+    public String toto(String a) {

+        toto_3++;

+        return a;

+    }

+

+    public String toto(String[] a) {

+        toto_4++;

+        return "toto";

+    }

+

+    public void toto1(String j) {

+        i++;

+        toto1++;

+        m_toto.toto1(j);

+    }

+

+    public Properties getProps() {

+        Properties props = new Properties();

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

+        props.put("gtoto", new Integer(toto));

+        props.put("gtoto_2", new Integer(toto_2));

+        props.put("gtoto_3", new Integer(toto_3));

+        props.put("gtoto_4", new Integer(toto_4));

+        props.put("gtoto1", new Integer(toto1));

+        props.put("glue", "glue");

+        Properties p2 = m_toto.getProps();

+        props.putAll(p2);

+        return props;

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java
new file mode 100644
index 0000000..e31a24a
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/A123/CheckService2.java
@@ -0,0 +1,25 @@
+/* 

+ * 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.runtime.core.services.A123;

+

+public interface CheckService2 {

+	

+	public boolean check();

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java
new file mode 100644
index 0000000..f704138
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BarService.java
@@ -0,0 +1,29 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface BarService {

+	

+	public boolean bar();

+	

+	public Properties getProps();

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java
new file mode 100644
index 0000000..a4c4854
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/BazService.java
@@ -0,0 +1,39 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface BazService {

+

+	boolean foo();

+	

+	Properties fooProps();

+	

+	Boolean getObject();

+	

+	boolean getBoolean();

+	

+	int getInt();

+	

+	long getLong();

+	

+	double getDouble();

+	

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
new file mode 100644
index 0000000..eca0faa
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/CheckService.java
@@ -0,0 +1,31 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface CheckService {

+    

+    public static final String foo = "foo";

+	

+	public boolean check();

+	

+	public Properties getProps();

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
new file mode 100644
index 0000000..37c1a65
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/FooService.java
@@ -0,0 +1,39 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface FooService {

+

+	boolean foo();

+	

+	Properties fooProps();

+	

+	Boolean getObject();

+	

+	boolean getBoolean();

+	

+	int getInt();

+	

+	long getLong();

+	

+	double getDouble();

+	

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Service.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Service.java
new file mode 100644
index 0000000..7b85548
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Service.java
@@ -0,0 +1,7 @@
+package org.apache.felix.ipojo.runtime.core.services;
+
+public interface Service {
+    
+    public int count();
+
+}
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java
new file mode 100644
index 0000000..ba526f5
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tata.java
@@ -0,0 +1,62 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface Tata {

+    

+    public Properties getPropsTata();

+    

+    public void tata();

+    

+    public int tataInt(int i);

+    public long tataLong(long l);

+    public double tataDouble(double d);

+    public char tataChar(char c);

+    public boolean tataBoolean(boolean b);

+    public short tataShort(short s);

+    public float tataFloat(float f);

+    public byte tataByte(byte b);

+    

+    public int[] tataInts(int[] its);

+    public long[] tataLongs(long[] l);

+    public double[] tataDoubles(double[] d);

+    public char[] tataChars(char[] c);

+    public boolean[] tataBooleans(boolean[] b);

+    public short[] tataShorts(short[] s);

+    public float[] tataFloats(float[] f);

+    public byte[] tataBytes(byte[] b);

+    

+    public String tataStr();

+    public String[] tataStrs();

+    

+    public void tata(int i, int j);

+    public void tata(String s);

+    

+    public String tata1(String a);

+    public String tata1(char[] a);

+    

+    public String tata5(String a, int i);

+    public String tata5(String[] a, int i);

+    public String tata5(String a, int[] i);

+    

+    public long add(int i, int j, int k);

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java
new file mode 100644
index 0000000..75ba4d3
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Tota.java
@@ -0,0 +1,78 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface Tota {

+    

+    public static final String specification="specification { " +

+    		"requires { " +

+    		    "$specification=\"org.apache.felix.ipojo.runtime.core.services.Toto\" " +

+    		    "$optional=\"true\" " +

+    		    "$aggregate=\"true\" " +

+    		    "$type=\"service\" " +

+    		"} }"; 

+    

+    public Properties getProps() throws UnsupportedOperationException;;

+    public Properties getPropsTata();

+    

+    public void tata();

+    

+    public int tataInt(int i);

+    public long tataLong(long l);

+    public double tataDouble(double d);

+    public char tataChar(char c);

+    public boolean tataBoolean(boolean b);

+    public short tataShort(short s);

+    public float tataFloat(float f);

+    public byte tataByte(byte b);

+    

+    public int[] tataInts(int[] its);

+    public long[] tataLongs(long[] l);

+    public double[] tataDoubles(double[] d);

+    public char[] tataChars(char[] c);

+    public boolean[] tataBooleans(boolean[] b);

+    public short[] tataShorts(short[] s);

+    public float[] tataFloats(float[] f);

+    public byte[] tataBytes(byte[] b);

+    

+    public String tataStr();

+    public String[] tataStrs();

+    

+    public void tata(int i, int j);

+    public void tata(String s);

+    

+    public String tata1(String a);

+    public String tata1(char[] a);

+    

+    public String tata5(String a, int i);

+    public String tata5(String[] a, int i);

+    public String tata5(String a, int[] i);

+    

+    public long add(int i, int j, int k);

+    

+    public void toto() throws UnsupportedOperationException;    

+    public void toto(int i, int j) throws UnsupportedOperationException;

+    public String toto(String a) throws UnsupportedOperationException;

+    

+    public void toto1(String j) throws UnsupportedOperationException;

+    

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java
new file mode 100644
index 0000000..8ed22ec
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Toto.java
@@ -0,0 +1,37 @@
+/* 

+ * 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.runtime.core.services;

+

+import java.util.Properties;

+

+public interface Toto {

+    

+    public Properties getProps();

+    

+    public void toto();    

+    public void toto(int i, int j);

+    public String toto(String a);

+    public String toto(String[] a);

+    

+    public void toto1(String j);

+    

+    public int count();

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/resources/metadata-providing.xml b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/resources/metadata-providing.xml
new file mode 100644
index 0000000..da0e7b3
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/resources/metadata-providing.xml
@@ -0,0 +1,155 @@
+<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 

+	    org.apache.felix.composite http://felix.apache.org/ipojo/schemas/SNAPSHOT/composite.xsd"

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

+	xmlns:comp="org.apache.felix.ipojo.composite">

+	<comp:composite name="composite.test.3" architecture="true">

+		<subservice action="instantiate"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService"

+			aggregate="true" filter="(factory.name=BazProviderType)" />

+		<comp:provides action="export"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService" />

+	</comp:composite>

+

+	<comp:composite name="composite.test.2" architecture="true">

+		<subservice action="instantiate"

+			specification="org.apache.felix.ipojo.runtime.core.services.CheckService"

+			filter="(factory.name=Baz2CheckProvider)" />

+		<comp:provides action="export"

+			specification="org.apache.felix.ipojo.runtime.core.services.CheckService" />

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService"

+			scope="composite" />

+	</comp:composite>

+

+	<comp:composite name="composite.test.1" architecture="true">

+		<subservice action="instantiate"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService"

+			filter="(factory.name=composite.test.3)" />

+		<subservice action="instantiate"

+			specification="org.apache.felix.ipojo.runtime.core.services.CheckService"

+			filter="(factory.name=composite.test.2)" />

+		<comp:provides action="export"

+			specification="org.apache.felix.ipojo.runtime.core.services.CheckService" />

+	</comp:composite>

+

+	<comp:composite name="composite.instantiator" architecture="true">

+		<subservice action="instantiate"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService"

+			filter="(factory.name=composite.test.3)" />

+		<subservice action="instantiate"

+			specification="org.apache.felix.ipojo.runtime.core.services.FooService" />

+		<comp:provides action="export"

+			specification="org.apache.felix.ipojo.runtime.core.services.BazService" />

+		<comp:provides action="export"

+			specification="org.apache.felix.ipojo.runtime.core.services.FooService" />

+	</comp:composite>

+

+	<!-- Test composition provides -->

+

+	<comp:composite name="comp-0" architecture="true">

+		<subservice action="instantiate"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tata" />

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.Toto" />

+		<comp:provides action="implement"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tota" />

+	</comp:composite>

+

+	<comp:composite name="comp-1" architecture="true">

+		<subservice action="instantiate"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tata" />

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.Toto" />

+		<comp:provides action="implement"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tota">

+			<delegation method="tataInt" policy="One" />

+			<delegation method="toto1" policy="All" />

+		</comp:provides>

+	</comp:composite>

+

+	<comp:composite name="comp-2" architecture="true">

+		<subservice action="instantiate"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tata"

+			aggregate="true" />

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.Toto"

+			aggregate="true" />

+		<comp:provides action="implement"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tota">

+			<delegation method="tataInt" policy="One" />

+			<delegation method="toto1" policy="All" />

+		</comp:provides>

+	</comp:composite>

+

+	<comp:composite name="comp-3" architecture="true">

+		<subservice action="instantiate"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tata" />

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.Toto"

+			optional="true" />

+		<comp:provides action="implement"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tota">

+		</comp:provides>

+	</comp:composite>

+

+	<comp:composite name="comp-4" architecture="true">

+		<subservice action="instantiate"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tata" />

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.Toto"

+			optional="true" />

+		<comp:provides action="implement"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tota">

+			<delegation method="tataInt" policy="One" />

+			<delegation method="toto1" policy="All" />

+		</comp:provides>

+	</comp:composite>

+

+	<comp:composite name="comp-5" architecture="true">

+		<subservice action="instantiate"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tata"

+			aggregate="true" />

+		<!-- <subservice action="import" specification="org.apache.felix.ipojo.test.comp:composite.service.Toto" aggregate ="true" optional="true"/> -->

+		<comp:provides action="implement"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tota">

+			<delegation method="tataInt" policy="One" />

+			<delegation method="toto1" policy="All" />

+		</comp:provides>

+	</comp:composite>

+

+	<comp:composite name="comp-6" architecture="true">

+		<subservice action="instantiate"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tata"

+			aggregate="true" />

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.Toto"

+			aggregate="true" optional="true" />

+		<comp:provides action="implement"

+			specification="org.apache.felix.ipojo.runtime.core.services.Toto">

+			<delegation method="toto1" policy="All" />

+		</comp:provides>

+		<comp:provides action="implement"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tata">

+			<delegation method="tataInt" policy="One" />

+		</comp:provides>

+	</comp:composite>

+

+	<comp:composite name="comp-7" architecture="true">

+		<instance component="tata" />

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.Toto" />

+		<comp:provides action="implement"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tota" />

+	</comp:composite>

+

+	<comp:composite name="comp-8" architecture="true">

+		<instance component="tata" />

+		<instance component="totoglue" />

+		<subservice action="import"

+			specification="org.apache.felix.ipojo.runtime.core.services.Toto" />

+		<comp:provides action="implement"

+			specification="org.apache.felix.ipojo.runtime.core.services.Tota" />

+	</comp:composite>

+</ipojo>

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/resources/metadata.xml b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/resources/metadata.xml
new file mode 100644
index 0000000..6143ff9
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/main/resources/metadata.xml
@@ -0,0 +1,112 @@
+<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

+	    org.apache.felix.composite http://felix.apache.org/ipojo/schemas/SNAPSHOT/composite.xsd"

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

+	xmlns:comp="org.apache.felix.ipojo.composite">

+	<!-- Used component type -->

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"

+		name="COMPO-FooProviderType-1" architecture="true">

+		<provides />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderType1"

+		name="COMPO-FooProviderType-2" architecture="true">

+		<provides>

+			<property name="int" type="int" value="2" />

+			<property name="long" type="long" value="40" />

+			<property name="string" type="java.lang.String" value="foo" />

+			<property name="strAProp" type="java.lang.String[]"

+				value="{foo, bar}" />

+			<property name="intAProp" type="int[]" value="{1,2,3}" />

+		</provides>

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderTypeDyn"

+		name="COMPO-FooProviderType-Dyn" architecture="true">

+		<provides>

+			<property name="int" field="intProp" value="2" />

+			<property name="boolean" field="boolProp" value="false" />

+			<property name="string" field="strProp" value="foo" />

+			<property name="strAProp" field="strAProp"

+				value="{foo, bar}" />

+			<property name="intAProp" field="intAProp" value="{ 1,2,3}" />

+		</provides>

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooProviderTypeDyn2"

+		name="COMPO-FooProviderType-Dyn2" architecture="true">

+		<provides>

+			<property name="int" field="intProp" value="4" />

+			<property name="boolean" field="boolProp" />

+			<property name="string" field="strProp" />

+			<property name="strAProp" field="strAProp" />

+			<property name="intAProp" field="intAProp"

+				value="{1, 2,3 }" />

+		</provides>

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.CheckServiceProvider"

+		name="COMPO-SimpleCheckServiceProvider" architecture="true">

+		<requires field="fs" />

+		<provides />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"

+		name="COMPO-FooBarProviderType-1" architecture="true">

+		<provides />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"

+		name="COMPO-FooBarProviderType-2" architecture="true">

+		<provides

+			specifications="{org.apache.felix.ipojo.runtime.core.services.FooService, org.apache.felix.ipojo.runtime.core.services.BarService }" />

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.FooBarProviderType1"

+		name="COMPO-FooBarProviderType-3" architecture="true">

+		<provides

+			specifications="{org.apache.felix.ipojo.runtime.core.services.FooService}">

+			<property name="baz" type="java.lang.String" value="foo" />

+		</provides>

+		<provides

+			specifications="{org.apache.felix.ipojo.runtime.core.services.BarService}">

+			<property name="baz" type="java.lang.String" value="bar" />

+		</provides>

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.BazProviderType1"

+		name="BazProviderType">

+		<provides />

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.TataProvider"

+		name="tata">

+		<provides />

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.TotoProvider"

+		name="toto" architecture="true">

+		<provides />

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.runtime.core.components.TotoProviderGlue"

+		name="totoglue">

+		<requires field="m_toto" scope="composite" />

+	</component>

+

+	<!--  Composite -->

+	<comp:composite name="composite.empty" architecture="true">

+	</comp:composite>

+

+	<component classname="org.apache.felix.ipojo.runtime.core.components.Baz2CheckProvider" name="Baz2CheckProvider" architecture="true">

+		<requires field="fs" scope="composite"/>

+		<provides/>

+	</component>

+

+</ipojo>

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
new file mode 100644
index 0000000..25ddc06
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
@@ -0,0 +1,225 @@
+package org.apache.felix.ipojo.runtime.core;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.ServiceContext;
+import org.apache.felix.ipojo.composite.CompositeManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.CompositeOption;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
+import org.ops4j.pax.tinybundles.core.TinyBundle;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.ow2.chameleon.testing.helpers.IPOJOHelper;
+import org.ow2.chameleon.testing.helpers.OSGiHelper;
+import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static junit.framework.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.*;
+
+/**
+ * Bootstrap the test from this project
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerMethod.class)
+public class Common {
+
+    @Inject
+    protected
+    BundleContext bc;
+
+    protected OSGiHelper osgiHelper;
+    protected IPOJOHelper ipojoHelper;
+
+    protected boolean deployTestedBundle = true;
+
+    @Configuration
+    public Option[] config() throws IOException {
+        Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
+        root.setLevel(Level.INFO);
+
+        if (deployTestedBundle) {
+            return options(
+                    cleanCaches(),
+                    ipojoBundles(),
+                    junitBundles(),
+                    testedBundle(),
+                    systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+            );
+        } else {
+            return options(
+                    cleanCaches(),
+                    ipojoBundles(),
+                    junitBundles(),
+                    systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
+            );
+        }
+    }
+
+    public static Option junitAndMockitoBundles() {
+        return new DefaultCompositeOption(
+                // Repository required to load harmcrest (OSGi-fied version).
+                repository("http://repository.springsource.com/maven/bundles/external").id(
+                        "com.springsource.repository.bundles.external"),
+
+                // Mockito without Hamcrest and Objenesis
+                mavenBundle("org.mockito", "mockito-core", "1.9.5"),
+
+                // Hamcrest with a version matching the range expected by Mockito
+                mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
+
+                // Objenesis with a version matching the range expected by Mockito
+                wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
+                        .exports("*;version=1.2"),
+
+                // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
+                // 4.9 which does not match the Mockito import.
+                CoreOptions.junitBundles(),
+
+                /*
+                 * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
+                 * java.lang.LinkageError: loader constraint violation in interface itable initialization:
+                 * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
+                 * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
+                 * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
+                 * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
+                 * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
+                 * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
+                 * proxy/Callback used in the signature
+                 *
+                 * So we disable the bootdelegation.
+                 */
+                frameworkProperty("felix.bootdelegation.implicit").value("false")
+        );
+    }
+
+
+    @Before
+    public void commonSetUp() {
+        osgiHelper = new OSGiHelper(bc);
+        ipojoHelper = new IPOJOHelper(bc);
+
+        // Dump OSGi Framework information
+        String vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VENDOR);
+        if (vendor == null) {
+            vendor = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
+        }
+        String version = (String) osgiHelper.getBundle(0).getHeaders().get(Constants.BUNDLE_VERSION);
+        System.out.println("OSGi Framework : " + vendor + " - " + version);
+    }
+
+    @After
+    public void commonTearDown() {
+        ipojoHelper.dispose();
+        osgiHelper.dispose();
+    }
+
+    public BundleContext getContext() {
+        return bc;
+    }
+
+    public static ServiceContext getServiceContext(ComponentInstance ci) {
+        if (ci instanceof CompositeManager) {
+            return ((CompositeManager) ci).getServiceContext();
+        } else {
+            throw new RuntimeException("Cannot get the service context from a non composite instance");
+        }
+    }
+
+    public CompositeOption ipojoBundles() {
+        return new DefaultCompositeOption(
+                mavenBundle("org.apache.felix", "org.apache.felix.ipojo").versionAsInProject(),
+                mavenBundle("org.apache.felix", "org.apache.felix.ipojo.composite").versionAsInProject(),
+                mavenBundle("org.ow2.chameleon.testing", "osgi-helpers").versionAsInProject(),
+                // configuration admin
+                mavenBundle("org.apache.felix",  "org.apache.felix.configadmin").versionAsInProject()
+        );
+    }
+
+    public Option testedBundle() throws MalformedURLException {
+        File out = new File("target/tested/bundle.jar");
+        if (out.exists()) {
+            return bundle(out.toURI().toURL().toExternalForm());
+        }
+
+        TinyBundle tested = TinyBundles.bundle();
+
+        // We look inside target/classes to find the class and resources
+        File classes = new File("target/classes");
+        Collection<File> files = FileUtils.listFilesAndDirs(classes, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
+        List<File> services = new ArrayList<File>();
+        for (File file : files) {
+            if (file.isDirectory()) {
+                // By convention we export of .services and .service package
+                if (file.getName().endsWith("services")  || file.getName().endsWith("service")) {
+                    services.add(file);
+                }
+            } else {
+                // We need to compute the path
+                String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+                tested.add(path, file.toURI().toURL());
+                System.out.println(file.getName() + " added to " + path);
+            }
+        }
+
+        // Export the inherited package, components and strategies
+        String export = "org.apache.felix.ipojo.runtime.core.components";
+        for (File file : services) {
+            if (export.length() > 0) { export += ", "; }
+            String path = file.getAbsolutePath().substring(classes.getAbsolutePath().length() +1);
+            String packageName = path.replace('/', '.');
+            export += packageName;
+        }
+
+        System.out.println("Exported packages : " + export);
+
+        InputStream inputStream = tested
+                .set(Constants.BUNDLE_SYMBOLICNAME, "test.bundle")
+                .set(Constants.IMPORT_PACKAGE, "*")
+                .set(Constants.EXPORT_PACKAGE, export)
+                .build(IPOJOStrategy.withiPOJO(new File("src/main/resources")));
+
+        try {
+            org.apache.commons.io.FileUtils.copyInputStreamToFile(inputStream, out);
+            return bundle(out.toURI().toURL().toExternalForm());
+        } catch (MalformedURLException e) {
+            throw new RuntimeException("Cannot compute the url of the manipulated bundle");
+        } catch (IOException e) {
+            throw new RuntimeException("Cannot write of the manipulated bundle");
+        }
+    }
+
+    public void assertContains(String s, String[] arrays, String object) {
+        for (String suspect : arrays) {
+            if (object.equals(suspect)) {
+                return;
+            }
+        }
+        fail("Assertion failed : " + s);
+    }
+
+
+}
diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestCompositeAPI.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestCompositeAPI.java
new file mode 100644
index 0000000..1effcb4
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/TestCompositeAPI.java
@@ -0,0 +1,184 @@
+/* 

+ * 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.runtime.core;

+

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

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

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

+import org.apache.felix.ipojo.runtime.core.services.BazService;

+import org.apache.felix.ipojo.runtime.core.services.CheckService;

+import org.apache.felix.ipojo.runtime.core.services.FooService;

+import org.junit.Test;

+import org.osgi.framework.InvalidSyntaxException;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestCompositeAPI extends Common {

+

+    @Test

+    public void testAPI() {

+        Factory fact1 = ipojoHelper.getFactory("composite.empty");

+        Properties p = new Properties();

+        p.put("instance.name", "empty-1");

+        ComponentInstance empty = null;

+        try {

+            empty = fact1.createComponentInstance(p);

+        } catch (Exception e) {

+            e.printStackTrace();

+            fail(e.getMessage());

+        }

+

+        ServiceContext sc = getServiceContext(empty);

+

+        Factory fact2 = ipojoHelper.getFactory("composite.test.2");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "2"); // 2

+        Factory fact3 = ipojoHelper.getFactory("composite.test.3");

+        Properties props3 = new Properties();

+        props3.put("instance.name", "3");

+        ComponentInstance comp2 = null;

+        ComponentInstance comp3 = null;

+        try {

+            comp2 = fact2.createComponentInstance(props2, sc);

+            comp3 = fact3.createComponentInstance(props3, sc);

+        } catch (Throwable e) {

+            e.printStackTrace();

+            fail(e.getMessage());

+        }

+

+        assertTrue("Test comp3", comp3.getState() == ComponentInstance.VALID);

+        assertTrue("Test comp2", comp2.getState() == ComponentInstance.VALID);

+

+        ServiceReference ref = null;

+

+        ref = ipojoHelper.getServiceReferenceByName(sc, CheckService.class.getName(), "2"); // 2

+

+        assertNotNull("Check ref", ref);

+        CheckService cs = (CheckService) sc.getService(ref);

+        assertTrue("Check invoke", cs.check());

+

+        comp3.dispose();

+        comp2.dispose();

+        empty.dispose();

+    }

+

+    @Test

+    public void testInstantiator() {

+        String type = "composite.instantiator";

+        Factory fact = ipojoHelper.getFactory(type);

+        ComponentInstance ci = null;

+        Properties p = new Properties();

+        p.put("instance.name", "mon_coeur");

+        try {

+            ci = fact.createComponentInstance(p);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        assertTrue("Check ci", ci.getState() == ComponentInstance.VALID);

+        ServiceReference ref = ipojoHelper.getServiceReferenceByName(BazService.class.getName(), "mon_coeur");

+        assertNotNull("Check ref", ref);

+        BazService bs = (BazService) getContext().getService(ref);

+        assertTrue("Check invocation", bs.foo());

+        getContext().ungetService(ref);

+        ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), "mon_coeur");

+        assertNotNull("Check ref 2 ", ref);

+        FooService fs = (FooService) getContext().getService(ref);

+        assertTrue("Check invocation", fs.foo());

+        getContext().ungetService(ref);

+        ci.dispose();

+    }

+

+    @Test

+    public void testAPI2() {

+        Factory fact1 = ipojoHelper.getFactory("composite.empty");

+        Properties p = new Properties();

+        p.put("instance.name", "empty-2");

+        ComponentInstance empty = null;

+        try {

+            empty = fact1.createComponentInstance(p);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        ServiceContext sc = getServiceContext(empty);

+

+        Factory fact2 = ipojoHelper.getFactory(sc, "composite.test.2");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "4");

+        Factory fact3 = ipojoHelper.getFactory(sc, "composite.test.3");

+        Properties props3 = new Properties();

+        props3.put("instance.name", "5");

+        ComponentInstance comp2 = null;

+        ComponentInstance comp3 = null;

+        try {

+            comp2 = fact2.createComponentInstance(props2, sc);

+            comp3 = fact3.createComponentInstance(props3, sc);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        assertTrue("Test comp3", comp3.getState() == ComponentInstance.VALID);

+        assertTrue("Test comp2", comp2.getState() == ComponentInstance.VALID);

+

+        ServiceReference ref = null;

+

+        ref = ipojoHelper.getServiceReferenceByName(sc, CheckService.class.getName(), "4");

+

+        assertNotNull("Check ref", ref);

+        CheckService cs = (CheckService) sc.getService(ref);

+        assertTrue("Check invoke", cs.check());

+

+        comp3.dispose();

+        comp2.dispose();

+        empty.dispose();

+    }

+

+    @Test

+    public void testApplication() {

+        Factory factory = ipojoHelper.getFactory("composite.test.1");

+        ComponentInstance ci = null;

+        Properties props = new Properties();

+        props.put("instance.name", "Test");

+        try {

+            ci = factory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot instantiate Test " + e.getMessage());

+        }

+

+        assertTrue("Check ci state", ci.getState() == ComponentInstance.VALID);

+

+        ServiceReference[] refs = null;

+        try {

+            refs = getContext().getServiceReferences(CheckService.class.getName(), "(instance.name=Test)");

+        } catch (InvalidSyntaxException e) {

+            fail("Invalid filter : " + e.getMessage());

+        }

+        assertNotNull("Check refs not null", refs);

+        CheckService cs = (CheckService) getContext().getService(refs[0]);

+

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

+        ci.dispose();

+

+    }

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp0.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp0.java
new file mode 100644
index 0000000..de6eb67
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp0.java
@@ -0,0 +1,343 @@
+/* 

+ * 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.runtime.core.providing;

+

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

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.components.TotoProvider;

+import org.apache.felix.ipojo.runtime.core.services.Tota;

+import org.apache.felix.ipojo.runtime.core.services.Toto;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestComp0 extends Common {

+

+    private ComponentFactory tataFactory;

+    private ComponentFactory totoFactory;

+    private ComponentFactory tataFactory2;

+    private ComponentInstance totoProv, totoProv2;

+    private ComponentInstance under;

+

+    @Before

+    public void setUp() {

+        tataFactory = (ComponentFactory) ipojoHelper.getFactory("tata");

+        totoFactory = (ComponentFactory) ipojoHelper.getFactory("toto");

+        tataFactory2 = (ComponentFactory) ipojoHelper.getFactory("comp-6");

+        tataFactory2.stop();

+        tataFactory.stop();

+

+        Properties props = new Properties();

+        props.put("instance.name", "toto provider");

+        try {

+            totoProv = totoFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            fail("Cannot create an instance : " + e.getMessage());

+        }

+

+        Properties props3 = new Properties();

+        props3.put("instance.name", "toto provider 2");

+        try {

+            totoProv2 = totoFactory.createComponentInstance(props3);

+        } catch (Exception e) {

+            fail("Cannot create an instance : " + e.getMessage());

+        }

+

+        totoProv.stop();

+        totoProv2.stop();

+

+        Factory factory = ipojoHelper.getFactory("comp-0");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "ff");

+        try {

+            under = factory.createComponentInstance(props2);

+        } catch (Exception e) {

+            e.printStackTrace();

+            fail("Cannot create an instance : " + e.getMessage());

+        }

+    }

+

+    @After

+    public void tearDown() {

+        tataFactory.start();

+        totoProv.dispose();

+        totoProv = null;

+        totoProv2.dispose();

+        totoProv2 = null;

+        tataFactory2.start();

+

+        // Reset counters

+        TotoProvider.toto = 0;

+        TotoProvider.toto_2 = 0;

+        TotoProvider.toto_3 = 0;

+        TotoProvider.toto_4 = 0;

+        TotoProvider.toto1 = 0;

+    }

+

+    @Test

+    public void testSimple() {

+        // Neither factory nor instance

+        assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));

+

+        // Start the importer

+        totoProv.start();

+        assertNotNull("Assert toto service - 1", getContext().getServiceReference(Toto.class.getName()));

+        assertTrue("Assert under state - 2", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));

+

+        // Start the factory

+        tataFactory.start();

+        assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));

+        ServiceReference ref = getContext().getServiceReference(Tota.class.getName());

+        Tota tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        Properties props = tota.getProps();

+        Integer toto = (Integer) props.get("toto");

+        Integer toto_2 = (Integer) props.get("toto_2");

+        Integer toto_3 = (Integer) props.get("toto_3");

+        Integer toto_4 = (Integer) props.get("toto_4");

+        assertEquals("Assert toto - 3", toto.intValue(), 1);

+        assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);

+        assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);

+        assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);

+        //Check tata

+        props = tota.getPropsTata();

+        Integer tata = (Integer) props.get("tata");

+        Integer tataStr = (Integer) props.get("tataStr");

+        Integer tataStrs = (Integer) props.get("tataStrs");

+        Integer tata_2 = (Integer) props.get("tata_2");

+        Integer tata_3 = (Integer) props.get("tata_3");

+        Integer tata1 = (Integer) props.get("tata1");

+        Integer tata1_1 = (Integer) props.get("tata1_1");

+        Integer tata5 = (Integer) props.get("tata5");

+        Integer tata5_1 = (Integer) props.get("tata5_1");

+        Integer tata5_2 = (Integer) props.get("tata5_2");

+        assertEquals("Assert tata - 3", tata.intValue(), 1);

+        assertEquals("Assert tataStr - 3", tataStr.intValue(), 1);

+        assertEquals("Assert tataStrs - 3", tataStrs.intValue(), 0);

+        assertEquals("Assert tata_2 - 3", tata_2.intValue(), 1);

+        assertEquals("Assert tata_3 - 3", tata_3.intValue(), 1);

+        assertEquals("Assert tata1 - 3", tata1.intValue(), 1);

+        assertEquals("Assert tata1_1 - 3", tata1_1.intValue(), 1);

+        assertEquals("Assert tata5 - 3", tata5.intValue(), 1);

+        assertEquals("Assert tata5_1 - 3", tata5_1.intValue(), 1);

+        assertEquals("Assert tata5_2 - 3", tata5_2.intValue(), 1);

+

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Start a second import

+        totoProv2.start();

+        assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        props = tota.getProps();

+        toto = (Integer) props.get("toto");

+        toto_2 = (Integer) props.get("toto_2");

+        toto_3 = (Integer) props.get("toto_3");

+        toto_4 = (Integer) props.get("toto_4");

+        assertEquals("Assert toto - 4", toto.intValue(), 2);

+        assertEquals("Assert toto_2 - 4", toto_2.intValue(), 2);

+        assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);

+        assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        tataStr = (Integer) props.get("tataStr");

+        tataStrs = (Integer) props.get("tataStrs");

+        tata_2 = (Integer) props.get("tata_2");

+        tata_3 = (Integer) props.get("tata_3");

+        tata1 = (Integer) props.get("tata1");

+        tata1_1 = (Integer) props.get("tata1_1");

+        tata5 = (Integer) props.get("tata5");

+        tata5_1 = (Integer) props.get("tata5_1");

+        tata5_2 = (Integer) props.get("tata5_2");

+        assertEquals("Assert tata - 4", tata.intValue(), 2);

+        assertEquals("Assert tataStr - 4", tataStr.intValue(), 2);

+        assertEquals("Assert tataStrs - 4", tataStrs.intValue(), 0);

+        assertEquals("Assert tata_2 - 4", tata_2.intValue(), 2);

+        assertEquals("Assert tata_3 - 4", tata_3.intValue(), 2);

+        assertEquals("Assert tata1 - 4", tata1.intValue(), 2);

+        assertEquals("Assert tata1_1 - 4", tata1_1.intValue(), 2);

+        assertEquals("Assert tata5 - 4", tata5.intValue(), 2);

+        assertEquals("Assert tata5_1 - 4", tata5_1.intValue(), 2);

+        assertEquals("Assert tata5_2 - 4", tata5_2.intValue(), 2);

+

+        getContext().ungetService(ref);

+        tota = null;

+

+        tataFactory.stop();

+        assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));

+

+        totoProv2.stop();

+        tataFactory.start();

+        assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        props = tota.getProps();

+        toto = (Integer) props.get("toto");

+        toto_2 = (Integer) props.get("toto_2");

+        toto_3 = (Integer) props.get("toto_3");

+        toto_4 = (Integer) props.get("toto_4");

+        assertEquals("Assert toto - 6", toto.intValue(), 3);

+        assertEquals("Assert toto_2 - 6", toto_2.intValue(), 3);

+        assertEquals("Assert toto_3 - 6", toto_3.intValue(), 3);

+        assertEquals("Assert toto_4 - 6", toto_4.intValue(), 0);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        tataStr = (Integer) props.get("tataStr");

+        tataStrs = (Integer) props.get("tataStrs");

+        tata_2 = (Integer) props.get("tata_2");

+        tata_3 = (Integer) props.get("tata_3");

+        tata1 = (Integer) props.get("tata1");

+        tata1_1 = (Integer) props.get("tata1_1");

+        tata5 = (Integer) props.get("tata5");

+        tata5_1 = (Integer) props.get("tata5_1");

+        tata5_2 = (Integer) props.get("tata5_2");

+        assertEquals("Assert tata - 6", tata.intValue(), 1);

+        assertEquals("Assert tataStr - 6", tataStr.intValue(), 1);

+        assertEquals("Assert tataStrs - 6", tataStrs.intValue(), 0);

+        assertEquals("Assert tata_2 - 6", tata_2.intValue(), 1);

+        assertEquals("Assert tata_3 - 6", tata_3.intValue(), 1);

+        assertEquals("Assert tata1 - 6", tata1.intValue(), 1);

+        assertEquals("Assert tata1_1 - 6", tata1_1.intValue(), 1);

+        assertEquals("Assert tata5 - 6", tata5.intValue(), 1);

+        assertEquals("Assert tata5_1 - 6", tata5_1.intValue(), 1);

+        assertEquals("Assert tata5_2 - 6", tata5_2.intValue(), 1);

+

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Is arch exposed

+        assertNotNull("Test arch", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "ff"));

+

+        totoProv.stop();

+

+        assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);

+        assertNotNull("Test arch-2", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "ff"));

+        assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));

+

+        under.dispose();

+        under = null;

+    }

+

+    private void invoke(Tota tota) {

+        tota.tata();

+

+        assertEquals("Assert invoke tataint", tota.tataInt(2), 2);

+        assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);

+        assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2, 0);

+        assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');

+        assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));

+        assertEquals("Assert invoke tataByte", tota.tataByte((byte) 2), 2);

+        assertEquals("Assert invoke tataShort", tota.tataShort((short) 5), 5);

+        assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5, 0);

+

+    }

+

+    private void invokeArrays(Tota tota) {

+

+        int[] a = new int[]{1, 2, 3};

+        assertEquals("Assert invoke tataint[]", tota.tataInts(a), a);

+

+        long[] b = new long[]{1, 2, 3};

+        assertEquals("Assert invoke tataLong[]", tota.tataLongs(b), b);

+

+        double[] c = new double[]{1, 2, 3};

+        assertEquals("Assert invoke tataDouble[]", tota.tataDoubles(c), c);

+

+        char[] d = new char[]{'a', 'b', 'c'};

+        assertEquals("Assert invoke tataChar[]", tota.tataChars(d), d);

+

+        boolean[] e = new boolean[]{true, false};

+        assertEquals("Assert invoke tataBoolean[]", tota.tataBooleans(e), e);

+

+        byte[] f = new byte[]{(byte) 1};

+        assertEquals("Assert invoke tataByte[]", tota.tataBytes(f), f);

+

+        short[] g = new short[]{(short) 1};

+        assertEquals("Assert invoke tataShort[]", tota.tataShorts(g), g);

+

+        float[] h = new float[]{5, 6, 7};

+        assertEquals("Assert invoke tataFloat[]", tota.tataFloats(h), h);

+

+    }

+

+    private void invokeStr(Tota tota) {

+        tota.tataStr();

+    }

+

+    private void invokeTata(Tota tota) {

+        tota.tata(1, 2);

+        tota.tata("tototototo");

+    }

+

+    private void invokeTata1(Tota tota) {

+        assertEquals("Assert tata1", tota.tata1("foo"), "foo");

+        assertEquals("Assert tata1 - 2", tota.tata1(new char[]{'a', 'b', 'c'}), "abc");

+    }

+

+    private void invokeTata5(Tota tota) {

+        assertEquals("Assert tata5 -1", tota.tata5("foo", 1), "foo" + 1);

+        assertEquals("Assert tata5 - 2", tota.tata5(new String[]{"a", "b", "c"}, 1), "31");

+        assertEquals("Assert tata5 - 3", tota.tata5("foo", new int[]{1, 2, 3}), "foo3");

+    }

+

+    private void invokeAdd(Tota tota) {

+        assertEquals("Assert add", tota.add(1, 1, 1), 3);

+    }

+

+    private void invokeToto(Tota tota) {

+        tota.toto();

+        assertEquals("Assert toto", tota.toto("foo"), "foo");

+        tota.toto(1, 2);

+    }

+

+    private void invokeAll(Tota tota) {

+        invoke(tota);

+        invokeArrays(tota);

+        invokeStr(tota);

+        invokeTata(tota);

+        invokeTata1(tota);

+        invokeTata5(tota);

+        invokeAdd(tota);

+        invokeToto(tota);

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp1.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp1.java
new file mode 100644
index 0000000..cec2ce8
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp1.java
@@ -0,0 +1,341 @@
+/* 

+ * 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.runtime.core.providing;

+

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

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.components.TotoProvider;

+import org.apache.felix.ipojo.runtime.core.services.Tota;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestComp1 extends Common {

+

+    private ComponentFactory tataFactory;

+    private ComponentFactory totoFactory;

+    private ComponentInstance totoProv, totoProv2;

+    private ComponentInstance under;

+    private ComponentFactory tataFactory2;

+

+    @Before

+    public void setUp() {

+        tataFactory = (ComponentFactory) ipojoHelper.getFactory("tata");

+        totoFactory = (ComponentFactory) ipojoHelper.getFactory("toto");

+        tataFactory2 = (ComponentFactory) ipojoHelper.getFactory("comp-6");

+        tataFactory2.stop();

+

+        tataFactory.stop();

+

+        Properties props = new Properties();

+        props.put("instance.name", "toto provider");

+        try {

+            totoProv = totoFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        Properties props3 = new Properties();

+        props3.put("instance.name", "toto provider 2");

+        try {

+            totoProv2 = totoFactory.createComponentInstance(props3);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        totoProv.stop();

+        totoProv2.stop();

+

+        Factory factory = ipojoHelper.getFactory("comp-1");

+        Properties props2 = new Properties();

+        try {

+            under = factory.createComponentInstance(props2);

+        } catch (Exception e) {

+            fail("Cannot create the instance : " + e.getMessage());

+        }

+

+    }

+

+    @After

+    public void tearDown() {

+        tataFactory.start();

+        totoProv.dispose();

+        totoProv = null;

+        totoProv2.dispose();

+        totoProv2 = null;

+        tataFactory2.start();

+

+        // Reset counters

+        TotoProvider.toto = 0;

+        TotoProvider.toto_2 = 0;

+        TotoProvider.toto_3 = 0;

+        TotoProvider.toto_4 = 0;

+        TotoProvider.toto1 = 0;

+    }

+

+    @Test

+    public void testSimple() {

+        // Neither factory nor instance

+        assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));

+

+        // Start the importer

+        totoProv.start();

+        assertTrue("Assert under state - 2 (" + under.getState() + ")", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));

+

+        // Start the factory

+        tataFactory.start();

+        assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));

+        ServiceReference ref = getContext().getServiceReference(Tota.class.getName());

+        Tota tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        Properties props = tota.getProps();

+        Integer toto = (Integer) props.get("toto");

+        Integer toto_2 = (Integer) props.get("toto_2");

+        Integer toto_3 = (Integer) props.get("toto_3");

+        Integer toto_4 = (Integer) props.get("toto_4");

+        assertEquals("Assert toto - 3 (" + toto.intValue() + ")", toto.intValue(), 1);

+        assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);

+        assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);

+        assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);

+        //Check tata

+        props = tota.getPropsTata();

+        Integer tata = (Integer) props.get("tata");

+        Integer tataStr = (Integer) props.get("tataStr");

+        Integer tataStrs = (Integer) props.get("tataStrs");

+        Integer tata_2 = (Integer) props.get("tata_2");

+        Integer tata_3 = (Integer) props.get("tata_3");

+        Integer tata1 = (Integer) props.get("tata1");

+        Integer tata1_1 = (Integer) props.get("tata1_1");

+        Integer tata5 = (Integer) props.get("tata5");

+        Integer tata5_1 = (Integer) props.get("tata5_1");

+        Integer tata5_2 = (Integer) props.get("tata5_2");

+        assertEquals("Assert tata - 3", tata.intValue(), 1);

+        assertEquals("Assert tataStr - 3", tataStr.intValue(), 1);

+        assertEquals("Assert tataStrs - 3", tataStrs.intValue(), 0);

+        assertEquals("Assert tata_2 - 3", tata_2.intValue(), 1);

+        assertEquals("Assert tata_3 - 3", tata_3.intValue(), 1);

+        assertEquals("Assert tata1 - 3", tata1.intValue(), 1);

+        assertEquals("Assert tata1_1 - 3", tata1_1.intValue(), 1);

+        assertEquals("Assert tata5 - 3", tata5.intValue(), 1);

+        assertEquals("Assert tata5_1 - 3", tata5_1.intValue(), 1);

+        assertEquals("Assert tata5_2 - 3", tata5_2.intValue(), 1);

+

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Start a second import

+        totoProv2.start();

+        assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        props = tota.getProps();

+        toto = (Integer) props.get("toto");

+        toto_2 = (Integer) props.get("toto_2");

+        toto_3 = (Integer) props.get("toto_3");

+        toto_4 = (Integer) props.get("toto_4");

+        assertEquals("Assert toto - 4", toto.intValue(), 2);

+        assertEquals("Assert toto_2 - 4", toto_2.intValue(), 2);

+        assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);

+        assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        tataStr = (Integer) props.get("tataStr");

+        tataStrs = (Integer) props.get("tataStrs");

+        tata_2 = (Integer) props.get("tata_2");

+        tata_3 = (Integer) props.get("tata_3");

+        tata1 = (Integer) props.get("tata1");

+        tata1_1 = (Integer) props.get("tata1_1");

+        tata5 = (Integer) props.get("tata5");

+        tata5_1 = (Integer) props.get("tata5_1");

+        tata5_2 = (Integer) props.get("tata5_2");

+        assertEquals("Assert tata - 4", tata.intValue(), 2);

+        assertEquals("Assert tataStr - 4", tataStr.intValue(), 2);

+        assertEquals("Assert tataStrs - 4", tataStrs.intValue(), 0);

+        assertEquals("Assert tata_2 - 4", tata_2.intValue(), 2);

+        assertEquals("Assert tata_3 - 4", tata_3.intValue(), 2);

+        assertEquals("Assert tata1 - 4", tata1.intValue(), 2);

+        assertEquals("Assert tata1_1 - 4", tata1_1.intValue(), 2);

+        assertEquals("Assert tata5 - 4", tata5.intValue(), 2);

+        assertEquals("Assert tata5_1 - 4", tata5_1.intValue(), 2);

+        assertEquals("Assert tata5_2 - 4", tata5_2.intValue(), 2);

+

+        getContext().ungetService(ref);

+        tota = null;

+

+        tataFactory.stop();

+        assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));

+

+        totoProv2.stop();

+        tataFactory.start();

+        assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        props = tota.getProps();

+        toto = (Integer) props.get("toto");

+        toto_2 = (Integer) props.get("toto_2");

+        toto_3 = (Integer) props.get("toto_3");

+        toto_4 = (Integer) props.get("toto_4");

+        assertEquals("Assert toto - 6", toto.intValue(), 3);

+        assertEquals("Assert toto_2 - 6", toto_2.intValue(), 3);

+        assertEquals("Assert toto_3 - 6", toto_3.intValue(), 3);

+        assertEquals("Assert toto_4 - 6", toto_4.intValue(), 0);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        tataStr = (Integer) props.get("tataStr");

+        tataStrs = (Integer) props.get("tataStrs");

+        tata_2 = (Integer) props.get("tata_2");

+        tata_3 = (Integer) props.get("tata_3");

+        tata1 = (Integer) props.get("tata1");

+        tata1_1 = (Integer) props.get("tata1_1");

+        tata5 = (Integer) props.get("tata5");

+        tata5_1 = (Integer) props.get("tata5_1");

+        tata5_2 = (Integer) props.get("tata5_2");

+        assertEquals("Assert tata - 6", tata.intValue(), 1);

+        assertEquals("Assert tataStr - 6", tataStr.intValue(), 1);

+        assertEquals("Assert tataStrs - 6", tataStrs.intValue(), 0);

+        assertEquals("Assert tata_2 - 6", tata_2.intValue(), 1);

+        assertEquals("Assert tata_3 - 6", tata_3.intValue(), 1);

+        assertEquals("Assert tata1 - 6", tata1.intValue(), 1);

+        assertEquals("Assert tata1_1 - 6", tata1_1.intValue(), 1);

+        assertEquals("Assert tata5 - 6", tata5.intValue(), 1);

+        assertEquals("Assert tata5_1 - 6", tata5_1.intValue(), 1);

+        assertEquals("Assert tata5_2 - 6", tata5_2.intValue(), 1);

+

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Is arch exposed

+        assertNotNull("Test arch", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), under.getInstanceName()));

+

+        totoProv.stop();

+

+        assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);

+        assertNotNull("Test arch-2", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), under.getInstanceName()));

+        assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));

+

+        under.dispose();

+        under = null;

+    }

+

+    private void invoke(Tota tota) {

+        tota.tata();

+

+        assertEquals("Assert invoke tataint", tota.tataInt(2), 2);

+        assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);

+        assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2, 0);

+        assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');

+        assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));

+        assertEquals("Assert invoke tataByte", tota.tataByte((byte) 2), 2);

+        assertEquals("Assert invoke tataShort", tota.tataShort((short) 5), 5);

+        assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5, 0);

+

+    }

+

+    private void invokeArrays(Tota tota) {

+

+        int[] a = new int[]{1, 2, 3};

+        assertEquals("Assert invoke tataint[]", tota.tataInts(a), a);

+

+        long[] b = new long[]{1, 2, 3};

+        assertEquals("Assert invoke tataLong[]", tota.tataLongs(b), b);

+

+        double[] c = new double[]{1, 2, 3};

+        assertEquals("Assert invoke tataDouble[]", tota.tataDoubles(c), c);

+

+        char[] d = new char[]{'a', 'b', 'c'};

+        assertEquals("Assert invoke tataChar[]", tota.tataChars(d), d);

+

+        boolean[] e = new boolean[]{true, false};

+        assertEquals("Assert invoke tataBoolean[]", tota.tataBooleans(e), e);

+

+        byte[] f = new byte[]{(byte) 1};

+        assertEquals("Assert invoke tataByte[]", tota.tataBytes(f), f);

+

+        short[] g = new short[]{(short) 1};

+        assertEquals("Assert invoke tataShort[]", tota.tataShorts(g), g);

+

+        float[] h = new float[]{5, 6, 7};

+        assertEquals("Assert invoke tataFloat[]", tota.tataFloats(h), h);

+

+    }

+

+    private void invokeStr(Tota tota) {

+        tota.tataStr();

+    }

+

+    private void invokeTata(Tota tota) {

+        tota.tata(1, 2);

+        tota.tata("tototototo");

+    }

+

+    private void invokeTata1(Tota tota) {

+        assertEquals("Assert tata1", tota.tata1("foo"), "foo");

+        assertEquals("Assert tata1 - 2", tota.tata1(new char[]{'a', 'b', 'c'}), "abc");

+    }

+

+    private void invokeTata5(Tota tota) {

+        assertEquals("Assert tata5 -1", tota.tata5("foo", 1), "foo" + 1);

+        assertEquals("Assert tata5 - 2", tota.tata5(new String[]{"a", "b", "c"}, 1), "31");

+        assertEquals("Assert tata5 - 3", tota.tata5("foo", new int[]{1, 2, 3}), "foo3");

+    }

+

+    private void invokeAdd(Tota tota) {

+        assertEquals("Assert add", tota.add(1, 1, 1), 3);

+    }

+

+    private void invokeToto(Tota tota) {

+        tota.toto();

+        assertEquals("Assert toto", tota.toto("foo"), "foo");

+        tota.toto(1, 2);

+    }

+

+    private void invokeAll(Tota tota) {

+        invoke(tota);

+        invokeArrays(tota);

+        invokeStr(tota);

+        invokeTata(tota);

+        invokeTata1(tota);

+        invokeTata5(tota);

+        invokeAdd(tota);

+        invokeToto(tota);

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp2.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp2.java
new file mode 100644
index 0000000..4004301
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp2.java
@@ -0,0 +1,238 @@
+/* 

+ * 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.runtime.core.providing;

+

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

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.components.TotoProvider;

+import org.apache.felix.ipojo.runtime.core.services.Tota;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestComp2 extends Common {

+

+    private ComponentFactory tataFactory;

+    private ComponentFactory totoFactory;

+    private ComponentInstance totoProv, totoProv2;

+    private ComponentInstance under;

+    private ComponentFactory tataFactory2;

+

+    @Before

+    public void setUp() {

+        tataFactory = (ComponentFactory) ipojoHelper.getFactory("tata");

+        totoFactory = (ComponentFactory) ipojoHelper.getFactory("toto");

+        tataFactory2 = (ComponentFactory) ipojoHelper.getFactory("comp-6");

+        tataFactory2.stop();

+        tataFactory.stop();

+

+        Properties props = new Properties();

+        props.put("instance.name", "toto provider");

+        try {

+            totoProv = totoFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        Properties props3 = new Properties();

+        props3.put("instance.name", "toto provider 2");

+        try {

+            totoProv2 = totoFactory.createComponentInstance(props3);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        totoProv.stop();

+        totoProv2.stop();

+

+        Factory factory = ipojoHelper.getFactory("comp-2");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "ff");

+        try {

+            under = factory.createComponentInstance(props2);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+    }

+

+    @After

+    public void tearDown() {

+        tataFactory.start();

+        totoProv.dispose();

+        totoProv = null;

+        totoProv2.dispose();

+        totoProv2 = null;

+        tataFactory2.start();

+

+        // Reset counters

+        TotoProvider.toto = 0;

+        TotoProvider.toto_2 = 0;

+        TotoProvider.toto_3 = 0;

+        TotoProvider.toto_4 = 0;

+        TotoProvider.toto1 = 0;

+    }

+

+    @Test

+    public void testSimple() {

+        // Neither factory nor instance

+        assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));

+

+        // Start the importer

+        totoProv.start();

+        assertTrue("Assert under state - 2 (" + under.getState() + ")", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));

+

+        // Start the factory

+        tataFactory.start();

+        assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));

+        ServiceReference ref = getContext().getServiceReference(Tota.class.getName());

+        Tota tota = (Tota) getContext().getService(ref);

+

+        invokeAll(tota);

+

+        // Check toto

+        Properties props = tota.getProps();

+        Integer toto = (Integer) props.get("toto");

+        Integer toto_2 = (Integer) props.get("toto_2");

+        Integer toto_3 = (Integer) props.get("toto_3");

+        Integer toto_4 = (Integer) props.get("toto_4");

+        Integer toto_1 = (Integer) props.get("toto1");

+        assertEquals("Assert toto - 3 (" + toto.intValue() + ")", toto.intValue(), 1);

+        assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);

+        assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);

+        assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);

+        assertEquals("Assert toto1 - 3 (" + toto_1.intValue() + ")", toto_1.intValue(), 1);

+        //Check tata

+        props = tota.getPropsTata();

+        Integer tata = (Integer) props.get("tata");

+        assertEquals("Assert tata - 3", tata.intValue(), 1);

+

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Start a second import

+        totoProv2.start();

+        assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        props = tota.getProps();

+        toto = (Integer) props.get("toto");

+        toto_2 = (Integer) props.get("toto_2");

+        toto_3 = (Integer) props.get("toto_3");

+        toto_4 = (Integer) props.get("toto_4");

+        toto_1 = (Integer) props.get("toto1");

+        assertEquals("Assert toto - 4 (" + toto.intValue() + ")", toto.intValue(), 2);

+        assertEquals("Assert toto_2 - 4 (" + toto_2.intValue() + ")", toto_2.intValue(), 2);

+        assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);

+        assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);

+        assertEquals("Assert toto1 - 4", toto_1.intValue(), 3);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        assertEquals("Assert tata - 4", tata.intValue(), 2);

+

+        getContext().ungetService(ref);

+        tota = null;

+

+        tataFactory.stop();

+        assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));

+

+        totoProv2.stop();

+        tataFactory.start();

+        assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        props = tota.getProps();

+        toto = (Integer) props.get("toto");

+        toto_2 = (Integer) props.get("toto_2");

+        toto_3 = (Integer) props.get("toto_3");

+        toto_4 = (Integer) props.get("toto_4");

+        toto_1 = (Integer) props.get("toto1");

+        assertEquals("Assert toto - 6 (" + toto.intValue() + ")", toto.intValue(), 3);

+        assertEquals("Assert toto_2 - 6 (" + toto_2.intValue() + ")", toto_2.intValue(), 3);

+        assertEquals("Assert toto_3 - 6", toto_3.intValue(), 3);

+        assertEquals("Assert toto_4 - 6", toto_4.intValue(), 0);

+        assertEquals("Assert toto1 - 6", toto_1.intValue(), 4);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        assertEquals("Assert tata - 6", tata.intValue(), 1);

+

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Is arch exposed

+        assertNotNull("Test arch", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "ff"));

+

+        totoProv.stop();

+

+        assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);

+        assertNotNull("Test arch-2", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "ff"));

+        assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));

+

+        under.dispose();

+        under = null;

+    }

+

+    private void invoke(Tota tota) {

+        tota.tata();

+

+        assertEquals("Assert invoke tataint", tota.tataInt(2), 2);

+        assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);

+        assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2, 0);

+        assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');

+        assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));

+        assertEquals("Assert invoke tataByte", tota.tataByte((byte) 2), 2);

+        assertEquals("Assert invoke tataShort", tota.tataShort((short) 5), 5);

+        assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5, 0);

+

+    }

+

+    private void invokeToto(Tota tota) {

+        tota.toto();

+        assertEquals("Assert toto", tota.toto("foo"), "foo");

+        tota.toto(1, 2);

+        tota.toto1("foo2");

+    }

+

+    private void invokeAll(Tota tota) {

+        invoke(tota);

+        invokeToto(tota);

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp3.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp3.java
new file mode 100644
index 0000000..06f4ee4
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp3.java
@@ -0,0 +1,271 @@
+/* 

+ * 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.runtime.core.providing;

+

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

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.components.TotoProvider;

+import org.apache.felix.ipojo.runtime.core.services.Tota;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestComp3 extends Common {

+

+    private ComponentFactory tataFactory;

+    private ComponentFactory totoFactory;

+    private ComponentInstance totoProv, totoProv2;

+    private ComponentInstance under;

+    private ComponentFactory tataFactory2;

+

+    @Before

+    public void setUp() {

+        tataFactory = (ComponentFactory) ipojoHelper.getFactory("tata");

+        totoFactory = (ComponentFactory) ipojoHelper.getFactory("toto");

+        tataFactory2 = (ComponentFactory) ipojoHelper.getFactory("comp-6");

+        tataFactory2.stop();

+        tataFactory.stop();

+

+        Properties props = new Properties();

+        props.put("instance.name", "toto provider");

+        try {

+            totoProv = totoFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        Properties props3 = new Properties();

+        props3.put("instance.name", "toto provider 2");

+        try {

+            totoProv2 = totoFactory.createComponentInstance(props3);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        totoProv.stop();

+        totoProv2.stop();

+

+        Factory factory = ipojoHelper.getFactory("comp-3");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "ff");

+        try {

+            under = factory.createComponentInstance(props2);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+    }

+

+    @After

+    public void tearDown() {

+        tataFactory.start();

+        totoProv.dispose();

+        totoProv = null;

+        totoProv2.dispose();

+        totoProv2 = null;

+        tataFactory2.start();

+

+        // Reset counters

+        TotoProvider.toto = 0;

+        TotoProvider.toto_2 = 0;

+        TotoProvider.toto_3 = 0;

+        TotoProvider.toto_4 = 0;

+        TotoProvider.toto1 = 0;

+    }

+

+    @Test

+    public void testSimple() {

+        // Neither factory nor instance

+        assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));

+

+        // Start the importer

+        totoProv.start();

+        assertTrue("Assert under state - 2 (" + under.getState() + ")", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));

+

+        // Start the factory

+        tataFactory.start();

+        assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));

+        ServiceReference ref = getContext().getServiceReference(Tota.class.getName());

+        Tota tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        Properties props = tota.getProps();

+        Integer toto = (Integer) props.get("toto");

+        Integer toto_2 = (Integer) props.get("toto_2");

+        Integer toto_3 = (Integer) props.get("toto_3");

+        Integer toto_4 = (Integer) props.get("toto_4");

+        Integer toto_1 = (Integer) props.get("toto1");

+        assertEquals("Assert toto - 3 (" + toto.intValue() + ")", toto.intValue(), 1);

+        assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);

+        assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);

+        assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);

+        assertEquals("Assert toto1 - 3 (" + toto_1.intValue() + ")", toto_1.intValue(), 1);

+        //Check tata

+        props = tota.getPropsTata();

+        Integer tata = (Integer) props.get("tata");

+        assertEquals("Assert tata - 3", tata.intValue(), 1);

+

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Start a second import

+        totoProv2.start();

+        assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        props = tota.getProps();

+        toto = (Integer) props.get("toto");

+        toto_2 = (Integer) props.get("toto_2");

+        toto_3 = (Integer) props.get("toto_3");

+        toto_4 = (Integer) props.get("toto_4");

+        toto_1 = (Integer) props.get("toto1");

+        assertEquals("Assert toto - 4 (" + toto.intValue() + ")", toto.intValue(), 2);

+        assertEquals("Assert toto_2 - 4 (" + toto_2.intValue() + ")", toto_2.intValue(), 2);

+        assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);

+        assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);

+        assertEquals("Assert toto1 - 4", toto_1.intValue(), 2);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        assertEquals("Assert tata - 4", tata.intValue(), 2);

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Stop the factory

+        tataFactory.stop();

+        assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));

+

+        totoProv2.stop();

+        totoProv.stop();

+        tataFactory.start();

+        assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAllOpt(tota);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        assertEquals("Assert tata - 4", tata.intValue(), 1);

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Is arch exposed

+        assertNotNull("Test arch", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "ff"));

+

+        tataFactory.stop();

+

+        assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);

+        assertNotNull("Test arch-2", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "ff"));

+        assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));

+

+        under.dispose();

+        under = null;

+    }

+

+    private void invoke(Tota tota) {

+        tota.tata();

+

+        assertEquals("Assert invoke tataint", tota.tataInt(2), 2);

+        assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);

+        assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2, 0);

+        assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');

+        assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));

+        assertEquals("Assert invoke tataByte", tota.tataByte((byte) 2), 2);

+        assertEquals("Assert invoke tataShort", tota.tataShort((short) 5), 5);

+        assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5, 0);

+

+    }

+

+    private void invokeStr(Tota tota) {

+        tota.tataStr();

+    }

+

+    private void invokeToto(Tota tota) {

+        tota.toto();

+        assertEquals("Assert toto", tota.toto("foo"), "foo");

+        tota.toto(1, 2);

+        tota.toto1("foo");

+    }

+

+    private void invokeAll(Tota tota) {

+        invoke(tota);

+        //invokeArrays(tota);

+        invokeStr(tota);

+        //invokeTata(tota);

+        //invokeTata1(tota);

+        //invokeTata5(tota);

+        //invokeAdd(tota);

+        invokeToto(tota);

+    }

+

+    private void invokeAllOpt(Tota tota) {

+        invoke(tota);

+        //invokeArrays(tota);

+        invokeStr(tota);

+        //invokeTata(tota);

+        //invokeTata1(tota);

+        //invokeTata5(tota);

+        //invokeAdd(tota);

+        invokeTotoOpt(tota);

+    }

+

+    private void invokeTotoOpt(Tota tota) {

+        try {

+            tota.toto();

+            fail("UnsupportedOperationException expected");

+        } catch (UnsupportedOperationException e) {

+        }

+

+        try {

+            assertEquals("Assert toto", tota.toto("foo"), "foo");

+            fail("UnsupportedOperationException expected");

+        } catch (UnsupportedOperationException e) {

+        }

+

+

+        try {

+            tota.toto(1, 2);

+            fail("UnsupportedOperationException expected");

+        } catch (UnsupportedOperationException e) {

+        }

+

+        try {

+            tota.toto1("foo");

+            fail("UnsupportedOperationException expected");

+        } catch (UnsupportedOperationException e) {

+        }

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp4.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp4.java
new file mode 100644
index 0000000..eca3287
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp4.java
@@ -0,0 +1,270 @@
+/* 

+ * 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.runtime.core.providing;

+

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

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.components.TotoProvider;

+import org.apache.felix.ipojo.runtime.core.services.Tota;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestComp4 extends Common {

+

+    private ComponentFactory tataFactory;

+    private ComponentFactory totoFactory;

+    private ComponentInstance totoProv, totoProv2;

+    private ComponentInstance under;

+    private ComponentFactory tataFactory2;

+

+    @Before

+    public void setUp() {

+        tataFactory = (ComponentFactory) ipojoHelper.getFactory("tata");

+        totoFactory = (ComponentFactory) ipojoHelper.getFactory("toto");

+        tataFactory2 = (ComponentFactory) ipojoHelper.getFactory("comp-6");

+        tataFactory2.stop();

+        tataFactory.stop();

+

+        Properties props = new Properties();

+        props.put("instance.name", "toto provider");

+        try {

+            totoProv = totoFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        Properties props3 = new Properties();

+        props3.put("instance.name", "toto provider 2");

+        try {

+            totoProv2 = totoFactory.createComponentInstance(props3);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        totoProv.stop();

+        totoProv2.stop();

+

+        Factory factory = ipojoHelper.getFactory("comp-4");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "ff");

+        try {

+            under = factory.createComponentInstance(props2);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+    }

+

+    @After

+    public void tearDown() {

+        tataFactory2.start();

+        tataFactory.start();

+        totoProv.dispose();

+        totoProv = null;

+        totoProv2.dispose();

+        totoProv2 = null;

+

+        // Reset counters

+        TotoProvider.toto = 0;

+        TotoProvider.toto_2 = 0;

+        TotoProvider.toto_3 = 0;

+        TotoProvider.toto_4 = 0;

+        TotoProvider.toto1 = 0;

+    }

+

+    @Test

+    public void testSimple() {

+        // Neither factory nor instance

+        assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));

+

+        // Start the importer

+        totoProv.start();

+        assertTrue("Assert under state - 2 (" + under.getState() + ")", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));

+

+        // Start the factory

+        tataFactory.start();

+        assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));

+        ServiceReference ref = getContext().getServiceReference(Tota.class.getName());

+        Tota tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        Properties props = tota.getProps();

+        Integer toto = (Integer) props.get("toto");

+        Integer toto_2 = (Integer) props.get("toto_2");

+        Integer toto_3 = (Integer) props.get("toto_3");

+        Integer toto_4 = (Integer) props.get("toto_4");

+        Integer toto_1 = (Integer) props.get("toto1");

+        assertEquals("Assert toto - 3 (" + toto.intValue() + ")", toto.intValue(), 1);

+        assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);

+        assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);

+        assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);

+        assertEquals("Assert toto1 - 3 (" + toto_1.intValue() + ")", toto_1.intValue(), 1);

+        //Check tata

+        props = tota.getPropsTata();

+        Integer tata = (Integer) props.get("tata");

+        assertEquals("Assert tata - 3", tata.intValue(), 1);

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Start a second import

+        totoProv2.start();

+        assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        props = tota.getProps();

+        toto = (Integer) props.get("toto");

+        toto_2 = (Integer) props.get("toto_2");

+        toto_3 = (Integer) props.get("toto_3");

+        toto_4 = (Integer) props.get("toto_4");

+        toto_1 = (Integer) props.get("toto1");

+        assertEquals("Assert toto - 4 (" + toto.intValue() + ")", toto.intValue(), 2);

+        assertEquals("Assert toto_2 - 4 (" + toto_2.intValue() + ")", toto_2.intValue(), 2);

+        assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);

+        assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);

+        assertEquals("Assert toto1 - 4", toto_1.intValue(), 2);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        assertEquals("Assert tata - 4", tata.intValue(), 2);

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Stop the factory

+        tataFactory.stop();

+        assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));

+

+        totoProv2.stop();

+        totoProv.stop();

+        tataFactory.start();

+        assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAllOpt(tota);

+        // Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        assertEquals("Assert tata - 6", tata.intValue(), 1);

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Is arch exposed

+        assertNotNull("Test arch", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "ff"));

+

+        tataFactory.stop();

+

+        assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);

+        assertNotNull("Test arch-2", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "ff"));

+        assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));

+

+        under.dispose();

+        under = null;

+    }

+

+    private void invoke(Tota tota) {

+        tota.tata();

+

+        assertEquals("Assert invoke tataint", tota.tataInt(2), 2);

+        assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);

+        assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2, 0);

+        assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');

+        assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));

+        assertEquals("Assert invoke tataByte", tota.tataByte((byte) 2), 2);

+        assertEquals("Assert invoke tataShort", tota.tataShort((short) 5), 5);

+        assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5, 0);

+

+    }

+

+    private void invokeStr(Tota tota) {

+        tota.tataStr();

+    }

+

+    private void invokeToto(Tota tota) {

+        tota.toto();

+        assertEquals("Assert toto", tota.toto("foo"), "foo");

+        tota.toto(1, 2);

+        tota.toto1("foo");

+    }

+

+    private void invokeAll(Tota tota) {

+        invoke(tota);

+        //invokeArrays(tota);

+        invokeStr(tota);

+        //invokeTata(tota);

+        //invokeTata1(tota);

+        //invokeTata5(tota);

+        //invokeAdd(tota);

+        invokeToto(tota);

+    }

+

+    private void invokeAllOpt(Tota tota) {

+        invoke(tota);

+        //invokeArrays(tota);

+        invokeStr(tota);

+        //invokeTata(tota);

+        //invokeTata1(tota);

+        //invokeTata5(tota);

+        //invokeAdd(tota);

+        invokeTotoOpt(tota);

+    }

+

+    private void invokeTotoOpt(Tota tota) {

+        try {

+            tota.toto();

+            fail("UnsupportedOperationException expected");

+        } catch (UnsupportedOperationException e) {

+        }

+

+        try {

+            assertEquals("Assert toto", tota.toto("foo"), "foo");

+            fail("UnsupportedOperationException expected");

+        } catch (UnsupportedOperationException e) {

+        }

+

+

+        try {

+            tota.toto(1, 2);

+            fail("UnsupportedOperationException expected");

+        } catch (UnsupportedOperationException e) {

+        }

+

+        try {

+            tota.toto1("foo");

+            fail("UnsupportedOperationException expected");

+        } catch (UnsupportedOperationException e) {

+        }

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp5.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp5.java
new file mode 100644
index 0000000..fc2a6bc
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp5.java
@@ -0,0 +1,272 @@
+/* 

+ * 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.runtime.core.providing;

+

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

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.components.TotoProvider;

+import org.apache.felix.ipojo.runtime.core.services.Tota;

+import static org.junit.Assert.*;

+

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+public class TestComp5 extends Common {

+

+    private ComponentFactory tataFactory;

+    private ComponentFactory totoFactory;

+    

+    private ComponentInstance totoProv, totoProv2;

+    private ComponentInstance under;

+	private ComponentFactory tataFactory2;

+

+    @Before

+    public void setUp() {

+        tataFactory = (ComponentFactory) ipojoHelper.getFactory("tata");

+        totoFactory = (ComponentFactory) ipojoHelper.getFactory("toto");

+        tataFactory2 = (ComponentFactory) ipojoHelper.getFactory("comp-6");

+        tataFactory2.stop();

+        tataFactory.stop();

+        

+        Properties props = new Properties();

+        props.put("instance.name","toto provider");

+        try {

+            totoProv = totoFactory.createComponentInstance(props);

+        } catch(Exception e) {

+            e.printStackTrace();

+        }

+        

+        Properties props3 = new Properties();

+        props3.put("instance.name","toto provider 2");

+        try {

+            totoProv2 = totoFactory.createComponentInstance(props3);

+        } catch(Exception e) {

+            e.printStackTrace();

+        }

+        

+        totoProv.stop();

+        totoProv2.stop();

+        

+        Factory factory = ipojoHelper.getFactory("comp-5");

+        Properties props2 = new Properties();

+        props2.put("instance.name","ff");

+        try {

+            under = factory.createComponentInstance(props2);

+        } catch(Exception e) {

+            e.printStackTrace();

+            fail("Cannot create an instance from comp-5 : " + e.getMessage());

+        }

+         

+    }

+    

+    @After

+    public void tearDown() {

+    	tataFactory2.start();

+        tataFactory.start();

+        totoProv.dispose();

+        totoProv = null;

+        totoProv2.dispose();

+        totoProv2 = null;

+        

+        // Reset counters

+        TotoProvider.toto = 0;

+        TotoProvider.toto_2 = 0;

+        TotoProvider.toto_3 = 0;

+        TotoProvider.toto_4 = 0;

+        TotoProvider.toto1 = 0;

+    }

+    

+    @Test

+    public void testSimple() {

+        // Neither factory nor instance

+        assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));

+        

+        // Start the importer

+        totoProv.start();

+        assertTrue("Assert under state - 2 ("+under.getState()+")", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));

+        

+        // Start the factory

+        tataFactory.start();

+        assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));

+        ServiceReference ref = getContext().getServiceReference(Tota.class.getName());

+        Tota tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        Properties props = tota.getProps();

+        Integer toto = (Integer) props.get("toto");

+        Integer toto_2 = (Integer) props.get("toto_2");

+        Integer toto_3 = (Integer) props.get("toto_3");

+        Integer toto_4 = (Integer) props.get("toto_4");

+        Integer toto_1 = (Integer) props.get("toto1");

+        assertEquals("Assert toto - 3 ("+toto.intValue()+")", toto.intValue(), 1);

+        assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);

+        assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);

+        assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);

+        assertEquals("Assert toto1 - 3 (" + toto_1.intValue() + ")", toto_1.intValue(), 1);

+        //Check tata

+        props = tota.getPropsTata();

+        Integer tata = (Integer) props.get("tata");

+        assertEquals("Assert tata - 3", tata.intValue(), 1);

+        getContext().ungetService(ref);

+        tota = null;

+        

+        // Start a second import

+        totoProv2.start();

+        assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        props = tota.getProps();

+        toto = (Integer) props.get("toto");

+        toto_2 = (Integer) props.get("toto_2");

+        toto_3 = (Integer) props.get("toto_3");

+        toto_4 = (Integer) props.get("toto_4");

+        toto_1 = (Integer) props.get("toto1");

+        assertEquals("Assert toto - 4 ("+toto.intValue()+")", toto.intValue(), 2);

+        assertEquals("Assert toto_2 - 4 ("+toto_2.intValue()+")", toto_2.intValue(), 2);

+        assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);

+        assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);

+        assertEquals("Assert toto1 - 4", toto_1.intValue(), 3);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        assertEquals("Assert tata - 4", tata.intValue(), 2);

+        getContext().ungetService(ref);

+        tota = null;

+        

+        // Stop the factory

+        tataFactory.stop();

+        assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));

+        

+        totoProv2.stop();

+        totoProv.stop();

+        tataFactory.start();

+        assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAllOpt(tota);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        assertEquals("Assert tata - 6", tata.intValue(), 1);

+        getContext().ungetService(ref);

+        tota = null;

+        

+        // Is arch exposed

+        assertNotNull("Test arch", ipojoHelper.getServiceReferenceByName( Architecture.class.getName(), "ff"));

+        

+        tataFactory.stop();

+        

+        assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);

+        assertNotNull("Test arch-2", ipojoHelper.getServiceReferenceByName( Architecture.class.getName(), "ff"));

+        assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));

+        

+        under.dispose();

+        under = null;

+    }

+

+

+

+    private void invoke(Tota tota) {

+        tota.tata();

+        

+        assertEquals("Assert invoke tataint", tota.tataInt(2), 2);

+        assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);

+        assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2, 0);

+        assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');

+        assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));

+        assertEquals("Assert invoke tataByte", tota.tataByte((byte)2), 2);

+        assertEquals("Assert invoke tataShort", tota.tataShort((short)5), 5);

+        assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5, 0);

+        

+    }

+    

+    

+    private void invokeStr(Tota tota) {

+        tota.tataStr();

+    }

+    

+    private void invokeToto(Tota tota) {

+        tota.toto();

+        assertEquals("Assert toto", tota.toto("foo"), "foo");

+        tota.toto(1,2);

+        tota.toto1("foo");

+    }

+    

+    private void invokeAll(Tota tota) {

+        invoke(tota);

+        //invokeArrays(tota);

+        invokeStr(tota);

+        //invokeTata(tota);

+        //invokeTata1(tota);

+        //invokeTata5(tota);

+        //invokeAdd(tota);

+        invokeToto(tota);

+    }

+    

+    private void invokeAllOpt(Tota tota) {

+        invoke(tota);

+        //invokeArrays(tota);

+        invokeStr(tota);

+        //invokeTata(tota);

+        //invokeTata1(tota);

+        //invokeTata5(tota);

+        //invokeAdd(tota);

+        invokeTotoOpt(tota);

+    }

+    

+    private void invokeTotoOpt(Tota tota) {

+        try {

+            tota.toto();

+            fail("UnsupportedOperationException expected");

+        } catch(UnsupportedOperationException e) { }

+        

+        try {

+            assertEquals("Assert toto", tota.toto("foo"), "foo");

+            fail("UnsupportedOperationException expected");

+        } catch(UnsupportedOperationException e) { }

+        

+        

+        try {

+            tota.toto(1,2);

+            fail("UnsupportedOperationException expected");

+        } catch(UnsupportedOperationException e) { }

+        

+        try {

+        	tota.toto1("foo");

+        	fail("UnsupportedOperationException expected");

+        } catch(UnsupportedOperationException e) { }

+    }

+    

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp6.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp6.java
new file mode 100644
index 0000000..de91e85
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp6.java
@@ -0,0 +1,293 @@
+/* 

+ * 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.runtime.core.providing;

+

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

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.components.TotoProvider;

+import org.apache.felix.ipojo.runtime.core.services.Tata;

+import org.apache.felix.ipojo.runtime.core.services.Toto;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestComp6 extends Common {

+

+    private ComponentFactory tataFactory;

+    private ComponentFactory totoFactory;

+    private ComponentInstance totoProv, totoProv2;

+    private ComponentInstance under;

+

+    @Before

+    public void setUp() {

+        tataFactory = (ComponentFactory) ipojoHelper.getFactory("tata");

+        totoFactory = (ComponentFactory) ipojoHelper.getFactory("toto");

+

+        tataFactory.stop();

+

+        Properties props = new Properties();

+        props.put("instance.name", "toto provider");

+        try {

+            totoProv = totoFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        Properties props3 = new Properties();

+        props3.put("instance.name", "toto provider 2");

+        try {

+            totoProv2 = totoFactory.createComponentInstance(props3);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        totoProv.stop();

+        totoProv2.stop();

+

+        Factory factory = ipojoHelper.getFactory("comp-6");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "ff");

+        try {

+            under = factory.createComponentInstance(props2);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+    }

+

+    @After

+    public void tearDown() {

+        tataFactory.start();

+        totoProv.dispose();

+        totoProv = null;

+        totoProv2.dispose();

+        totoProv2 = null;

+

+        // Reset counters

+        TotoProvider.toto = 0;

+        TotoProvider.toto_2 = 0;

+        TotoProvider.toto_3 = 0;

+        TotoProvider.toto_4 = 0;

+        TotoProvider.toto1 = 0;

+    }

+

+    @Test

+    public void testSimple() {

+        // Neither factory nor instance

+        assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);

+        ServiceReference refToto = ipojoHelper.getServiceReferenceByName(Toto.class.getName(), "ff");

+        ServiceReference refTata = ipojoHelper.getServiceReferenceByName(Tata.class.getName(), "ff");

+        assertNull("Assert no toto service - 1", refToto);

+        assertNull("Assert no tata service - 1", refTata);

+

+        // Start the importer

+        totoProv.start();

+        assertTrue("Assert under state - 2 (" + under.getState() + ")", under.getState() == ComponentInstance.INVALID);

+        refToto = ipojoHelper.getServiceReferenceByName(Toto.class.getName(), "ff");

+        refTata = ipojoHelper.getServiceReferenceByName(Tata.class.getName(), "ff");

+        assertNull("Assert no toto service - 2", refToto);

+        assertNull("Assert no tata service - 2", refTata);

+

+        // Start the factory

+        tataFactory.start();

+        assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);

+        refToto = ipojoHelper.getServiceReferenceByName(Toto.class.getName(), "ff");

+        refTata = ipojoHelper.getServiceReferenceByName(Tata.class.getName(), "ff");

+        assertNotNull("Assert toto service - 3", refToto);

+        assertNotNull("Assert tata service - 3", refTata);

+        Toto toto = (Toto) getContext().getService(refToto);

+        Tata tata = (Tata) getContext().getService(refTata);

+

+        invokeAll(tata);

+        invokeToto(toto);

+

+        // Check toto

+        Properties props = toto.getProps();

+        Integer toto_0 = (Integer) props.get("toto");

+        Integer toto_2 = (Integer) props.get("toto_2");

+        Integer toto_3 = (Integer) props.get("toto_3");

+        Integer toto_4 = (Integer) props.get("toto_4");

+        Integer toto_1 = (Integer) props.get("toto1");

+        assertEquals("Assert toto - 3 (" + toto_0.intValue() + ")", toto_0.intValue(), 1);

+        assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);

+        assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);

+        assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);

+        assertEquals("Assert toto1 - 3 (" + toto_1.intValue() + ")", toto_1.intValue(), 1);

+        //Check tata

+        props = tata.getPropsTata();

+        Integer tata_0 = (Integer) props.get("tata");

+        assertEquals("Assert tata - 3", tata_0.intValue(), 1);

+

+        getContext().ungetService(refToto);

+        getContext().ungetService(refTata);

+        toto = null;

+        tata = null;

+

+        // Start a second import

+        totoProv2.start();

+        assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);

+        refToto = ipojoHelper.getServiceReferenceByName(Toto.class.getName(), "ff");

+        refTata = ipojoHelper.getServiceReferenceByName(Tata.class.getName(), "ff");

+        assertNotNull("Assert toto service - 4", refToto);

+        assertNotNull("Assert tata service - 4", refTata);

+

+        toto = (Toto) getContext().getService(refToto);

+        tata = (Tata) getContext().getService(refTata);

+        invokeAll(tata);

+        invokeToto(toto);

+

+        // Check toto

+        props = toto.getProps();

+        toto_0 = (Integer) props.get("toto");

+        toto_2 = (Integer) props.get("toto_2");

+        toto_3 = (Integer) props.get("toto_3");

+        toto_4 = (Integer) props.get("toto_4");

+        toto_1 = (Integer) props.get("toto1");

+        assertEquals("Assert toto - 4 (" + toto_0.intValue() + ")", toto_0.intValue(), 2);

+        assertEquals("Assert toto_2 - 4 (" + toto_2.intValue() + ")", toto_2.intValue(), 2);

+        assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);

+        assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);

+        assertEquals("Assert toto1 - 4", toto_1.intValue(), 3);

+        //Check tata

+        props = tata.getPropsTata();

+        tata_0 = (Integer) props.get("tata");

+        assertEquals("Assert tata - 4", tata_0.intValue(), 2);

+        getContext().ungetService(refToto);

+        getContext().ungetService(refTata);

+        toto = null;

+        tata = null;

+

+        // Stop the factory

+        tataFactory.stop();

+        assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);

+        refToto = ipojoHelper.getServiceReferenceByName(Toto.class.getName(), "ff");

+        refTata = ipojoHelper.getServiceReferenceByName(Tata.class.getName(), "ff");

+        assertNull("Assert no toto service - 5", refToto);

+        assertNull("Assert no tata service - 5", refTata);

+

+        totoProv2.stop();

+        totoProv.stop();

+        tataFactory.start();

+        assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);

+        refToto = ipojoHelper.getServiceReferenceByName(Toto.class.getName(), "ff");

+        refTata = ipojoHelper.getServiceReferenceByName(Tata.class.getName(), "ff");

+        assertNotNull("Assert toto service - 6", refToto);

+        assertNotNull("Assert tata service - 6", refTata);

+        toto = (Toto) getContext().getService(refToto);

+        tata = (Tata) getContext().getService(refTata);

+

+        invokeAll(tata);

+        invokeTotoOpt(toto);

+        //  Check tata

+        props = tata.getPropsTata();

+        tata_0 = (Integer) props.get("tata");

+        assertEquals("Assert tata - 6", tata_0.intValue(), 1);

+        getContext().ungetService(refToto);

+        getContext().ungetService(refTata);

+        toto = null;

+        tata = null;

+

+        // Is arch exposed

+        assertNotNull("Test arch", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "ff"));

+

+        tataFactory.stop();

+

+        assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);

+        assertNotNull("Test arch-2", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "ff"));

+        refToto = ipojoHelper.getServiceReferenceByName(Toto.class.getName(), "ff");

+        refTata = ipojoHelper.getServiceReferenceByName(Tata.class.getName(), "ff");

+        assertNull("Assert no toto service - 7", refToto);

+        assertNull("Assert no tata service - 7", refTata);

+

+        under.dispose();

+        under = null;

+    }

+

+    private void invoke(Tata tota) {

+        tota.tata();

+

+        assertEquals("Assert invoke tataint", tota.tataInt(2), 2);

+        assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);

+        assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2, 0);

+        assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');

+        assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));

+        assertEquals("Assert invoke tataByte", tota.tataByte((byte) 2), 2);

+        assertEquals("Assert invoke tataShort", tota.tataShort((short) 5), 5);

+        assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5, 0);

+

+    }

+

+    private void invokeStr(Tata tota) {

+        tota.tataStr();

+    }

+

+    private void invokeToto(Toto tota) {

+        tota.toto();

+        assertEquals("Assert toto", tota.toto("foo"), "foo");

+        tota.toto(1, 2);

+        tota.toto1("foo");

+    }

+

+    private void invokeAll(Tata tota) {

+        invoke(tota);

+        //invokeArrays(tota);

+        invokeStr(tota);

+        //invokeTata(tota);

+        //invokeTata1(tota);

+        //invokeTata5(tota);

+        //invokeAdd(tota);

+    }

+

+    private void invokeTotoOpt(Toto tota) {

+        try {

+            tota.toto();

+            fail("UnsupportedOperationException expected");

+        } catch (UnsupportedOperationException e) {

+        }

+

+        try {

+            assertEquals("Assert toto", tota.toto("foo"), "foo");

+            fail("UnsupportedOperationException expected");

+        } catch (UnsupportedOperationException e) {

+        }

+

+

+        try {

+            tota.toto(1, 2);

+            fail("UnsupportedOperationException expected");

+        } catch (UnsupportedOperationException e) {

+        }

+

+        try {

+            tota.toto1("foo");

+            fail("UnsupportedOperationException expected");

+        } catch (UnsupportedOperationException e) {

+        }

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp7.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp7.java
new file mode 100644
index 0000000..d47fe48
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp7.java
@@ -0,0 +1,339 @@
+/* 

+ * 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.runtime.core.providing;

+

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

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.components.TotoProvider;

+import org.apache.felix.ipojo.runtime.core.services.Tota;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestComp7 extends Common {

+

+    private ComponentFactory tataFactory;

+    private ComponentFactory totoFactory;

+    private ComponentFactory tataFactory2;

+    private ComponentInstance totoProv, totoProv2;

+    private ComponentInstance under;

+

+    @Before

+    public void setUp() {

+        tataFactory = (ComponentFactory) ipojoHelper.getFactory("tata");

+        totoFactory = (ComponentFactory) ipojoHelper.getFactory("toto");

+        tataFactory2 = (ComponentFactory) ipojoHelper.getFactory("comp-6");

+        tataFactory2.stop();

+

+        Properties props = new Properties();

+        props.put("instance.name", "toto provider");

+        try {

+            totoProv = totoFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        Properties props3 = new Properties();

+        props3.put("instance.name", "toto provider 2");

+        try {

+            totoProv2 = totoFactory.createComponentInstance(props3);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        totoProv.stop();

+        totoProv2.stop();

+

+        Factory factory = ipojoHelper.getFactory("comp-7");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "ff");

+        try {

+            under = factory.createComponentInstance(props2);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+        tataFactory.stop();

+

+    }

+

+    @After

+    public void tearDown() {

+        tataFactory.start();

+        totoProv.dispose();

+        totoProv = null;

+        totoProv2.dispose();

+        totoProv2 = null;

+        tataFactory2.start();

+

+        // Reset counters

+        TotoProvider.toto = 0;

+        TotoProvider.toto_2 = 0;

+        TotoProvider.toto_3 = 0;

+        TotoProvider.toto_4 = 0;

+        TotoProvider.toto1 = 0;

+    }

+

+    @Test

+    public void testSimple() {

+        // Neither factory nor instance

+        assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));

+

+        // Start the importer

+        totoProv.start();

+        assertTrue("Assert under state - 2", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));

+

+        // Start the factory

+        tataFactory.start();

+        assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));

+        ServiceReference ref = getContext().getServiceReference(Tota.class.getName());

+        Tota tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        Properties props = tota.getProps();

+        Integer toto = (Integer) props.get("toto");

+        Integer toto_2 = (Integer) props.get("toto_2");

+        Integer toto_3 = (Integer) props.get("toto_3");

+        Integer toto_4 = (Integer) props.get("toto_4");

+        assertEquals("Assert toto - 3 (" + toto.intValue() + ")", toto.intValue(), 1);

+        assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);

+        assertEquals("Assert toto_3 - 3", toto_3.intValue(), 1);

+        assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);

+        //Check tata

+        props = tota.getPropsTata();

+        Integer tata = (Integer) props.get("tata");

+        Integer tataStr = (Integer) props.get("tataStr");

+        Integer tataStrs = (Integer) props.get("tataStrs");

+        Integer tata_2 = (Integer) props.get("tata_2");

+        Integer tata_3 = (Integer) props.get("tata_3");

+        Integer tata1 = (Integer) props.get("tata1");

+        Integer tata1_1 = (Integer) props.get("tata1_1");

+        Integer tata5 = (Integer) props.get("tata5");

+        Integer tata5_1 = (Integer) props.get("tata5_1");

+        Integer tata5_2 = (Integer) props.get("tata5_2");

+        assertEquals("Assert tata - 3", tata.intValue(), 1);

+        assertEquals("Assert tataStr - 3", tataStr.intValue(), 1);

+        assertEquals("Assert tataStrs - 3", tataStrs.intValue(), 0);

+        assertEquals("Assert tata_2 - 3", tata_2.intValue(), 1);

+        assertEquals("Assert tata_3 - 3", tata_3.intValue(), 1);

+        assertEquals("Assert tata1 - 3", tata1.intValue(), 1);

+        assertEquals("Assert tata1_1 - 3", tata1_1.intValue(), 1);

+        assertEquals("Assert tata5 - 3", tata5.intValue(), 1);

+        assertEquals("Assert tata5_1 - 3", tata5_1.intValue(), 1);

+        assertEquals("Assert tata5_2 - 3", tata5_2.intValue(), 1);

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Start a second import

+        totoProv2.start();

+        assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        props = tota.getProps();

+        toto = (Integer) props.get("toto");

+        toto_2 = (Integer) props.get("toto_2");

+        toto_3 = (Integer) props.get("toto_3");

+        toto_4 = (Integer) props.get("toto_4");

+        assertEquals("Assert toto - 4", toto.intValue(), 2);

+        assertEquals("Assert toto_2 - 4", toto_2.intValue(), 2);

+        assertEquals("Assert toto_3 - 4", toto_3.intValue(), 2);

+        assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        tataStr = (Integer) props.get("tataStr");

+        tataStrs = (Integer) props.get("tataStrs");

+        tata_2 = (Integer) props.get("tata_2");

+        tata_3 = (Integer) props.get("tata_3");

+        tata1 = (Integer) props.get("tata1");

+        tata1_1 = (Integer) props.get("tata1_1");

+        tata5 = (Integer) props.get("tata5");

+        tata5_1 = (Integer) props.get("tata5_1");

+        tata5_2 = (Integer) props.get("tata5_2");

+        assertEquals("Assert tata - 4", tata.intValue(), 2);

+        assertEquals("Assert tataStr - 4", tataStr.intValue(), 2);

+        assertEquals("Assert tataStrs - 4", tataStrs.intValue(), 0);

+        assertEquals("Assert tata_2 - 4", tata_2.intValue(), 2);

+        assertEquals("Assert tata_3 - 4", tata_3.intValue(), 2);

+        assertEquals("Assert tata1 - 4", tata1.intValue(), 2);

+        assertEquals("Assert tata1_1 - 4", tata1_1.intValue(), 2);

+        assertEquals("Assert tata5 - 4", tata5.intValue(), 2);

+        assertEquals("Assert tata5_1 - 4", tata5_1.intValue(), 2);

+        assertEquals("Assert tata5_2 - 4", tata5_2.intValue(), 2);

+

+        getContext().ungetService(ref);

+        tota = null;

+

+        tataFactory.stop();

+        assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));

+

+        totoProv2.stop();

+        tataFactory.start();

+        assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        props = tota.getProps();

+        toto = (Integer) props.get("toto");

+        toto_2 = (Integer) props.get("toto_2");

+        toto_3 = (Integer) props.get("toto_3");

+        toto_4 = (Integer) props.get("toto_4");

+        assertEquals("Assert toto - 6", toto.intValue(), 3);

+        assertEquals("Assert toto_2 - 6", toto_2.intValue(), 3);

+        assertEquals("Assert toto_3 - 6", toto_3.intValue(), 3);

+        assertEquals("Assert toto_4 - 6", toto_4.intValue(), 0);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        tataStr = (Integer) props.get("tataStr");

+        tataStrs = (Integer) props.get("tataStrs");

+        tata_2 = (Integer) props.get("tata_2");

+        tata_3 = (Integer) props.get("tata_3");

+        tata1 = (Integer) props.get("tata1");

+        tata1_1 = (Integer) props.get("tata1_1");

+        tata5 = (Integer) props.get("tata5");

+        tata5_1 = (Integer) props.get("tata5_1");

+        tata5_2 = (Integer) props.get("tata5_2");

+        assertEquals("Assert tata - 6", 1, tata.intValue());

+        assertEquals("Assert tataStr - 6", tataStr.intValue(), 1);

+        assertEquals("Assert tataStrs - 6", tataStrs.intValue(), 0);

+        assertEquals("Assert tata_2 - 6", tata_2.intValue(), 1);

+        assertEquals("Assert tata_3 - 6", tata_3.intValue(), 1);

+        assertEquals("Assert tata1 - 6", tata1.intValue(), 1);

+        assertEquals("Assert tata1_1 - 6", tata1_1.intValue(), 1);

+        assertEquals("Assert tata5 - 6", tata5.intValue(), 1);

+        assertEquals("Assert tata5_1 - 6", tata5_1.intValue(), 1);

+        assertEquals("Assert tata5_2 - 6", tata5_2.intValue(), 1);

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Is arch exposed

+        assertNotNull("Test arch", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "ff"));

+

+        totoProv.stop();

+

+        assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);

+        assertNotNull("Test arch-2", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "ff"));

+        assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));

+

+        under.dispose();

+        under = null;

+    }

+

+    private void invoke(Tota tota) {

+        tota.tata();

+

+        assertEquals("Assert invoke tataint", tota.tataInt(2), 2);

+        assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);

+        assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2, 0);

+        assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');

+        assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));

+        assertEquals("Assert invoke tataByte", tota.tataByte((byte) 2), 2);

+        assertEquals("Assert invoke tataShort", tota.tataShort((short) 5), 5);

+        assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5, 0);

+

+    }

+

+    private void invokeArrays(Tota tota) {

+

+        int[] a = new int[]{1, 2, 3};

+        assertEquals("Assert invoke tataint[]", tota.tataInts(a), a);

+

+        long[] b = new long[]{1, 2, 3};

+        assertEquals("Assert invoke tataLong[]", tota.tataLongs(b), b);

+

+        double[] c = new double[]{1, 2, 3};

+        assertEquals("Assert invoke tataDouble[]", tota.tataDoubles(c), c);

+

+        char[] d = new char[]{'a', 'b', 'c'};

+        assertEquals("Assert invoke tataChar[]", tota.tataChars(d), d);

+

+        boolean[] e = new boolean[]{true, false};

+        assertEquals("Assert invoke tataBoolean[]", tota.tataBooleans(e), e);

+

+        byte[] f = new byte[]{(byte) 1};

+        assertEquals("Assert invoke tataByte[]", tota.tataBytes(f), f);

+

+        short[] g = new short[]{(short) 1};

+        assertEquals("Assert invoke tataShort[]", tota.tataShorts(g), g);

+

+        float[] h = new float[]{5, 6, 7};

+        assertEquals("Assert invoke tataFloat[]", tota.tataFloats(h), h);

+

+    }

+

+    private void invokeStr(Tota tota) {

+        tota.tataStr();

+    }

+

+    private void invokeTata(Tota tota) {

+        tota.tata(1, 2);

+        tota.tata("tototototo");

+    }

+

+    private void invokeTata1(Tota tota) {

+        assertEquals("Assert tata1", tota.tata1("foo"), "foo");

+        assertEquals("Assert tata1 - 2", tota.tata1(new char[]{'a', 'b', 'c'}), "abc");

+    }

+

+    private void invokeTata5(Tota tota) {

+        assertEquals("Assert tata5 -1", tota.tata5("foo", 1), "foo" + 1);

+        assertEquals("Assert tata5 - 2", tota.tata5(new String[]{"a", "b", "c"}, 1), "31");

+        assertEquals("Assert tata5 - 3", tota.tata5("foo", new int[]{1, 2, 3}), "foo3");

+    }

+

+    private void invokeAdd(Tota tota) {

+        assertEquals("Assert add", tota.add(1, 1, 1), 3);

+    }

+

+    private void invokeToto(Tota tota) {

+        tota.toto();

+        assertEquals("Assert toto", tota.toto("foo"), "foo");

+        tota.toto(1, 2);

+    }

+

+    private void invokeAll(Tota tota) {

+        invoke(tota);

+        invokeArrays(tota);

+        invokeStr(tota);

+        invokeTata(tota);

+        invokeTata1(tota);

+        invokeTata5(tota);

+        invokeAdd(tota);

+        invokeToto(tota);

+    }

+

+

+}

diff --git a/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp8.java b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp8.java
new file mode 100644
index 0000000..32c1402
--- /dev/null
+++ b/ipojo/runtime/composite-it/src/it/ipojo-composite-service-providing-test/src/test/java/org/apache/felix/ipojo/runtime/core/providing/TestComp8.java
@@ -0,0 +1,369 @@
+/* 

+ * 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.runtime.core.providing;

+

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

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

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

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

+import org.apache.felix.ipojo.runtime.core.Common;

+import org.apache.felix.ipojo.runtime.core.components.TotoProvider;

+import org.apache.felix.ipojo.runtime.core.components.TotoProviderGlue;

+import org.apache.felix.ipojo.runtime.core.services.Tota;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.Test;

+import org.osgi.framework.ServiceReference;

+

+import java.util.Properties;

+

+import static org.junit.Assert.*;

+

+public class TestComp8 extends Common {

+

+    private ComponentFactory tataFactory;

+    private ComponentFactory totoFactory;

+    private ComponentFactory tataFactory2;

+    private ComponentInstance totoProv, totoProv2;

+    private ComponentInstance under;

+

+    @Before

+    public void setUp() {

+        tataFactory = (ComponentFactory) ipojoHelper.getFactory("tata");

+        totoFactory = (ComponentFactory) ipojoHelper.getFactory("toto");

+        tataFactory2 = (ComponentFactory) ipojoHelper.getFactory("comp-6");

+        tataFactory2.stop();

+

+        Properties props = new Properties();

+        props.put("instance.name", "toto provider");

+        try {

+            totoProv = totoFactory.createComponentInstance(props);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        Properties props3 = new Properties();

+        props3.put("instance.name", "toto provider 2");

+        try {

+            totoProv2 = totoFactory.createComponentInstance(props3);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+

+        totoProv.stop();

+        totoProv2.stop();

+

+        Factory factory = ipojoHelper.getFactory("comp-8");

+        Properties props2 = new Properties();

+        props2.put("instance.name", "ff");

+        try {

+            under = factory.createComponentInstance(props2);

+        } catch (Exception e) {

+            e.printStackTrace();

+        }

+        tataFactory.stop();

+

+    }

+

+    @After

+    public void tearDown() {

+        tataFactory.start();

+        totoProv.dispose();

+        totoProv = null;

+        totoProv2.dispose();

+        totoProv2 = null;

+        tataFactory2.start();

+

+        // Reset counters

+        TotoProvider.toto = 0;

+        TotoProvider.toto_2 = 0;

+        TotoProvider.toto_3 = 0;

+        TotoProvider.toto_4 = 0;

+        TotoProvider.toto1 = 0;

+        TotoProviderGlue.toto = 0;

+        TotoProviderGlue.toto_2 = 0;

+        TotoProviderGlue.toto_3 = 0;

+        TotoProviderGlue.toto_4 = 0;

+        TotoProviderGlue.toto1 = 0;

+    }

+

+    @Test

+    public void testSimple() {

+        // Neither factory nor instance

+        assertTrue("Assert under state - 1", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 1", getContext().getServiceReference(Tota.class.getName()));

+

+        // Start the importer

+        totoProv.start();

+        assertTrue("Assert under state - 2", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 2", getContext().getServiceReference(Tota.class.getName()));

+

+        // Start the factory

+        tataFactory.start();

+        assertTrue("Assert under state - 3", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 3", getContext().getServiceReference(Tota.class.getName()));

+        ServiceReference ref = getContext().getServiceReference(Tota.class.getName());

+        Tota tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        Properties props = tota.getProps();

+        Integer toto = (Integer) props.get("toto");

+        Integer toto_2 = (Integer) props.get("toto_2");

+        Integer toto_3 = (Integer) props.get("toto_3");

+        Integer toto_4 = (Integer) props.get("toto_4");

+        Integer gtoto = (Integer) props.get("gtoto");

+        Integer gtoto_2 = (Integer) props.get("gtoto_2");

+        Integer gtoto_3 = (Integer) props.get("gtoto_3");

+        Integer gtoto_4 = (Integer) props.get("gtoto_4");

+        assertEquals("Assert toto - 3 (" + toto.intValue() + ")", toto.intValue(), 1);

+        assertEquals("Assert toto_2 - 3", toto_2.intValue(), 1);

+        assertEquals("Assert toto_3 - 3", toto_3.intValue(), 0);

+        assertEquals("Assert toto_4 - 3", toto_4.intValue(), 0);

+        assertEquals("Assert gtoto - 3 (" + gtoto.intValue() + ")", gtoto.intValue(), 1);

+        assertEquals("Assert gtoto_2 - 3", gtoto_2.intValue(), 1);

+        assertEquals("Assert gtoto_3 - 3", gtoto_3.intValue(), 1);

+        assertEquals("Assert gtoto_4 - 3", gtoto_4.intValue(), 0);

+        //Check tata

+        props = tota.getPropsTata();

+        Integer tata = (Integer) props.get("tata");

+        Integer tataStr = (Integer) props.get("tataStr");

+        Integer tataStrs = (Integer) props.get("tataStrs");

+        Integer tata_2 = (Integer) props.get("tata_2");

+        Integer tata_3 = (Integer) props.get("tata_3");

+        Integer tata1 = (Integer) props.get("tata1");

+        Integer tata1_1 = (Integer) props.get("tata1_1");

+        Integer tata5 = (Integer) props.get("tata5");

+        Integer tata5_1 = (Integer) props.get("tata5_1");

+        Integer tata5_2 = (Integer) props.get("tata5_2");

+        assertEquals("Assert tata - 3", tata.intValue(), 1);

+        assertEquals("Assert tataStr - 3", tataStr.intValue(), 1);

+        assertEquals("Assert tataStrs - 3", tataStrs.intValue(), 0);

+        assertEquals("Assert tata_2 - 3", tata_2.intValue(), 1);

+        assertEquals("Assert tata_3 - 3", tata_3.intValue(), 1);

+        assertEquals("Assert tata1 - 3", tata1.intValue(), 1);

+        assertEquals("Assert tata1_1 - 3", tata1_1.intValue(), 1);

+        assertEquals("Assert tata5 - 3", tata5.intValue(), 1);

+        assertEquals("Assert tata5_1 - 3", tata5_1.intValue(), 1);

+        assertEquals("Assert tata5_2 - 3", tata5_2.intValue(), 1);

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Start a second import

+        totoProv2.start();

+        assertTrue("Assert under state - 4", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 4", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        props = tota.getProps();

+        toto = (Integer) props.get("toto");

+        toto_2 = (Integer) props.get("toto_2");

+        toto_3 = (Integer) props.get("toto_3");

+        toto_4 = (Integer) props.get("toto_4");

+        gtoto = (Integer) props.get("gtoto");

+        gtoto_2 = (Integer) props.get("gtoto_2");

+        gtoto_3 = (Integer) props.get("gtoto_3");

+        gtoto_4 = (Integer) props.get("gtoto_4");

+        assertEquals("Assert toto - 4", toto.intValue(), 2);

+        assertEquals("Assert toto_2 - 4", toto_2.intValue(), 2);

+        assertEquals("Assert toto_3 - 4", toto_3.intValue(), 0);

+        assertEquals("Assert toto_4 - 4", toto_4.intValue(), 0);

+        assertEquals("Assert gtoto - 4 (" + gtoto.intValue() + ")", gtoto.intValue(), 2);

+        assertEquals("Assert gtoto_2 - 4", gtoto_2.intValue(), 2);

+        assertEquals("Assert gtoto_3 - 4", gtoto_3.intValue(), 2);

+        assertEquals("Assert gtoto_4 - 4", gtoto_4.intValue(), 0);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        tataStr = (Integer) props.get("tataStr");

+        tataStrs = (Integer) props.get("tataStrs");

+        tata_2 = (Integer) props.get("tata_2");

+        tata_3 = (Integer) props.get("tata_3");

+        tata1 = (Integer) props.get("tata1");

+        tata1_1 = (Integer) props.get("tata1_1");

+        tata5 = (Integer) props.get("tata5");

+        tata5_1 = (Integer) props.get("tata5_1");

+        tata5_2 = (Integer) props.get("tata5_2");

+        assertEquals("Assert tata - 4", tata.intValue(), 2);

+        assertEquals("Assert tataStr - 4", tataStr.intValue(), 2);

+        assertEquals("Assert tataStrs - 4", tataStrs.intValue(), 0);

+        assertEquals("Assert tata_2 - 4", tata_2.intValue(), 2);

+        assertEquals("Assert tata_3 - 4", tata_3.intValue(), 2);

+        assertEquals("Assert tata1 - 4", tata1.intValue(), 2);

+        assertEquals("Assert tata1_1 - 4", tata1_1.intValue(), 2);

+        assertEquals("Assert tata5 - 4", tata5.intValue(), 2);

+        assertEquals("Assert tata5_1 - 4", tata5_1.intValue(), 2);

+        assertEquals("Assert tata5_2 - 4", tata5_2.intValue(), 2);

+

+        getContext().ungetService(ref);

+        tota = null;

+

+        tataFactory.stop();

+        assertTrue("Assert under state - 5", under.getState() == ComponentInstance.INVALID);

+        assertNull("Assert no tota service - 5", getContext().getServiceReference(Tota.class.getName()));

+

+        totoProv2.stop();

+        tataFactory.start();

+        assertTrue("Assert under state - 6", under.getState() == ComponentInstance.VALID);

+        assertNotNull("Assert tota service - 6", getContext().getServiceReference(Tota.class.getName()));

+        ref = getContext().getServiceReference(Tota.class.getName());

+        tota = (Tota) getContext().getService(ref);

+        invokeAll(tota);

+        // Check toto

+        props = tota.getProps();

+        toto = (Integer) props.get("toto");

+        toto_2 = (Integer) props.get("toto_2");

+        toto_3 = (Integer) props.get("toto_3");

+        toto_4 = (Integer) props.get("toto_4");

+        gtoto = (Integer) props.get("gtoto");

+        gtoto_2 = (Integer) props.get("gtoto_2");

+        gtoto_3 = (Integer) props.get("gtoto_3");

+        gtoto_4 = (Integer) props.get("gtoto_4");

+        assertEquals("Assert toto - 6", toto.intValue(), 3);

+        assertEquals("Assert toto_2 - 6", toto_2.intValue(), 3);

+        assertEquals("Assert toto_3 - 6", toto_3.intValue(), 0);

+        assertEquals("Assert toto_4 - 6", toto_4.intValue(), 0);

+        assertEquals("Assert gtoto - 6 (" + gtoto.intValue() + ")", gtoto.intValue(), 3);

+        assertEquals("Assert gtoto_2 - 6", gtoto_2.intValue(), 3);

+        assertEquals("Assert gtoto_3 - 6", gtoto_3.intValue(), 3);

+        assertEquals("Assert gtoto_4 - 6", gtoto_4.intValue(), 0);

+        //Check tata

+        props = tota.getPropsTata();

+        tata = (Integer) props.get("tata");

+        tataStr = (Integer) props.get("tataStr");

+        tataStrs = (Integer) props.get("tataStrs");

+        tata_2 = (Integer) props.get("tata_2");

+        tata_3 = (Integer) props.get("tata_3");

+        tata1 = (Integer) props.get("tata1");

+        tata1_1 = (Integer) props.get("tata1_1");

+        tata5 = (Integer) props.get("tata5");

+        tata5_1 = (Integer) props.get("tata5_1");

+        tata5_2 = (Integer) props.get("tata5_2");

+        assertEquals("Assert tata - 6", tata.intValue(), 1);

+        assertEquals("Assert tataStr - 6", tataStr.intValue(), 1);

+        assertEquals("Assert tataStrs - 6", tataStrs.intValue(), 0);

+        assertEquals("Assert tata_2 - 6", tata_2.intValue(), 1);

+        assertEquals("Assert tata_3 - 6", tata_3.intValue(), 1);

+        assertEquals("Assert tata1 - 6", tata1.intValue(), 1);

+        assertEquals("Assert tata1_1 - 6", tata1_1.intValue(), 1);

+        assertEquals("Assert tata5 - 6", tata5.intValue(), 1);

+        assertEquals("Assert tata5_1 - 6", tata5_1.intValue(), 1);

+        assertEquals("Assert tata5_2 - 6", tata5_2.intValue(), 1);

+        getContext().ungetService(ref);

+        tota = null;

+

+        // Is arch exposed

+        assertNotNull("Test arch", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "ff"));

+

+        totoProv.stop();

+

+        assertTrue("Assert under state - 7", under.getState() == ComponentInstance.INVALID);

+        assertNotNull("Test arch-2", ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "ff"));

+        assertNull("Assert no tota service - 7", getContext().getServiceReference(Tota.class.getName()));

+

+        under.dispose();

+        under = null;

+    }

+

+    private void invoke(Tota tota) {

+        tota.tata();

+

+        assertEquals("Assert invoke tataint", tota.tataInt(2), 2);

+        assertEquals("Assert invoke tataLong", tota.tataLong(2), 2);

+        assertEquals("Assert invoke tataDouble", tota.tataDouble(2), 2, 0);

+        assertEquals("Assert invoke tataChar", tota.tataChar('a'), 'a');

+        assertTrue("Assert invoke tataBoolean", tota.tataBoolean(true));

+        assertEquals("Assert invoke tataByte", tota.tataByte((byte) 2), 2);

+        assertEquals("Assert invoke tataShort", tota.tataShort((short) 5), 5);

+        assertEquals("Assert invoke tataFloat", tota.tataFloat(5), 5, 0);

+

+    }

+

+    private void invokeArrays(Tota tota) {

+

+        int[] a = new int[]{1, 2, 3};

+        assertEquals("Assert invoke tataint[]", tota.tataInts(a), a);

+

+        long[] b = new long[]{1, 2, 3};

+        assertEquals("Assert invoke tataLong[]", tota.tataLongs(b), b);

+

+        double[] c = new double[]{1, 2, 3};

+        assertEquals("Assert invoke tataDouble[]", tota.tataDoubles(c), c);

+

+        char[] d = new char[]{'a', 'b', 'c'};

+        assertEquals("Assert invoke tataChar[]", tota.tataChars(d), d);

+

+        boolean[] e = new boolean[]{true, false};

+        assertEquals("Assert invoke tataBoolean[]", tota.tataBooleans(e), e);

+

+        byte[] f = new byte[]{(byte) 1};

+        assertEquals("Assert invoke tataByte[]", tota.tataBytes(f), f);

+

+        short[] g = new short[]{(short) 1};

+        assertEquals("Assert invoke tataShort[]", tota.tataShorts(g), g);

+

+        float[] h = new float[]{5, 6, 7};

+        assertEquals("Assert invoke tataFloat[]", tota.tataFloats(h), h);

+

+    }

+

+    private void invokeStr(Tota tota) {

+        tota.tataStr();

+    }

+

+    private void invokeTata(Tota tota) {

+        tota.tata(1, 2);

+        tota.tata("tototototo");

+    }

+

+    private void invokeTata1(Tota tota) {

+        assertEquals("Assert tata1", tota.tata1("foo"), "foo");

+        assertEquals("Assert tata1 - 2", tota.tata1(new char[]{'a', 'b', 'c'}), "abc");

+    }

+

+    private void invokeTata5(Tota tota) {

+        assertEquals("Assert tata5 -1", tota.tata5("foo", 1), "foo" + 1);

+        assertEquals("Assert tata5 - 2", tota.tata5(new String[]{"a", "b", "c"}, 1), "31");

+        assertEquals("Assert tata5 - 3", tota.tata5("foo", new int[]{1, 2, 3}), "foo3");

+    }

+

+    private void invokeAdd(Tota tota) {

+        assertEquals("Assert add", tota.add(1, 1, 1), 3);

+    }

+

+    private void invokeToto(Tota tota) {

+        tota.toto();

+        assertEquals("Assert toto", tota.toto("foo"), "foo");

+        tota.toto(1, 2);

+    }

+

+    private void invokeAll(Tota tota) {

+        invoke(tota);

+        invokeArrays(tota);

+        invokeStr(tota);

+        invokeTata(tota);

+        invokeTata1(tota);

+        invokeTata5(tota);

+        invokeAdd(tota);

+        invokeToto(tota);

+    }

+

+

+}