Author: gnodet
Date: Wed Mar 10 19:37:34 2010
New Revision: 921525

URL: http://svn.apache.org/viewvc?rev=921525&view=rev
Log:
FELIX-2175: Improve the Blueprint component to parse / introspect blueprint 
configuration files and generate OBR service requirements / capabilities 
accordingly

Modified:
    
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BlueprintPlugin.java
    
felix/trunk/bundleplugin/src/main/resources/org/apache/felix/bundleplugin/blueprint.xsl
    felix/trunk/bundleplugin/src/test/resources/OSGI-INF/blueprint/bp.xml

Modified: 
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BlueprintPlugin.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BlueprintPlugin.java?rev=921525&r1=921524&r2=921525&view=diff
==============================================================================
--- 
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BlueprintPlugin.java
 (original)
+++ 
felix/trunk/bundleplugin/src/main/java/org/apache/felix/bundleplugin/BlueprintPlugin.java
 Wed Mar 10 19:37:34 2010
@@ -9,6 +9,7 @@ import java.io.InputStreamReader;
 import java.net.URL;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -48,8 +49,8 @@ public class BlueprintPlugin implements 
 
         String bpHeader = analyzer.getProperty("Bundle-Blueprint", 
"OSGI-INF/blueprint");
         Map<String, Map<String,String>> map = Processor.parseHeader(bpHeader, 
null);
-        for (String root : map.keySet()) {
-
+        for (String root : map.keySet())
+        {
             Jar jar = analyzer.getJar();
             Map<String, Resource> dir = jar.getDirectories().get(root);
             if(dir == null || dir.isEmpty())
@@ -115,22 +116,19 @@ public class BlueprintPlugin implements 
             {
                 Set<Attribute> orgAttr = 
parseHeader(analyzer.getProperty(header), null);
                 Set<Attribute> newAttr = hdrs.get(header);
-                for (Attribute a : newAttr)
+                for (Iterator<Attribute> it = newAttr.iterator(); 
it.hasNext();)
                 {
-                    boolean found = false;
+                    Attribute a = it.next();
                     for (Attribute b : orgAttr)
                     {
                         if (b.getName().equals(a.getName()))
                         {
-                            found = true;
+                            it.remove();
                             break;
                         }
                     }
-                    if (!found)
-                    {
-                        orgAttr.add(a);
-                    }
                 }
+                orgAttr.addAll(newAttr);
                 // Rebuild from orgAttr
                 StringBuilder sb = new StringBuilder();
                 for (Attribute a : orgAttr)

Modified: 
felix/trunk/bundleplugin/src/main/resources/org/apache/felix/bundleplugin/blueprint.xsl
URL: 
http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/resources/org/apache/felix/bundleplugin/blueprint.xsl?rev=921525&r1=921524&r2=921525&view=diff
==============================================================================
--- 
felix/trunk/bundleplugin/src/main/resources/org/apache/felix/bundleplugin/blueprint.xsl
 (original)
+++ 
felix/trunk/bundleplugin/src/main/resources/org/apache/felix/bundleplugin/blueprint.xsl
 Wed Mar 10 19:37:34 2010
@@ -31,7 +31,7 @@
         <xsl:if test="not($nsh_interface = '' or $nsh_namespace = '')">
             <xsl:for-each select="descendant-or-self::node() | 
descendant-or-self::node()/attribute::*">
                 <xsl:if test="not(namespace-uri() = 
'http://www.osgi.org/xmlns/blueprint/v1.0.0' or namespace-uri() = '')">
-                    <xsl:value-of select="concat('Import-Service:', 
$nsh_interface, ';', $nsh_namespace, '=', namespace-uri())" />
+                    <xsl:value-of select="concat('Import-Service:', 
$nsh_interface, ';', $nsh_namespace, '=&quot;', namespace-uri(), '&quot;')" />
                     <xsl:text>
                     </xsl:text>
                 </xsl:if>
@@ -80,7 +80,7 @@
                 </xsl:otherwise>
             </xsl:choose>
             <xsl:for-each select="bp:service-properties/bp:entry">
-                <xsl:value-of select="concat(';', @key, '=', @value)" />
+                <xsl:value-of select="concat(';', @key, '=&quot;', @value, 
'&quot;')" />
             </xsl:for-each>
             <xsl:text>
             </xsl:text>

Modified: felix/trunk/bundleplugin/src/test/resources/OSGI-INF/blueprint/bp.xml
URL: 
http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/test/resources/OSGI-INF/blueprint/bp.xml?rev=921525&r1=921524&r2=921525&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/test/resources/OSGI-INF/blueprint/bp.xml 
(original)
+++ felix/trunk/bundleplugin/src/test/resources/OSGI-INF/blueprint/bp.xml Wed 
Mar 10 19:37:34 2010
@@ -45,6 +45,12 @@
         </service-properties>
     </service>
 
+    <service interface="p6.Foo">
+        <service-properties>
+            <entry key="k" value="v2" />
+        </service-properties>
+    </service>
+
     <service>
         <interfaces>
             <value>p7.Foo</value>


Reply via email to