This component has been deprecated in favor to servicemix-scripting component.
ServiceMix supports Groovy which allows Groovy scripts to be used as endpoints, transformers or services. This allows you to combine the power of the Groovy scripting language with the ServiceMix JBI container and any off the shelf JBI components to create a very flexible and agile integration solution.
The GroovyComponent is an extension of the Scripting support and supports the same variable bindings.
Example
Before we go into detail of how you can work with JBI and Groovy in ServiceMix, lets show a simple hello world kinda example.
As you can see the component is configured with a piece of Groovy to execute when the service is invoked. (BTW if you wanna see this script in action try the test case and XML config file.
Now we'll go through the various options which are available when working with JBI and Groovy in ServiceMix
Maintaining state across requests
Its often handy to keep track of state across requests. There is a variable called 'bindings' which you can use to maintain state...
Working with JBI properties
In ServiceMix you can access the JBI message properties as a Map and work natively with it in Groovy using various mechanisms. e.g.
or use an intermediate object if you've lots of properties to set
or just use the native property syntax
Generating output
Groovy provides various mechanism for generating the output (whether it is the result of a service or a transformation). Which mechanism you use depends on your use case and personal preference.
String templates
You can use Groovy string templates to output XML, which is a nice, simple way to generate blocks of XML with dynamic content
Notice the user above of the input messages's 'name' property, which is equivalent to the expression
POJO return values
You can return a POJO as the body of a message - which other components can either transform or the default Marshaler will figure out the right thing to do.
Using Groovy Markup
Groovy supports a simple and concise markup mechanism which can be used to programatically generate some XML markup (either DOM, SAX or any other XML model) while retaining the full power of Groovy within the control flow of the markup.
4 Comments
Anonymous
ionolsen42 May we exchange links with your site? http://www_3_1.gmail.com/ www_3_1
http://www_3_2.gmail.com/ www_3_2
http://www_3_3.gmail.com/ www_3_3
http://www_3_4.gmail.com/ www_3_4
http://www_3_5.gmail.com/ www_3_5
http://www_3_6.gmail.com/ www_3_6
http://www_3_7.gmail.com/ www_3_7
http://www_3_8.gmail.com/ www_3_8
http://www_3_9.gmail.com/ www_3_9
http://www_3_10.gmail.com/ www_3_10
http://www_3_11.gmail.com/ www_3_11
Anonymous
ionolsen42 So interesting site, thanks! http://www_3_1.gmail.com/ www_3_1
http://www_3_2.gmail.com/ www_3_2
http://www_3_3.gmail.com/ www_3_3
http://www_3_4.gmail.com/ www_3_4
http://www_3_5.gmail.com/ www_3_5
http://www_3_6.gmail.com/ www_3_6
http://www_3_7.gmail.com/ www_3_7
http://www_3_8.gmail.com/ www_3_8
http://www_3_9.gmail.com/ www_3_9
http://www_3_10.gmail.com/ www_3_10
http://www_3_11.gmail.com/ www_3_11
Anonymous
ionolsen43 I like your site http://wiki.cubic.uni-koeln.de/cdkwiki/media/autoinsurancequotes.html insurance companies
http://wiki.cubic.uni-koeln.de/cdkwiki/media/insurancelife.html term life insurance
http://wiki.cubic.uni-koeln.de/cdkwiki/media/carinsurance.html geico car insurance
http://www.spod.ethz.ch/wiki/lib/exe/fetch.php?id=spod%3Aanregungen_webseite&cache=cache&media=spod:automobileinsurance.html teen car insurance
http://wiki.cubic.uni-koeln.de/cdkwiki/media/autoinsurancecompany.html auto insurance td
http://www.spod.ethz.ch/wiki/lib/exe/fetch.php?id=spod%3Aanregungen_webseite&cache=cache&media=spod:healthinsurancequote.html travelers insurance
Anonymous
ionolsen43 Your site is very cognitive. I think you will have good future. http://www.spod.ethz.ch/wiki/lib/exe/fetch.php?id=spod%3Aanregungen_webseite&cache=cache&media=spod:autoinsurancecompany.html automobile ins co
http://www.spod.ethz.ch/wiki/lib/exe/fetch.php?id=spod%3Aanregungen_webseite&cache=cache&media=spod:autoinsurancequote.html auto insurance term
http://wiki.cubic.uni-koeln.de/cdkwiki/media/termlifeinsurance.html
http://wiki.cubic.uni-koeln.de/cdkwiki/media/dentalinsurance.html no dental insurance
http://www.spod.ethz.ch/wiki/lib/exe/fetch.php?id=spod%3Aanregungen_webseite&cache=cache&media=spod:carinsurance.html car insurance
http://wiki.cubic.uni-koeln.de/cdkwiki/media/lifeinsurancequote.html insurance broker