<?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:vm="http://www.mulesource.org/schema/mule/vm/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/vm/2.0 http://www.mulesource.org/schema/mule/vm/2.0/mule-vm.xsd">

    <vm:connector name="default">
        <service-overrides
                inboundTransformer="org.mule.transformer.simple.InboundAppendTransformer"
                outboundTransformer="org.mule.transformer.simple.OutboundAppendTransformer"/>
    </vm:connector>

    <vm:connector name="queue" queueEvents="true"/>

    <custom-transformer name="response" class="org.mule.transformer.simple.StringAppendTransformer">
        <spring:property name="message" value=" response"/>
    </custom-transformer>

    <vm:endpoint name="in-global-name-global-transformer" path="in-global-name-global-transformer"
                 connector-ref="default"/>
    <vm:endpoint name="out-global-name-global-transformer" path="out-global-name-global-transformer"
                 connector-ref="queue"/>
    <vm:endpoint name="global-name-global-transformer" path="global-name-global-transformer" connector-ref="default"
                 responseTransformer-refs="response" synchronous="true"/>

    <vm:endpoint name="in-global-name-url-transformer" path="in-global-name-url-transformer" connector-ref="default"/>
    <vm:endpoint name="out-global-name-url-transformer" path="out-global-name-url-transformer" connector-ref="queue"/>
    <vm:endpoint name="global-name-url-transformer" path="global-name-url-transformer?responseTransformers=response"
                 connector-ref="default" synchronous="true"/>

    <vm:endpoint name="in-global-name-local-transformer" path="in-global-name-local-transformer"
                 connector-ref="default"/>
    <vm:endpoint name="out-global-name-local-transformer" path="out-global-name-local-transformer"
                 connector-ref="queue"/>
    <vm:endpoint name="global-name-local-transformer" path="global-name-local-transformer" connector-ref="default"
                 synchronous="true"/>

    <vm:endpoint name="in-local-name-local-transformer" path="in-local-name-local-transformer" connector-ref="default"/>
    <vm:endpoint name="out-local-name-local-transformer" path="out-local-name-local-transformer" connector-ref="queue"/>

    <vm:endpoint name="in-local-name-url-transformer" path="in-local-name-url-transformer" connector-ref="default"/>
    <vm:endpoint name="out-local-name-url-transformer" path="out-local-name-url-transformer" connector-ref="queue"/>

    <model name="response transformer tests">

        <service name="gngt">
            <inbound>
                <inbound-endpoint ref="in-global-name-global-transformer"/>
            </inbound>
            <echo-component/>
            <outbound>
                <chaining-router>
                    <outbound-endpoint ref="global-name-global-transformer"/>
                    <outbound-endpoint ref="out-global-name-global-transformer"/>
                </chaining-router>
            </outbound>
        </service>

        <service name="gngt-bounce">
            <inbound>
                <inbound-endpoint ref="global-name-global-transformer"/>
            </inbound>
            <echo-component/>
        </service>

        <service name="gnut">
            <inbound>
                <inbound-endpoint ref="in-global-name-url-transformer"/>
            </inbound>
            <echo-component/>
            <outbound>
                <chaining-router>
                    <outbound-endpoint ref="global-name-url-transformer"/>
                    <outbound-endpoint ref="out-global-name-url-transformer"/>
                </chaining-router>
            </outbound>
        </service>

        <service name="gnut-bounce">
            <inbound>
                <inbound-endpoint ref="global-name-url-transformer"/>
            </inbound>
            <echo-component/>
        </service>

        <service name="gnlt">
            <inbound>
                <inbound-endpoint ref="in-global-name-local-transformer"/>
            </inbound>
            <echo-component/>
            <outbound>
                <chaining-router>
                    <outbound-endpoint ref="global-name-local-transformer" responseTransformer-refs="response"/>
                    <outbound-endpoint ref="out-global-name-local-transformer"/>
                </chaining-router>
            </outbound>
        </service>

        <service name="gnlt-bounce">
            <inbound>
                <inbound-endpoint ref="global-name-local-transformer"/>
            </inbound>
            <echo-component/>
        </service>

        <service name="lnlt">
            <inbound>
                <inbound-endpoint ref="in-local-name-local-transformer"/>
            </inbound>
            <echo-component/>
            <outbound>
                <chaining-router>
                    <vm:outbound-endpoint path="local-name-local-transformer" responseTransformer-refs="response"
                                          synchronous="true" connector-ref="default"/>
                    <outbound-endpoint ref="out-local-name-local-transformer"/>
                </chaining-router>
            </outbound>
        </service>

        <service name="lnlt-bounce">
            <inbound>
                <vm:inbound-endpoint path="local-name-local-transformer" connector-ref="default"/>
            </inbound>
            <echo-component/>
        </service>

        <service name="lnut">
            <inbound>
                <inbound-endpoint ref="in-local-name-url-transformer"/>
            </inbound>
            <echo-component/>
            <outbound>
                <chaining-router>
                    <vm:outbound-endpoint path="local-name-url-transformer?responseTransformers=response"
                                          synchronous="true" connector-ref="default"/>
                    <outbound-endpoint ref="out-local-name-url-transformer"/>
                </chaining-router>
            </outbound>
        </service>

        <service name="lnut-bounce">
            <inbound>
                <vm:inbound-endpoint path="local-name-url-transformer" connector-ref="default"/>
            </inbound>
            <echo-component/>
        </service>

    </model>

</mule>
