Project

General

Profile

1
package eu.dnetlib.enabling.is.sn;
2

    
3
import java.util.Collection;
4

    
5
import eu.dnetlib.enabling.is.sn.resourcestate.ResourceStateSubscription;
6
import eu.dnetlib.enabling.is.sn.rmi.SubscriptionRequestRejectedException;
7
import org.springframework.cache.annotation.CacheEvict;
8
import org.springframework.cache.annotation.Cacheable;
9

    
10
/**
11
 * A subscription registry stores subscriptions.
12
 * 
13
 * <p>
14
 * Different subscription registries know how to to store different kind of subscriptions. Each registry is specialized
15
 * in one type of subscriptions and knows how to quickly find all potentially interesting subscriptions so that a
16
 * particular NotificationDetector can do his job the quickest way possible.
17
 * </p>
18
 * 
19
 * <p>
20
 * This interface is generic only for subscription purposes because the Subscriber component simply tries to register a
21
 * new subscription to all available subscription registries.
22
 * </p>
23
 * 
24
 * <p>
25
 * Normally a subscription registry manages only a set of topic expression prefixes, but this interface doesn't force
26
 * the Subscriber to know this information; instead the subscription registry itself will decide whether to accept the
27
 * subscription or not.
28
 * </p>
29
 * <p>
30
 * Since many subscription registries may accept the same subscription, the identifier is preallocated by the
31
 * Subscriber, since the subscription is only one, and even if we give the possibility for several detectors to detect
32
 * it from different sources only one event will be generated.
33
 * </p>
34
 * 
35
 * @author marko
36
 * 
37
 */
38
public interface SubscriptionRegistry {
39

    
40
	/**
41
	 * register a subscription.
42
	 * 
43
	 * @param subscription
44
	 *            subscription request
45
	 * @return if we can accept this subcription we return the (possibly changed) identifier, otherwise null
46
	 */
47
	String registerSubscription(SubscriptionRequest subscription) throws SubscriptionRequestRejectedException;
48

    
49
	/**
50
	 * Unsubscribe a subscription if it exists.
51
	 * 
52
	 * @param subId subscription identifier
53
	 * @return true if this subscription existed and was successfully removed
54
	 */
55
	boolean unsubscribe(final String subId);
56

    
57
	/**
58
	 * return all subscriptions matching a given prefix and a given type. Wildcard subscriptions will match any resource type.
59
	 *
60
	 * @param prefix
61
	 *            prefix
62
	 * @param type
63
	 *            concrete type
64
	 * @param resId
65
	 *            resource identifier
66
	 * @return all matching subscriptions
67
	 */
68
	Collection<ResourceStateSubscription> listMatchingSubscriptions(final String prefix, final String type, final String resId);
69

    
70
	/**
71
	 * return all subscriptions.
72
	 *
73
	 * @return all subscriptions
74
	 */
75
	Collection<ResourceStateSubscription> listSubscriptions();
76

    
77
	/**
78
	 * removes a particular subscription.
79
	 *
80
	 * @param subscriptionId identifier
81
	 * @return true if successful
82
	 */
83
	boolean removeSubscription(String subscriptionId);
84
}
(19-19/23)