org.atmosphere.cache
Class DefaultBroadcasterCache

java.lang.Object
  extended by org.atmosphere.cache.DefaultBroadcasterCache
All Implemented Interfaces:
BroadcasterCache

public class DefaultBroadcasterCache
extends Object
implements BroadcasterCache


Field Summary
 
Fields inherited from interface org.atmosphere.cpr.BroadcasterCache
DEFAULT
 
Constructor Summary
DefaultBroadcasterCache()
           
 
Method Summary
 CacheMessage addToCache(String broadcasterId, AtmosphereResource r, BroadcastMessage e)
          Start tracking messages associated with AtmosphereResource from the cache.
 void cleanup()
          Clean resources associated with this instance.
 void clearCache(String broadcasterId, AtmosphereResource r, CacheMessage cache)
          Remove the previously cached message.
 void configure(BroadcasterConfig config)
          Configure the cache.
 void excludeFromCache(String broadcasterId, AtmosphereResource r)
          Allow an application to exclude, or block, an AtmosphereResource to received cached message.
 BroadcasterCache inspector(BroadcasterCacheInspector interceptor)
          Add a BroadcasterCacheInspector that will be invoked before a message gets added to the cache.
 List<Object> retrieveFromCache(String id, AtmosphereResource r)
          Retrieve messages associated with AtmosphereResource.
 void start()
          This method is invoked when the Broadcaster is started.
 void stop()
          This method is invoked when the Broadcaster is stopped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultBroadcasterCache

public DefaultBroadcasterCache()
Method Detail

start

public void start()
Description copied from interface: BroadcasterCache
This method is invoked when the Broadcaster is started.

Specified by:
start in interface BroadcasterCache

stop

public void stop()
Description copied from interface: BroadcasterCache
This method is invoked when the Broadcaster is stopped.

Specified by:
stop in interface BroadcasterCache

cleanup

public void cleanup()
Description copied from interface: BroadcasterCache
Clean resources associated with this instance. This method is useful when ExecutorServices are shared and some future must be cancelled. This method will always be invoked when a Broadcaster gets destroyed.

Specified by:
cleanup in interface BroadcasterCache

configure

public void configure(BroadcasterConfig config)
Description copied from interface: BroadcasterCache
Configure the cache.

Specified by:
configure in interface BroadcasterCache
Parameters:
config - a BroadcasterConfig

addToCache

public CacheMessage addToCache(String broadcasterId,
                               AtmosphereResource r,
                               BroadcastMessage e)
Description copied from interface: BroadcasterCache
Start tracking messages associated with AtmosphereResource from the cache.

Specified by:
addToCache in interface BroadcasterCache
Parameters:
broadcasterId - The associated Broadcaster#addAtmosphereResource(AtmosphereResource).getID
r - AtmosphereResource
e - BroadcastMessage.
Returns:
The CacheMessage

retrieveFromCache

public List<Object> retrieveFromCache(String id,
                                      AtmosphereResource r)
Description copied from interface: BroadcasterCache
Retrieve messages associated with AtmosphereResource.

Specified by:
retrieveFromCache in interface BroadcasterCache
Parameters:
id - The associated Broadcaster#addAtmosphereResource(AtmosphereResource).getID
r - AtmosphereResource
Returns:
a List of messages (String).

clearCache

public void clearCache(String broadcasterId,
                       AtmosphereResource r,
                       CacheMessage cache)
Description copied from interface: BroadcasterCache
Remove the previously cached message.

Specified by:
clearCache in interface BroadcasterCache
Parameters:
broadcasterId - The Broadcaster.getID()
r - an AtmosphereResource
cache - the CacheMessage

excludeFromCache

public void excludeFromCache(String broadcasterId,
                             AtmosphereResource r)
Description copied from interface: BroadcasterCache
Allow an application to exclude, or block, an AtmosphereResource to received cached message. No new message will get sent to this client except the ones already cached.

Specified by:
excludeFromCache in interface BroadcasterCache
Parameters:
broadcasterId - The Broadcaster.getID()
r - an AtmosphereResource

inspector

public BroadcasterCache inspector(BroadcasterCacheInspector interceptor)
Description copied from interface: BroadcasterCache
Add a BroadcasterCacheInspector that will be invoked before a message gets added to the cache.

Specified by:
inspector in interface BroadcasterCache
Parameters:
interceptor - an instance of BroadcasterCacheInspector
Returns:
this


Copyright © 2013. All Rights Reserved.