org.atmosphere.cache
Class AbstractBroadcasterCache

java.lang.Object
  extended by org.atmosphere.cache.AbstractBroadcasterCache
All Implemented Interfaces:
BroadcasterCache
Direct Known Subclasses:
HeaderBroadcasterCache, SessionBroadcasterCache

public abstract class AbstractBroadcasterCache
extends Object
implements BroadcasterCache

Abstract BroadcasterCache which is used to implement headers or query parameters or session based caching.

Author:
Paul Khodchenkov, Jeanfrancois Arcand

Field Summary
protected  ConcurrentHashMap<String,List<String>> bannedResources
           
protected  List<Object> emptyList
           
protected  List<BroadcasterCacheInspector> inspectors
           
protected  long invalidateCacheInterval
           
protected  boolean isShared
           
protected  long maxCacheTime
           
protected  List<CacheMessage> messages
           
protected  Set<String> messagesIds
           
protected  ReadWriteLock readWriteLock
           
protected  ScheduledExecutorService reaper
           
protected  ScheduledFuture scheduledFuture
           
 
Fields inherited from interface org.atmosphere.cpr.BroadcasterCache
DEFAULT
 
Constructor Summary
AbstractBroadcasterCache()
           
 
Method Summary
 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.
protected  List<Object> get(long cacheHeaderTime)
           
 boolean includeInCache(String broadcasterId, AtmosphereResource r)
          Re-allow an AtmosphereResource to receive cached message.
protected  boolean inspect(BroadcastMessage m)
           
 BroadcasterCache inspector(BroadcasterCacheInspector b)
          Add a BroadcasterCacheInspector that will be invoked before a message gets added to the cache.
protected  CacheMessage put(BroadcastMessage message, Long now)
           
 AbstractBroadcasterCache setInvalidateCacheInterval(long invalidateCacheInterval)
          Set the time, in millisecond, the cache will be checked and purged.
 AbstractBroadcasterCache setMaxCacheTime(long maxCacheTime)
          Set the maxium time, in millisecond, a message stay alive in the cache.
 void start()
          Start
 void stop()
          Stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.atmosphere.cpr.BroadcasterCache
addToCache, retrieveFromCache
 

Field Detail

messages

protected final List<CacheMessage> messages

messagesIds

protected final Set<String> messagesIds

readWriteLock

protected final ReadWriteLock readWriteLock

scheduledFuture

protected ScheduledFuture scheduledFuture

maxCacheTime

protected long maxCacheTime

invalidateCacheInterval

protected long invalidateCacheInterval

reaper

protected ScheduledExecutorService reaper

isShared

protected boolean isShared

inspectors

protected final List<BroadcasterCacheInspector> inspectors

bannedResources

protected final ConcurrentHashMap<String,List<String>> bannedResources

emptyList

protected final List<Object> emptyList
Constructor Detail

AbstractBroadcasterCache

public AbstractBroadcasterCache()
Method Detail

start

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

Specified by:
start in interface BroadcasterCache

stop

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

Specified by:
stop in interface BroadcasterCache

put

protected CacheMessage put(BroadcastMessage message,
                           Long now)

get

protected List<Object> get(long cacheHeaderTime)

setInvalidateCacheInterval

public AbstractBroadcasterCache setInvalidateCacheInterval(long invalidateCacheInterval)
Set the time, in millisecond, the cache will be checked and purged.

Parameters:
invalidateCacheInterval -
Returns:
this

setMaxCacheTime

public AbstractBroadcasterCache setMaxCacheTime(long maxCacheTime)
Set the maxium time, in millisecond, a message stay alive in the cache.

Parameters:
maxCacheTime - the maxium time, in millisecond, a message stay alive in the cache.
Returns:
this

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(BroadcastMessage m)

configure

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

Specified by:
configure in interface BroadcasterCache

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.

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

includeInCache

public boolean includeInCache(String broadcasterId,
                              AtmosphereResource r)
Description copied from interface: BroadcasterCache
Re-allow an AtmosphereResource to receive cached message.

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


Copyright © 2013. All Rights Reserved.