Skip to content

Commit

Permalink
[FELIX-5794] maven-bundle-plugin fails to parse meta-persistence
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1833192 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
gnodet committed Jun 8, 2018
1 parent 1d2716f commit 0f47585
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.io.InputStreamReader;
import java.net.URL;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -134,7 +135,7 @@ private void process( Analyzer analyzer, String path, Resource resource, Set<Str

public Set<String> analyze( InputStream in ) throws Exception
{
Set<String> refers = new HashSet<String>();
Set<String> refers = new LinkedHashSet<String>();
ByteArrayOutputStream bout = new ByteArrayOutputStream();
javax.xml.transform.Result r = new StreamResult( bout );
javax.xml.transform.Source s = new StreamSource( in );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,31 @@
<xsl:template name="service-capability">
<xsl:param name="interface"/>
<xsl:param name="attributes" select="''"/>
<xsl:value-of select="concat('Provide-Capability: osgi.service;effective:=active;',
'objectClass=', $interface, ';',
$attributes,
$nl)"/>
<xsl:choose>
<xsl:when test="string-length($attributes)>0">
<xsl:value-of select="concat('Provide-Capability: osgi.service;effective:=active;',
'objectClass=', $interface, ';', $attributes, $nl)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('Provide-Capability: osgi.service;effective:=active;',
'objectClass=', $interface, $nl)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="service-requirement">
<xsl:param name="interface"/>
<xsl:param name="attributes" select="''"/>
<xsl:value-of select="concat('Require-Capability: osgi.service;effective:=active;',
'objectClass=', $interface, ';',
$attributes,
$nl)"/>
<xsl:choose>
<xsl:when test="string-length($attributes)>0">
<xsl:value-of select="concat('Require-Capability: osgi.service;effective:=active;',
'objectClass=', $interface, ';', $attributes, $nl)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('Require-Capability: osgi.service;effective:=active;',
'objectClass=', $interface, $nl)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void testNamedJndi() throws Exception {
" <jta-data-source>osgi:service/jdbc/h2DS</jta-data-source>\n" +
" </persistence-unit>\n" +
"</persistence>";
String expectedReqs = "osgi.extender;osgi.extender=aries.jpa,osgi.service;effective:=active;objectClass=javax.transaction.TransactionManager;";
String expectedReqs = "osgi.extender;osgi.extender=aries.jpa,osgi.service;effective:=active;objectClass=javax.transaction.TransactionManager";
assertTransformation(xmlStr, expectedReqs);
}

Expand All @@ -46,7 +46,7 @@ public void testService() throws Exception {
" <jta-data-source>osgi:service/javax.sql.DataSource/(&amp;(db=mydb)(version=3.1))</jta-data-source>\n" +
" </persistence-unit>\n" +
"</persistence>";
String expectedReqs = "osgi.extender;osgi.extender=aries.jpa,osgi.service;effective:=active;objectClass=javax.sql.DataSource;filter:=\"(&(db=mydb)(version=3.1))\",osgi.service;effective:=active;objectClass=javax.transaction.TransactionManager;";
String expectedReqs = "osgi.extender;osgi.extender=aries.jpa,osgi.service;effective:=active;objectClass=javax.transaction.TransactionManager,osgi.service;effective:=active;objectClass=javax.sql.DataSource;filter:=\"(&(db=mydb)(version=3.1))\"";
assertTransformation(xmlStr, expectedReqs);
}

Expand All @@ -68,5 +68,6 @@ protected byte[] getBytes() throws Exception {
plugin.analyzeJar(analyzer);

assertEquals(expectedReqs, analyzer.getProperty("Require-Capability"));

}
}

0 comments on commit 0f47585

Please sign in to comment.