<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:http="http://cxf.apache.org/transports/http/configuration" xmlns:t="http://dnetlib.eu/springbeans/t"
       xmlns:template="http://dnetlib.eu/springbeans/template"
       xmlns="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd


                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd

                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">


    <bean id="objectStoreService"
          class="eu.dnetlib.data.objectstore.modular.ModularObjectStoreService"
          init-method="start" destroy-method="stop"
          p:feeder-ref="objectstoreFeeder"
          p:objectStoreDeliver-ref="objectstoreDeliver"
          p:notificationHandler-ref="objectstoreNotificationHandler"
            />

    <bean id="objectstoreFeeder"
          class="eu.dnetlib.data.objectstore.modular.ModularObjectStoreFeeder"
          p:dao-ref="${services.objectstore.dao}"
          p:resultSetClientFactory-ref="objectstoreResultSetClientFactory"
          p:serviceLocator-ref="uniqueServiceLocator"
            />

    <bean id="objectstoreDeliver"
          class="eu.dnetlib.data.objectstore.modular.ModularObjectStoreDeliver"
          p:dao-ref="${services.objectstore.dao}"
          p:resultSetClientFactory-ref="objectstoreResultSetClientFactory"

            />


    <bean id="objectstoreResultSetClientFactory" parent="resultSetClientFactory"
          p:pageSize="${services.objectstore.rsfactory.pagesize}"/>


    <bean id="objectstoreProfileCreator" class="eu.dnetlib.data.objectstore.modular.ObjectStoreProfileCreator"
          p:serviceLocator-ref="uniqueServiceLocator" p:objectstoreDsTemplate-ref="objectstoreDsTemplate"
          p:endpoint-ref="objectStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder"/>

    <bean id="objectstoreNotificationHandler"
          class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
          p:blackboardExecutor-ref="objectstoreBlackboardExecutor"/>

    <bean id="objectstoreBlackboardExecutor"
          class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
          p:blackboardHandler-ref="blackboardHandler"
          p:actionType="eu.dnetlib.data.objectstore.modular.ObjectStoreActions"
          p:incomplete="false">
        <property name="actionMap">
            <map>
                <entry key="CREATE">
                    <bean class="eu.dnetlib.data.objectstore.modular.CreateObjectStoreAction"
                          p:profileCreator-ref="objectstoreProfileCreator" p:dao-ref="${services.objectstore.dao}"/>
                </entry>
                <entry key="DELETE">
                    <bean class="eu.dnetlib.data.objectstore.modular.DeleteObjectStoreAction"
                          p:profileCreator-ref="objectstoreProfileCreator" p:dao-ref="${services.objectstore.dao}"/>
                </entry>
                <entry key="DROP_CONTENT">
                    <bean class="eu.dnetlib.data.objectstore.modular.DropContentObjectStoreAction"
                          p:dao-ref="${services.objectstore.dao}"/>
                </entry>

                <entry key="FEED">
                    <bean class="eu.dnetlib.data.objectstore.modular.FeedObjectStoreAction"
                          p:profileCreator-ref="objectstoreProfileCreator"
                          p:storeFeeder-ref="objectstoreFeeder"
                          p:dao-ref="${services.objectstore.dao}"/>
                </entry>

                <entry key="FEEDOBJECT">
                    <bean class="eu.dnetlib.data.objectstore.modular.FeedCompleteObjectAction"
                          p:storeFeeder-ref="objectstoreFeeder"
                          p:dao-ref="${services.objectstore.dao}"/>
                </entry>
            </map>
        </property>
    </bean>


    <bean id="objectStoreLocator" class="eu.dnetlib.enabling.tools.StaticServiceLocator"
          p:service-ref="objectStoreService"/>


    <bean id="objectstoreDsTemplate"
          class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
          p:template="classpath:/eu/dnetlib/data/objectstore/objectstoreds-template.xml"
          scope="prototype"/>


    <!-- endpoints -->
    <jaxws:endpoint id="objectStoreServiceEndpoint"
                    implementor="#objectStoreService" implementorClass="eu.dnetlib.data.objectstore.rmi.ObjectStoreService"
                    address="/objectStore"/>

    <template:instance name="serviceRegistrationManager"
                       t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
                       t:name="objectStoreServiceRegistrationManager" t:service="objectStoreService"
                       t:endpoint="objectStoreServiceEndpoint" t:jobScheduler="jobScheduler"
                       t:serviceRegistrator="blackboardServiceRegistrator"/>


</beans>
