public abstract class AbstractBroadcasterCache extends java.lang.Object implements BroadcasterCache
BroadcasterCache which is used to implement headers, query parameters or
session based caching.| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<java.lang.Object> |
emptyList |
protected java.util.List<BroadcasterCacheInspector> |
inspectors |
protected long |
invalidateCacheInterval |
protected boolean |
isShared |
protected long |
maxCacheTime |
protected java.util.List<CacheMessage> |
messages |
protected java.util.Set<java.lang.String> |
messagesIds |
protected java.util.concurrent.locks.ReadWriteLock |
readWriteLock |
protected java.util.concurrent.ScheduledExecutorService |
reaper |
protected java.util.concurrent.ScheduledFuture |
scheduledFuture |
DEFAULT| Constructor and Description |
|---|
AbstractBroadcasterCache() |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanup()
Clean resources associated with this instance.
|
void |
clearCache(java.lang.String broadcasterId,
AtmosphereResource r,
CacheMessage cache)
Remove the previously cached message.
|
void |
configure(BroadcasterConfig config)
Configure the cache.
|
void |
excludeFromCache(java.lang.String broadcasterId,
AtmosphereResource r)
Allow an application to exclude, or block, an
AtmosphereResource to received cached message. |
protected java.util.List<java.lang.Object> |
get(long cacheHeaderTime) |
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,
java.lang.Long now) |
AbstractBroadcasterCache |
setInvalidateCacheInterval(long invalidateCacheInterval)
Set the delay between cache purges.
|
AbstractBroadcasterCache |
setMaxCacheTime(long maxCacheTime)
Set the maximum time a message stays alive in the cache.
|
void |
start()
This method is invoked when the Broadcaster is started.
|
void |
stop()
This method is invoked when the Broadcaster is stopped.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddToCache, retrieveFromCacheprotected final java.util.List<CacheMessage> messages
protected final java.util.Set<java.lang.String> messagesIds
protected final java.util.concurrent.locks.ReadWriteLock readWriteLock
protected java.util.concurrent.ScheduledFuture scheduledFuture
protected long maxCacheTime
protected long invalidateCacheInterval
protected java.util.concurrent.ScheduledExecutorService reaper
protected boolean isShared
protected final java.util.List<BroadcasterCacheInspector> inspectors
protected final java.util.List<java.lang.Object> emptyList
public void start()
BroadcasterCachestart in interface BroadcasterCachepublic void cleanup()
BroadcasterCacheBroadcaster gets destroyed.cleanup in interface BroadcasterCachepublic void stop()
BroadcasterCachestop in interface BroadcasterCacheprotected CacheMessage put(BroadcastMessage message, java.lang.Long now)
protected java.util.List<java.lang.Object> get(long cacheHeaderTime)
public AbstractBroadcasterCache setInvalidateCacheInterval(long invalidateCacheInterval)
invalidateCacheInterval - the purge interval in millisecondspublic AbstractBroadcasterCache setMaxCacheTime(long maxCacheTime)
maxCacheTime - the maximum time in milliseconds.public BroadcasterCache inspector(BroadcasterCacheInspector b)
BroadcasterCacheBroadcasterCacheInspector that will be invoked before a message gets added to the cache.inspector in interface BroadcasterCacheb - an instance of BroadcasterCacheInspectorprotected boolean inspect(BroadcastMessage m)
public void configure(BroadcasterConfig config)
BroadcasterCacheconfigure in interface BroadcasterCacheconfig - a BroadcasterConfigpublic void clearCache(java.lang.String broadcasterId,
AtmosphereResource r,
CacheMessage cache)
BroadcasterCacheclearCache in interface BroadcasterCachebroadcasterId - The Broadcaster.getID()r - an AtmosphereResourcecache - the CacheMessagepublic void excludeFromCache(java.lang.String broadcasterId,
AtmosphereResource r)
BroadcasterCacheAtmosphereResource to received cached message.
No new message will get sent to this client except the ones already cached.excludeFromCache in interface BroadcasterCachebroadcasterId - The Broadcaster.getID()r - an AtmosphereResourceCopyright © 2018. All Rights Reserved.