<?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:util="http://www.springframework.org/schema/util"
      xmlns:spring="http://www.springframework.org/schema/beans"
      xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
       http://www.mulesource.org/schema/mule/core/2.0 http://www.mulesource.org/schema/mule/core/2.0/mule.xsd">

    <configuration defaultSynchronousEndpoints="true" defaultRemoteSync="true">
        <default-threading-profile maxBufferSize="42" maxThreadsActive="16"
                                   maxThreadsIdle="3" poolExhaustedAction="WAIT" threadTTL="60001"/>
    </configuration>

    <global-property name="doCompression" value="true"/>
    <global-property name="beanProperty1" value="this was set from the manager properties!"/>
    <global-property name="OS_Version" value="not found"/>


    <!-- TODO ConnectionStrategies on endpoints -->
    <!-- Remove Endpoint Identifiers -->
    <!-- remove interceptor stacks -->
    <!--<custom-transaction-manager-factory class="org.mule.tck.testmodels.mule.TestTransactionManagerFactory"/>-->
    <spring:bean name="txManagerFactory" class="org.mule.tck.testmodels.mule.TestTransactionManagerFactory"/>

    <!-- pulled out to management-startup-test.xml in integration
    <mgmt:jmx-default-config name="jmxAgent"/>
    <mgmt:rmi-server name="rmiAgent"/>
    <mgmt:jmx-server name="jmxAgent">
    <mgmt:connector-server url="service:jmx:rmi:///jndi/rmi://localhost:1099/server" rebind="true"/>
    </mgmt:jmx-server>

    <mgmt:chainsaw-notifications chainsawHost="localhost" chainsawPort="20202" name="chainsaw">
        <mgmt:level-mapping eventId="ModelNotification.stop" severity="WARN"/> 
    </mgmt:chainsaw-notifications>
    -->

    <custom-connector name="dummyConnector" class="org.mule.tck.testmodels.mule.TestConnector">
        <dispatcher-threading-profile maxBufferSize="2"/>
        <custom-exception-strategy class="org.mule.tck.testmodels.mule.TestExceptionStrategy"/>
    </custom-connector>

    <custom-transformer name="TestCompressionTransformer"
                        class="org.mule.tck.testmodels.mule.TestCompressionTransformer" returnClass="java.lang.String">
        <spring:property name="beanProperty2" value="12"/>
        <spring:property name="containerProperty" value="myString"/>
    </custom-transformer>

    <no-action-transformer name="Default"/>

    <endpoint name="fruitBowlEndpoint" address="test://fruitBowlPublishQ">
         <message-property-filter pattern="foo=bar"/>
    </endpoint>
    <endpoint name="waterMelonEndpoint" address="test://test.queue" encoding="UTF-8-TEST"/>
    <endpoint name="appleInEndpoint" address="test://AppleQueue"/>
    <endpoint name="appleResponseEndpoint" address="test://AppleResponseQueue"/>
    <endpoint name="orangeEndpoint" address="test://orangeQ">
        <property key="beanProperty2" value="12"/>
        <property key="containerProperty" value="myString"/>
    </endpoint>
    <endpoint name="testEPWithCS" address="test://test.queue2"/>
    
    <endpoint name="endpointWithProps" address="test://endpointWithProps">
    	<properties>
    		<spring:entry key="brand" value="Juicy Baby!"/>
    		<spring:entry key="segments" value="9"/>
    		<spring:entry key="radius" value="4.21"/>
			<spring:entry key="mapProperties">
				<spring:map>
				    <spring:entry key="prop1" value="prop1"/>
			    	<spring:entry key="prop2" value="prop2"/>
				</spring:map>
			</spring:entry>
			<spring:entry key="listProperties">
				<spring:list>
					<spring:value>prop1</spring:value>
					<spring:value>prop2</spring:value>
					<spring:value>prop3</spring:value>
				</spring:list>
			</spring:entry>
			<spring:entry key="arrayProperties">
				<spring:list>
					<spring:value>prop4</spring:value>
					<spring:value>prop5</spring:value>
					<spring:value>prop6</spring:value>
				</spring:list>
			</spring:entry>
    	</properties>
    </endpoint>

    <!-- TODO RM*: Add an interceptor wrapper and use spring AOP to configure these -->
    <!--<interceptor-stack name="default">-->
    <!--<interceptor className="org.mule.interceptors.LoggingInterceptor"/>-->
    <!--<interceptor className="org.mule.interceptors.TimerInterceptor"/>-->
    <!--</interceptor-stack>-->

    <spring:bean name="apple" class="org.mule.tck.testmodels.fruit.Apple"/>

    <spring:bean name="orange" class="org.mule.tck.testmodels.fruit.Orange">
        <spring:property name="brand" value="Juicy Baby!"/>
        <spring:property name="segments" value="9"/>
        <spring:property name="radius" value="4.21"/>
        <spring:property name="mapProperties">
            <spring:map>
                <spring:entry key="prop1" value="prop1"/>
                <spring:entry key="prop2" value="prop2"/>
            </spring:map>
        </spring:property>
        <spring:property name="listProperties">
            <spring:list>
                <spring:value>prop1</spring:value>
                <spring:value>prop2</spring:value>
                <spring:value>prop3</spring:value>
            </spring:list>
        </spring:property>
        <spring:property name="arrayProperties">
            <spring:list>
                <spring:value>prop4</spring:value>
                <spring:value>prop5</spring:value>
                <spring:value>prop6</spring:value>
            </spring:list>
        </spring:property>
    </spring:bean>
    
    <model name="main">
        <custom-exception-strategy class="org.mule.tck.testmodels.mule.TestExceptionStrategy">
            <outbound-endpoint address=" test://component.exceptions "/>
        </custom-exception-strategy>

        <custom-entry-point-resolver-set class="org.mule.tck.testmodels.mule.TestEntryPointResolverSet"/>

        <service name="orangeComponent">
            <inbound>
                <forwarding-catch-all-strategy>
                    <outbound-endpoint address="test://catch.all"/>
                </forwarding-catch-all-strategy>
                <inbound-endpoint name="Orange" address="test://orange/" transformer-refs="TestCompressionTransformer"
                                  responseTransformer-refs="TestCompressionTransformer"/>
                <inbound-endpoint ref="orangeEndpoint" transformer-refs="TestCompressionTransformer">
                    <payload-type-filter expectedType="java.lang.String"/>
                    <property key="testLocal" value="value1"/>
                </inbound-endpoint>
            </inbound>

            <component>
                <spring-object bean="orange"/>
                <binding interface="org.mule.tck.testmodels.fruit.FruitCleaner" method="wash">
                    <outbound-endpoint address="test://do.wash"/>
                </binding>
                <binding interface="org.mule.tck.testmodels.fruit.FruitCleaner" method="polish">
                    <outbound-endpoint address="test://do.polish"/>
                </binding>
            </component>            

            <outbound>
                <outbound-pass-through-router>
                    <outbound-endpoint ref="appleInEndpoint" transformer-refs="TestCompressionTransformer"/>
                </outbound-pass-through-router>
            </outbound>

            <async-reply timeout="10001">
                <inbound-endpoint address="test://response1"/>
                <inbound-endpoint ref="appleResponseEndpoint"/>
                <custom-async-reply-router class="org.mule.tck.testmodels.mule.TestResponseAggregator"/>
            </async-reply>

            <default-service-exception-strategy>
                <outbound-endpoint address="test://orange.exceptions"/>
            </default-service-exception-strategy>
        </service>

        <service name="appleComponent">
            <inbound>
                <custom-catch-all-strategy class="org.mule.tck.testmodels.mule.TestCatchAllStrategy"/>
                <inbound-endpoint ref="appleInEndpoint"/>
                <selective-consumer-router>
                    <payload-type-filter expectedType="java.lang.String"/>
                </selective-consumer-router>
                <idempotent-receiver-router>
                </idempotent-receiver-router>
            </inbound>

            <component>
                <spring-object bean="apple"/>
            </component>

            <outbound>
                <custom-catch-all-strategy class="org.mule.tck.testmodels.mule.TestCatchAllStrategy"/>
                <filtering-router transformer-refs="TestCompressionTransformer">
                    <outbound-endpoint address="test://appleQ2" name="TestApple-Out"/>
                    <payload-type-filter expectedType="java.lang.String"/>
                </filtering-router>

                <filtering-router>
                    <outbound-endpoint ref="waterMelonEndpoint"/>
                    <and-filter>
                        <regex-filter pattern="the quick brown (.*)"/>
                        <regex-filter pattern="(.*) brown (.*)"/>
                    </and-filter>
                </filtering-router>
            </outbound>

            <!--<custom-exception-strategy class="org.mule.DefaultExceptionStrategy"/>-->
            <default-connector-exception-strategy/>
        </service>
    </model>
</mule>
