<?xml version="1.0" encoding="UTF-8"?>
<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="http://www.springframework.org/schema/beans"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

	<bean id="fSObjectstoreDao"
	      class="eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao"
	      p:db-ref="objectstoreMongoDB" p:objectStoreRESTURI-ref="restURIString"
	      p:upsert="${services.objectStore.mongodb.upsert}"/>

	<bean id="restURIString" class="java.lang.String">
		<constructor-arg value="${services.objectStore.RESTURI}"/>
	</bean>

	<bean id="objectStoreFileSystemUtility" class="eu.dnetlib.data.objectstore.filesystem.FileSystemUtility"/>

	<bean id="objectStoreMongoClient" class="com.mongodb.MongoClient">
		<constructor-arg index="0" type="com.mongodb.ServerAddress">
			<bean class="com.mongodb.ServerAddress">
				<constructor-arg index="0" value="${services.objectStore.mongodb.host}"/>
				<constructor-arg index="1" value="${services.objectStore.mongodb.port}"/>
			</bean>
		</constructor-arg>
		<constructor-arg index="1" type="com.mongodb.MongoClientOptions">
			<bean class="eu.dnetlib.data.objectstore.filesystem.MongoFSOptionsFactory"
			      p:connectionsPerHost="${services.objectStore.mongodb.connectionsPerHost}"/>
		</constructor-arg>
	</bean>

	<bean id="objectstoreMongoDB" factory-bean="objectStoreMongoClient" factory-method="getDatabase">
		<constructor-arg index="0" type="java.lang.String" value="${services.objectStore.mongodb.db}"/>
	</bean>

	<bean id="objectStoreIntegrityChecker" class="eu.dnetlib.data.objectstore.filesystem.IndexIntegrityChecker"/>

	<bean t:id="objectStoreJobSchedulerAccessor"
	      class="org.springframework.scheduling.quartz.SchedulerAccessorBean"
	      p:scheduler-ref="jobScheduler">
		<property name="triggers">
			<list>
				<bean class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
					<property name="jobDetail">
						<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"
						      p:targetObject-ref="objectStoreIntegrityChecker" p:targetMethod="check"/>
					</property>
					<property name="cronExpression" value="${services.objectstore.mongodb.integritycheck.cron}"/>
				</bean>
			</list>
		</property>
	</bean>

</beans>
