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

	<!-- beans -->
	<bean name="isSNService" class="eu.dnetlib.enabling.is.sn.ISSNServiceImpl"
		p:endpoint-ref="isSNServiceEndpoint" p:core-ref="isSNServiceCore"
		init-method="start" destroy-method="stop" />

	<bean name="isSNServiceCore" class="eu.dnetlib.enabling.is.sn.ISSNServiceCore"
		p:registry-ref="issResourceStateNotificationRegistry"
		p:backupDir="${services.is.sn.data.path}/backups"/>

	<bean name="issnNotificationDetector" class="eu.dnetlib.enabling.is.sn.NotificationDetectorImpl"
		p:sender-ref="issnNotificationSender" p:registry-ref="issResourceStateNotificationRegistry" />

	<bean id="issnNotificationDetectorPendingSupport"
		class="eu.dnetlib.enabling.is.sn.resourcestate.PendingResourceStateNotificationDetectorFilter"
		p:delegate-ref="issnNotificationDetector" />

	<bean id="subscriptionRequestFilter" class="eu.dnetlib.enabling.is.sn.resourcestate.SubscriptionRequestFilter" />
	
	<!--
		set this condition to true to globally inhibit notification processing
	-->
	<bean id="issnInhibitionCondition" class="eu.dnetlib.miscutils.coupling.StaticCondition" />

	<bean id="issnNotificationDetectorConditional"
		class="eu.dnetlib.enabling.is.sn.resourcestate.ConditionalResourceStateNotificationDetectorFilter"
		p:inhibitionCondition-ref="issnInhibitionCondition" p:delegate-ref="issnNotificationDetectorPendingSupport" />

	<bean id="issResourceStateNotificationRegistry"
		class="eu.dnetlib.enabling.is.sn.resourcestate.ResourceStateSubscriptionRegistry"
		p:subscriptionDao-ref="hibernateResourceStateSubscriptionDAO" />

	<bean name="issnNotificationSender"
		class="eu.dnetlib.enabling.is.sn.AsynchronousNotificationSenderImpl"
		p:invoker-ref="issnNotificationInvoker" init-method="start" />

	<bean name="issnNotificationInvocationLogger"
		class="eu.dnetlib.enabling.is.sn.MemoryNotificationInvocationLogger" />

	<bean name="issnNotificationInvoker" class="eu.dnetlib.enabling.is.sn.NotificationInvokerImpl"
		p:invocationLogger-ref="issnNotificationInvocationLogger" />

	<bean name="issnIntegrationTrigger" class="eu.dnetlib.enabling.is.sn.NotificationTriggerImpl"
		p:name="issnIntegrationTrigger" p:detector-ref="issnNotificationDetectorConditional" />


	<bean id="issnCacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"
	      p:cacheManager-ref="issnCacheManagerFactory" />

	<bean id="issnCacheManagerFactory"
	      class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
	      p:cacheManagerName="issnCacheManager" />

	<bean id="issnCache"
	      class="org.springframework.cache.ehcache.EhCacheFactoryBean"
	      p:eternal="false" p:timeToLive="${services.is.sn.subscriptions.cache.ttl}"
	      p:timeToIdle="${services.is.sn.subscriptions.cache.ttl}"
	      p:overflowToDisk="false"
	      p:maxElementsInMemory="${services.is.sn.subscriptions.cache.size}"
	      p:cacheManager-ref="issnCacheManagerFactory"
	      p:cacheName="issnCache" p:name="subscriptions" />

	<!-- endpoints -->
	<jaxws:endpoint id="isSNServiceEndpoint" implementor="#isSNService"
		implementorClass="eu.dnetlib.enabling.is.sn.rmi.ISSNService" address="/isSN" />

	<template:instance name="serviceRegistrationManager"
		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
		t:name="isSNServiceRegistrationManager" t:service="isSNService"
		t:endpoint="isSNServiceEndpoint" t:jobScheduler="jobScheduler" />
</beans>
