After creating the new Anypoint Connector Project, the first two things we want to do immediately are to change the base package name(currently the base package name is too long: com.huongdanjava.huongdanjavaloggercomponent 🙂 ) and change the name of Huong Dan Java Logger from HuongDanJavaLoggerComponent to “Huong Dan Java Logger”.
To change the package name, right-click the package name, select Refactor, and then select Rename. I will rename the package to com.huongdanjava.hdjlogger (remember to choose Rename subpackages):
Result:
Next, to rename the Logger component from HuongDanJavaLoggerComponent to Huong Dan Java Logger, let open the HuongDanJavaLoggerComponentConnector class, and change the value of the friendlyName attribute in the @Connect annotation to “Huong Dan Java Logger”. The contents of the HuongDanJavaLoggerComponentConnector class will now look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
package com.huongdanjava.hdjlogger; import org.mule.api.annotations.Config; import org.mule.api.annotations.Connector; import org.mule.api.annotations.Processor; import com.huongdanjava.hdjlogger.config.ConnectorConfig; @Connector(name="huong-dan-java-logger-component", friendlyName="Huong Dan Java Logger") public class HuongDanJavaLoggerComponentConnector { @Config ConnectorConfig config; /** * Custom processor * * @param friend Name to be used to generate a greeting message. * @return A greeting message */ @Processor public String greet(String friend) { /* * MESSAGE PROCESSOR CODE GOES HERE */ return config.getGreeting() + " " + friend + ". " + config.getReply(); } public ConnectorConfig getConfig() { return config; } public void setConfig(ConnectorConfig config) { this.config = config; } } |
Now, if you install this Logger component into Anypoint Studio by right-clicking on the project, selecting Anypoint Connector and then selecting Install or Update, you will see in the Mule Palette, our Logger component: