Simple Java component in Mule
-
Upload
christian-hipolito -
Category
Technology
-
view
97 -
download
0
Transcript of Simple Java component in Mule
Simple Java Component in Mule
How to use Java in Mule
• Ever wonder how to use your own java class or utility in mule? Here is a simple sample on how to use a java component or class in mule.
• This project used mule 3.8 and 6.0 anypointstudio.
Building your Java Component
• Assuming that you already created a new project. In this sample, I created a project named “simplejavacomponent”.
• Also created a package for the java class i will create.
• Based from the previous slide, I created a class named “SimpleJavaComponent”.
• Also implement an interface named “Callable” from org.mule.api.lifecycle. You need this inherit classes by overriding the method “onCall” with a parameter name “MuleEventContext”.
• The override method simply returns any object or Object.
• In the previous slide, I simply get the current MuleMessage from the eventContext or MuleEventContext.
• Then I get the current payload and Cast it in a String. Then I simply return a String payload just to showcase how to call a java component. You can return any objects in onCall.
• You can used this functionality if you want to get values from current payload and manipulate those values to a new payload or simply regenerate the current payload to correct or format some values.
END