<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC 
	"-//SPRING//DTD BEAN//EN" 
	"http://www.springframework.org/dtd/spring-beans.dtd">
<!--
	iEat Data Access Context
	
	This Spring bean context is used to define components of the iEat
	application which vary between running the application in different 
	environments, for example as a web application or as JUnit test 
	cases.
-->
<beans>
	<!-- DataSource to the iEat application database. -->
	<bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiName"><value>java:comp/env/jdbc/ieat</value></property>
	</bean>
	
	<!-- JNDI-bound javax.mail.Session for use in JNDI-enabled container. -->
	<bean id="myMailSession" class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiName"><value>java:/comp/env/mail/ieat</value></property>
	</bean>
	
	<!-- Spring MailSender implementation for sending system emails. -->
	<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
		<property name="session"><ref bean="myMailSession"/></property>
	</bean>

	<bean id="domainObjectFactory" class="magoffin.matt.ieat.biz.impl.JAXBDomainObjectFactoryImpl"/>
	
	<!-- Hibernate SessionFactory definition. -->
	<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource"><ref local="myDataSource"/></property>
		<property name="mappingResources">
			<list>
				<value>ieat.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/Base.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/Course.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/Difficulty.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/Ethnicity.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/Ingredient.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/Meal.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/MealRecipe.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/PrepTime.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/Recipe.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/RecipeComment.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/RecipeIngredient.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/RecipeRating.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/RecipeStep.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/RelatedRecipe.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/RelationKind.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/System.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/Unit.hbm.xml</value>
				<value>magoffin/matt/ieat/domain/User.hbm.xml</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">${hibernate.dialect}</prop>
				<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
				<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
				<prop key="hibernate.max_fetch_depth">4</prop>
			</props>
		</property>
	</bean>

	<!-- Transaction implementation. -->
	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory"><ref local="mySessionFactory"/></property>
		<property name="dataSource"><ref local="myDataSource"/></property>
	</bean>
	
</beans>
