net.rim.pushsdk.subscription
Class SubMemoryDataStore

java.lang.Object
  extended by net.rim.pushsdk.subscription.SubMemoryDataStore

public class SubMemoryDataStore
extends Object

Represents in-memory storage of subscriber data. The in-memory storage is persisted to a disk store on shutdown and read from the disk store on startup.

Warning: For testing use only. It is not meant for production use.

Author:
mdandrea

Constructor Summary
SubMemoryDataStore()
           
 
Method Summary
 void destroy()
          Flushes the cache to disk.
 Subscriber loadFromStore(SubscriberPrimaryKey key)
          Loads a subscriber from in-memory storage.
 List<SubscriberPrimaryKey> loadKeysFromStore()
          Loads the keys for the subscribers currently in memory.
 Subscriber removeFromStore(SubscriberPrimaryKey key)
          Removes a subscriber from memory.
 void saveInStore(SubscriberPrimaryKey key, Subscriber subscriber)
          Saves a subscriber in memory.
 void setCache(net.sf.ehcache.Cache cache)
          Sets the cache to be used for storing subscriber data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubMemoryDataStore

public SubMemoryDataStore()
Method Detail

setCache

public void setCache(net.sf.ehcache.Cache cache)
Sets the cache to be used for storing subscriber data. This should not be null.

Parameters:
cache - the cache for storing subscriber data

destroy

public void destroy()
Flushes the cache to disk.


loadFromStore

public Subscriber loadFromStore(SubscriberPrimaryKey key)
Loads a subscriber from in-memory storage.

Parameters:
key - the key of the subscriber to look up
Returns:
the loaded subscriber

loadKeysFromStore

public List<SubscriberPrimaryKey> loadKeysFromStore()
Loads the keys for the subscribers currently in memory.

Returns:
the keys

saveInStore

public void saveInStore(SubscriberPrimaryKey key,
                        Subscriber subscriber)
Saves a subscriber in memory.

Parameters:
key - the key of the subscriber
subscriber - the subscriber to be stored

removeFromStore

public Subscriber removeFromStore(SubscriberPrimaryKey key)
Removes a subscriber from memory.

Parameters:
key - the key of the subscriber
Returns:
the subscriber that was removed


Copyright © 2011 Research In Motion. All Rights Reserved.