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

	<import resource="classpath:gov/va/med/cds/ejb/config/envSpecificContext.xml"/>
	<import resource="classpath:gov/va/med/cds/mediator/config/message-mediator-context.xml"/>
	<import resource="classpath:gov/va/med/cds/mediator/config/message-mediator-persistence-context.xml"/>
	<import resource="classpath:gov/va/med/cds/audit/persistence/jms/jmsAuditLogContext.xml"/>
	<import resource="classpath:gov/va/med/cds/scheduler/schedulerPersistenceContext.xml"/>
	<import resource="classpath:gov/va/med/cds/scheduler/spring-quartz-context.xml"/>

	<!-- This bean sets up property replacement so that variables can be externalized to system properties -->
	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
		<property name="locations">
			<list>
				<value>classpath:gov/va/med/mediator/config/properties/defaultWeblogic.properties
				</value>
			</list>
		</property>
	</bean>

	<bean id="cdsServiceExt" factory-bean="cdsServiceFactory" factory-method="create" lazy-init="true"/>

	<bean id="cdsServiceFactory" class="gov.va.med.cds.client.ClinicalDataServiceFactory" lazy-init="true">
		<property name="serviceBindingId" ref="CDS_SVC_ID"/>
		<property name="endpointResolver" ref="endpointResolver"/>
	</bean>

	<bean id="xsltHelper" class="gov.va.med.cds.xml.transform.XsltHelper">
		<constructor-arg index="0" ref="xsltLocations"/>
		<constructor-arg index="1" ref="extensionFunctions"/>
	</bean>

	<util:list id="xsltLocations" value-type="java.lang.String">
		<value>classpath:gov/va/med/cds/xslt/*.xsl</value>
		<value>classpath:gov/va/med/cds/xslt/filter/*.xsl</value>
	</util:list>

	<util:list id="extensionFunctions" value-type="net.sf.saxon.lib.ExtensionFunctionDefinition">
		<bean class="gov.va.med.cds.mediator.xml.transform.saxonextensions.Hl7SupportMessageDataExtFunc"/>
		<bean class="gov.va.med.cds.mediator.xml.transform.saxonextensions.Hl7SupportCreateMessageDatetimeExtFunc"/>
		<bean class="gov.va.med.cds.mediator.xml.transform.saxonextensions.Hl7SupportMessageControlIdExtFunc"/>
		<bean class="gov.va.med.cds.mediator.xml.transform.saxonextensions.Hl7SupportRequestWhatCodeExtFunc"/>
		<bean class="gov.va.med.cds.mediator.xml.transform.saxonextensions.Hl7UtilityGetSendingFacilityExtFunc"/>
		<bean class="gov.va.med.cds.mediator.xml.transform.saxonextensions.AddCheckSumtoIcnExtFunc"/>
		<bean class="gov.va.med.cds.mediator.xml.transform.saxonextensions.WorkStateExceptionCountExtFunc"/>
		<bean class="gov.va.med.cds.mediator.xml.transform.saxonextensions.WorkStateFormattedExceptionDetailExtFunc"/>
		<bean class="gov.va.med.cds.mediator.xml.transform.saxonextensions.SurveyParseExtFunc"/>
	</util:list>

	<bean id="hdrDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiName" value="${cds.jdbc.dataSource.hdr2.jndiName}"/>
	</bean>

	<bean id="auditLogClobStoreTransactionManager" class="org.springframework.transaction.jta.WebLogicJtaTransactionManager"/>
	
	<aop:config>
		<aop:pointcut id="clobStoreTxMethods" expression="execution(* gov.va.med.cds.audit.persistence.CdsAuditClobStoreInterface.*(..))"/>
		<aop:pointcut id="auditLogTxMethods" expression="execution(* gov.va.med.cds.audit.persistence.AuditLogPersistenceManagerInterface.*(..))"/>
		<aop:pointcut id="hl7AuditDaoTxMethods" expression="execution(* gov.va.med.cds.mediator.persistence.Hl7AuditDaoInterface.*(..))"/>
		<aop:advisor advice-ref="clobStoreTxAdvice" pointcut-ref="clobStoreTxMethods" order="1"/>
		<aop:advisor advice-ref="auditLogTxAdvice" pointcut-ref="auditLogTxMethods" order="2"/>
		<aop:advisor advice-ref="hl7AuditDaoTxAdvice" pointcut-ref="hl7AuditDaoTxMethods" order="3"/>
	</aop:config>

	<tx:advice id="auditLogTxAdvice" transaction-manager="auditLogClobStoreTransactionManager">
		<tx:attributes>
			<tx:method name="storeAuditLog" propagation="REQUIRED" isolation="READ_COMMITTED"/>
		</tx:attributes>
	</tx:advice>

	<tx:advice id="clobStoreTxAdvice" transaction-manager="auditLogClobStoreTransactionManager">
		<tx:attributes>
			<tx:method name="persistCdsAuditClob" propagation="REQUIRES_NEW" isolation="READ_COMMITTED"/>
		</tx:attributes>
	</tx:advice>

	<tx:advice id="hl7AuditDaoTxAdvice" transaction-manager="auditLogClobStoreTransactionManager">
		<tx:attributes>
			<tx:method name="addMessage" propagation="REQUIRES_NEW" isolation="READ_COMMITTED"/>
		</tx:attributes>
	</tx:advice>

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

	<bean id="cdsAppName" class="java.lang.String">
		<constructor-arg value="${cdsAppName}"/>
	</bean>

	<bean id="pathwaysAppName" class="java.lang.String">
		<constructor-arg value="${pathwaysAppName}"/>
	</bean>

</beans>