FELIX-1552: add support for blueprint and spring-dm declarations to import the discovered packages

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@810699 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/felix/bnd/BlueprintComponent.java b/bundleplugin/src/main/java/org/apache/felix/bnd/BlueprintComponent.java
new file mode 100644
index 0000000..daa4257
--- /dev/null
+++ b/bundleplugin/src/main/java/org/apache/felix/bnd/BlueprintComponent.java
@@ -0,0 +1,21 @@
+package org.apache.felix.bnd;
+
+import java.util.List;
+import java.util.ArrayList;
+
+import aQute.lib.spring.XMLTypeProcessor;
+import aQute.lib.spring.XMLType;
+import aQute.lib.osgi.Analyzer;
+
+public class BlueprintComponent extends XMLTypeProcessor {
+
+    protected List<XMLType> getTypes(Analyzer analyzer) throws Exception {
+        List<XMLType> types = new ArrayList<XMLType>();
+
+        String header = analyzer.getProperty("Bundle-Blueprint", "OSGI-INF/blueprint");
+        process(types,"blueprint.xsl", header, ".*\\.xml"); 
+
+        return types;
+    }
+
+}
diff --git a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
index 80917e4..8d06c7a 100644
--- a/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ b/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -55,6 +55,7 @@
 import org.apache.maven.project.MavenProjectHelper;
 import org.apache.maven.shared.osgi.DefaultMaven2OsgiConverter;
 import org.apache.maven.shared.osgi.Maven2OsgiConverter;
+import org.apache.felix.bnd.BlueprintComponent;
 import org.codehaus.plexus.archiver.UnArchiver;
 import org.codehaus.plexus.archiver.manager.ArchiverManager;
 import org.codehaus.plexus.util.DirectoryScanner;
@@ -66,6 +67,8 @@
 import aQute.lib.osgi.EmbeddedResource;
 import aQute.lib.osgi.FileResource;
 import aQute.lib.osgi.Jar;
+import aQute.lib.spring.SpringXMLType;
+import aQute.lib.spring.JPAComponent;
 
 
 /**
@@ -882,6 +885,10 @@
 
         properties.put( "classifier", classifier == null ? "" : classifier );
 
+        // Add default plugins
+        header( properties, Analyzer.PLUGIN,
+                BlueprintComponent.class.getName() + "," + SpringXMLType.class.getName());
+
         return properties;
     }
 
diff --git a/bundleplugin/src/main/resources/org/apache/felix/bnd/blueprint.xsl b/bundleplugin/src/main/resources/org/apache/felix/bnd/blueprint.xsl
new file mode 100644
index 0000000..3b1968b
--- /dev/null
+++ b/bundleplugin/src/main/resources/org/apache/felix/bnd/blueprint.xsl
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+	<xsl:output method="text" />
+
+	<xsl:template match="/">
+
+		<!-- Match all attributes that holds a class or a comma delimited 
+		     list of classes and print them -->
+
+		<xsl:for-each select="
+				//bp:bean/@class 
+			|	//bp:service/@interface 
+			|   //bp:service/bp:interfaces/bp:value/text()
+ 			|	//bp:reference/@interface
+			|	//bp:reference-list/@interface
+		">
+			<xsl:value-of select="." />
+			<xsl:text>
+			</xsl:text>
+		</xsl:for-each>
+
+		<xsl:for-each select="
+				//bp:bean/bp:argument/@type
+		    |	//bp:list/@value-type 
+    		|	//bp:set/@value-type 
+    		|	//bp:array/@value-type 
+			|   //bp:map/@key-type
+			|   //bp:map/@value-type
+		">
+		    <xsl:choose>
+		        <xsl:when test="contains(., '[')"><xsl:value-of select="substring-before(., '[')"/></xsl:when>
+		        <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
+			</xsl:choose>
+			<xsl:text>
+			</xsl:text>
+		</xsl:for-each>
+
+	</xsl:template>
+
+
+</xsl:stylesheet>
+