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

    <jdbc:connector name="jdbcConnector1" dataSource-ref="testDS1"/>

    <jdbc:connector name="jdbcConnector2" dataSource-ref="testDS2"/>

    <jdbc:connector name="jdbcConnector3" dataSource-ref="testDS1">
        <jdbc:query key="getTest"
                    value="SELECT ID, TYPE, DATA, ACK, RESULT FROM TEST WHERE TYPE = ${type} AND ACK IS NULL" />
        <jdbc:query key="getTest2"
                    value="SELECT ID, TYPE, DATA, ACK, RESULT FROM TEST WHERE TYPE = ${type} AND ACK IS NULL" />
        <jdbc:query key="getTest.ack"
                    value="UPDATE TEST SET ACK = ${function:NOW} WHERE ID = ${id} AND TYPE = ${type} AND DATA = ${data}" />
    </jdbc:connector>

    <jdbc:endpoint name="testJdbcEndpoint" address="jdbc://getTest?type=1" connector-ref="jdbcConnector3">
        <jdbc:query key="getTest2" value="OVERRIDDEN VALUE" />
        <jdbc:query key="getTest3" value="SELECT ID, TYPE, DATA, ACK, RESULT FROM TEST WHERE TYPE = ${type} AND ACK IS NULL" />
    </jdbc:endpoint>

    <spring:bean id="testDS1" class="org.mule.transport.jdbc.test.TestDataSource" />

    <spring:beans>
        <jee:jndi-lookup id="testDS2" jndi-name="jdbc/testDS" environment-ref="jndiEnv" />
        
        <util:map id="jndiEnv">
            <spring:entry key="java.naming.factory.initial" value="org.mule.transport.jdbc.test.JdbcTestContextFactory" />
        </util:map>
    </spring:beans>

</mule>
