<?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:osgi="http://www.springframework.org/schema/osgi"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                      http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi-1.0-m3.xsd">

    <spring:bean id="muleManager" class="org.mule.module.osgi.MuleSoaManager"/>

    <!-- Used to set mule object names to their corresponding bean id -->
    <spring:bean id="muleNameProcessor" class="org.mule.module.spring.MuleObjectNameProcessor"/>

    <spring:bean id="fileConnector" class="org.mule.providers.file.FileConnector">
        <spring:property name="pollingFrequency" value="1000"/>
    </spring:bean>

    <spring:bean id="httpConnector" class="org.mule.providers.http.HttpConnector">
    </spring:bean>

    <!--
           All transformers must be defined here.  For this example we have two transformers
           used to transform the inbound events for the Greeter and Chatter components into
           objects they understand.  The entryPointResolver configured on the Model below will
           determine which method to call on our components based on the return types of these
           transformers.
       -->
    <spring:bean id="BytesToString" class="org.mule.transformers.simple.ByteArrayToObject">
        <spring:property name="returnClass">
            <spring:value>java.lang.String</spring:value>
        </spring:property>
    </spring:bean>
    <osgi:service ref="BytesToString" interface="org.mule.umo.transformer.UMOTransformer"/>

    <spring:bean id="HttpToString" class="org.mule.example.hello.HttpRequestToString">
        <spring:property name="returnClass">
            <spring:value>java.lang.String</spring:value>
        </spring:property>
    </spring:bean>
    <osgi:service ref="HttpToString" interface="org.mule.umo.transformer.UMOTransformer"/>

    <spring:bean id="StringToNameString" class="org.mule.example.hello.StringToNameString">
        <spring:property name="returnClass">
            <spring:value>org.mule.example.hello.NameString</spring:value>
        </spring:property>
    </spring:bean>
    <osgi:service ref="StringToNameString" interface="org.mule.umo.transformer.UMOTransformer"/>

    <spring:bean id="NameStringToChatString" class="org.mule.example.hello.NameStringToChatString">
        <spring:property name="returnClass">
            <spring:value>org.mule.example.hello.ChatString</spring:value>
        </spring:property>
    </spring:bean>
    <osgi:service ref="NameStringToChatString" interface="org.mule.umo.transformer.UMOTransformer"/>

    <spring:bean id="ChatStringToString" class="org.mule.example.hello.ChatStringToString">
        <spring:property name="returnClass">
            <spring:value>java.lang.String</spring:value>
        </spring:property>
    </spring:bean>
    <osgi:service ref="ChatStringToString" interface="org.mule.umo.transformer.UMOTransformer"/>

    <!--
        A Mule descriptor defines all the necessary information about how your components will
        interact with the framework, other components in the system and external sources.
        Please refer to the Configuration Guide for a full description of all the parameters.
    -->
    <spring:bean id="GreeterUMO" class="org.mule.impl.MuleDescriptor">
        <spring:property name="inboundEndpoint">
            <spring:bean class="org.mule.impl.endpoint.MuleEndpoint">
                <spring:property name="endpointURI">
                    <spring:bean class="org.mule.impl.endpoint.MuleEndpointURI">
                        <constructor-arg>
                            <spring:value>file:///tmp/in?transformers=BytesToString,StringToNameString</spring:value>
                        </constructor-arg>
                    </spring:bean>
                </spring:property>
            </spring:bean>
        </spring:property>
        <spring:property name="outboundEndpoint">
            <spring:bean class="org.mule.impl.endpoint.MuleEndpoint">
                <spring:property name="endpointURI">
                    <spring:bean class="org.mule.impl.endpoint.MuleEndpointURI">
                        <constructor-arg>
                            <spring:value>vm://chitchatter</spring:value>
                        </constructor-arg>
                    </spring:bean>
                </spring:property>
            </spring:bean>
        </spring:property>
        <spring:property name="implementation">
            <spring:value>Greeter</spring:value>
        </spring:property>
    </spring:bean>

    <!--
    This is the actual bean used by the GreeterUMO. Notice that it is a singleton.  This
    important when component pooling is used (which it is by default).
    -->
    <spring:bean id="Greeter" class="org.mule.example.hello.Greeter"/>

    <spring:bean id="ChitChatUMO" class="org.mule.impl.MuleDescriptor">
        <spring:property name="inboundEndpoint">
            <spring:bean class="org.mule.impl.endpoint.MuleEndpoint">
                <spring:property name="endpointURI">
                    <spring:bean class="org.mule.impl.endpoint.MuleEndpointURI">
                        <constructor-arg>
                            <spring:value>vm://chitchatter?transformers=NameStringToChatString</spring:value>
                        </constructor-arg>
                    </spring:bean>
                </spring:property>
            </spring:bean>
        </spring:property>
        <spring:property name="outboundEndpoint">
            <spring:bean class="org.mule.impl.endpoint.MuleEndpoint">
                <spring:property name="endpointURI">
                    <spring:bean class="org.mule.impl.endpoint.MuleEndpointURI">
                        <constructor-arg>
                            <spring:value>file:///tmp/out?transformers=ChatStringToString</spring:value>
                        </constructor-arg>
                    </spring:bean>
                </spring:property>
            </spring:bean>
        </spring:property>
        <spring:property name="implementation">
            <spring:value>ChitChatter</spring:value>
        </spring:property>
    </spring:bean>

    <!--
    This is the actual bean used by the ChitChatUMO. Notice that it is a singleton.  This
    important when component pooling is used (which it is by default).
    -->
    <spring:bean id="ChitChatter" class="org.mule.example.hello.ChitChatter"/>
</mule>
