Static compilation and type checking

   Exchange Pre-configured Maestro services.  |   Platform Developer |  All versions   This feature is related to v5.1 and higher.

In order to enforce a Groovy execution environment with high performance and strong security controls, Fluent Groovy services deployed into Temenos Journey Manager (TJM) are compiled statically. In addition to providing a much stronger security model, statically compiled Groovy services also execute at near native Java speed, much faster than dynamically compiled Groovy. One difference with statically compiled Groovy services is that you cannot use some of Groovy's dynamic language features such as GPath expressions or Groovy meta programming features.

If you are used to writing Java code, this will be a familiar coding environment for you. If you have been developing Groovy scripts to run in a dynamic compilation environment then this article may help you make the adjustments required to transition to static Groovy compilation. Documented below are some common issues found when you move from dynamic Groovy to static Groovy:

GPath Expressions

GPath is a path expression language integrated into Groovy which allows parts of nested structured data to be identified. This feature is often used in the context of processing XML but also for standard object graphs or nested Map structures.

As GPath expressions are not supported in static Groovy, the TJM Fluent SDK includes a very handy utility class (com.avoka.tm.util.Path) that can be used in place of GPath expressions. To learn more, see Interrogate structured data paths.

Multiple Assignments

Groovy allows you to perform multiple assignments in a single statement. For example:

// Break out the elements of the date of birth
def (dobDay, dobMonth, dobYear) = dobStr?.tokenize('/')

Static type checking will not allow this and will give the following error message:

[Static type checking] - Multiple assignments without list expressions on the right hand side are unsupported in static type checking mode

To overcome this issue you must resort to more traditional assignment methods:

// Break out the elements of the date of birth
String dobDay, dobMonth, dobYear
String[] dobItems = dobStr?.tokenize('/')
if(dobItems.length == 2){
    dobDay = dobItems[0]
    dobMonth = dobItems[1]
    dobYear = dobItems[2]
}