<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:spring="http://www.springframework.org/schema/beans"
       xmlns:scripting="http://www.mulesource.org/schema/mule/scripting/2.0"
       xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.0"
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.mulesource.org/schema/mule/core/2.0 http://www.mulesource.org/schema/mule/core/2.0/mule.xsd
       http://www.mulesource.org/schema/mule/scripting/2.0 http://www.mulesource.org/schema/mule/scripting/2.0/mule-scripting.xsd
       http://www.mulesource.org/schema/mule/stdio/2.0 http://www.mulesource.org/schema/mule/stdio/2.0/mule-stdio.xsd">

    <description>
        This example demonstrates invoking a Groovy script as the service component.
    </description>
    
    <scripting:script name="scriptText">
        def msg = eventContext.transformMessageToString()
        log.boilerPlate("Message Received: ${msg} - class: ${msg.class.name}")
        return ["Hello", ":-)"];
    </scripting:script>
    
    <stdio:connector name="SystemStreamConnector"
                     promptMessage="Please enter a message: "
                     messageDelayTime="1000"/>

    <model name="main">
        <service name="ScriptService">
            <inbound>
                <stdio:inbound-endpoint system="IN"/>
                <!-- For unit testing -->
                <inbound-endpoint address="vm://scripting"/>
            </inbound>
            <pooled-component>
                <prototype-object class="org.mule.module.scripting.component.ScriptComponent">
                    <property key="scriptEngineName" value="groovy"/>
                    <property key="scriptText" value-ref="scriptText"/>
                </prototype-object>
            </pooled-component>
        </service>
    </model>
</mule>
