org.atmosphere.cache
Class EventCacheBroadcasterCache

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

public class EventCacheBroadcasterCache
extends Object
implements BroadcasterCache

An improved BroadcasterCache implementation.

Author:
Paul Khodchenkov, Jeanfrancois Arcand

Nested Class Summary
static class EventCacheBroadcasterCache.CacheMessage
           
static class EventCacheBroadcasterCache.ClientQueue
           
 
Nested classes/interfaces inherited from interface org.atmosphere.cpr.BroadcasterCache
BroadcasterCache.Message, BroadcasterCache.STRATEGY
 
Field Summary
protected  List<BroadcasterCacheInspector> inspectors
           
protected  ScheduledExecutorService taskScheduler
           
 
Constructor Summary
EventCacheBroadcasterCache()
           
 
Method Summary
 Map<String,Long> activeClients()
           
 EventCacheBroadcasterCache.CacheMessage addCacheCandidate(String broadcasterId, AtmosphereResource r, Object e)
          For backward compatibility with 1.0.9 and lower, use the method above.
 void addToCache(String broadcasterId, AtmosphereResource r, BroadcasterCache.Message e)
          Start tracking messages associated with AtmosphereResource from the cache
 void clearCache(String broadcasterId, AtmosphereResourceImpl r, EventCacheBroadcasterCache.CacheMessage message)
           
protected  boolean inspect(BroadcasterCache.Message m)
           
 BroadcasterCache inspector(BroadcasterCacheInspector b)
          Add a BroadcasterCacheInspector that will be invoked before a message gets added to the cache.
protected  void invalidateExpiredEntries()
           
 Map<String,EventCacheBroadcasterCache.ClientQueue> messages()
           
 List<Object> retrieveFromCache(String broadcasterId, AtmosphereResource r)
          Retrieve messages associated with AtmosphereResource
 void setClientIdleTime(long clientIdleTime)
           
 void setExecutorService(ScheduledExecutorService reaper)
           
 void setInvalidateCacheInterval(long invalidateCacheInterval)
           
 void start()
          Start
 void stop()
          Stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inspectors

protected final List<BroadcasterCacheInspector> inspectors

taskScheduler

protected ScheduledExecutorService taskScheduler
Constructor Detail

EventCacheBroadcasterCache

public EventCacheBroadcasterCache()
Method Detail

setInvalidateCacheInterval

public void setInvalidateCacheInterval(long invalidateCacheInterval)

setClientIdleTime

public void setClientIdleTime(long clientIdleTime)

setExecutorService

public void setExecutorService(ScheduledExecutorService reaper)

start

public void start()
Description copied from interface: BroadcasterCache
Start

Specified by:
start in interface BroadcasterCache

invalidateExpiredEntries

protected void invalidateExpiredEntries()

stop

public void stop()
Description copied from interface: BroadcasterCache
Stop

Specified by:
stop in interface BroadcasterCache

addToCache

public void addToCache(String broadcasterId,
                       AtmosphereResource r,
                       BroadcasterCache.Message 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 - a broadcasted message.

addCacheCandidate

public EventCacheBroadcasterCache.CacheMessage addCacheCandidate(String broadcasterId,
                                                                 AtmosphereResource r,
                                                                 Object e)
For backward compatibility with 1.0.9 and lower, use the method above.

Parameters:
broadcasterId -
r -
e -
Returns:

retrieveFromCache

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

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

clearCache

public void clearCache(String broadcasterId,
                       AtmosphereResourceImpl r,
                       EventCacheBroadcasterCache.CacheMessage message)

messages

public Map<String,EventCacheBroadcasterCache.ClientQueue> messages()

activeClients

public Map<String,Long> activeClients()

inspector

public BroadcasterCache inspector(BroadcasterCacheInspector b)
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
Returns:
this

inspect

protected boolean inspect(BroadcasterCache.Message m)


Copyright © 2013. All Rights Reserved.