Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How To Invoke Java Function Within Data Weave

How To Invoke Java Function Within Data Weave

How To Invoke Java Function Within Data Weave

Jitendra Bafna

May 01, 2017
Tweet

More Decks by Jitendra Bafna

Other Decks in Technology

Transcript

  1. Data Weave DataWeave makes transformations very easy. DataWeave is a

    language used to query and transform complex data. It contains a lot of operators, including filters and functions. It supports various formats including XML, JSON, CSV, Java, and EDI out of the box. DataWeave code looks like JSON syntax and is format-neutral. It is very much possible to invoke Java/Groovy function within DataWeave.
  2. Invoke MEL Function Within DataWeave Transform You will receive two

    numbers as input message (Json format) and return addition of 2 numbers. Below you can see what will be the input and output.
  3. Invoke MEL Function Within DataWeave Transform Declare Spring MEL Function

    You need declare a Spring MEL function in global configuration xml as shown below :
  4. Invoke MEL Function Within DataWeave Transform DataWeave Transform You need

    to invoke function addition expecting 2 arguments and it invoke with dataweave transform as shown below:
  5. Invoke Java Function Within DataWeave Transform Now, you will see

    how to invoke java function with your dataweave transformation. For example, if you have class with name TestClass.java which have function addTwoNumbers accept two argument and return the sum of two arguments.
  6. Invoke Java Function Within DataWeave Transform Mule Global Configuration Now,

    you need to make the entry of Java function in Mule Global Configuration as shown below:
  7. Invoke Java Function Within DataWeave Transform DataWeave Transform You need

    to invoke function addition expecting 2 arguments and it invoke with dataweave transform as shown below:
  8. Invoke Java Function Within Mule Flow Now you will see

    how to invoke the java function with Mule flow. Define Spring Beans You need to define spring beans in your Mule xml flow as shown below :
  9. Invoke Java Function Within Mule Flow Invoke Component Add invoke

    component in your flow and this will invoke your java class in the flow.
  10. Invoke Java Function Within Mule Flow • Display Name is

    unique name for your component in the application. • Name is the name of message processor used for logging purpose. • Object Ref is a bean-name and it is reference to object contains method to be invoked. • Method is a function that need to be invoked. • Method Arguments is the parameters that needs to be pass to function. Multiple arguments can be specify using comma separated. • Method Arguments Types is data type for argument. Multiple argument type can specify using comma separated. Use this property whenever you have multiple method with same name in same class. Now, you are aware how to invoke Java function within your dataweave transformation and Mule flow!