public class UUIDBroadcasterCache extends Object implements BroadcasterCache
BroadcasterCache implementation that is based on the unique identifier (UUID) that all
AtmosphereResources have.| Modifier and Type | Class and Description |
|---|---|
static class |
UUIDBroadcasterCache.ClientQueue |
| Modifier and Type | Field and Description |
|---|---|
protected List<Object> |
emptyList |
protected List<BroadcasterCacheInspector> |
inspectors |
protected ScheduledExecutorService |
taskScheduler |
DEFAULT| Constructor and Description |
|---|
UUIDBroadcasterCache() |
| Modifier and Type | Method and Description |
|---|---|
Map<String,Long> |
activeClients() |
CacheMessage |
addToCache(String broadcasterId,
AtmosphereResource r,
BroadcastMessage message)
Start tracking messages associated with
AtmosphereResource from the cache. |
void |
cleanup()
Clean resources associated with this instance.
|
void |
clearCache(String broadcasterId,
AtmosphereResource r,
CacheMessage message)
Remove the previously cached message.
|
void |
configure(BroadcasterConfig config)
Configure the cache.
|
void |
excludeFromCache(String broadcasterId,
AtmosphereResource r)
Allow an application to exclude, or block, an
AtmosphereResource to received 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 void |
invalidateExpiredEntries() |
Map<String,UUIDBroadcasterCache.ClientQueue> |
messages() |
List<Object> |
retrieveFromCache(String broadcasterId,
AtmosphereResource r)
Retrieve messages associated with
AtmosphereResource. |
void |
setClientIdleTime(long clientIdleTime) |
void |
setInvalidateCacheInterval(long invalidateCacheInterval) |
void |
start()
This method is invoked when the Broadcaster is started.
|
void |
stop()
This method is invoked when the Broadcaster is stopped.
|
String |
toString() |
protected String |
uuid(AtmosphereResource r) |
protected final List<BroadcasterCacheInspector> inspectors
protected ScheduledExecutorService taskScheduler
public void configure(BroadcasterConfig config)
BroadcasterCacheconfigure in interface BroadcasterCacheconfig - a BroadcasterConfigpublic void start()
BroadcasterCachestart in interface BroadcasterCachepublic void stop()
BroadcasterCachestop in interface BroadcasterCachepublic void cleanup()
BroadcasterCacheBroadcaster gets destroyed.cleanup in interface BroadcasterCachepublic CacheMessage addToCache(String broadcasterId, AtmosphereResource r, BroadcastMessage message)
BroadcasterCacheAtmosphereResource from the cache.addToCache in interface BroadcasterCachebroadcasterId - The associated Broadcaster#addAtmosphereResource(AtmosphereResource).getIDr - AtmosphereResourcemessage - BroadcastMessage.CacheMessagepublic List<Object> retrieveFromCache(String broadcasterId, AtmosphereResource r)
BroadcasterCacheAtmosphereResource.retrieveFromCache in interface BroadcasterCachebroadcasterId - The associated Broadcaster#addAtmosphereResource(AtmosphereResource).getIDr - AtmosphereResourceList of messages (String).public void clearCache(String broadcasterId, AtmosphereResource r, CacheMessage message)
BroadcasterCacheclearCache in interface BroadcasterCachebroadcasterId - The Broadcaster.getID()r - an AtmosphereResourcemessage - the CacheMessagepublic 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 String uuid(AtmosphereResource r)
public Map<String,UUIDBroadcasterCache.ClientQueue> messages()
protected boolean inspect(BroadcastMessage m)
public void setInvalidateCacheInterval(long invalidateCacheInterval)
public void setClientIdleTime(long clientIdleTime)
protected void invalidateExpiredEntries()
public void excludeFromCache(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 © 2014. All Rights Reserved.