ServiceMix Script
Info |
---|
The ServiceMix Script component |
...
is deprecated. Please use the ServiceMix Scripting component instead. |
The ServiceMix Script component provides JBI integration with scripting engines
Info | ||
---|---|---|
| ||
There is also a JSR-223 enabled service engine for scripting. Have a look at servicemix-scripting component. |
Note that this component is only available in releases >= 3.1 and older scripting component will be deprecated in future releases.
This component leverages Spring support for dynamic languages, so you will find useful informations on the Spring site.
Simple example
Maven Archetype
You can use Maven servicemix-script-service-unit archetype to create Script service unit:
Code Block |
---|
mvn archetype:create \
-DarchetypeGroupId=org.apache.servicemix.tooling \
-DarchetypeArtifactId=servicemix-script-service-unit \
-DarchetypeVersion=2010.01 \
-DgroupId=your.group.id \
-DartifactId=your.artifact.id \
-Dversion=your-version
|
Endpoint Configuration
The Script endpoint is able to run Groovy script to process messages.Here is an example of a SU deploymennt. The SU is only a zip of these two files:
Code Block | ||
---|---|---|
| ||
<beans xmlns:script="http://org.apache.servicemix/script/1.0" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:test="urn:test"> <script:exchangeProcessor service="test:groovy" endpoint="endpoint"> <property name="helpers"> <list> <ref bean="groovyExchangeHelper" /> </list> </property> <property name="implementation" ref="groovyExchangeProcessor" /> </script:exchangeProcessor> <script:exchangeHelper id="groovyExchangeHelper" singleton="true" /> <lang:groovy id="groovyExchangeProcessor" script-source="classpath:GroovyExchangeProcessor.groovy"> <lang:property name="exchangeHelper" ref="groovyExchangeHelper" /> </lang:groovy> </beans> |
...