Static Parameter map injected into XsltComponent
------------------------------------------------
Key: SM-705
URL: https://issues.apache.org/activemq/browse/SM-705
Project: ServiceMix
Issue Type: New Feature
Components: servicemix-components
Affects Versions: 3.0.1
Environment: NA
Reporter: Ramon Buckland
Assigned To: Guillaume Nodet
Priority: Minor
Fix For: 3.0.1
Attachments: xslt-parameters.patch
This patch is an enhancement for the XsltComponent.
We had a requirement whereby we wanted to inject a "System Variable" into the
XSLT so we could use it's value as part of the
transformation process.
eg:
java -Dsome.system.property=SomeValue ....
In the servicemix.xml file where the XsltComponent is defined you can now add a
map of parameters.
<sm:activationSpec componentName="transformer" service="foo:transformer">
<sm:component><bean
class="org.apache.servicemix.components.xslt.XsltComponent">
<property name="xsltResource" value="classpath:mytransform.xsl"/>
<property name="xsltParameters">
<map>
<entry key="stringParam" value="staticString"/>
<entry key="someProperty" value="${some.system.property}"/>
<entry key="bean" value-ref="someBeanRef"/>
</map>
</property>
</bean></sm:component>
And, as are properties on the JBI message added in, we also add these
parameters to the XSLT.
Of course you need to declare your intention to use the properties.
<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
version='1.0'>
<xsl:output method="xml" indent="yes" encoding="ISO-8859-1"/>
<xsl:param name="stringParam"/>
<xsl:param name="someProperty"/>
<xsl:param name="bean"/>
....
</xsl:stylesheet>
A handy Hint, we use this in a real world by using the Spring
PropertyPlaceholder, the properties files sit outside
the SU's and SA's and we can then change "behaviour" really easily by adjusting
our properties.
<beans xmlns:spring="http://xbean.org/schemas/spring/1.0">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:myproperties.properties</value>
</list>
</property>
</bean>
</beans>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira