Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The GroovyComponent is an extension of the JSR 223 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.

Wiki Markup
{snippet:id=xmlText|lang=xml|url=http://cvs.servicemix.codehaus.org/*checkout*/servicemix/base/src/test/resources/org/servicemix/client/example.xml?rev=HEAD}

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

Working with 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.

...

Code Block
// lets output some XML using GroovyMarkup
outMessage.body = builder.hello(version:1.2) {
  world(person:inMessage.properties.name, location:'London')
}

Examples

...