Last active
October 20, 2016 14:21
-
-
Save fganora/59c4b079b8283b2d1009ad931c43c4f3 to your computer and use it in GitHub Desktop.
Mule flow with Groovy transformer (which creates a local class and instantiates / maps an object of that class)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" 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="jsongroovyFlow"> | |
<http:listener config-ref="HTTP_Listener_Configuration" path="/jsongroovy" doc:name="HTTP"/> | |
<scripting:transformer returnClass="java.lang.String" doc:name="Groovy"> | |
<scripting:script engine="Groovy"><![CDATA[class RequestAttributes { | |
String method | |
String uri | |
} | |
def obj = new RequestAttributes(method: message.getInboundProperty("http.method"), uri: message.getInboundProperty("http.request.uri")) | |
return "${obj.method} (${obj.uri})".toString()]]></scripting:script> | |
</scripting:transformer> | |
</flow> | |
</mule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment