<?xml version="1.0" encoding="UTF-8"?>

<!--
========================================================================================================================
beans-service.xml

Copyright (c) 2013 Manning Publications Co.

Willie Wheeler (willie.wheeler@gmail.com)

Book: http://manning.com/wheeler/
Blog: http://springinpractice.com/
Code: https://github.com/springinpractice
========================================================================================================================
-->
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jee="http://www.springframework.org/schema/jee"
	xmlns:p="http://www.springframework.org/schema/p"
	xmlns:task="http://www.springframework.org/schema/task"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:util="http://www.springframework.org/schema/util"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="
		http://www.springframework.org/schema/beans
		http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
		http://www.springframework.org/schema/context
		http://www.springframework.org/schema/context/spring-context-3.1.xsd
		http://www.springframework.org/schema/jee
		http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
		http://www.springframework.org/schema/task
		http://www.springframework.org/schema/task/spring-task-3.1.xsd
		http://www.springframework.org/schema/tx
		http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
		http://www.springframework.org/schema/util
		http://www.springframework.org/schema/util/spring-util-3.1.xsd">
	
	<context:component-scan base-package="com.springinpractice.ch08.dao.hbn" />
	<context:component-scan base-package="com.springinpractice.ch08.service.impl" />
	
	<jee:jndi-lookup id="dataSource" jndi-name="jdbc/Sip08DS" resource-ref="true" />
	<jee:jndi-lookup id="mailSession" jndi-name="mail/Session" resource-ref="true" />
	
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
		p:dataSource-ref="dataSource"
		p:packagesToScan="com.springinpractice.ch08.model">
		
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
				<prop key="hibernate.show_sql">false</prop>
			</props>
		</property>
	</bean>
	
	<bean id="transactionManager"
	      class="org.springframework.orm.hibernate3.HibernateTransactionManager"
	      p:sessionFactory-ref="sessionFactory" />
	
	<tx:annotation-driven />
	
	<bean id="mailSender"
		class="org.springframework.mail.javamail.JavaMailSenderImpl"
		p:session-ref="mailSession" />
		
	<bean id="velocityEngine"
		class="org.springframework.ui.velocity.VelocityEngineFactoryBean"
		p:resourceLoaderPath="classpath:/velocity/" />
	
	<util:properties id="contactServiceProps" location="classpath:/spring/contactService.properties" />
	
	<task:annotation-driven />
	<task:executor id="userMessageExecutor" pool-size="5-10" queue-capacity="100" keep-alive="300" />
	
</beans>
