org.atmosphere.cpr
Interface BroadcasterCache

All Known Implementing Classes:
AbstractBroadcasterCache, DefaultBroadcasterCache, HeaderBroadcasterCache, SessionBroadcasterCache, UUIDBroadcasterCache

public interface BroadcasterCache

A BroadcasterCache is used to persist broadcasted Object Broadcaster.broadcast(Object). Disconnected clients can always retrieve message that were broadcasted during their "downtime". BroadcasterCache are useful when a the long polling technique is used and prevent application from loosing event between re-connection.

A BroadcasterCache can be configured by invoking BroadcasterConfig.setBroadcasterCache(BroadcasterCache) by defining it in your web/application.xml or by using the BroadcasterCacheService


Field Summary
static BroadcasterCache DEFAULT
           
 
Method Summary
 CacheMessage addToCache(String broadcasterId, AtmosphereResource r, BroadcastMessage e)
          Start tracking messages associated with AtmosphereResource from the cache
 void clearCache(String broadcasterId, AtmosphereResource r, CacheMessage cache)
          Remove the previously cached message.
 void configure(AtmosphereConfig config)
          Configure the cache.
 void excludeFromCache(String broadcasterId, AtmosphereResource r)
          Allow an application to exclude, or block, an AtmosphereResource to received cached message.
 boolean includeInCache(String broadcasterId, AtmosphereResource r)
          Re-allow an AtmosphereResource to receive 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()
          Start
 void stop()
          Stop
 

Field Detail

DEFAULT

static final BroadcasterCache DEFAULT
Method Detail

start

void start()
Start


stop

void stop()
Stop


configure

void configure(AtmosphereConfig config)
Configure the cache.


addToCache

CacheMessage addToCache(String broadcasterId,
                        AtmosphereResource r,
                        BroadcastMessage e)
Start tracking messages associated with AtmosphereResource from the cache

Parameters:
broadcasterId - The associated Broadcaster#addAtmosphereResource(AtmosphereResource).getID
r - AtmosphereResource
e - BroadcastMessage.
Returns:
The CacheMessage

retrieveFromCache

List<Object> retrieveFromCache(String id,
                               AtmosphereResource r)
Retrieve messages associated with AtmosphereResource

Parameters:
id - The associated Broadcaster#addAtmosphereResource(AtmosphereResource).getID
r - AtmosphereResource
Returns:
a List of messages (String).

clearCache

void clearCache(String broadcasterId,
                AtmosphereResource r,
                CacheMessage cache)
Remove the previously cached message.

Parameters:
broadcasterId - The Broadcaster.getID()
r - an AtmosphereResource
cache - the CacheMessage

excludeFromCache

void excludeFromCache(String broadcasterId,
                      AtmosphereResource r)
Allow an application to exclude, or block, an AtmosphereResource to received cached message.

Parameters:
broadcasterId - The Broadcaster.getID()
r - an AtmosphereResource

includeInCache

boolean includeInCache(String broadcasterId,
                       AtmosphereResource r)
Re-allow an AtmosphereResource to receive cached message.

Parameters:
broadcasterId - The Broadcaster.getID()
r - an AtmosphereResource

inspector

BroadcasterCache inspector(BroadcasterCacheInspector interceptor)
Add a BroadcasterCacheInspector that will be invoked before a message gets added to the cache.

Parameters:
interceptor -
Returns:
this


Copyright © 2013. All Rights Reserved.