Contact Us 1-800-596-4880

@Groovy Annotation

A parameter injection annotation that can be used on component entry points and transformer methods, this annotation can be used to execute an Groovy expression on the message payload with the result being passed into the method. For example, if you are expecting a Java Bean, this can be injected and an Groovy expression evaluated against it. For more information about scripting support in Mule see the Scripting Module Reference.

Lets say our payload is a Person object that has a field called emailAddress.

public class MyComponent {
    public Object process(@Groovy("payload.emailAddress") String email) {
        // do stuff
    }
}

Context Bindings

In the example above 'payload' is a context binding that gives you access to the message payload directly in Groovy. There are other context bindings available to Groovy scripts, See Script Context Bindings for more information.

Validation

All expressions in Mule have their syntax validated to ensure the expression is well formed. In rare cases you may want to turn this off for Groovy depending on whether the expression has any braces that are not closed. To do this you need to set a system property -

-Dmule.validate.expressions=false