<?xml version="1.0" encoding="UTF-8"?>
<!--
    R Service Bus
    
    Copyright (c) Copyright of OpenAnalytics BVBA, 2010-2014
 
    ===========================================================================
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.
 
    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>
        
    @author rsb.development@openanalytics.eu
-->
<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:context="http://www.springframework.org/schema/context"
    xmlns:task="http://www.springframework.org/schema/task"
    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/task http://www.springframework.org/schema/task/spring-task.xsd">

    <!-- Configuration loading and validation -->
    <bean id="configuration" class="eu.openanalytics.rsb.config.ConfigurationFactory"
                             factory-method="loadJsonConfiguration" />

    <bean class="eu.openanalytics.rsb.config.SpringContextEventListener" />

    <!-- Statistics handler -->
    <bean id="jobStatisticsHandler"
          class="eu.openanalytics.rsb.stats.JobStatisticsHandlerFactory"
          factory-method="create"
          init-method="initialize"
          destroy-method="destroy">
        <constructor-arg index="0" value="#{configuration.jobStatisticsHandlerConfiguration.className}" />
        <constructor-arg index="1" value="#{configuration.jobStatisticsHandlerConfiguration.parameters}" />
    </bean>

    <!-- Spring components -->
    <context:annotation-config />
    <context:component-scan
          base-package="eu.openanalytics.rsb.component,eu.openanalytics.rsb.data,eu.openanalytics.rsb.message,eu.openanalytics.rsb.rservi" />
    <bean id="messageSource"
          class="org.springframework.context.support.ResourceBundleMessageSource"
          p:basename="messages" />
    <task:annotation-driven/>
</beans>
