<?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" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
	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
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd 
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

	<bean id="hdrDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiName" value="${cds.jdbc.dataSource.hdr2.jndiName}" />
	</bean>
	
	<bean id="transactionManager"  class="org.springframework.transaction.jta.WebLogicJtaTransactionManager" />
		
	<aop:config>
		<aop:pointcut id="clobStoreTxMethods" expression="execution(* gov.va.med.cds.audit.persistence.CdsAuditClobStoreInterface.*(..))" />
		<aop:advisor advice-ref="clobStoreTxAdvice" pointcut-ref="clobStoreTxMethods" order="1" />
	</aop:config>

	<tx:advice id="clobStoreTxAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="persistCdsAuditClob" propagation="REQUIRES_NEW" isolation="READ_COMMITTED" />
		</tx:attributes>
	</tx:advice>
	
	<util:constant id="initialContextFactory" static-field="javax.naming.Context.INITIAL_CONTEXT_FACTORY" />
	<util:constant id="providerUrl" static-field="javax.naming.Context.PROVIDER_URL" />

	<bean id="mbeanServer" class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiName" value="java:comp/env/jmx/runtime" />
	</bean>

	<!-- Spring JMS Configuration start -->
	<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" />
			</bean>
		</property>
	</bean>

	<!-- JMS Template that wraps the Topic that the Async test will listen on for the acknowledgements of processing by FPDS -->
	<bean id="responseQueueJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
		<property name="connectionFactory" ref="cachedFpdsConnectionFactory" />
	</bean>

	<bean id="clinicalDataResponse" class="gov.va.med.cds.clinicaldata.vhim400.ClinicalDataResponse400" />
			
	<bean id="cdsStatelessSession" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean" lazy-init="true">
		<property name="jndiName" value="ejb/remote/gov/va/med/cds/ClinicalDataServiceSynchronousSession"/>
		<property name="businessInterface" value="gov.va.med.cds.client.ClinicalDataServiceInterface"/>
	</bean>												
	
	<!-- <jee:remote-slsb id="cdsStatelessSession" jndi-name="ejb/remote/gov/va/med/cds/ClinicalDataServiceSynchronousSession" 
	business-interface="gov.va.med.cds.client.ClinicalDataServiceInterface" /> -->
	
	<bean id="responseErrorSectionExtractor"
		class="gov.va.med.cds.response.util.ResponseErrorSectionExtractor">
		<property name="severityList">
			<list value-type="java.lang.String">
				<value>errors</value>
				<value>fatalErrors</value>
				<value>warnings</value>
			</list>
		</property>
	</bean>
	
	<bean id="xsltHelper" class="gov.va.med.cds.xml.transform.XsltHelper">
		<property name="xsltLocations" >
			<list>
				<value>classpath:gov/va/med/repositories/fpds/ejb/xslt/*.xsl</value>
			</list>
		</property>
	</bean>
	
	<!--  Hl7 TCP Socket Client configuration -->
	<bean id="abstractMllpSocketBasedClientProxy" class="gov.va.med.cds.client.proxy.AbstractMllpSocketBasedClientProxy" abstract="true">
		<property name="blockingConnectionFactory" ref="blockingConnectionFactory" />
		<property name="port" value="5000" /><!--  we believe this can be constant across all VistA sites as the common port Hl7Listeners are configured to accept requests-->
		<property name="getReadWriteChannel" ref="getReadWriteChannel" />
	</bean>

	<bean id="dnsSocketProxy" class="gov.va.med.cds.client.proxy.MllpDnsSocketBasedClientProxy" parent="abstractMllpSocketBasedClientProxy" />

	<bean id="getReadWriteChannel" class="gov.va.med.cds.client.proxy.GetReadWriteChannel" />
	
	<bean id="blockingConnectionFactory" class="gov.va.med.cds.client.proxy.BlockingConnectionFactory">
		<property name="connectionTimeoutMillis" value="10000" />
		<property name="readTimeoutMillis" value="10000" />
		<property name="idleTimeoutMillis" value="10000" />
	</bean>
	<!--  end Hl7 TCP Socket configuration -->
	
	<bean id="hl7Utility" class="gov.va.med.cds.hapi.HL7Utility">
		<property name="jdbcTemplateForMessageControlId" ref="jdbcTemplateForMessageControlId" />
		<property name="sendingApplicaionDestinationMap" ref="sendingApplicationAckResponseDestinationMap" />
	</bean>
	<bean id="jdbcTemplateForMessageControlId" class="org.springframework.jdbc.core.JdbcTemplate">
		<property name="dataSource" ref="hdrDataSource"/>
	</bean>
	<!-- CR ACK response routing -->
	<util:map id="sendingApplicationAckResponseDestinationMap" map-class="java.util.HashMap">
		<entry key="HDRFTP" value="jms/fpds/FtpHl7AckQueue" />
		<entry key="FTP" value="jms/fpds/FtpHl7AckQueue" />
	</util:map>
					
</beans>
