Groovy Guide
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.
You can think of Groovy as JavaScript for the server. It is a dynamic language, there are no compile and deploy steps. Just write it and run it.
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 Third-party Libraries.
Simple Example
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 Hello text and this line is printed using the println function.
def name = 'World'
println "Hello $name!"
And as expected the result is:
Hello World!
Learning Groovy
If you are familiar with programming in a modern language then you will be able to quickly learn Groovy. It has a C like syntax in common with C#, JavaScript and Java, but has scripting features so you don't have to write lots of code.
This Groovy Guide will provide you with a quick and gental introduction to the language, but will give you the skills you need to develop Groovy Service scripts.
As you are working through the Groovy Guide examples, please use the Groovy Script Console under the System menu. This provides you a play ground to 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 example below has the Type Checked option and is showing the cause of the error and its line number.
Without type checking the corresponding error is illustrated below. Note this error includes no line number and you would need to search you script to find the corresponding missing method.
Thu Apr 17 11:41:54 EST 2014
2014-04-17
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)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55)
at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at Script1.run(Script1.groovy:9)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:518)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:556)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:527)
Please note when using the Groovy 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 Groovy Type Checked on your service please configure the service definitions groovyTypeChecked Service Parameter to be true. By default this option is set to off, to ensure backward compatiblity with older scripts.
Next Steps
The next topic discusses Groovy Declarations.
Once you have completed this Groovy Guide and you want to learn more please see the Groovy Language Documentation.