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

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.atmosphere.cpr.BroadcasterCache
BroadcasterCache.Message, BroadcasterCache.STRATEGY
 
Field Summary
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
           
 
Constructor Summary
AbstractBroadcasterCache()
           
 
Method Summary
protected  List<Object> get(long cacheHeaderTime)
           
 ScheduledExecutorService getReaper()
          Return the ScheduledExecutorService
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 put(BroadcasterCache.Message 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.
 AbstractBroadcasterCache setReaper(ScheduledExecutorService reaper)
          Set the ScheduledExecutorService to clear the cached message.
 AbstractBroadcasterCache setShared(boolean isShared)
          Set to true the associated getReaper() is shared amongs BroadcasterCache
 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
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 void put(BroadcasterCache.Message message,
                   Long now)

get

protected List<Object> get(long cacheHeaderTime)

setShared

public AbstractBroadcasterCache setShared(boolean isShared)
Set to true the associated getReaper() is shared amongs BroadcasterCache

Parameters:
isShared - to true if shared. False by default.
Returns:
this

setReaper

public AbstractBroadcasterCache setReaper(ScheduledExecutorService reaper)
Set the ScheduledExecutorService to clear the cached message.

Parameters:
reaper - the ScheduledExecutorService to clear the cached message.
Returns:
this

getReaper

public ScheduledExecutorService getReaper()
Return the ScheduledExecutorService

Returns:
the ScheduledExecutorService

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:

inspect

protected boolean inspect(BroadcasterCache.Message m)


Copyright © 2012. All Rights Reserved.