<?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:p="http://www.springframework.org/schema/p"
    xmlns:mongo="http://www.springframework.org/schema/data/mongo"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
  xsi:schemaLocation="
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context.xsd
          http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
          http://www.springframework.org/schema/data/mongo
          http://www.springframework.org/schema/data/mongo/spring-mongo-1.2.xsd
          http://www.springframework.org/schema/data/jpa
          http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd">

  <context:property-placeholder order="1000" ignore-unresolvable="true" ignore-resource-not-found="false" location="WEB-INF/renkan.properties"/>
  <context:property-placeholder  order="1" ignore-unresolvable="true" ignore-resource-not-found="true" location="classpath:renkan_run.properties"/>
  <!-- Default bean name is 'mongo' -->
  <mongo:mongo host="${mongodb.host.name}" port="${mongodb.host.port}" />

  <!-- Offers convenience methods and automatic mapping between MongoDB JSON documents and your domain classes. -->
  <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
      <constructor-arg ref="mongo"/>
    <constructor-arg value="${mongodb.db.name}"/>
    <property name="writeResultChecking" value="EXCEPTION"/>
  </bean>

  <mongo:repositories base-package="org.iri_research.renkan" factory-class="org.iri_research.renkan.repositories.RenkanRepositoryFactoryBean" />

  <bean id="mongeez" class="org.mongeez.MongeezRunner">
    <property name="mongo" ref="mongo"/>
    <property name="executeEnabled" value="true"/>
    <property name="dbName" value="${mongodb.db.name}"/>
    <property name="file" value="classpath:org/iri_research/renkan/migrations/mongeez.xml"/>
  </bean>

</beans>
