Java component

SrilathaKante1 316 views 8 slides Dec 02, 2016
Slide 1
Slide 1 of 8
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8

About This Presentation

These slides explain about the Java Component in Anypoint Studio.


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 "; } }