You are viewing an older version of this topic. To go to a different version, use the version menu at the upper-right. +

Groovy Component Reference


Groovy Component Reference


The Groovy component can be used to enhance the user interface of your web and database applications. The Groovy component provides developers with the facilities to integrate custom scripts into a flow using the Groovy scripting engine. As an example, you can write a custom script using Groovy language for an application, save it in a separate file and then configure the Groovy component to reference the file. Or, after placing the Groovy component on the Studio canvas you can type in the script through the Groovy Pattern Properties pane. The Groovy component is very similar to Java, Python and Ruby components.
Groovy also allows the developer to configure interceptors and alter the values or references of particular properties in a script. Interceptors are configured to provide additional services to a message as it flows through a component. For example, a developer can configure an interceptor to execute scheduling or logging of a particular event while a message is being processed. The Groovy component also includes a custom interceptor which allows you to configure settings for Spring elements. Use the Advanced tab to access Script Properties, then define the value and reference for a particular property in the script.

When using Groovy, typing-in or appending a script to the component is the only configuration required.


If the application referencing Groovy expects a response, use a request-response endpoint to enable the Groovy component to communicate in a two-way fashion (See: below).


If Groovy is used to simply pass data to the client, the transaction is referred to as one-way. No response is required from the client (See: below).


Refer to the generic Script Component Reference page to see how a script works with one-way and request-response endpoints.

General Tab

To configure the Groovy component, from the Message Flow canvas double-click the Groovy icon to open the Pattern Properties pane. Use the General tab to specify the file location of the script or simply type in the script on the script text window. The scripting engine is Groovy.


Panel Description


Defaults to the generic component name. Change the Display Name, which must be alpha-numeric, to reflect the component’s specific role, i.e., Groovy Script Welcome Page.


Select one of the following ways to reference the script.
Script Text: Type the script the component will load directly into this space.
Script File; Enter the location of the script to be loaded by the component. The file can reside on the classpath or the local file system.

Advanced Tab

Use the Advanced tab to optionally configure interceptors and (depending on the interceptor) enter Spring values. You also have the option to specify script properties, which are key/value pairs used to alter or change properties in the script. See the Script Component Reference page for information on using the advanced tab.


Panel Description

Interceptors Management

Interceptors enable the developer to provide additional services to the component such as the ability to log transactions and the ability to log the time for each transaction. Use the Add Custom Interceptor to create a custom interceptor that can reference Spring objects. The Interceptor Stack enables you to bundle multiple interceptors. Use the Interceptor Stack to apply multiple interceptors on a Groovy component. The interceptors will be applied in the order defined in the stack.

Script Properties

Configure these parameters to define attribute keys and their associated values. This enables a component to quickly look up a value associated with a key.

Documentation tab

The Documentation tab lets you add optional descriptive documentation for the Groovy component. Each component has a Documentation tab and optional Description field.


Panel Description


Enter all relevant information regarding this Groovy component. This information is displayed in Studio when you hover over the component icon on the Message Flow canvas.

Mule ESB Reference:

Refer to the generic Script component reference page to see how a script works with one-way and request-response endpoints.

For more information see the Mule ESB page Scripting Module.