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

    <!-- keepSendSocketOpen is required for the Async test case -->
    <tcp:connector name="tcpConnector" keepSendSocketOpen="true" socketSoLinger="0">
        <tcp:length-protocol payloadOnly="true"/>
    </tcp:connector>

    <tcp:endpoint name="clientEndpoint" host="localhost" port="60198" synchronous="true"/>
    <tcp:endpoint name="asyncClientEndpoint1" host="localhost" port="60199" synchronous="false"/>
    <tcp:endpoint name="asyncClientEndpoint2" host="localhost" port="60197" synchronous="false"/>

    <model name="main">

        <service name="testComponent1">
            <inbound>
                <tcp:inbound-endpoint ref="clientEndpoint"/>
            </inbound>
            <component class="org.mule.tck.functional.FunctionalTestComponent"/>
        </service>

        <!-- this doesn't work because it uses the output stream and length encoding doesn't
             support streams -->
        <service name="testComponent2">
            <inbound>
                <tcp:inbound-endpoint ref="asyncClientEndpoint1"/>
            </inbound>
            <pooled-component>
                <prototype-object class="org.mule.tck.functional.FunctionalTestComponent">
                    <properties>
                        <spring:entry key="eventCallback">
                            <spring:bean class="org.mule.tck.functional.ResponseWriterCallback"/>
                        </spring:entry>
                    </properties>
                </prototype-object>
            </pooled-component>
        </service>

        <!-- this doesn't work because, in essence, the existing socket is opened in the wrong
             direction.  so it keeps sending the reply to itself... -->
        <service name="testComponent3">
            <inbound>
                <tcp:inbound-endpoint ref="asyncClientEndpoint2"/>
            </inbound>
            <pooled-component class="org.mule.tck.functional.FunctionalTestComponent"/>
            <outbound>
                <outbound-pass-through-router>
                    <tcp:outbound-endpoint ref="asyncClientEndpoint2"/>
                </outbound-pass-through-router>
            </outbound>
        </service>

    </model>

</mule>
