<?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 id="templateManager" class="gov.va.med.cds.template.TemplateManager">
		<constructor-arg index="0" ref="templateService" />
		<constructor-arg index="1" ref="templateCacheManager" />
		<constructor-arg index="2" ref="templateCache" />
	</bean>
	
	<bean id="templateCacheManager" class="gov.va.med.cds.template.HibernateOracleTemplateCachePersistence">
		<property name="sessionFactory" ref="hdr2TfsSessionFactory"/>
	</bean>
	
	<bean id="hdr2TfsSessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
		<property name="dataSource" ref="hdrDataSource" />
		<property name="mappingResources">
			<list>
				<!-- TFR Mapping Files -->
				<value>gov/va/med/cds/persistence/hibernate/tfs/DomainEntryPoint.hbm.xml</value>
				<value>gov/va/med/cds/persistence/hibernate/tfs/TemplateSchema.hbm.xml</value>
				<value>gov/va/med/cds/persistence/hibernate/tfs/VhimVersion.hbm.xml</value>
				<value>gov/va/med/cds/persistence/hibernate/tfs/FilterSchema.hbm.xml</value>
				<value>gov/va/med/cds/persistence/hibernate/tfs/EntryFilter.hbm.xml</value>

			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
				<prop key="hibernate.show_sql">${hibernate.show.sql}</prop>
			</props>
		</property>
	</bean>

	<bean id="templateCache" class="gov.va.med.cds.template.TemplateCache">
		<constructor-arg>
			<bean class="gov.va.med.cds.util.LRUHashMap">
				<!-- LRU cache size -->
				<constructor-arg index="0" value="100" />
			</bean>
		</constructor-arg>
	</bean>

	<bean id="templateManagerMBeanExporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
		<property name="beans">
			<map>
				<entry key="gov.va.med.cds.template:name=cds-template-manager" value-ref="templateManager" />
			</map>
		</property>
		<property name="assembler">
			<bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
				<property name="interfaceMappings">
					<props>
						<prop key="gov.va.med.cds.template:name=cds-template-manager">
							gov.va.med.cds.template.TemplateManagerMBeanInterface
						</prop>
					</props>
				</property>
			</bean>
		</property>
		<property name="server" ref="mbeanServer" />
		<property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING" />
	</bean>

</beans>
