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

<!--
========================================================================================================================
beans-mongodb.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:mongo="http://www.springframework.org/schema/data/mongo"
	xmlns:p="http://www.springframework.org/schema/p"
	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/data/mongo
		http://www.springframework.org/schema/data/mongo/spring-mongo-1.1.xsd">	
	
	<!-- Simple configuration -->
	<!-- Defines the Mongo instance using defaults host="localhost", port="27017" -->
	<mongo:mongo />
	
	<!-- More advanced configuration -->
	<!--
	<mongo:mongo host="localhost" port="27017">
		<mongo:options
			connections-per-host="10"
			threads-allowed-to-block-for-connection-multiplier="5"
			max-wait-time="12000"
			connect-timeout="0"
			socket-timeout="0"
			auto-connect-retry="false" />
	</mongo:mongo>
	-->
	
	<!-- Mongo template -->
	<bean id="mongoTemplate"
		class="org.springframework.data.mongodb.core.MongoTemplate"
		p:writeResultChecking="EXCEPTION">
		
		<constructor-arg ref="mongo" />
		<constructor-arg value="techsite" />
	</bean>
	
	<!-- Generates dynamic DAO implementation -->
	<mongo:repositories base-package="com.springinpractice.ch12.dao" />
	
	<!-- To translate any MongoExceptions thrown in @Repository-annotated classes -->
	<context:annotation-config />
</beans>
