groovy demo

8
Groovy Introduction and how to use in Mule Groovy Connector Demo

Upload: ramakrishna-kapa

Post on 07-Jan-2017

168 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Groovy demo

Groovy Introduction and how to use in Mule

Groovy Connector Demo

Page 2: Groovy demo

Apache Groovy is a powerful, optionally typed and dynamic language, with static-typing and static compilation capabilities, for the Java platform aimed at improving developer productivity thanks to a concise, familiar and easy to learn syntax.Apache Groovy is an object-oriented programming language for the Java platform. It is a dynamic language with features similar to those of Python, Ruby, Perl, and Smalltalk.

Groovy Features

Page 3: Groovy demo

Click on File NEW Mule project Project name Groovy Demo Drag Http connector from Mule palette Add http global end point like following

image Drag the Groovy component and add the

following script. Println('demo payload');

Create project on AnyPoint Studio

Page 4: Groovy demo

Http connector properties

Page 5: Groovy demo

Groovy component properties

Page 6: Groovy demo

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"

xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-

scripting.xsd"> <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener

Configuration"/> <flow name="groovydemoFlow"> <http:listener config-ref="HTTP_Listener_Configuration" path="/demo" doc:name="HTTP"/> <scripting:component doc:name="Groovy"> <scripting:script engine="Groovy"><![CDATA[println('demo payload');]]></scripting:script> </scripting:component> </flow> </mule>

XML code here

Page 7: Groovy demo

Click on Run as mule application

Page 8: Groovy demo

After deploying the application successfully

http://localhost:8081/demo

We can see the payload on console as “demo payload”

Out put: