<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
    <!--
    All objects are registered with the MuleManager. The AutowireUMOManagerFactoryBean
    is responsible for determining the UMOManager to implement, creates a default UMOModel
    and autowires the components to the model and all other global objects to the MuleManager.
    -->
    <bean id="muleManager" class="org.mule.extras.spring.config.AutowireUMOManagerFactoryBean"/>

    <!-- Used to set mule object names to their corresponding bean id -->
    <bean id="muleNameProcessor" class="org.mule.extras.spring.config.MuleObjectNameProcessor"/>
    <!--
    	The system stream connector is used to send and receive information via the
    	System.in and System.out. Note this connector is only really useful for testing
    	purposes.
    	promptMessage - is what is written to the console
    	messageDelayTime - is the time in milliseconds before the user is prompted again.
    	These properties are set as bean properties on the connector.
    -->
    <bean id="systemStreamConnector" class="org.mule.providers.stream.SystemStreamConnector">
        <property name="promptMessage"><value>Please enter your name: </value></property>
        <property name="messageDelayTime"><value>1000</value></property>
    </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.
       -->
    <bean id="StringToNameString" singleton="false" class="org.mule.samples.hello.StringToNameString">
        <property name="returnClass"><value>org.mule.samples.hello.NameString</value></property>
    </bean>

    <bean id="NameStringToChatString" singleton="false" class="org.mule.samples.hello.NameStringToChatString">
        <property name="returnClass"><value>org.mule.samples.hello.ChatString</value></property>
    </bean>

    <bean id="ChatStringToString" singleton="false" class="org.mule.samples.hello.ChatStringToString">
        <property name="returnClass"><value>java.lang.String</value></property>
    </bean>

    <!--
        An interceptor is a peice of code that can be configued to execute
        before and/or after an event is received for a component.
        You can define a stack of interceptors that will be executed in sequence.
        You can then configure the stack on your components.
        Note the interceptor stack must not be a singleton.  Each component needs its
        own copy of an interceptor stack.Th
    -->
    <bean id="defaultInterceptorStack" singleton="false" class="java.util.ArrayList">
        <constructor-arg>
            <list>
                <bean id="loggingInterceptor" class="org.mule.interceptors.LoggingInterceptor"/>
                <bean id="timerInterceptor" class="org.mule.interceptors.TimerInterceptor"/>
            </list>
        </constructor-arg>
    </bean>

    <!--
        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.
    -->
    <bean id="GreeterUMO" class="org.mule.impl.MuleDescriptor">
        <property name="inboundEndpoint">
            <bean  class="org.mule.impl.endpoint.MuleEndpoint">
                <property name="endpointURI">
                    <bean class="org.mule.impl.endpoint.MuleEndpointURI">
                        <constructor-arg>
                            <value>stream://localhost?transformers=StringToNameString</value>
                        </constructor-arg>
                    </bean>
               </property>
            </bean>
        </property>
        <property name="outboundEndpoint">
            <bean  class="org.mule.impl.endpoint.MuleEndpoint">
                <property name="endpointURI">
                    <bean class="org.mule.impl.endpoint.MuleEndpointURI">
                        <constructor-arg>
                            <value>vm://chitchatter</value>
                        </constructor-arg>
                    </bean>
               </property>
            </bean>
        </property>
        <property name="implementation"><value>Greeter</value></property>
        <!--
        Here we tell this component to use the interceptor stack defined above
        -->
        <property name="interceptors">
                <ref local="defaultInterceptorStack"/>
        </property>
    </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).
    -->
    <bean id="Greeter" singleton="false" class="org.mule.samples.hello.Greeter"/>

    <bean id="ChitChatUMO" class="org.mule.impl.MuleDescriptor">
        <property name="inboundEndpoint">
            <bean  class="org.mule.impl.endpoint.MuleEndpoint">
                <property name="endpointURI">
                    <bean class="org.mule.impl.endpoint.MuleEndpointURI">
                        <constructor-arg>
                            <value>vm://chitchatter?transformers=NameStringToChatString</value>
                        </constructor-arg>
                    </bean>
               </property>
            </bean>
        </property>
        <property name="outboundEndpoint">
            <bean  class="org.mule.impl.endpoint.MuleEndpoint">
                <property name="endpointURI">
                    <bean class="org.mule.impl.endpoint.MuleEndpointURI">
                        <constructor-arg>
                            <value>stream://localhost?transformers=ChatStringToString</value>
                        </constructor-arg>
                    </bean>
               </property>
            </bean>
        </property>
        <property name="implementation"><value>ChitChatter</value></property>
        <!--
          Here we tell this component to use the interceptor stack defined above
        -->
        <property name="interceptors">
                <ref local="defaultInterceptorStack"/>
        </property>
    </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).
    -->
    <bean id="ChitChatter" singleton="false" class="org.mule.samples.hello.ChitChatter"/>
</beans>

