<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
	
	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
	</bean>
	
	<util:properties id="jndiEnvironment">
		<prop key="java.naming.factory.initial">${cds.client.java.naming.factory.initial}</prop>
		<prop key="java.naming.provider.url">${cds.client.java.naming.provider.url}</prop>
	</util:properties>
	
	<!-- Spring JMS Configuration start-->
	<bean id="cachingCdsConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
		<property name="targetConnectionFactory">
			<bean class="org.springframework.jndi.JndiObjectFactoryBean">
				<property name="jndiName" value="jms/cds/CdsConnectionFactory"/>
				<property name="jndiEnvironment" ref="jndiEnvironment"/>
			</bean>
		</property>
	</bean>
	
	<bean id="cdsDefaultResponseQueueDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiEnvironment" ref="jndiEnvironment"/>
		<property name="jndiName" value="jms/cds/CdsResponseQueue"/>
	</bean>
	
	<bean id="questionnaireResultsQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiEnvironment" ref="jndiEnvironment"/>
		<property name="jndiName" value="jms/cds/QuestionnaireResultsQueue"/>
	</bean>
	
	<!-- JMS Template that wraps the Queue that the Async test will publish questionnaire results to to be processed by CDS. -->
	<bean id="questionnaireResultQueueJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
		<property name="connectionFactory" ref="cachingCdsConnectionFactory"/>
		<property name="defaultDestination" ref="questionnaireResultsQueue"/>
	</bean>
	
	<!-- FPDS -->
	<bean id="cachedFpdsConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
		<property name="targetConnectionFactory">
			<bean class="org.springframework.jndi.JndiObjectFactoryBean">
				<property name="jndiName" value="jms/fpds/FpdsConnectionFactory" />
				<property name="jndiEnvironment" ref="jndiEnvironment"/>
			</bean>
		</property>
	</bean>

	<bean id="fpdsResponseQueueDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiEnvironment" ref="jndiEnvironment"/>
		<property name="jndiName" value="jms/fpds/DefaultHl7AckQueue" />
	</bean>
	
	<bean id="fpdsAckResponseQueueDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiEnvironment" ref="jndiEnvironment"/>
		<property name="jndiName" value="jms/fpds/FtpHl7AckQueue" />
	</bean>
	
	<bean id="tiuHl7Queue" class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiEnvironment" ref="jndiEnvironment"/>
		<property name="jndiName" value="jms/fpds/TiuHl7Queue"/>
	</bean>

	<!-- JMS Template that wraps the Topic that the Async test will listen on for the acknowledgements of processing by FPDS -->
	<bean id="tiuHl7QueueJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
		<property name="connectionFactory" ref="cachedFpdsConnectionFactory" />
		<property name="defaultDestination" ref="tiuHl7Queue" />
	</bean>
	
	<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
		<property name="environment">
			<props>
				<prop key="java.naming.factory.initial">${cds.client.java.naming.factory.initial}</prop>
				<prop key="java.naming.provider.url">${cds.client.java.naming.provider.url}</prop>
				<prop key="java.naming.security.principal">${cds.appserver.admin.username}</prop>
				<prop key="java.naming.security.credentials">${cds.appserver.admin.password}</prop>
			</props>
		</property>
	</bean>
	
	
</beans>
