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

    <!-- Activates various annotations to be detected in bean classes -->
    <context:annotation-config />
    <mvc:annotation-driven />

    <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 id="springConfigurer"
        class="org.iri_research.renkan.coweb.SpringConfigurer"
        factory-method="getInstance" />

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


    <!-- Scans the classpath for annotated components that will be auto-registered as Spring beans.
     For example @Controller and @Service. Make sure to set the correct base-package-->
    <context:component-scan base-package="org.iri_research.renkan.models" />
    <context:component-scan base-package="org.iri_research.renkan.rest" />
    <context:component-scan base-package="org.iri_research.renkan.coweb" />
    <context:component-scan base-package="org.iri_research.renkan.management" />
        
    <bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" id="messageSource">
        <property name="basenames">
            <list>
                <value>META-INF/i18n/messages</value>
                <value>classpath:org/springframework/security/messages</value>
            </list>
        </property>
        <property name="defaultEncoding" value="UTF-8"/>
        <property name="fallbackToSystemLocale" value="true" />
    </bean>

</beans>
