Data Mapper – Using MEL to invoke Java functions:

Using MEL to invoke Java functions:

We can use one of two expression languages in DataMapper: Mule Expression Language (MEL) or Clover Transformation Language (CTL) and we can invoke Java functions using MEL.

Step 1: When you create a new mapping, DataMapper utilizes MEL by default. If you have previously changed your Default Script Type to CTL, you can change it back to MEL in the Mule Studio Preferences (Mule Studio > Preferences).

m1

Step 2: Create any mapping you want, then click “Script” (upper right corner of the DataMapper console) to view the script, that looks something like this:  “output.name = input.name”.

Step 3: Click to set your cursor just after “input.name” then add “.toLowerCase()” . This modification invokes a Java function to change the input name to lowercase. See example below.

m2Step 4: We can also call a java class in the script tag and check the example below:

TIP!  We can also use auto-complete to invoke a Java function? Set your cursor at the end of “input.name” then hit “Ctrl + Space Bar” to display a list of auto-complete options.m5

 

Leave a comment