<?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:jaxws="http://cxf.apache.org/jaxws"
	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
	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"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.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 class="org.springframework.scheduling.quartz.SchedulerFactoryBean"
		depends-on="mdStoreService">
		<property name="triggers">
			<list>
				<ref bean="mdStoreCheckTrigger"/>
			</list>
		</property>
	</bean>

	<bean id="mdStoreEnsureIndexScheduler"
		class="eu.dnetlib.data.mdstore.modular.mongodb.utils.EnsureIndexJob"
		p:cronExpression="${services.mdstore.mongodb.ensureindex.cron}" 
		p:enabled="${services.mdstore.mongodb.ensureindex.enable}"
		p:dao-ref="mongodbMDStoreDao" />
		
	<bean id="mdStoreCheckTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean"
		p:startDelay="${services.mdstore.mongodb.checkmetadata.startdelay}" p:repeat-count="0" p:repeatInterval="60000">
		<property name="jobDetail">
			<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
				<property name="targetObject" ref="mdStoreCheckMetadataMBean" />
				<property name="targetMethod" value="runOnStart" />
				<property name="concurrent" value="false" />
			</bean>
		</property>
	</bean>		
		
	<bean id="mdStoreCheckMetadataMBean"
		class="eu.dnetlib.data.mdstore.modular.mongodb.utils.MetadataCheckJob" 
		depends-on="mdStoreService"		
		p:runOnStart="${services.mdstore.mongodb.checkmetadata.onstart}"
		p:dao-ref="mongodbMDStoreDao" p:serviceLocator-ref="uniqueServiceLocator" 
		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
		
	<bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter">
		<property name="beans">
			<map>
				<entry key="mongodbMDStore:name=metadata" value-ref="mdStoreCheckMetadataMBean" />
			</map>
		</property>
	</bean>
				
</beans>
