Groovy is a powerful scripting language which runs on the Java Virtual Machine. This gives you access to all the facilities provided by Journey Manager and Java, while providing a scripting language without the steep learning curve of Java.
The Temenos Journey platform provides customized Groovy runtime with security constraints for running in an application server context. For Groovy version information, see Groovy Lang in Journey Manager 3rd Party Libraries.
The simple hello world example below defines a variable called
name, and assigns it the value
'World'. Then on the next line this variable
$name is included in the text output to the screen using the
def name = 'World'
println "Hello $name!"
And as expected the result is:
This Groovy guide provides a quick introduction to the language to give you the skills you need to start developing Groovy Service scripts.
As you are working through the examples in this guide, you can use the Groovy Script Console under the System menu in your Journey Manager environment. This provides a playground where you can try out examples and prototype Groovy scripts.
Script Type Checking
Where possible configure your services to use the Groovy Script Type Checked option. When using the option the script will be parsed before executing to see whether there are any script type errors. These compilation style errors messages are generally more informative that the standard Groovy dynamic execution errors.
The following example has the Script Type Checked option, and displays the cause of the error and where (line and column number) it occurs.
Without type checking, the error is reported as shown below. Note that the error doesn't include the line number so you would need to search you script to find the corresponding missing method.
Thu Apr 17 11:41:54 EST 2014
groovy.lang.MissingMethodException: No signature of method: java.util.Date.formatter() is applicable for argument types: (java.lang.String) values: [yyyy-MM-dd'T'HH:mm:ss]
Possible solutions: format(java.lang.String), format(java.lang.String, java.util.TimeZone)
When using the Script Type Checked option, you may need to write your scripts in a more statically declared Java-like fashion to enable the Groovy runtime to figure out what you are trying to achieve.
To configure Script Type Checked on your service, configure the service definitions groovyTypeChecked Service Parameter to be
true. By default, this option is not set to ensure backward compatiblity with older scripts.
If you want to learn more about Groovy once you have completed this guide, see Groovy Language Documentation.