public class InMemorySubscriptionDB extends HashMap<String,SubscriptionInfo> implements ISubscriptionDB
Default implementation of subscription DB backed up by a hash map that is fully stored in memory.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
InMemorySubscriptionDB() |
Modifier and Type | Method and Description |
---|---|
void |
checkSubscription(SubscriptionInfo sub)
Checks that the suscription is valid for the particular application
For example if a topic is specified it should be one of the topics advertised by the notification service
|
String |
generateNewSubscriptionID()
Generates a new unique ID for a new subscription
|
SubscriptionInfo |
get(String id)
Retrieves subscription by ID from database
|
Collection<SubscriptionInfo> |
getAllSubscriptions()
Gets all subscriptions in this database
|
List<SubscriptionInfo> |
getUserSubscriptions(String userID)
Retrieves the list of all subscriptions associated to a given user ID
|
void |
put(SubscriptionInfo sub)
Adds the subscription to the database
|
SubscriptionInfo |
remove(String id)
Removed subscription with given ID from database
|
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
equals, hashCode, toString
public void checkSubscription(SubscriptionInfo sub) throws IllegalArgumentException
ISubscriptionDB
checkSubscription
in interface ISubscriptionDB
IllegalArgumentException
- thrown if the subscription is not valid with the appropriate messagepublic SubscriptionInfo get(String id)
ISubscriptionDB
get
in interface ISubscriptionDB
id
- ID of subscription to retrievepublic void put(SubscriptionInfo sub)
ISubscriptionDB
put
in interface ISubscriptionDB
sub
- new subscriptionpublic SubscriptionInfo remove(String id)
ISubscriptionDB
remove
in interface ISubscriptionDB
id
- ID of subscription to removepublic String generateNewSubscriptionID()
ISubscriptionDB
generateNewSubscriptionID
in interface ISubscriptionDB
public Collection<SubscriptionInfo> getAllSubscriptions()
ISubscriptionDB
getAllSubscriptions
in interface ISubscriptionDB
public List<SubscriptionInfo> getUserSubscriptions(String userID)
ISubscriptionDB
getUserSubscriptions
in interface ISubscriptionDB
Copyright © 2016 Sensia Software LLC. All rights reserved.