public abstract class AbstractBroadcasterCache extends Object implements BroadcasterCache
BroadcasterCache
which is used to implement headers, query parameters or
session based caching.Modifier and Type | Field and Description |
---|---|
protected AtmosphereConfig |
config |
protected List<Object> |
emptyList |
protected List<BroadcasterCacheInspector> |
inspectors |
protected long |
invalidateCacheInterval |
protected boolean |
isShared |
protected List<BroadcasterCacheListener> |
listeners |
protected long |
maxCacheTime |
protected List<CacheMessage> |
messages |
protected Set<String> |
messagesIds |
protected ReadWriteLock |
readWriteLock |
protected ScheduledExecutorService |
reaper |
protected ScheduledFuture |
scheduledFuture |
DEFAULT, NULL
Constructor and Description |
---|
AbstractBroadcasterCache() |
Modifier and Type | Method and Description |
---|---|
BroadcasterCache |
addBroadcasterCacheListener(BroadcasterCacheListener l)
Add a
BroadcasterCacheListener |
BroadcasterCache |
cacheCandidate(String broadcasterId,
String uuid)
Add a
AtmosphereResource.uuid() to the list of active AtmosphereResource
Message will be cached for the resource associated with the uuid. |
void |
cleanup()
Clean resources associated with this instance.
|
BroadcasterCache |
clearCache(String broadcasterId,
String uuid,
CacheMessage cache)
Remove the previously cached message.
|
void |
configure(AtmosphereConfig config)
Configure an AtmosphereFramework object.
|
BroadcasterCache |
excludeFromCache(String broadcasterId,
AtmosphereResource r)
Allow an application to exclude, or block, an
AtmosphereResource to received cached message. |
protected List<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,
Long now,
String uuid) |
BroadcasterCache |
removeBroadcasterCacheListener(BroadcasterCacheListener l)
Remove a
BroadcasterCacheListener |
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, wait
addToCache, retrieveFromCache
protected final List<CacheMessage> messages
protected final ReadWriteLock readWriteLock
protected ScheduledFuture scheduledFuture
protected long maxCacheTime
protected long invalidateCacheInterval
protected ScheduledExecutorService reaper
protected boolean isShared
protected final List<BroadcasterCacheInspector> inspectors
protected final List<BroadcasterCacheListener> listeners
protected AtmosphereConfig config
public void start()
BroadcasterCache
start
in interface BroadcasterCache
public void cleanup()
BroadcasterCache
Broadcaster
gets destroyed.cleanup
in interface BroadcasterCache
public void stop()
BroadcasterCache
stop
in interface BroadcasterCache
protected CacheMessage put(BroadcastMessage message, Long now, String uuid)
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)
BroadcasterCache
BroadcasterCacheInspector
that will be invoked before a message gets added to the cache.inspector
in interface BroadcasterCache
b
- an instance of BroadcasterCacheInspector
protected boolean inspect(BroadcastMessage m)
public void configure(AtmosphereConfig config)
AtmosphereConfigAware
configure
in interface AtmosphereConfigAware
config
- AtmosphereConfig
public BroadcasterCache clearCache(String broadcasterId, String uuid, CacheMessage cache)
BroadcasterCache
clearCache
in interface BroadcasterCache
broadcasterId
- The Broadcaster.getID()
uuid
- an AtmosphereResource.uuid()
cache
- the CacheMessage
public BroadcasterCache excludeFromCache(String broadcasterId, AtmosphereResource r)
BroadcasterCache
AtmosphereResource
to received cached message.
No new message will get sent to this client except the ones already cached.excludeFromCache
in interface BroadcasterCache
broadcasterId
- The Broadcaster.getID()
r
- an AtmosphereResource
public BroadcasterCache cacheCandidate(String broadcasterId, String uuid)
BroadcasterCache
AtmosphereResource.uuid()
to the list of active AtmosphereResource
Message will be cached for the resource associated with the uuid.cacheCandidate
in interface BroadcasterCache
broadcasterId
- The Broadcaster.getID()
uuid
- an AtmosphereResource.uuid()
public BroadcasterCache addBroadcasterCacheListener(BroadcasterCacheListener l)
BroadcasterCache
BroadcasterCacheListener
addBroadcasterCacheListener
in interface BroadcasterCache
l
- a BroadcasterCacheListener
public BroadcasterCache removeBroadcasterCacheListener(BroadcasterCacheListener l)
BroadcasterCache
BroadcasterCacheListener
removeBroadcasterCacheListener
in interface BroadcasterCache
l
- a BroadcasterCacheListener
Copyright © 2016. All rights reserved.