<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

    <!--
        This context initialises the MuleEventMulticaster and two Test beans used for sending and recieving
        MuleEvents.  The testBeans have a callback which is used in the tests to control the behaviour of the components.
        Both beans are MuleSubscriptionEventListeners which means they hae methods for getting and setting
        subscriptions.  You can specify that a bean receices all events either by setting the subscription proprty to
        '*' or by implementing MuleEventListener.
        
        The irregular part of this test configuration is that the Mule VM provider is used.  This provider uses
        in-memory queues to store events and is useful for testing as no additional connections need to be made.
        In a real configuration the VM provider would not be used as it passes events around in the same vm which
        isn't necessary in Spring as you can use Spring's event mechanism for that.  Also if you do use the VM provider
        do not set subscriptions to '*' for beans that publish events as the bean will keep receiving the event it publishes.
        This does not happen when using the other Mule providers.
    -->

    <!-- The Mule implementation of ApplicationEventMulticaster.  On startup the application
        context will look in the container for a bean called applicationEventMulticaster and
        register it as the spring context event multicaster -->
    <bean id="applicationEventMulticaster"
        class="org.mule.module.spring.events.MuleEventMulticaster"
        init-method="initialise">
        <property name="asynchronous">
            <value>true</value>
        </property>
        <property name="subscriptions">
            <list>
                <value>vm://*</value>
            </list>
        </property>
    </bean>

    <!-- this bean implements MuleSubscriptioneventListener which means it will receive any events published
        on enpoints that start with event.
    -->
    <bean id="testSubscribingEventBean1"
        class="org.mule.module.spring.events.TestSubscriptionEventBean">
        <property name="subscriptions">
            <list>
                <value>vm://event.*</value>
            </list>
        </property>
    </bean>

    <!-- this bean implements MuleSubscriptioneventListener which means it will receive any events published
        on enpoint test.event.bean.2. note that the enpoint is mapped further up in the config
    -->
    <bean id="testSubscribingEventBean2"
        class="org.mule.module.spring.events.TestSubscriptionEventBean">
        <property name="subscriptions">
            <list>
                <value>vm://testBean2</value>
            </list>
        </property>
    </bean>

    <!-- this is a bean that implements the ApplicationListener.  This bean will receive
        all events except Mule events
    -->
    <bean id="testEventSpringBean"
        class="org.mule.module.spring.events.TestApplicationEventBean" />

    <!-- this is a bean that implements the ApplicationListener and MuleEventListener.  This bean will receive
        all events
    -->
    <bean id="testAllEventBean"
        class="org.mule.module.spring.events.TestAllEventBean" />

    <!-- This bean implements MuleEventListener which means it will receive all Mule events regardless
        of the endpoint they were published on
    -->
    <bean id="testNonSubscribingMuleEventBean"
        class="org.mule.module.spring.events.TestMuleEventBean" />

</beans>