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

    The contents of this file are subject to the license and copyright
    detailed in the LICENSE and NOTICE files at the root of the source
    tree and available online at

    http://www.dspace.org/license/

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

    <!-- Place all DSpace core service bean definitions below here -->

    <!-- PROPERTY PLACEHOLDER SETUP -->
    <!-- The following two beans are a cool trick. They let us use dynamic properties
         like ${dspace.dir} within our Spring bean XML configuration files. These
         property values are then dynamically loaded via our DSpaceConfigurationService. -->
    <!-- First, configure a property placeholder. This lets us use properties like ${..} within Spring bean configs -->
    <bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="properties" ref="dspaceConfigurationFactoryBean"/>
    </bean>
    <!-- Next, wire it up to use our DSpaceConfigurationFactoryBean. This bean will use our configured
         DSpace ConfigurationService for all property substitution in Spring XML files -->
    <bean id="dspaceConfigurationFactoryBean" class="org.dspace.servicemanager.config.DSpaceConfigurationFactoryBean">
       <constructor-arg ref="org.dspace.services.ConfigurationService" />
    </bean>
    <!-- end PROPERTY PLACEHOLDER SETUP-->

    <!-- CACHING service beans -->
    <bean id="org.dspace.services.CachingService" class="org.dspace.services.caching.CachingServiceImpl" />

    <!-- This is the main cache manager -->
    <bean id="org.dspace.caching.ehcache.CacheManager"
        class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
        <property name="configLocation">
            <bean class="org.dspace.servicemanager.spring.ResourceFinder" factory-method="getResourceFromPaths">
                <constructor-arg>
                    <list>
                        <value>ehcache-config.xml</value>
                        <value>caching/ehcache-config.xml</value>
                    </list>
                </constructor-arg>
            </bean>
        </property>
    </bean>
    <!-- CACHING end beans -->

    <!-- SESSION - session and request services (implemented as a single bean) -->
    <bean id="org.dspace.services.SessionService" class="org.dspace.services.sessions.SessionRequestServiceImpl" />
    <alias alias="org.dspace.services.RequestService" name="org.dspace.services.SessionService" />
    <!-- SESSION end beans -->
    
    <!-- EVENTS -->
    <bean id="org.dspace.services.EventService" class="org.dspace.services.events.SystemEventService" />

    <!-- EMAIL -->
    <bean id="org.dspace.services.email.EmailServiceImpl"
        class="org.dspace.services.email.EmailServiceImpl">
        <property name="cfg"
                  ref="org.dspace.services.ConfigurationService" />
    </bean>

    <!-- DSpaceServicesFactory (for easy access to above core services) -->
    <bean id="dSpaceServicesFactory" class="org.dspace.services.factory.DSpaceServicesFactoryImpl"/>

</beans>