<?xml version="1.0" encoding="UTF-8"?>
<!--  Namespace type configuration  -->
<beans default-lazy-init="false"
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:jms="http://www.springframework.org/schema/jms"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans 
		http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
		http://www.springframework.org/schema/jms 
		http://www.springframework.org/schema/jms/spring-jms-3.0.xsd">
   
   <!-- ###################################################################################### -->
	<!-- Jndi Templates -->
   <!-- ###################################################################################### -->	
	<bean id="ccht.jndiTemplate.clusterAttended" class="org.springframework.jndi.JndiTemplate">
		<property name="environment">
			<props>
				<prop key="java.naming.provider.url">${jms.provider.url.clusterAttended}</prop>
				<prop key="java.naming.factory.initial">${java.naming.factory.initial}</prop>
			</props>
		</property>
	</bean>	
	<bean id="ccht.jndiTemplate.clusterUnattended" class="org.springframework.jndi.JndiTemplate">
		<property name="environment">
			<props>
				<prop key="java.naming.provider.url">${jms.provider.url.clusterUnattended}</prop>
				<prop key="java.naming.factory.initial">${java.naming.factory.initial}</prop>
			</props>
		</property>
	</bean>   
	
	<alias alias="ccht.jndiTemplate.batchProcess.primary" name="ccht.jndiTemplate.clusterUnattended"/>
	<alias alias="ccht.jndiTemplate.batchProcess.fallback1" name="ccht.jndiTemplate.clusterAttended"/>	
	<alias alias="ccht.jndiTemplate.common.primary" name="ccht.jndiTemplate.clusterUnattended"/>
	<alias alias="ccht.jndiTemplate.common.fallback1" name="ccht.jndiTemplate.clusterAttended"/>	
	<alias alias="ccht.jndiTemplate.reporting.primary" name="ccht.jndiTemplate.clusterUnattended"/>
	<alias alias="ccht.jndiTemplate.reporting.fallback1" name="ccht.jndiTemplate.clusterAttended"/>	
	
	<bean id="abstract.ccht.jndi" abstract="true" class="org.springframework.jndi.JndiObjectFactoryBean"/>
	<bean id="abstract.ccht.jndi.primary" abstract="true" parent="abstract.ccht.jndi">
		<property name="lookupOnStartup" value="false"/>
	</bean>				
	<bean id="abstract.ccht.jndi.fallback" abstract="true" parent="abstract.ccht.jndi">
		<!-- don't change this as we want all fallback beans to have lookupOnStartup=false -->
		<property name="lookupOnStartup" value="false"/>
		<property name="cache" value="false"/>		
	</bean>				
	
   <!-- ###################################################################################### -->	
    <!--  Connection factory -->		
   <!-- ###################################################################################### -->    
	<bean id="abstract.ccht.jms.internal.ConnectionFactory.primary" abstract="true" parent="abstract.ccht.jndi.primary">
		<property name="jndiName" value="ihta.jms.queue.ConnectionFactory"/>
		<property name="proxyInterface" value="javax.jms.ConnectionFactory"/>		
	</bean>    
	<bean id="abstract.ccht.jms.internal.ConnectionFactory.fallback" abstract="true" parent="abstract.ccht.jndi.fallback">
		<property name="jndiName" value="ihta.jms.queue.ConnectionFactory"/>
		<property name="proxyInterface" value="javax.jms.ConnectionFactory"/>		
	</bean>    	
	<bean id="ccht.jms.internal.ConnectionFactory.batchProcess.primary" parent="abstract.ccht.jms.internal.ConnectionFactory.primary">
		<property name="jndiTemplate" ref="ccht.jndiTemplate.batchProcess.primary"/>
	</bean>
	<bean id="ccht.jms.internal.ConnectionFactory.batchProcess.fallback1" parent="abstract.ccht.jms.internal.ConnectionFactory.fallback">
		<property name="jndiTemplate" ref="ccht.jndiTemplate.batchProcess.fallback1"/>
	</bean>	
	<bean id="ccht.jms.internal.ConnectionFactory.common.primary" parent="abstract.ccht.jms.internal.ConnectionFactory.primary">
		<property name="jndiTemplate" ref="ccht.jndiTemplate.common.primary"/>
	</bean>		
	<bean id="ccht.jms.internal.ConnectionFactory.common.fallback1" parent="abstract.ccht.jms.internal.ConnectionFactory.fallback">
		<property name="jndiTemplate" ref="ccht.jndiTemplate.common.fallback1"/>
	</bean>			
	<bean id="ccht.jms.internal.ConnectionFactory.reporting.primary" parent="abstract.ccht.jms.internal.ConnectionFactory.primary">
		<property name="jndiTemplate" ref="ccht.jndiTemplate.reporting.primary"/>
	</bean>	
	<bean id="ccht.jms.internal.ConnectionFactory.reporting.fallback1" parent="abstract.ccht.jms.internal.ConnectionFactory.fallback">
		<property name="jndiTemplate" ref="ccht.jndiTemplate.reporting.fallback1"/>
	</bean>	
  
   <!-- ###################################################################################### -->  
    <!--  Destinations (queues/topics) --> 
    <!--
    	Configuration note: Lazy loading of JNDI lookup for JMS Destinations does not work with JndiObjectFactoryBean.
    	The Spring team recommends configuring as such with JndiDestinationResolver.
    	See http://jira.springframework.org/browse/SPR-3553.
     -->
    <!-- <bean id="abstract.ccht.jms.internal.queue" abstract="true" parent="abstract.ccht.jndi">
		<property name="proxyInterface" value="javax.jms.Queue"/>		    
    </bean> -->     
   <!-- ###################################################################################### -->    
	<bean id="abstract.ccht.jms.destinationResolver" abstract="true" class="org.springframework.jms.support.destination.JndiDestinationResolver"/>   
	<bean id="abstract.ccht.jms.destinationResolver.primary" abstract="true" parent="abstract.ccht.jms.destinationResolver"/>
	<bean id="abstract.ccht.jms.destinationResolver.fallback" abstract="true" parent="abstract.ccht.jms.destinationResolver">	
		<property name="cache" value="false"/>
	</bean>
	<bean id="ccht.jms.destinationResolver.batchProcess.primary" parent="abstract.ccht.jms.destinationResolver.primary">		
	    <property name="jndiTemplate" ref="ccht.jndiTemplate.batchProcess.primary"/>
	</bean>
	<bean id="ccht.jms.destinationResolver.batchProcess.fallback1" parent="abstract.ccht.jms.destinationResolver.fallback">		
	    <property name="jndiTemplate" ref="ccht.jndiTemplate.batchProcess.fallback1"/>
	</bean>	
	<bean id="ccht.jms.destinationResolver.common.primary" parent="abstract.ccht.jms.destinationResolver.primary">
	    <property name="jndiTemplate" ref="ccht.jndiTemplate.common.primary"/>	
	</bean>
	<bean id="ccht.jms.destinationResolver.common.fallback1" parent="abstract.ccht.jms.destinationResolver.fallback">
	    <property name="jndiTemplate" ref="ccht.jndiTemplate.common.fallback1"/>	
	</bean>		
	<bean id="ccht.jms.destinationResolver.reporting.primary" parent="abstract.ccht.jms.destinationResolver.primary">
	    <property name="jndiTemplate" ref="ccht.jndiTemplate.reporting.primary"/>	
	</bean>	
	<bean id="ccht.jms.destinationResolver.reporting.fallback1" parent="abstract.ccht.jms.destinationResolver.fallback">
	    <property name="jndiTemplate" ref="ccht.jndiTemplate.reporting.fallback1"/>	
	</bean>	
	
   <!-- ###################################################################################### -->	
	<!--  JMS Templates -->
   <!-- ###################################################################################### -->	
	<bean id="ccht.jms.defaultMessageConverter" class="gov.va.med.fw.service.jms.DefaultMessageConverter"/>
	
	<bean id="abstract.ccht.jmsTemplate" abstract="true" class="org.springframework.jms.core.JmsTemplate">
		<property name="messageConverter" ref="ccht.jms.defaultMessageConverter" />
	</bean>	
	<bean id="abstract.ccht.jms.template.batchProcess" abstract="true" parent="abstract.ccht.jmsTemplate" >
		<property name="defaultDestinationName" value="ihta.jms.queue.BatchQueue"/>
	</bean>	
	<bean id="ccht.jms.template.batchProcess.primary" parent="abstract.ccht.jms.template.batchProcess" >
		<property name="connectionFactory" ref="ccht.jms.internal.ConnectionFactory.batchProcess.primary" />
		<property name="destinationResolver" ref="ccht.jms.destinationResolver.batchProcess.primary" />		
	</bean>
	<bean id="ccht.jms.template.batchProcess.fallback1" parent="abstract.ccht.jms.template.batchProcess" >
		<property name="connectionFactory" ref="ccht.jms.internal.ConnectionFactory.batchProcess.fallback1" />
		<property name="destinationResolver" ref="ccht.jms.destinationResolver.batchProcess.fallback1" />		
	</bean>	
	<bean id="abstract.ccht.jms.template.common" abstract="true" parent="abstract.ccht.jmsTemplate" >
		<property name="defaultDestinationName" value="ihta.jms.queue.EventQueue"/>
	</bean>			
	<bean id="ccht.jms.template.common.primary" parent="abstract.ccht.jms.template.common" >
		<property name="connectionFactory" ref="ccht.jms.internal.ConnectionFactory.common.primary"/>
		<property name="destinationResolver" ref="ccht.jms.destinationResolver.common.primary" />						
	</bean>		
	<bean id="ccht.jms.template.common.fallback1" parent="abstract.ccht.jms.template.common" >
		<property name="connectionFactory" ref="ccht.jms.internal.ConnectionFactory.common.fallback1"/>
		<property name="destinationResolver" ref="ccht.jms.destinationResolver.common.fallback1" />						
	</bean>			
	<bean id="abstract.ccht.jms.template.reporting" abstract="true" parent="abstract.ccht.jmsTemplate" >
		<property name="defaultDestinationName" value="ihta.jms.queue.SchedulerQueue"/>
	</bean>	
	<bean id="ccht.jms.template.reporting.primary" parent="abstract.ccht.jms.template.reporting" >
		<property name="connectionFactory" ref="ccht.jms.internal.ConnectionFactory.reporting.primary" />
		<property name="destinationResolver" ref="ccht.jms.destinationResolver.reporting.primary" />				
	</bean>
	<bean id="ccht.jms.template.reporting.fallback1" parent="abstract.ccht.jms.template.reporting" >
		<property name="connectionFactory" ref="ccht.jms.internal.ConnectionFactory.reporting.fallback1" />
		<property name="destinationResolver" ref="ccht.jms.destinationResolver.reporting.fallback1" />				
	</bean>
		
   <!-- ###################################################################################### -->		
	<!--  Message Producers -->
   <!-- ###################################################################################### -->	
	<bean id="abstract.common.jms.producer" abstract="true" class="gov.va.med.fw.service.jms.AsynchronousMessageProducerServiceImpl">
	    <property name="supportsDistributedTransactions" value="true"/>
	    <property name="checkIntervalSecsAfterFallback" value="600"/>	    
	</bean>
	
	<bean id="abstract.common.jms.producer.synchronous" abstract="true" class="gov.va.med.fw.service.jms.SynchronousMessageProducerServiceImpl">  
	</bean>
		
    <bean id="common.jms.producer.batchProcessEvents" parent="abstract.common.jms.producer">
	    <property name="jmsTemplatePrimary" ref="ccht.jms.template.batchProcess.primary"/>    
	    <property name="jmsTemplatesFallback">
	    	<list>
		        <ref bean="ccht.jms.template.batchProcess.fallback1"/>		        
	    	</list>	    	
	    </property>
    </bean>    
    <bean id="common.jms.producer.commonEvents" parent="abstract.common.jms.producer">
	    <property name="jmsTemplatePrimary" ref="ccht.jms.template.common.primary"/>    
	    <property name="jmsTemplatesFallback">
	    	<list>
		        <ref bean="ccht.jms.template.common.fallback1"/>		        
	    	</list>	    	
	    </property>
    </bean>            
    <bean id="common.jms.producer.reportingEvents" parent="abstract.common.jms.producer">
	    <property name="jmsTemplatePrimary" ref="ccht.jms.template.reporting.primary"/>    
	    <property name="jmsTemplatesFallback">
	    	<list>
		        <ref bean="ccht.jms.template.reporting.fallback1"/>		        
	    	</list>	    	
    </property>
    </bean>  
        
    <!--  Message Producers: Payloads (gov.va.fw.service.jms.JMSPayload)-->
    <!--  NOTE: These must be prototype beans!!! -->    
    <bean id="createReportJMSPayload" class="gov.va.med.fw.service.jms.JMSPayload" scope="prototype">
        <property name="targetServiceDescriptor"><idref bean="generateReportServiceDescriptor" /></property>
    </bean>
    
    <bean id="runBatchJobJMSPayload" class="gov.va.med.fw.service.jms.JMSPayload" scope="prototype">
        <property name="targetServiceDescriptor"><idref bean="runBatchJobServiceDescriptor" /></property>
    </bean>

	<bean id="qirNotificationJMSPayLoadName" class="gov.va.med.fw.service.jms.JMSPayload" scope="prototype">
        <property name="targetServiceDescriptor"><idref bean="qirNotificationServiceDescriptor" /></property>
    </bean>
        
   <!-- ###################################################################################### -->            
    <!--  Message Consumers: Service Descriptors (gov.va.med.fw.service.ServiceDescriptor) -->    
    <!--  NOTE: These can be moved into the app context of JMS consumer (eg, MDB/EJB) -->
   <!-- ###################################################################################### -->    	
	<bean id="generateReportServiceDescriptor" class="gov.va.med.fw.service.ServiceDescriptor">
    	<!-- <property name="serviceName"><idref bean="reportGenerationService" /></property>--> 
    	<property name="serviceName" value="test1" /> 
    	<property name="methodName" value="buildReport"/>
    	<property name="builder" ref="reportSetupBuilder" />
	</bean>
	
	<bean id="runBatchJobServiceDescriptor" class="gov.va.med.fw.service.ServiceDescriptor">
    	<!-- <property name="serviceName"><idref bean="batchProcessService" /></property> --> 
    	<property name="serviceName" value="test2" /> 
    	<property name="methodName" value="executeJob"/>
    	<property name="builder" ref="jobDetailsBuilder" />
	</bean>	 
	
	<bean id="qirNotificationServiceDescriptor" class="gov.va.med.fw.service.ServiceDescriptor">
    	<!-- <property name="serviceName"><idref bean="qirService" /></property> --> 
    	<property name="serviceName" value="test3" /> 
    	<property name="methodName" value="sendVendorResponseDueEMail"/>
    	<property name="builder" ref="qirBuilder" />
	</bean>
		
			<bean id="reportSetupBuilder" class="gov.va.med.ccht.builder.ReportSetupBuilder">
			</bean>
	
			<bean id="jobDetailsBuilder" class="gov.va.med.ccht.builder.BatchJobDetailsBuilder">
			</bean>
	
			<bean id="qirBuilder" class="gov.va.med.ccht.builder.QIRBuilder">
			</bean>
		
</beans>

