These slides explain about the Java Component in Anypoint Studio.
Size: 47.52 KB
Language: en
Added: Dec 02, 2016
Slides: 8 pages
Slide Content
Mule ESB By Srilatha Kante
Java Component The Java component enables the developer to package custom Java code that executes when the component receives a message. The Java component can be used to enhance the functionality and capability of your web-based applications written in Java.
Java Component To configure the Java component, selecting a class is the only required entry . The class is simply a collection of properties, attributes and methods the component applies to all messages In addition, this component allows you to optionally configure Singleton (object factory that creates an object instance) and Spring (object factory used to obtain Spring bean instances) object factories, which are invoked when a message is received
Example
Start.. In the package explorer right click on your project and select New > Class Name your class, and make the package org.mule.transformers You can use the basic class as a skeleton to construct a simple Java Component:
Java Class Sample package com.mypackage ; public class JavaComponentDemo { public String greetMe (String name){ return name; } }
Exception Check for the Exception related to Callable interface Callable is an interface which is provided by mule for using the Java Component in flows Callable needs an overridden method called onCall ()
Usage of Callable Interface package com.mypackage ; import org.mule.api.MuleEventContext ; import org.mule.api.lifecycle.Callable ; public class JavaComponentDemo implements Callable{ @Override public Object onCall ( MuleEventContext eventContext ) throws Exception { return "Hello "; } }