<?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 id="resultSetCacheManager"
		class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" />
	<!-- p:configLocation="classpath:eu/dnetlib/enabling/resultset/ehcache.xml" -->

	<bean id="resultSetRegistryCache" class="eu.dnetlib.miscutils.cache.EhCache">
		<property name="cache">
			<bean id="resultSetRegistryCacheCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"
				p:cacheManager-ref="resultSetCacheManager" p:cacheName="resultSetFactoryCache"
				p:eternal="false" p:timeToLive="${services.is.resultset.resultSetRegistryCache.timeToIdle}"
				p:timeToIdle="${services.is.resultset.resultSetRegistryCache.timeToIdle}" />
		</property>
	</bean>

	<bean id="resultSetRegistryMaxIdleTimeCache" class="eu.dnetlib.miscutils.cache.EhCache">
		<property name="cache">
			<bean id="resultSetRegistryMaxIdleTimeCacheCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"
				p:cacheManager-ref="resultSetCacheManager" p:cacheName="resultSetFactoryMaxIdleTimeCache"
				p:eternal="false" p:timeToLive="${services.is.resultset.resultSetRegistryMaxIdleTimeCache.timeToIdle}"
				p:timeToIdle="${services.is.resultset.resultSetRegistryMaxIdleTimeCache.timeToIdle}" />
		</property>
	</bean>

	<!-- backing store for the pushResultSetDao -->
	<bean id="pushResultSetStoreCache" class="eu.dnetlib.miscutils.cache.EhCache">
		<property name="cache">
			<bean id="pushResultSetStoreCacheCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"
				p:eternal="false" p:timeToLive="${services.is.resultset.push.timeToIdle}" p:timeToIdle="${services.is.resultset.push.timeToIdle}" 
				p:overflowToDisk="true"
				p:maxElementsInMemory="${services.is.resultset.push.maxElementsInMemory}" 
				p:maxElementsOnDisk="${services.is.resultset.push.maxElementsOnDisk}"
				p:cacheManager-ref="resultSetCacheManager" p:cacheName="pushResultSetStoreCache" />
		</property>
	</bean>

	<!-- resultset descriptor store for the pushResultSetDao -->
	<bean id="pushResultSetDescriptorCache" class="eu.dnetlib.miscutils.cache.EhCache">
		<property name="cache">
			<bean id="pushResultSetDescriptorCacheCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"
				p:eternal="false" p:timeToLive="1800" p:timeToIdle="1800"
				p:cacheManager-ref="resultSetCacheManager" p:cacheName="pushResultSetDescriptorCache" />
		</property>
	</bean>

	<bean id="resultSetDescriptorFactory" class="eu.dnetlib.springutils.beans.factory.PrototypeFactory">
		<lookup-method name="newInstance" bean="resultSetDescriptorPrototype" />
	</bean>

	<bean id="resultSetDescriptorPrototype" class="eu.dnetlib.enabling.resultset.push.ResultSetDescriptor"
		p:rangeLength="100" scope="prototype" />

	<bean id="resultSetRegistry" class="eu.dnetlib.enabling.resultset.ResultSetRegistryImpl"
		p:cache-ref="resultSetRegistryCache" p:maxIdleTimeCache-ref="resultSetRegistryMaxIdleTimeCache" />

<!--
  <bean id="resultSetEPRPool" class="eu.dnetlib.enabling.resultset.ResultSetEPRPool"
   p:resultSetService-ref="resultSetService" />
-->

	<!-- <bean id="resultSetFactory" class="eu.dnetlib.enabling.resultset.LocalResultSetFactoryImpl" -->
	<!-- <bean id="resultSetFactory" class="eu.dnetlib.enabling.resultset.EPRPoolingLocalResultSetFactoryImpl" p:pool-ref="resultSetEPRPool" 
		p:resultSetService-ref="resultSetService" /> -->

  <bean id="resultSetFactory" class="eu.dnetlib.enabling.resultset.LocalResultSetFactoryImpl" 
		p:resultSetService-ref="resultSetService" /> 

	<bean id="openResultSetFactory"
		class="eu.dnetlib.enabling.resultset.LocalOpenResultSetFactoryImpl"
		p:resultSetService-ref="resultSetService" />
		
<!--
	<bean id="openResultSetFactory"
		class="eu.dnetlib.enabling.resultset.EPRPoolingLocalOpenResultSetFactoryImpl" p:pool-ref="resultSetEPRPool"
		p:resultSetService-ref="resultSetService" />
-->
	<bean id="mappedResultSetFactory" class="eu.dnetlib.enabling.resultset.MappedResultSetFactory"
		p:serviceResolver-ref="serviceResolver" p:resultSetFactory-ref="resultSetFactory" />
		
	<bean id="parallelMappedResultSetFactory" class="eu.dnetlib.enabling.resultset.ParallelMappedResultSetFactory"
		p:serviceResolver-ref="serviceResolver" p:resultSetFactory-ref="resultSetFactory" />		

	<bean id="xsltResultSetFactory"
		class="eu.dnetlib.enabling.resultset.XSLTMappedResultSetFactory"
		p:serviceResolver-ref="serviceResolver" p:resultSetFactory-ref="resultSetFactory" />

	<bean id="countingResultSetFactory" class="eu.dnetlib.enabling.resultset.CountingResultSetFactory"
		p:serviceResolver-ref="serviceResolver" p:resultSetFactory-ref="resultSetFactory" />

	<bean id="streamingResultSetFactory" class="eu.dnetlib.enabling.resultset.StreamingResultSetFactory"
		p:resultSetFactory-ref="resultSetFactory" />

	<bean id="cachingResultSetFactory" class="eu.dnetlib.enabling.resultset.CachingResultSetFactory"
		p:resultSetFactory-ref="resultSetFactory" />

	<bean id="pushResultSetFactory"
		class="eu.dnetlib.enabling.resultset.push.TransientPushResultSetFactory"
		p:dao-ref="pushResultSetDao" p:resultSetService-ref="resultSetService" />

	<bean id="iterableResultSetFactory" class="eu.dnetlib.enabling.resultset.IterableResultSetFactory"
		p:fetchSize="10" p:resultSetFactory-ref="openResultSetFactory"
		lazy-init="true" />


	<bean id="pushResultSetDao"
		class="eu.dnetlib.enabling.resultset.push.CacheTransientResultSetDaoImpl"
		p:cache-ref="pushResultSetStoreCache" p:resultSetCache-ref="pushResultSetDescriptorCache" />

	<bean id="customResultSetPropertyDao" class="eu.dnetlib.enabling.resultset.ResultSetPropertyDaoImpl" />

	<bean id="resultSetService" class="eu.dnetlib.enabling.resultset.ResultSetServiceImpl"
		init-method="start" p:resultsetRegistry-ref="resultSetRegistry"
		p:pushFactory-ref="pushResultSetFactory" p:endpoint-ref="resultSetServiceEndpoint"
		p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" p:customPropertyDao-ref="customResultSetPropertyDao" />
		
	<!-- endpoints -->
	<jaxws:endpoint id="resultSetServiceEndpoint"
		implementor="#resultSetService" implementorClass="eu.dnetlib.enabling.resultset.rmi.ResultSetService"
		address="/resultSet" />

	<template:instance name="serviceRegistrationManager"
		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
		t:name="resultSetServiceRegistrationManager" t:service="resultSetService"
		t:endpoint="resultSetServiceEndpoint" t:jobScheduler="jobScheduler" />

</beans>
