Though Mule Studio has a lot of built in componets , however, it does provides opportunities to create our own. This article will talk about that.
We need
First create a Mule Project.Then create a "Project" from the "src/main/java"
From the "New Java Package" window that appears, enter "org.mule.customcomponentexamples" in the Name field.Click "Finish" button
Now, from the package created, right click on that to create a "Class"
Once the "New Java Class" window opens, enter "MyClass" in the "Name" field and click on "Finish" button.
Write the below code in "MyClass.Java"
package org.mule.customcomponentexamples;
import java.util.*;
import java.text.*;
public class MyClass
{
public String SayHello(String strName)
{
Date presentDate = new Date();
SimpleDateFormat ft = new SimpleDateFormat ("E yyyy.MM.dd 'at' hh:mm:ss a zzz");
String currentDateTime = ft.format(presentDate);
return "Welcome " + strName + " .It is: " + currentDateTime;
}
}
Now from the EndPoints pallete, choose Http Endpoint and change it's Port to 8082.Next from the Components pallete, choose "Java" component
Drag and drop it on the "Message Flow" container.
Double click on the "Java Component" and from the properties window that appears, enter "org.mule.customcomponentexamples.MyClass" in the "Class Name".Click "OK" once done. Components
Hope you have enjoyed the tutorial.More to come soon.
Latest Articles
Latest Articles from Niladri.Biswas
Login to post response