You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2011/08/18 13:32:22 UTC

svn commit: r1159173 [1/5] - in /felix/trunk/ipojo: ant/ ant/src/main/java/org/apache/felix/ipojo/task/ manipulator/ manipulator/src/main/java/org/apache/felix/ipojo/manipulation/ manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ manipulato...

Author: clement
Date: Thu Aug 18 11:32:19 2011
New Revision: 1159173

URL: http://svn.apache.org/viewvc?rev=1159173&view=rev
Log:
Fixed FELIX-3078 and FELIX-3079

The new manipulation process is now easily embeddable and the process can be extended.

Thanks to Guillaume Sauthier for this hard work.

Added:
    felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/AntReporter.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManifestProvider.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationEngine.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationResultVisitor.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationUnit.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationVisitor.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/MetadataProvider.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Reporter.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ResourceStore.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ResourceVisitor.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/manifest/
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/manifest/DirectManifestProvider.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/manifest/FileManifestProvider.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/AnnotationMetadataProvider.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/CacheableMetadataProvider.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/CompositeMetadataProvider.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/EmptyMetadataProvider.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/FileMetadataProvider.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/metadata/StreamMetadataProvider.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/render/
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/render/ManipulatedMetadataFilter.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/render/MetadataFilter.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/render/MetadataRenderer.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/reporter/
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/reporter/EmptyReporter.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/reporter/SystemReporter.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/DirectoryResourceStore.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/JarFileResourceStore.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/ManifestBuilder.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/ResourceMapper.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/builder/
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/builder/DefaultManifestBuilder.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/mapper/
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/mapper/FileSystemResourceMapper.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/mapper/IdentityResourceMapper.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/store/mapper/WABResourceMapper.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Collections5.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Metadatas.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Streams.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/util/Strings.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/visitor/
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/visitor/ManipulationAdapter.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/visitor/ManipulationResultAdapter.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/visitor/check/
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/visitor/check/CheckFieldConsistencyResultVisitor.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/visitor/check/CheckFieldConsistencyVisitor.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/visitor/writer/
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/visitor/writer/ManipulatedResourcesWriter.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/visitor/writer/ManipulatedResultWriter.java
    felix/trunk/ipojo/manipulator/src/main/resources/xsd/
    felix/trunk/ipojo/manipulator/src/main/resources/xsd/composite.xsd
    felix/trunk/ipojo/manipulator/src/main/resources/xsd/core.xsd
    felix/trunk/ipojo/manipulator/src/main/resources/xsd/event-admin.xsd
    felix/trunk/ipojo/manipulator/src/main/resources/xsd/extender-pattern.xsd
    felix/trunk/ipojo/manipulator/src/main/resources/xsd/jmx.xsd
    felix/trunk/ipojo/manipulator/src/main/resources/xsd/temporal.xsd
    felix/trunk/ipojo/manipulator/src/main/resources/xsd/whiteboard-pattern.xsd
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/ManipulationEngineTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/manifest/
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/manifest/DirectManifestProviderTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/manifest/FileManifestProviderTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/metadata/
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/metadata/AnnotationMetadataProviderTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/metadata/CacheableMetadataProviderTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/metadata/CompositeMetadataProviderTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/metadata/EmptyMetadataProviderTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/metadata/FileMetadataProviderTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/metadata/StreamMetadataProviderTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/render/
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/render/ManipulatedMetadataFilterTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/render/MetadataRendererTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/DirectoryResourceStoreTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/JarFileResourceStoreTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/builder/
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/builder/DefaultManifestBuilderTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/FileSystemResourceMapperTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/IdentityResourceMapperTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/store/mapper/WABResourceMapperTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/util/
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/util/StreamsTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/util/StringsTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/check/
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/check/CheckFieldConsistencyResultVisitorTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/writer/
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/writer/ManipulatedResourcesWriterTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulator/visitor/writer/ManipulatedResultWriterTestCase.java
    felix/trunk/ipojo/manipulator/src/test/java/test/AnnotatedComponent.java
    felix/trunk/ipojo/manipulator/src/test/resources/MANIFEST.MF
    felix/trunk/ipojo/manipulator/src/test/resources/empty-metadata.xml
    felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/MavenReporter.java
Modified:
    felix/trunk/ipojo/ant/pom.xml
    felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java
    felix/trunk/ipojo/manipulator/pom.xml
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/Pojoization.java
    felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/xml/parser/XMLMetadataParser.java
    felix/trunk/ipojo/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/PojoizationTest.java
    felix/trunk/ipojo/plugin/pom.xml
    felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java

Modified: felix/trunk/ipojo/ant/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/ant/pom.xml?rev=1159173&r1=1159172&r2=1159173&view=diff
==============================================================================
--- felix/trunk/ipojo/ant/pom.xml (original)
+++ felix/trunk/ipojo/ant/pom.xml Thu Aug 18 11:32:19 2011
@@ -46,7 +46,7 @@
     <dependency>
       <groupId>org.apache.felix</groupId>
       <artifactId>org.apache.felix.ipojo.manipulator</artifactId>
-      <version>1.8.0</version>
+      <version>1.9.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>xerces</groupId>
@@ -121,6 +121,14 @@
           <configLocation>http://felix.apache.org/ipojo/dev/checkstyle_ipojo.xml</configLocation>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 </project>

Added: felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/AntReporter.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/AntReporter.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/AntReporter.java (added)
+++ felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/AntReporter.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,68 @@
+/*
+ * 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.task;
+
+import org.apache.felix.ipojo.manipulator.reporter.EmptyReporter;
+import org.apache.tools.ant.Project;
+
+/**
+ * An {@code AntReporter} wraps an Ant project (central place for logging in ant
+ * into an iPOJO Reporter.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class AntReporter extends EmptyReporter {
+
+    /**
+     * Ant Project (used for log).
+     */
+    private Project project;
+
+    public AntReporter(Project project) {
+        this.project = project;
+    }
+
+    @Override
+    public void trace(String message, Object... args) {
+        String formatted = String.format(message, getMessageArguments(args));
+        project.log(formatted, Project.MSG_DEBUG);
+    }
+
+    @Override
+    public void info(String message, Object... args) {
+        String formatted = String.format(message, getMessageArguments(args));
+        project.log(formatted, Project.MSG_INFO);
+    }
+
+    @Override
+    public void warn(String message, Object... args) {
+        String formatted = String.format(message, getMessageArguments(args));
+        project.log(formatted, Project.MSG_WARN);
+        getWarnings().add(formatted);
+    }
+
+    @Override
+    public void error(String message, Object... args) {
+        String formatted = String.format(message, getMessageArguments(args));
+        project.log(formatted, Project.MSG_ERR);
+        getErrors().add(formatted);
+    }
+
+}

Modified: felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java?rev=1159173&r1=1159172&r2=1159173&view=diff
==============================================================================
--- felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java (original)
+++ felix/trunk/ipojo/ant/src/main/java/org/apache/felix/ipojo/task/IPojoTask.java Thu Aug 18 11:32:19 2011
@@ -24,6 +24,7 @@ import org.apache.felix.ipojo.manipulato
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
+import sun.awt.geom.AreaOp;
 
 /**
  * iPOJO Ant Task. This Ant task manipulates an input bundle.
@@ -192,7 +193,8 @@ public class IPojoTask extends Task {
             }
         }
 
-        Pojoization pojo = new Pojoization();
+        AntReporter reporter = new AntReporter(getProject());
+        Pojoization pojo = new Pojoization(reporter);
         if (m_ignoreAnnotations) {
             pojo.disableAnnotationProcessing();
         }
@@ -204,10 +206,12 @@ public class IPojoTask extends Task {
         } else {
             pojo.directoryPojoization(m_directory, m_metadata, m_manifest);
         }
-        for (int i = 0; i < pojo.getWarnings().size(); i++) {
-            log((String) pojo.getWarnings().get(i), Project.MSG_WARN);
+        for (int i = 0; i < reporter.getWarnings().size(); i++) {
+            log((String) reporter.getWarnings().get(i), Project.MSG_WARN);
+        }
+        if (reporter.getErrors().size() > 0) {
+            throw new BuildException((String) reporter.getErrors().get(0));
         }
-        if (pojo.getErrors().size() > 0) { throw new BuildException((String) pojo.getErrors().get(0)); }
 
         if (m_input != null) {
             String out;

Modified: felix/trunk/ipojo/manipulator/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/pom.xml?rev=1159173&r1=1159172&r2=1159173&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/pom.xml (original)
+++ felix/trunk/ipojo/manipulator/pom.xml Thu Aug 18 11:32:19 2011
@@ -46,10 +46,21 @@
         </exclusion>
       </exclusions>
     </dependency>
+      <dependency>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.ipojo.metadata</artifactId>
+        <version>1.4.0</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.ipojo.annotations</artifactId>
+        <version>1.8.0</version>
+      </dependency>
     <dependency>
-      <groupId>org.apache.felix</groupId>
-      <artifactId>org.apache.felix.ipojo.metadata</artifactId>
-      <version>1.4.0</version>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
+      <version>1.8.5</version>
+      <scope>test</scope>
     </dependency>
   </dependencies>
   <build>
@@ -65,7 +76,7 @@
             <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
             <Bundle-Vendor> The Apache Software Foundation </Bundle-Vendor>
             <Bundle-Description> iPOJO Manipulator </Bundle-Description>
-            <Export-Package> org.apache.felix.ipojo.manipulator
+            <Export-Package> org.apache.felix.ipojo.manipulator.*
             </Export-Package>
             <Private-Package> org.apache.felix.ipojo.manipulation,
               org.apache.felix.ipojo.manipulation.annotations,
@@ -75,8 +86,8 @@
               META-INF/LICENSE=LICENSE,
               META-INF/LICENSE.asm=LICENSE.asm,
               META-INF/NOTICE=NOTICE,
-              xsd=src/main/resources,
-              META-INF/DEPENDENCIES=DEPENDENCIES
+              META-INF/DEPENDENCIES=DEPENDENCIES,
+              {maven-resources}
             </Include-Resource>
             <Import-Package>!org.objectweb.asm.tree, *</Import-Package>
           </instructions>

Modified: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java?rev=1159173&r1=1159172&r2=1159173&view=diff
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java (original)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/Manipulator.java Thu Aug 18 11:32:19 2011
@@ -1,157 +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.manipulation;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.felix.ipojo.metadata.Attribute;
-import org.apache.felix.ipojo.metadata.Element;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassWriter;
-
-/**
- * iPOJO Byte code Manipulator.
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- *
- */
-public class Manipulator {
-    /**
-     * Store the visited fields : [name of the field, type of the field].
-     */
-    private Map m_fields;
-
-    /**
-     * Store the interface implemented by the class.
-     */
-    private List m_interfaces;
-
-    /**
-     * Store the methods list.
-     */
-    private List m_methods;
-
-    /**
-     * Pojo super class.
-     */
-    private String m_superClass;
-
-    /**
-     * List of owned inner classed.
-     */
-    private List m_inners;
-
-    /**
-     * Manipulate the given byte array.
-     * @param origin : original class.
-     * @return the manipulated class, if the class is already manipulated, the original class.
-     * @throws IOException : if an error occurs during the manipulation.
-     */
-    public byte[] manipulate(byte[] origin) throws IOException {
-        InputStream is1 = new ByteArrayInputStream(origin);
-
-        // First check if the class is already manipulated :
-        ClassReader ckReader = new ClassReader(is1);
-        ClassChecker ck = new ClassChecker();
-        ckReader.accept(ck, ClassReader.SKIP_FRAMES);
-        is1.close();
-
-        m_fields = ck.getFields(); // Get visited fields (contains only POJO fields)
-
-        // Get interfaces and super class.
-        m_interfaces = ck.getInterfaces();
-        m_superClass = ck.getSuperClass();
-
-        // Get the methods list
-        m_methods = ck.getMethods();
-
-        m_inners = ck.getInnerClasses();
-
-        ClassWriter finalWriter = null;
-        if (!ck.isalreadyManipulated()) {
-            // Manipulation ->
-            // Add the _setComponentManager method
-            // Instrument all fields
-            InputStream is2 = new ByteArrayInputStream(origin);
-            ClassReader cr0 = new ClassReader(is2);
-            ClassWriter cw0 = new ClassWriter(ClassWriter.COMPUTE_MAXS);
-            //CheckClassAdapter ch = new CheckClassAdapter(cw0);
-            MethodCreator preprocess = new MethodCreator(cw0, m_fields, m_methods);
-            cr0.accept(preprocess, ClassReader.SKIP_FRAMES);
-            is2.close();
-            finalWriter = cw0;
-        }
-        // The file is in the bundle
-        if (ck.isalreadyManipulated()) {
-            return origin;
-        } else {
-            return finalWriter.toByteArray();
-        }
-    }
-
-    /**
-     * Compute component type manipulation metadata.
-     * @return the manipulation metadata of the class.
-     */
-    public Element getManipulationMetadata() {
-        Element elem = new Element("Manipulation", "");
-
-        if (m_superClass != null) {
-            elem.addAttribute(new Attribute("super", m_superClass));
-        }
-
-        for (int j = 0; j < m_interfaces.size(); j++) {
-            Element itf = new Element("Interface", "");
-            Attribute att = new Attribute("name", m_interfaces.get(j).toString());
-            itf.addAttribute(att);
-            elem.addElement(itf);
-        }
-
-        for (Iterator it = m_fields.keySet().iterator(); it.hasNext();) {
-            Element field = new Element("Field", "");
-            String name = (String) it.next();
-            String type = (String) m_fields.get(name);
-            Attribute attName = new Attribute("name", name);
-            Attribute attType = new Attribute("type", type);
-            field.addAttribute(attName);
-            field.addAttribute(attType);
-            elem.addElement(field);
-        }
-
-        for (int j = 0; j < m_methods.size(); j++) {
-            MethodDescriptor method = (MethodDescriptor) m_methods.get(j);
-            elem.addElement(method.getElement());
-        }
-
-        return elem;
-    }
-
-    public Map getFields() {
-        return m_fields;
-    }
-
-    public List getInnerClasses() {
-        return m_inners;
-    }
-
-}
+/*
+ * 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.manipulation;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.felix.ipojo.metadata.Attribute;
+import org.apache.felix.ipojo.metadata.Element;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassWriter;
+
+/**
+ * iPOJO Byte code Manipulator.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ *
+ */
+public class Manipulator {
+    /**
+     * Store the visited fields : [name of the field, type of the field].
+     */
+    private Map m_fields;
+
+    /**
+     * Store the interface implemented by the class.
+     */
+    private List m_interfaces;
+
+    /**
+     * Store the methods list.
+     */
+    private List m_methods;
+
+    /**
+     * Pojo super class.
+     */
+    private String m_superClass;
+
+    /**
+     * List of owned inner classed.
+     */
+    private List<String> m_inners;
+
+    /**
+     * Manipulate the given byte array.
+     * @param origin : original class.
+     * @return the manipulated class, if the class is already manipulated, the original class.
+     * @throws IOException : if an error occurs during the manipulation.
+     */
+    public byte[] manipulate(byte[] origin) throws IOException {
+        InputStream is1 = new ByteArrayInputStream(origin);
+
+        // First check if the class is already manipulated :
+        ClassReader ckReader = new ClassReader(is1);
+        ClassChecker ck = new ClassChecker();
+        ckReader.accept(ck, ClassReader.SKIP_FRAMES);
+        is1.close();
+
+        m_fields = ck.getFields(); // Get visited fields (contains only POJO fields)
+
+        // Get interfaces and super class.
+        m_interfaces = ck.getInterfaces();
+        m_superClass = ck.getSuperClass();
+
+        // Get the methods list
+        m_methods = ck.getMethods();
+
+        m_inners = ck.getInnerClasses();
+
+        ClassWriter finalWriter = null;
+        if (!ck.isalreadyManipulated()) {
+            // Manipulation ->
+            // Add the _setComponentManager method
+            // Instrument all fields
+            InputStream is2 = new ByteArrayInputStream(origin);
+            ClassReader cr0 = new ClassReader(is2);
+            ClassWriter cw0 = new ClassWriter(ClassWriter.COMPUTE_MAXS);
+            //CheckClassAdapter ch = new CheckClassAdapter(cw0);
+            MethodCreator preprocess = new MethodCreator(cw0, m_fields, m_methods);
+            cr0.accept(preprocess, ClassReader.SKIP_FRAMES);
+            is2.close();
+            finalWriter = cw0;
+        }
+        // The file is in the bundle
+        if (ck.isalreadyManipulated()) {
+            return origin;
+        } else {
+            return finalWriter.toByteArray();
+        }
+    }
+
+    /**
+     * Compute component type manipulation metadata.
+     * @return the manipulation metadata of the class.
+     */
+    public Element getManipulationMetadata() {
+        Element elem = new Element("Manipulation", "");
+
+        if (m_superClass != null) {
+            elem.addAttribute(new Attribute("super", m_superClass));
+        }
+
+        for (int j = 0; j < m_interfaces.size(); j++) {
+            Element itf = new Element("Interface", "");
+            Attribute att = new Attribute("name", m_interfaces.get(j).toString());
+            itf.addAttribute(att);
+            elem.addElement(itf);
+        }
+
+        for (Iterator it = m_fields.keySet().iterator(); it.hasNext();) {
+            Element field = new Element("Field", "");
+            String name = (String) it.next();
+            String type = (String) m_fields.get(name);
+            Attribute attName = new Attribute("name", name);
+            Attribute attType = new Attribute("type", type);
+            field.addAttribute(attName);
+            field.addAttribute(attType);
+            elem.addElement(field);
+        }
+
+        for (int j = 0; j < m_methods.size(); j++) {
+            MethodDescriptor method = (MethodDescriptor) m_methods.get(j);
+            elem.addElement(method.getElement());
+        }
+
+        return elem;
+    }
+
+    public Map getFields() {
+        return m_fields;
+    }
+
+    public List<String> getInnerClasses() {
+        return m_inners;
+    }
+
+}

Added: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManifestProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManifestProvider.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManifestProvider.java (added)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManifestProvider.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.manipulator;
+
+import java.util.jar.Manifest;
+
+/**
+ * A {@code ManifestProvider} is responsible of providing the original
+ * {@link Manifest} of the manipulated Bundle.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface ManifestProvider {
+
+    /**
+     * Returns the original bundle's Manifest.
+     * @return Manifest of the bundle
+     */
+    Manifest getManifest();
+}

Added: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationEngine.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationEngine.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationEngine.java (added)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationEngine.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,153 @@
+/*
+ * 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.manipulator;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.felix.ipojo.manipulation.InnerClassManipulator;
+import org.apache.felix.ipojo.manipulation.Manipulator;
+
+/**
+ * A {@code ManipulationEngine} is responsible to drive the component's
+ * classes manipulation.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ManipulationEngine {
+
+    /**
+     * List of component types.
+     */
+    private List<ManipulationUnit> manipulationUnits = new ArrayList<ManipulationUnit>();
+
+    /**
+     * Error reporting.
+     */
+    private Reporter m_reporter;
+
+    /**
+     * Bytecode store.
+     */
+    private ResourceStore m_store;
+
+    /**
+     * The visitor handling output result.
+     */
+    private ManipulationVisitor manipulationVisitor;
+
+    /**
+     * Add information related to a discovered component that will be manipulated.
+     * @param component additional component
+     */
+    public void addManipulationUnit(ManipulationUnit component) {
+        manipulationUnits.add(component);
+    }
+
+    public void setManipulationVisitor(ManipulationVisitor manipulationVisitor) {
+        this.manipulationVisitor = manipulationVisitor;
+    }
+
+    /**
+     * @param reporter Feedback reporter.
+     */
+    public void setReporter(Reporter reporter) {
+        this.m_reporter = reporter;
+    }
+
+    /**
+     * Provides the bytecode store that allows to retrieve bytecode of the
+     * component's related resources (inner classes for example).
+     * @param store Helps to locate bytecode for classes.
+     */
+    public void setResourceStore(ResourceStore store) {
+        this.m_store = store;
+    }
+
+    /**
+     * Manipulates classes of all the given component's.
+     */
+    public void generate() {
+
+        // Iterates over the list of discovered components
+        // Note that this list includes components from metadata.xml AND from annotations
+
+        for (ManipulationUnit info : manipulationUnits) {
+
+            byte[] bytecode;
+            try {
+                bytecode = m_store.read(info.getResourcePath());
+            } catch (IOException e) {
+                m_reporter.error("Cannot find bytecode for class '" + info.getClassName() + "': no bytecode found.");
+                return;
+            }
+
+            // Is the visitor interested in this component ?
+            ManipulationResultVisitor result = manipulationVisitor.visitManipulationResult(info.getComponentMetadata());
+
+            if (result != null) {
+                // Should always be the case
+
+                // Manipulate the original bytecode and store the modified one
+                Manipulator manipulator = new Manipulator();
+                try {
+                    byte[] out = manipulator.manipulate(bytecode);
+                    // Call the visitor
+                    result.visitClassStructure(manipulator.getManipulationMetadata());
+                    result.visitManipulatedResource(info.getResourcePath(), out);
+                } catch (IOException e) {
+                    m_reporter.error("Cannot manipulate the class " + info.getClassName() + " : " + e.getMessage());
+                    return;
+                }
+
+
+                // Visit inner classes
+                for (String inner : manipulator.getInnerClasses()) {
+                    // Get the bytecode and start manipulation
+                    String resourcePath = inner + ".class";
+                    String outerClassInternalName = info.getClassName().replace('.', '/');
+                    byte[] innerClassBytecode;
+                    try {
+                        innerClassBytecode = m_store.read(resourcePath);
+                    } catch (IOException e) {
+                        m_reporter.error("Cannot find inner class '" + resourcePath + "'");
+                        return;
+                    }
+
+                    // Manipulate inner class
+                    try {
+                        InnerClassManipulator innerManipulator = new InnerClassManipulator(outerClassInternalName, manipulator.getFields().keySet());
+                        byte[] manipulated = innerManipulator.manipulate(innerClassBytecode);
+                        // Propagate manipulated resource
+                        result.visitManipulatedResource(resourcePath, manipulated);
+                    } catch (IOException e) {
+                        m_reporter.error("Cannot manipulate inner class '" + resourcePath + "'");
+                        return;
+                    }
+                }
+
+                // All resources have been manipulated for this component
+                result.visitEnd();
+            }
+        }
+    }
+}

Added: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationResultVisitor.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationResultVisitor.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationResultVisitor.java (added)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationResultVisitor.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,48 @@
+/**
+ * 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.manipulator;
+
+import org.apache.felix.ipojo.metadata.Element;
+
+/**
+ * Visit manipulation results.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface ManipulationResultVisitor {
+
+    /**
+     * Called once per visitor with the class' structure discovered during manipulation.
+     * @param structure Component's structure (discovered during manipulation, not the data from metadata.xml)
+     */
+    void visitClassStructure(Element structure);
+
+    /**
+     * Accept a manipulated resource (main component class or inner classes).
+     * @param type type name
+     * @param resource manipulated bytecode
+     */
+    void visitManipulatedResource(String type, byte[] resource);
+
+    /**
+     * Called when all resources from this manipulation result have been processed.
+     */
+    void visitEnd();
+}

Added: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationUnit.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationUnit.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationUnit.java (added)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationUnit.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,72 @@
+/*
+ * 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.manipulator;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.felix.ipojo.manipulator.util.Strings;
+import org.apache.felix.ipojo.metadata.Element;
+
+/**
+ * Component Info.
+ * Represent a component type to be manipulated or already manipulated.
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
+public class ManipulationUnit {
+
+    private Element m_componentMetadata;
+
+    private String m_resourcePath;
+
+    private String m_className;
+
+    /**
+     * Constructor.
+     * @param resourcePath class name
+     * @param meta component type metadata
+     */
+    public ManipulationUnit(String resourcePath, Element meta) {
+        this.m_resourcePath = resourcePath;
+        this.m_componentMetadata = meta;
+        this.m_className = Strings.asClassName(resourcePath);
+    }
+
+    /**
+     * @return Component Type metadata.
+     */
+    public Element getComponentMetadata() {
+        return m_componentMetadata;
+    }
+
+    /**
+     * @return Resource path
+     */
+    public String getResourcePath() {
+        return m_resourcePath;
+    }
+
+    /**
+     * @return Fully qualified class name
+     */
+    public String getClassName() {
+        return m_className;
+    }
+
+}

Added: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationVisitor.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationVisitor.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationVisitor.java (added)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/ManipulationVisitor.java Thu Aug 18 11:32:19 2011
@@ -0,0 +1,48 @@
+/**
+ * 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.manipulator;
+
+import org.apache.felix.ipojo.metadata.Element;
+
+/**
+ * Visit manipulation results.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface ManipulationVisitor {
+
+    /**
+     * Accept a manipulation result for the given component metadata.
+     * @param metadata component's metadata (from XML or annotations)
+     * @return a ManipulationResultVisitor if interested in theses manipulation results
+     */
+    ManipulationResultVisitor visitManipulationResult(Element metadata);
+
+    /**
+     * Visit metadata not associated with a component (ie no bytecode manipulation needed).
+     * @param metadata usually {@code instance}/{@code composite} metadata
+     */
+    void visitMetadata(Element metadata);
+
+    /**
+     * Called when all metadata have been processed.
+     */
+    void visitEnd();
+}

Added: felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/MetadataProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/MetadataProvider.java?rev=1159173&view=auto
==============================================================================
--- felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/MetadataProvider.java (added)
+++ felix/trunk/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulator/MetadataProvider.java Thu Aug 18 11:32:19 2011
@@ -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.manipulator;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.felix.ipojo.metadata.Element;
+
+/**
+ * A {@code MetadataProvider} is responsible to provide iPOJO's metadata.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface MetadataProvider {
+
+    /**
+     * Gather all the metadata.
+     * @return a list of iPOJO metadata (never return null)
+     * @throws IOException if something wet wrong during gathering.
+     */
+    List<Element> getMetadatas() throws IOException;
+}