Fix FELIX-2755 Allow the manipulator and the different front end to use several metadata files

Modify some test projects to use this new feature.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1054377 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java b/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java
index 850c68b..2731ed8 100644
--- a/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java
+++ b/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java
@@ -1,4 +1,4 @@
-/* 
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -169,7 +169,11 @@
             if (!m_metadata.exists()) {
                 throw new BuildException("No metadata file found - the file " + m_metadata.getAbsolutePath() + " does not exist");
             } else {
-                log("Metadata file : " + m_metadata.getAbsolutePath());
+            	if (m_metadata.isDirectory()) {
+            		log("Metadata directory : " + m_metadata.getAbsolutePath());
+            	} else {
+            		log("Metadata file : " + m_metadata.getAbsolutePath());
+            	}
             }
         }
 
@@ -243,10 +247,7 @@
         if (version.startsWith("1.4")) {
             System.setProperty("org.xml.sax.driver", "org.apache.xerces.parsers.SAXParser");
         }
-
     }
 
-
-
 }
 
diff --git a/ipojo/composite/pom.xml b/ipojo/composite/pom.xml
index 7a1298c..cab706b 100644
--- a/ipojo/composite/pom.xml
+++ b/ipojo/composite/pom.xml
@@ -117,7 +117,7 @@
               <goal>ipojo-bundle</goal>
             </goals>
             <configuration>
-              <metadata>metadata.xml</metadata>
+              <metadata>src/main/resources/metadata.xml</metadata>
               <ignoreAnnotations>true</ignoreAnnotations>
             </configuration>
           </execution>
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java
index 7bb8a24..0c82646 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java
@@ -1018,27 +1018,36 @@
      * @param metadataFile the metadata file
      */
     private void parseXMLMetadata(File metadataFile) {
-        try {
-            InputStream stream = null;
-            URL url = metadataFile.toURI().toURL();
-            if (url == null) {
-                warn("Cannot find the metadata file : " + metadataFile.getAbsolutePath());
-                m_metadata = new ArrayList/*Element*/();
-            } else {
-                stream = url.openStream();
-                parseXMLMetadata(stream); // m_metadata is set by the method.
-            }
-        } catch (MalformedURLException e) {
-            error("Cannot open the metadata input stream from " + metadataFile.getAbsolutePath() + ": " + e.getMessage());
-            m_metadata = null;
-        } catch (IOException e) {
-            error("Cannot open the metadata input stream: " + metadataFile.getAbsolutePath() + ": " + e.getMessage());
-            m_metadata = null;
-        }
+    	if (metadataFile.isDirectory()) {
+    		// Traverse the directory and parse all files.
+    		File[] files = metadataFile.listFiles();
+    		for (int i = 0; i< files.length; i++) {
+    			parseXMLMetadata(files[i]);
+    		}
+    	} else if (metadataFile.getName().endsWith(".xml")) { // Detect XML by extension,
+    														  // others are ignored.
+	        try {
+	            InputStream stream = null;
+	            URL url = metadataFile.toURI().toURL();
+	            if (url == null) {
+	                warn("Cannot find the metadata file : " + metadataFile.getAbsolutePath());
+	                m_metadata = new ArrayList/*Element*/();
+	            } else {
+	                stream = url.openStream();
+	                parseXMLMetadata(stream); // m_metadata is set by the method.
+	            }
+	        } catch (MalformedURLException e) {
+	            error("Cannot open the metadata input stream from " + metadataFile.getAbsolutePath() + ": " + e.getMessage());
+	            m_metadata = null;
+	        } catch (IOException e) {
+	            error("Cannot open the metadata input stream: " + metadataFile.getAbsolutePath() + ": " + e.getMessage());
+	            m_metadata = null;
+	        }
 
-        // m_metadata can be either an empty array or an Element
-        // array with component type description. It also can be null
-        // if no metadata file is given.
+	        // m_metadata can be either an empty array or an Element
+	        // array with component type description. It also can be null
+	        // if no metadata file is given.
+    	}
     }
 
     /**
diff --git a/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java b/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java
index 0499cbf..4f0e18d 100644
--- a/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java
+++ b/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java
@@ -20,8 +20,6 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.util.Arrays;
 import java.util.List;
@@ -63,7 +61,7 @@
 
     /**
      * Location of the metadata file or iPOJO metadata configuration.
-     * @parameter alias="metadata" default-value="metadata.xml"
+     * @parameter alias="metadata"
      */
     private String m_metadata;
 
@@ -134,39 +132,55 @@
 
         // Get metadata
         // Check if metadata are contained in the configuration
-        InputStream is = null;
+        File metadata = null; // Metadata File or directory containing the metadata files.
+        InputStream is = null; //Use if contained in the configuration
 
         if (isXML()) {
             is = new ByteArrayInputStream(m_metadata.getBytes());
         } else {
+        	// If the metadata is not set,
+        	// first check if ./src/main/ipojo exists, if so look into it.
             if (m_metadata == null) {
-                // Try with metadata.xml
-                m_metadata = "metadata.xml";
-            }
-            // Look for the metadata file in the output directory
-            File meta = new File(m_outputDirectory + File.separator + m_metadata);
-            // If not found look inside the pom directory
-            if (! meta.exists()) {
-                meta = new File(m_project.getBasedir() + File.separator + m_metadata);
+            	File m = new File(m_project.getBasedir(), "src/main/ipojo");
+            	if (m.isDirectory()) {
+            		metadata = m;
+            		getLog().info("Metadata directory : " + metadata.getAbsolutePath());
+            	} else {
+            		// Else check target/classes/metadata.xml
+            		File meta = new File(m_outputDirectory + File.separator + "metadata.xml");
+            		if (! meta.exists()) {
+            			// If it still does not exist, try ./metadata.xml
+                        meta = new File(m_project.getBasedir() + File.separator + m_metadata);
+                    }
+
+            		if (meta.exists()) {
+            			metadata = meta;
+            			getLog().info("Metadata file : " + metadata.getAbsolutePath());
+            		}
+
+            		// No metadata.
+            	}
+            } else {
+            	// metadata path set.
+            	File m = new File(m_project.getBasedir(), m_metadata);
+            	if (! m.exists()) {
+            		throw new MojoExecutionException("The metadata file does not exist : " + m.getAbsolutePath());
+            	}
+            	metadata = m;
+            	if (m.isDirectory()) {
+            		getLog().info("Metadata directory : " + metadata.getAbsolutePath());
+            	} else {
+            		getLog().info("Metadata file : " + metadata.getAbsolutePath());
+            	}
             }
 
-            getLog().info("Metadata file : " + meta.getAbsolutePath());
-            if (!meta.exists()) {
-                // Verify if annotations are ignored
+            if (metadata == null) {
+            	// Verify if annotations are ignored
                 if (m_ignoreAnnotations) {
                     getLog().info("No metadata file found - ignoring annotations");
                     return;
                 } else {
                     getLog().info("No metadata file found - trying to use only annotations");
-                    meta = null;
-                }
-            }
-
-            if (meta != null) {
-                try {
-                    is = new FileInputStream(meta);
-                } catch (FileNotFoundException e) {
-                    throw new MojoExecutionException("the specified metadata file does not exist: " + e.getMessage());
                 }
             }
         }
@@ -174,8 +188,8 @@
         // Get input bundle, we use the already create artifact.
         File in = m_project.getArtifact().getFile();
         getLog().info("Input Bundle File : " + in.getAbsolutePath());
-        if (!in.exists()) {
-            throw new MojoExecutionException("the specified bundle file does not exist");
+        if (! in.exists()) {
+            throw new MojoExecutionException("The specified bundle file does not exist : " + in.getAbsolutePath());
         }
 
         File out = new File(m_buildDirectory + File.separator + "_out.jar");
@@ -186,8 +200,12 @@
 
         // Executes the pojoization.
         if (is == null) {
-            pojo.pojoization(in, out, (File) null); // Only annotations
-        } else  {
+        	if (metadata == null) { // No metadata.
+        		pojo.pojoization(in, out, (File) null); // Only annotations
+        	} else {
+        		pojo.pojoization(in, out, metadata); // Metadata set
+        	}
+        } else  { // In-Pom metadata.
             pojo.pojoization(in, out, is);
         }
 
diff --git a/ipojo/tests/core/configuration/src/main/resources/metadata.xml b/ipojo/tests/core/configuration/src/main/ipojo/metadata.xml
similarity index 74%
rename from ipojo/tests/core/configuration/src/main/resources/metadata.xml
rename to ipojo/tests/core/configuration/src/main/ipojo/metadata.xml
index ede1eff..7955c4a 100644
--- a/ipojo/tests/core/configuration/src/main/resources/metadata.xml
+++ b/ipojo/tests/core/configuration/src/main/ipojo/metadata.xml
@@ -247,87 +247,4 @@
 			<property method="setClasses" name="cls"/>

 		</properties>

 	</component>

-

-	<!--  updated -->

-	 <component

-		classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"

-		name="CONFIG-FooProviderType-ConfUpdated" architecture="true">

-		<provides />

-		<properties updated="updated">

-			<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}" />

-		</properties>

-	</component>

-

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"

-		name="CONFIG-FooProviderType-ConfNoValueUpdated" architecture="true">

-		<provides />

-		<properties updated="updated">

-			<property name="int" field="intProp"/>

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

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

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

-			<property name="intAProp" field="intAProp"/>

-		</properties>

-	</component>

-

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"

-		name="CONFIG-FooProviderType-4Updated" architecture="true">

-		<provides>

-			<property name="foo" field="m_foo" />

-			<property name="bar" field="m_bar" />

-			<property name="baz" type="java.lang.String" />

-		</provides>

-		<properties propagation="true" pid="FooProvider-3" updated="updated">

-			<property name="foo" field="m_foo" />

-			<property name="bar" field="m_bar" />

-		</properties>

-	</component>

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType2"

-		name="CONFIG-FooProviderType-4Updated2" architecture="true">

-		<provides>

-			<property name="foo" field="m_foo" />

-			<property name="bar" field="m_bar" />

-			<property name="baz" type="java.lang.String" />

-		</provides>

-		<properties propagation="true" pid="FooProvider-3" updated="updated">

-			<property name="foo" field="m_foo" />

-			<property name="bar" field="m_bar" />

-		</properties>

-	</component>

-

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"

-		name="CONFIG-FooProviderType-3Updated" architecture="true">

-		<provides>

-			<property name="foo" field="m_foo" />

-			<property name="bar" field="m_bar" />

-			<property name="baz" type="java.lang.String" />

-		</provides>

-		<properties propagation="true" updated="updated">

-			<property name="foo" field="m_foo" />

-			<property name="bar" field="m_bar" />

-		</properties>

-	</component>

-	<component

-		classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType2"

-		name="CONFIG-FooProviderType-3Updated2" architecture="true">

-		<provides>

-			<property name="foo" field="m_foo" />

-			<property name="bar" field="m_bar" />

-			<property name="baz" type="java.lang.String" />

-		</provides>

-		<properties propagation="true" updated="updated">

-			<property name="foo" field="m_foo" />

-			<property name="bar" field="m_bar" />

-		</properties>

-	</component>

-

 </ipojo>

diff --git a/ipojo/tests/core/configuration/src/main/ipojo/updated.xml b/ipojo/tests/core/configuration/src/main/ipojo/updated.xml
new file mode 100644
index 0000000..09374e8
--- /dev/null
+++ b/ipojo/tests/core/configuration/src/main/ipojo/updated.xml
@@ -0,0 +1,86 @@
+<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

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

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

+	<!--  updated -->

+	 <component

+		classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"

+		name="CONFIG-FooProviderType-ConfUpdated" architecture="true">

+		<provides />

+		<properties updated="updated">

+			<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}" />

+		</properties>

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"

+		name="CONFIG-FooProviderType-ConfNoValueUpdated" architecture="true">

+		<provides />

+		<properties updated="updated">

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

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

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

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

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

+		</properties>

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"

+		name="CONFIG-FooProviderType-4Updated" architecture="true">

+		<provides>

+			<property name="foo" field="m_foo" />

+			<property name="bar" field="m_bar" />

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

+		</provides>

+		<properties propagation="true" pid="FooProvider-3" updated="updated">

+			<property name="foo" field="m_foo" />

+			<property name="bar" field="m_bar" />

+		</properties>

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType2"

+		name="CONFIG-FooProviderType-4Updated2" architecture="true">

+		<provides>

+			<property name="foo" field="m_foo" />

+			<property name="bar" field="m_bar" />

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

+		</provides>

+		<properties propagation="true" pid="FooProvider-3" updated="updated">

+			<property name="foo" field="m_foo" />

+			<property name="bar" field="m_bar" />

+		</properties>

+	</component>

+

+	<component

+		classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"

+		name="CONFIG-FooProviderType-3Updated" architecture="true">

+		<provides>

+			<property name="foo" field="m_foo" />

+			<property name="bar" field="m_bar" />

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

+		</provides>

+		<properties propagation="true" updated="updated">

+			<property name="foo" field="m_foo" />

+			<property name="bar" field="m_bar" />

+		</properties>

+	</component>

+	<component

+		classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType2"

+		name="CONFIG-FooProviderType-3Updated2" architecture="true">

+		<provides>

+			<property name="foo" field="m_foo" />

+			<property name="bar" field="m_bar" />

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

+		</provides>

+		<properties propagation="true" updated="updated">

+			<property name="foo" field="m_foo" />

+			<property name="bar" field="m_bar" />

+		</properties>

+	</component>

+

+</ipojo>

diff --git a/ipojo/tests/core/service-providing/src/main/ipojo/README b/ipojo/tests/core/service-providing/src/main/ipojo/README
new file mode 100644
index 0000000..657bcef
--- /dev/null
+++ b/ipojo/tests/core/service-providing/src/main/ipojo/README
@@ -0,0 +1 @@
+This folder contains the iPOJO metadata.
\ No newline at end of file
diff --git a/ipojo/tests/core/service-providing/src/main/ipojo/basics.xml b/ipojo/tests/core/service-providing/src/main/ipojo/basics.xml
new file mode 100644
index 0000000..5816366
--- /dev/null
+++ b/ipojo/tests/core/service-providing/src/main/ipojo/basics.xml
@@ -0,0 +1,121 @@
+<ipojo

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

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

+>

+    <!-- Simple provider  -->

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"

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

+        <provides/>

+    </component>

+

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"

+     name="PS-FooProviderType-itf" architecture="true">

+        <provides

+         specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>

+    </component>

+

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"

+     name="PS-FooProviderType-3" architecture="true">

+        <provides>

+            <property name="foo" field="m_foo"/>

+            <property name="bar" field="m_bar"/>

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

+        </provides>

+        <properties propagation="true">

+            <property name="foo" field="m_foo"/>

+            <property name="bar" field="m_bar"/>

+        </properties>

+    </component>

+

+    <!-- Providers providing 2 services -->

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1"

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

+        <provides/>

+    </component>

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1"

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

+        <provides

+         specifications="{org.apache.felix.ipojo.test.scenarios.ps.service.FooService, org.apache.felix.ipojo.test.scenarios.ps.service.BarService }"/>

+    </component>

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1"

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

+        <provides

+         specifications="{org.apache.felix.ipojo.test.scenarios.ps.service.FooService}">

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

+        </provides>

+        <provides

+         specifications="{org.apache.felix.ipojo.test.scenarios.ps.service.BarService}">

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

+        </provides>

+    </component>

+

+

+    <!-- Provider with dynamic property -->

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"

+     name="PS-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.test.scenarios.component.FooProviderType1"

+     name="PS-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.test.scenarios.component.FooProviderTypeDyn2"

+     name="PS-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>

+

+    <!--  Null Check -->

+    <component classname="org.apache.felix.ipojo.test.scenarios.component.NullCheckServiceProvider" immediate="true"

+     name="PS-Null">

+        <provides>

+            <property field="prop1"/>

+            <property field="prop2"/>

+        </provides>

+    </component>

+

+    <!-- Anonymous classes -->

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderWithAnonymousClass"

+     name="PS-FooProviderTypeAnonymous-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>

+</ipojo>

diff --git a/ipojo/tests/core/service-providing/src/main/ipojo/callbacks/callbacks.xml b/ipojo/tests/core/service-providing/src/main/ipojo/callbacks/callbacks.xml
new file mode 100644
index 0000000..7963170
--- /dev/null
+++ b/ipojo/tests/core/service-providing/src/main/ipojo/callbacks/callbacks.xml
@@ -0,0 +1,41 @@
+<ipojo

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

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

+>

+    <!-- Registration callbacks -->

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"

+     name="PS-Callbacks-reg-only">

+        <provides post-registration="registered"/>

+    </component>

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"

+     name="PS-Callbacks-both">

+        <provides post-registration="registered" post-unregistration="unregistered"/>

+    </component>

+	<component

+     classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"

+     name="PS-Callbacks-unreg-only">

+        <provides post-unregistration="unregistered"/>

+    </component>

+	<component

+     classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"

+     name="PS-Callbacks-both-2">

+        <provides

+			specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"

+			post-unregistration="unregistered" post-registration="registered"/>

+		<provides

+			specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService"

+			post-unregistration="unregistered2" post-registration="registered2"/>

+    </component>

+	<component

+     classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"

+     name="PS-Callbacks-both-1">

+        <provides

+			specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"

+			post-unregistration="unregistered" post-registration="registered"/>

+		<provides

+			specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService"

+			post-unregistration="unregistered" post-registration="registered"/>

+    </component>

+</ipojo>

diff --git a/ipojo/tests/core/service-providing/src/main/ipojo/concrete-abstract.xml b/ipojo/tests/core/service-providing/src/main/ipojo/concrete-abstract.xml
new file mode 100644
index 0000000..25366c8
--- /dev/null
+++ b/ipojo/tests/core/service-providing/src/main/ipojo/concrete-abstract.xml
@@ -0,0 +1,28 @@
+<ipojo

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

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

+>

+

+    <!-- Concrete and abstract class -->

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"

+     name="PS-PI4" architecture="true">

+        <provides specifications="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"/>

+    </component>

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation2"

+     name="PS-PI5" architecture="true">

+        <provides specifications="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"/>

+    </component>

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation4"

+     name="PS-PI6" architecture="true">

+        <provides specifications="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"/>

+    </component>

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation3"

+     name="PS-PI7" architecture="true">

+        <provides specifications="[org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation, org.apache.felix.ipojo.test.scenarios.ps.service.FooService]"/>

+    </component>

+

+</ipojo>

diff --git a/ipojo/tests/core/service-providing/src/main/ipojo/controller/service-controller.xml b/ipojo/tests/core/service-providing/src/main/ipojo/controller/service-controller.xml
new file mode 100644
index 0000000..bff80f4
--- /dev/null
+++ b/ipojo/tests/core/service-providing/src/main/ipojo/controller/service-controller.xml
@@ -0,0 +1,86 @@
+<ipojo

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

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

+>

+    <!--  Service Controller -->

+    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.ControllerCheckService"

+     name="PS-Controller-1-default">

+        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">

+            <controller field="controller"/>

+        </provides>

+        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">

+        </provides>

+    </component>

+    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.ControllerCheckService"

+     name="PS-Controller-1-false">

+        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">

+            <property name="test2" type="string" value="test2"/>

+            <controller field="controller" value="false"/>

+            <property name="test" type="string" value="test"/>

+        </provides>

+        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">

+        </provides>

+    </component>

+    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"

+     name="PS-Controller-2-truetrue">

+        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">

+            <property name="test2" type="string" value="test2"/>

+            <controller field="controllerFoo" value="true"/>

+            <property name="test" type="string" value="test"/>

+        </provides>

+        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">

+            <controller field="controllerCS" value="true"/>

+        </provides>

+    </component>

+    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"

+     name="PS-Controller-2-truefalse">

+        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">

+            <property name="test2" type="string" value="test2"/>

+            <controller field="controllerFoo" value="false"/>

+            <property name="test" type="string" value="test"/>

+        </provides>

+        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">

+            <controller field="controllerCS" value="true"/>

+        </provides>

+    </component>

+

+    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"

+     name="PS-Controller-2-spec1">

+        <provides>

+            <property name="test2" type="string" value="test2"/>

+            <controller field="controllerFoo" value="false" specification="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>

+            <controller field="controllerCS" value="true" specification="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService"/>

+            <property name="test" type="string" value="test"/>

+        </provides>

+    </component>

+

+    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"

+     name="PS-Controller-2-spec2">

+        <provides>

+            <property name="test2" type="string" value="test2"/>

+            <controller field="controllerFoo" value="true" specification="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>

+            <controller field="controllerCS" value="true" specification="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService"/>

+            <property name="test" type="string" value="test"/>

+        </provides>

+    </component>

+

+    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"

+     name="PS-Controller-2-spec3">

+        <provides>

+            <property name="test2" type="string" value="test2"/>

+            <controller field="controllerFoo" value="true" specification="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>

+            <controller field="controllerCS" value="true"/>

+            <property name="test" type="string" value="test"/>

+        </provides>

+    </component>

+

+    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"

+     name="PS-Controller-2-spec4">

+        <provides>

+            <property name="test2" type="string" value="test2"/>

+            <controller field="controllerFoo" value="false" specification="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>

+            <controller field="controllerCS" value="true"/>

+            <property name="test" type="string" value="test"/>

+        </provides>

+    </component>

+</ipojo>

diff --git a/ipojo/tests/core/service-providing/src/main/ipojo/inheritance/inheritance.xml b/ipojo/tests/core/service-providing/src/main/ipojo/inheritance/inheritance.xml
new file mode 100644
index 0000000..dd103ac
--- /dev/null
+++ b/ipojo/tests/core/service-providing/src/main/ipojo/inheritance/inheritance.xml
@@ -0,0 +1,45 @@
+<ipojo

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

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

+>

+

+    <!--  Inherited Provides -->

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation1"

+     name="PS-PI1" architecture="true">

+        <provides/>

+    </component>

+

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation1"

+     name="PS-PI1-1" architecture="true">

+        <provides

+         specifications="org.apache.felix.ipojo.test.scenarios.ps.service.ParentParentInterface"/>

+    </component>

+

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation1"

+     name="PS-PI1-2" architecture="true">

+        <provides

+         specifications="{org.apache.felix.ipojo.test.scenarios.ps.service.ParentParentInterface, org.apache.felix.ipojo.test.scenarios.ps.service.ParentInterface2}"/>

+    </component>

+

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation2"

+     name="PS-PI2" architecture="true">

+        <provides/>

+    </component>

+

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation2"

+     name="PS-PI2-1" architecture="true">

+        <provides

+         specifications="org.apache.felix.ipojo.test.scenarios.ps.service.ParentParentInterface"/>

+    </component>

+

+    <component

+     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation3"

+     name="PS-PI3" architecture="true">

+        <provides/>

+    </component>

+</ipojo>

diff --git a/ipojo/tests/core/service-providing/src/main/resources/metadata.xml b/ipojo/tests/core/service-providing/src/main/resources/metadata.xml
deleted file mode 100644
index 1d6fa95..0000000
--- a/ipojo/tests/core/service-providing/src/main/resources/metadata.xml
+++ /dev/null
@@ -1,304 +0,0 @@
-<ipojo

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

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

->

-    <!-- Simple provider  -->

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"

-     name="PS-FooProviderType-1" architecture="true">

-        <provides/>

-    </component>

-

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"

-     name="PS-FooProviderType-itf" architecture="true">

-        <provides

-         specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>

-    </component>

-

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderType1"

-     name="PS-FooProviderType-3" architecture="true">

-        <provides>

-            <property name="foo" field="m_foo"/>

-            <property name="bar" field="m_bar"/>

-            <property name="baz" type="java.lang.String"/>

-        </provides>

-        <properties propagation="true">

-            <property name="foo" field="m_foo"/>

-            <property name="bar" field="m_bar"/>

-        </properties>

-    </component>

-

-    <!-- Providers providing 2 services -->

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1"

-     name="PS-FooBarProviderType-1" architecture="true">

-        <provides/>

-    </component>

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1"

-     name="PS-FooBarProviderType-2" architecture="true">

-        <provides

-         specifications="{org.apache.felix.ipojo.test.scenarios.ps.service.FooService, org.apache.felix.ipojo.test.scenarios.ps.service.BarService }"/>

-    </component>

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.FooBarProviderType1"

-     name="PS-FooBarProviderType-3" architecture="true">

-        <provides

-         specifications="{org.apache.felix.ipojo.test.scenarios.ps.service.FooService}">

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

-        </provides>

-        <provides

-         specifications="{org.apache.felix.ipojo.test.scenarios.ps.service.BarService}">

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

-        </provides>

-    </component>

-

-

-    <!-- Provider with dynamic property -->

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderTypeDyn"

-     name="PS-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.test.scenarios.component.FooProviderType1"

-     name="PS-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.test.scenarios.component.FooProviderTypeDyn2"

-     name="PS-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>

-

-    <!--  Inherited Provides -->

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation1"

-     name="PS-PI1" architecture="true">

-        <provides/>

-    </component>

-

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation1"

-     name="PS-PI1-1" architecture="true">

-        <provides

-         specifications="org.apache.felix.ipojo.test.scenarios.ps.service.ParentParentInterface"/>

-    </component>

-

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation1"

-     name="PS-PI1-2" architecture="true">

-        <provides

-         specifications="{org.apache.felix.ipojo.test.scenarios.ps.service.ParentParentInterface, org.apache.felix.ipojo.test.scenarios.ps.service.ParentInterface2}"/>

-    </component>

-

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation2"

-     name="PS-PI2" architecture="true">

-        <provides/>

-    </component>

-

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation2"

-     name="PS-PI2-1" architecture="true">

-        <provides

-         specifications="org.apache.felix.ipojo.test.scenarios.ps.service.ParentParentInterface"/>

-    </component>

-

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation3"

-     name="PS-PI3" architecture="true">

-        <provides/>

-    </component>

-

-    <!-- Concrete and abstract class -->

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"

-     name="PS-PI4" architecture="true">

-        <provides specifications="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"/>

-    </component>

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation2"

-     name="PS-PI5" architecture="true">

-        <provides specifications="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"/>

-    </component>

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation4"

-     name="PS-PI6" architecture="true">

-        <provides specifications="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation"/>

-    </component>

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessImplementation3"

-     name="PS-PI7" architecture="true">

-        <provides specifications="[org.apache.felix.ipojo.test.scenarios.component.inherited.ProcessParentImplementation, org.apache.felix.ipojo.test.scenarios.ps.service.FooService]"/>

-    </component>

-

-    <!--  Null Check -->

-    <component classname="org.apache.felix.ipojo.test.scenarios.component.NullCheckServiceProvider" immediate="true"

-     name="PS-Null">

-        <provides>

-            <property field="prop1"/>

-            <property field="prop2"/>

-        </provides>

-    </component>

-

-    <!--  Service Controller -->

-    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.ControllerCheckService"

-     name="PS-Controller-1-default">

-        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">

-            <controller field="controller"/>

-        </provides>

-        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">

-        </provides>

-    </component>

-    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.ControllerCheckService"

-     name="PS-Controller-1-false">

-        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">

-            <property name="test2" type="string" value="test2"/>

-            <controller field="controller" value="false"/>

-            <property name="test" type="string" value="test"/>

-        </provides>

-        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">

-        </provides>

-    </component>

-    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"

-     name="PS-Controller-2-truetrue">

-        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">

-            <property name="test2" type="string" value="test2"/>

-            <controller field="controllerFoo" value="true"/>

-            <property name="test" type="string" value="test"/>

-        </provides>

-        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">

-            <controller field="controllerCS" value="true"/>

-        </provides>

-    </component>

-    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"

-     name="PS-Controller-2-truefalse">

-        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">

-            <property name="test2" type="string" value="test2"/>

-            <controller field="controllerFoo" value="false"/>

-            <property name="test" type="string" value="test"/>

-        </provides>

-        <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">

-            <controller field="controllerCS" value="true"/>

-        </provides>

-    </component>

-    

-    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"

-     name="PS-Controller-2-spec1">

-        <provides>

-            <property name="test2" type="string" value="test2"/>

-            <controller field="controllerFoo" value="false" specification="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>

-            <controller field="controllerCS" value="true" specification="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService"/>

-            <property name="test" type="string" value="test"/>

-        </provides>

-    </component>

-    

-    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"

-     name="PS-Controller-2-spec2">

-        <provides>

-            <property name="test2" type="string" value="test2"/>

-            <controller field="controllerFoo" value="true" specification="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>

-            <controller field="controllerCS" value="true" specification="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService"/>

-            <property name="test" type="string" value="test"/>

-        </provides>

-    </component>

-    

-    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"

-     name="PS-Controller-2-spec3">

-        <provides>

-            <property name="test2" type="string" value="test2"/>

-            <controller field="controllerFoo" value="true" specification="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>

-            <controller field="controllerCS" value="true"/>

-            <property name="test" type="string" value="test"/>

-        </provides>

-    </component>

-    

-    <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"

-     name="PS-Controller-2-spec4">

-        <provides>

-            <property name="test2" type="string" value="test2"/>

-            <controller field="controllerFoo" value="false" specification="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"/>

-            <controller field="controllerCS" value="true"/>

-            <property name="test" type="string" value="test"/>

-        </provides>

-    </component>

-    

-    

-

-    <!-- Anonymous classes -->

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.FooProviderWithAnonymousClass"

-     name="PS-FooProviderTypeAnonymous-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>

-

-    <!-- Registration callbacks -->

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"

-     name="PS-Callbacks-reg-only">

-        <provides post-registration="registered"/>

-    </component>

-    <component

-     classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"

-     name="PS-Callbacks-both">

-        <provides post-registration="registered" post-unregistration="unregistered"/>

-    </component>

-	<component

-     classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"

-     name="PS-Callbacks-unreg-only">

-        <provides post-unregistration="unregistered"/>

-    </component>

-	<component

-     classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"

-     name="PS-Callbacks-both-2">

-        <provides

-			specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"

-			post-unregistration="unregistered" post-registration="registered"/>

-		<provides

-			specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService"

-			post-unregistration="unregistered2" post-registration="registered2"/>

-    </component>

-	<component

-     classname="org.apache.felix.ipojo.test.scenarios.component.callbacks.CallbacksCheckService"

-     name="PS-Callbacks-both-1">

-        <provides

-			specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService"

-			post-unregistration="unregistered" post-registration="registered"/>

-		<provides

-			specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService"

-			post-unregistration="unregistered" post-registration="registered"/>

-    </component>

-</ipojo>

diff --git a/ipojo/tests/manipulator/manipulation/src/main/resources/metadata.xml b/ipojo/tests/manipulator/manipulation/src/main/ipojo/metadata.xml
similarity index 100%
rename from ipojo/tests/manipulator/manipulation/src/main/resources/metadata.xml
rename to ipojo/tests/manipulator/manipulation/src/main/ipojo/metadata.xml