<?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:p="http://www.springframework.org/schema/p"
	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">

	<!--
		Depends on: jaxwsEndpointReferenceBuilder (declared in
		applicationContext-epr.xml), lookupLocator, registryLocator
	-->

	<!-- service registrator -->
	<bean id="serviceRegistrator"
		class="eu.dnetlib.enabling.tools.registration.ServiceRegistrator"
		p:serviceLocator-ref="uniqueServiceLocator"	p:serviceNameResolver-ref="defaultServiceNameResolver"
		p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" p:hnmLocator-ref="${services.registration.default.hnmlocator}" />

	<bean id="blackboardServiceRegistrator"
		class="eu.dnetlib.enabling.tools.registration.BlackboardServiceRegistrator"
		p:serviceLocator-ref="uniqueServiceLocator"
		p:serviceNameResolver-ref="defaultServiceNameResolver"
		p:eprBuilder-ref="jaxwsEndpointReferenceBuilder"
		p:hnmLocator-ref="${services.registration.default.hnmlocator}" />

	<bean id="dynamicHNMLocator" class="eu.dnetlib.enabling.tools.DynamicHNMLocator"
		p:serviceLocator-ref="uniqueServiceLocator" />

	<bean id="nullHNMLocator" class="eu.dnetlib.enabling.tools.NullHNMLocator" />

	<bean id="defaultServiceNameResolver"
		class="eu.dnetlib.enabling.tools.registration.InterfaceServiceNameResolverCompatibility">
		<property name="mapping">
			<map>
				<entry key="ISStoreService" value="IS_StoreService" />
				<entry key="ISRegistryService" value="IS_RegistryService" />
				<entry key="ISLookUpService" value="IS_LookUpService" />
				<entry key="ISSNService" value="IS_SNService" />
				<entry key="MSROService" value="MS_ROService" />
				<entry key="MSRMService" value="MS_RMService" />
				<entry key="DlmService" value="DLMService" />
				<entry key="MDStoreService" value="MDStoreService" />
				<entry key="IndexService" value="IndexService" />
<!--				<entry key="IHarvestingManagerService" value="HarvestingManagerService" />-->
<!--				<entry key="ITransformationManagerService" value="TransformationManagerService" />-->
			</map>
		</property>
	</bean>

	<template:define name="serviceRegistrationManager"
		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ServiceRegistrationManagerImpl"
		t:serviceRegistrator="serviceRegistrator">

		<bean t:id="$name$" class="dummy" t:class="$serviceRegistrationManagerClass$"
			p:service-ref="$service$" p:endpoint-ref="$endpoint$"
			p:disabled="\${services.registration.disabled}" lazy-init="true"
			p:serviceLocator-ref="uniqueServiceLocator" p:registrator-ref="$serviceRegistrator$" />

		<bean t:id="$name$TriggerDetails"
			class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"
			p:targetBeanName="$name$" p:targetMethod="tick" />

		<bean t:id="$name$Trigger"
			class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean"
			p:startDelay="\${services.registration.delay}" p:repeatInterval="2000"
			p:jobDetail-ref="$name$TriggerDetails" />

		<bean t:id="$name$Triggers"
			class="eu.dnetlib.springutils.beans.factory.SingleListFactoryBean"
			p:value-ref="$name$Trigger" />

		<bean t:id="$name$jobSchedulerAccessor"
			class="org.springframework.scheduling.quartz.SchedulerAccessorBean"
			p:scheduler-ref="$jobScheduler$" p:triggers-ref="$name$Triggers">
		</bean>

	</template:define>

</beans>
