<?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:context="http://www.springframework.org/schema/context"
 xmlns:mvc="http://www.springframework.org/schema/mvc"
 xmlns:util="http://www.springframework.org/schema/util"
 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/mvc
  http://www.springframework.org/schema/mvc/spring-mvc.xsd
  http://www.springframework.org/schema/util
  http://www.springframework.org/schema/util/spring-util.xsd
  ">
  
    <context:annotation-config />
    <mvc:annotation-driven />

    <context:component-scan base-package="org.iri_research.renkan.management" />
    <context:component-scan base-package="org.iri_research.renkan.models" />
    <context:component-scan base-package="org.iri_research.renkan.repositories" />
        
    <util:properties id="propsLocations">
        <prop key="servletContextProps">META-INF/renkan.properties</prop>
        <prop key="classpathProps">classpath:renkan_run.properties</prop>
    </util:properties>

    <!--context:property-placeholder  order="1000" ignore-unresolvable="true" ignore-resource-not-found="false" location="${propsLocations.servletContextProps}"/>  
    <context:property-placeholder  order="1" ignore-unresolvable="true" ignore-resource-not-found="true" location="${propsLocations.classpathProps}"/-->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="order" value="1000"/>
        <property name="location" value="#{propsLocations.servletContextProps}"/>
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
        <property name="IgnoreResourceNotFound" value="false"/>
    </bean> 
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="order" value="1"/>
        <property name="location" value="#{propsLocations.classpathProps}"/>
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
        <property name="IgnoreResourceNotFound" value="true"/>
    </bean> 
        
    <bean id="renkanProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="IgnoreResourceNotFound" value="true"/>
        <property name="locations">
            <list>
                <value>#{propsLocations.servletContextProps}</value>
                <value>#{propsLocations.classpathProps}</value>
            </list>
        </property>
        <property name="fileEncoding" value="UTF-8"/>
    </bean>
    
    <!-- Configures the annotation-driven Spring MVC Controller programming model.
    Note that, with Spring 3.0, this tag works in Servlet MVC only!  -->
    
    <!-- Loads MongoDB configuraton -->
    <import resource="mongo-config.xml"/>

    <bean class="org.iri_research.renkan.RenkanProperties"
        factory-method="getInstance" />
    
</beans>