<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:util="http://www.springframework.org/schema/util" xmlns:template="http://dnetlib.eu/springbeans/template"
	xmlns:t="http://dnetlib.eu/springbeans/t"
	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://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
		http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd
		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
	
	<!--  beans -->
	
	<bean id="hcmService"
		class="eu.dnetlib.enabling.hcm.HostingContextManagerServiceImpl"
		init-method="start" destroy-method="stop"  
		p:notificationHandler-ref="hcmNotificationHandler"/>
		
	<bean id="hcmNotificationHandler" class="eu.dnetlib.enabling.tools.blackboard.NotificationHandlerChainImpl"
		p:handlers-ref="dynamicSubscriptionActions">
		<property name="handlerExecutor">
			<bean class="org.springframework.core.task.SyncTaskExecutor" />
		</property>
	</bean>
	
	<bean id="dynamicSubscriptionActions"
		class="eu.dnetlib.enabling.hcm.sn.HCMSubscriptionListFactory" />
		
	<bean id="hcmSubscriber" class="eu.dnetlib.enabling.hcm.sn.HCMSubscriberImpl"
		p:endpoint-ref="hcmServiceEndpoint" p:serviceLocator-ref="uniqueServiceLocator" 
		p:actions-ref="dynamicSubscriptionActions" />
 		
	<bean t:id="hcmJobSchedulerAccessor"
		class="org.springframework.scheduling.quartz.SchedulerAccessorBean"
		p:scheduler-ref="jobScheduler">
		<property name="triggers">
			<list>
				<bean id="hcmSubscriptionTrigger"
					class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean"
					p:startDelay="6000" p:repeatCount="0">
					<property name="jobDetail">
						<bean id="hcmSubscriptionJobDetails"
							class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"
							p:targetObject-ref="hcmSubscriber" p:targetMethod="subscribeAll" />
					</property>
				</bean>
			</list>
		</property>
	</bean>				

	<!-- endpoints -->
	<jaxws:endpoint id="hcmServiceEndpoint" implementor="#hcmService"
		implementorClass="eu.dnetlib.enabling.hcm.rmi.HostingContextManagerService"
		address="/hcm" />

	<template:instance name="serviceRegistrationManager"
		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
		t:name="hcmServiceRegistrationManager" t:service="hcmService"
		t:endpoint="hcmServiceEndpoint" t:jobScheduler="jobScheduler" />
</beans>
