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
This class wraps all messages to be delivered to a client.
|
| Modifier and Type | Field and Description |
|---|---|
protected List<Object> |
emptyList |
protected List<BroadcasterCacheInspector> |
inspectors |
protected List<BroadcasterCacheListener> |
listeners |
protected ScheduledExecutorService |
taskScheduler |
DEFAULT, NULL| Constructor and Description |
|---|
UUIDBroadcasterCache() |
| Modifier and Type | Method and Description |
|---|---|
Map<String,Long> |
activeClients() |
BroadcasterCache |
addBroadcasterCacheListener(BroadcasterCacheListener l)
Add a
BroadcasterCacheListener |
CacheMessage |
addToCache(String broadcasterId,
String uuid,
BroadcastMessage message)
Start tracking messages associated with
AtmosphereResource from the cache. |
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 message)
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 boolean |
inspect(BroadcastMessage m) |
BroadcasterCache |
inspector(BroadcasterCacheInspector b)
Add a
BroadcasterCacheInspector that will be invoked before a message gets added to the cache. |
List<BroadcasterCacheInspector> |
inspectors() |
protected void |
invalidateExpiredEntries() |
List<BroadcasterCacheListener> |
listeners() |
Map<String,UUIDBroadcasterCache.ClientQueue> |
messages() |
BroadcasterCache |
removeBroadcasterCacheListener(BroadcasterCacheListener l)
Remove a
BroadcasterCacheListener |
List<Object> |
retrieveFromCache(String broadcasterId,
String uuid)
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
protected final List<BroadcasterCacheListener> listeners
public void configure(AtmosphereConfig config)
AtmosphereConfigAwareconfigure in interface AtmosphereConfigAwareconfig - AtmosphereConfigpublic 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, String uuid, BroadcastMessage message)
BroadcasterCacheAtmosphereResource from the cache.addToCache in interface BroadcasterCachebroadcasterId - The associated Broadcaster#addAtmosphereResource(AtmosphereResource).getIDuuid - AtmosphereResource.uuid()message - BroadcastMessage.CacheMessagepublic List<Object> retrieveFromCache(String broadcasterId, String uuid)
BroadcasterCacheAtmosphereResource.retrieveFromCache in interface BroadcasterCachebroadcasterId - The associated org.atmosphere.cpr.Broadcaster#addAtmosphereResource(org.atmosphere.cpr.AtmosphereResource).getIDuuid - AtmosphereResourceList of messages (String).public BroadcasterCache clearCache(String broadcasterId, String uuid, CacheMessage message)
BroadcasterCacheclearCache in interface BroadcasterCachebroadcasterId - The Broadcaster.getID()uuid - an AtmosphereResource.uuid()message - 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 BroadcasterCacheInspectorpublic BroadcasterCache addBroadcasterCacheListener(BroadcasterCacheListener l)
BroadcasterCacheBroadcasterCacheListeneraddBroadcasterCacheListener in interface BroadcasterCachel - a BroadcasterCacheListenerpublic BroadcasterCache removeBroadcasterCacheListener(BroadcasterCacheListener l)
BroadcasterCacheBroadcasterCacheListenerremoveBroadcasterCacheListener in interface BroadcasterCachel - a BroadcasterCacheListenerprotected 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 BroadcasterCache 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 AtmosphereResourcepublic BroadcasterCache cacheCandidate(String broadcasterId, String uuid)
BroadcasterCacheAtmosphereResource.uuid() to the list of active AtmosphereResource
Message will be cached for the resource associated with the uuid.cacheCandidate in interface BroadcasterCachebroadcasterId - The Broadcaster.getID()uuid - an AtmosphereResource.uuid()public List<BroadcasterCacheListener> listeners()
public List<BroadcasterCacheInspector> inspectors()
Copyright © 2016. All rights reserved.