<?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">

	<!-- beans -->
	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
		p:iterableResultSetFactory-ref="iterableResultSetFactory"
		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />

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

	<bean id="mdstoreBlackboardExecutor"
		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
		p:blackboardHandler-ref="blackboardHandler"
		p:actionType="eu.dnetlib.data.mdstore.modular.action.MDStoreActions"
		p:incomplete="false">
		<property name="actionMap">
			<map>
				<entry key="CREATE">
					<bean class="eu.dnetlib.data.mdstore.modular.action.CreateAction"
						p:profileCreator-ref="mdstoreProfileCreator"
						p:dao-ref="${services.mdstore.dao}" />
				</entry>
				<entry key="DELETE">
					<bean class="eu.dnetlib.data.mdstore.modular.action.DeleteAction"
						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
				</entry>
				<entry key="FEED">
					<bean class="eu.dnetlib.data.mdstore.modular.action.FeedAction"
						p:dao-ref="${services.mdstore.dao}" 
						p:feeder-ref="mdstoreFeeder"/>
				</entry>
				<entry key="RUN_PLUGIN">
					<bean class="eu.dnetlib.data.mdstore.modular.action.PluginAction"
						p:dao-ref="${services.mdstore.dao}" />
				</entry>				
			</map>
		</property>
	</bean>

	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />

	<bean id="mdstoreDsTemplate"
		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
		scope="prototype" />

	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />

	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
		p:pageSize="${services.mdstore.rsfactory.pagesize}"
		p:timeout="${services.mdstore.rsfactory.timeout}"
	    p:connectTimeout="${services.mdstore.rsfactory.connectTimeout}"/>


	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />

 	<bean id="dummyMDstorePlugin" class="eu.dnetlib.data.mdstore.modular.action.DummyPlugin" />
	
	<bean id="mdStorePluginEnumerator" class="eu.dnetlib.data.mdstore.modular.action.MDStorePluginEnumerator" />


    <bean id="mdstoreUtils" class="eu.dnetlib.data.mdstore.modular.MDStoreUtils"/>
	

	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
		/> -->
<!-- 	<bean id="mdstoreRecordParser"  -->
<!-- 		factory-bean="recordParserFactory" factory-method="newInstance"/> -->
	
	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
		p:parserType="${services.mdstore.recordParser}" />
		
	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />

	<!-- endpoints -->
	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />

	<template:instance name="serviceRegistrationManager"
		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
		t:serviceRegistrator="blackboardServiceRegistrator" />
</beans>
