Package org.atmosphere.cache
Class AbstractBroadcasterCache
java.lang.Object
org.atmosphere.cache.AbstractBroadcasterCache
- All Implemented Interfaces:
BroadcasterCache,AtmosphereConfigAware
- Direct Known Subclasses:
SessionBroadcasterCache
Abstract
BroadcasterCache which is used to implement headers, query parameters or
session based caching.- Author:
- Paul Khodchenkov, Jeanfrancois Arcand
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AtmosphereConfigprotected final List<BroadcasterCacheInspector> protected longprotected booleanprotected final List<BroadcasterCacheListener> protected longprotected final List<CacheMessage> protected final ReadWriteLockprotected ScheduledExecutorServiceprotected ScheduledFuture<?> Fields inherited from interface org.atmosphere.cpr.BroadcasterCache
DEFAULT, NULL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd aBroadcasterCacheListenercacheCandidate(String broadcasterId, String uuid) Add aAtmosphereResource.uuid()to the list of activeAtmosphereResourceMessage will be cached for the resource associated with the uuid.voidcleanup()Clean resources associated with this instance.clearCache(String broadcasterId, String uuid, CacheMessage cache) Remove the previously cached message.voidconfigure(AtmosphereConfig config) Configure an AtmosphereFramework object.excludeFromCache(String broadcasterId, AtmosphereResource r) Allow an application to exclude, or block, anAtmosphereResourceto received cached message.get(long cacheHeaderTime) protected booleanAdd aBroadcasterCacheInspectorthat will be invoked before a message gets added to the cache.protected CacheMessageput(BroadcastMessage message, Long now, String uuid) Remove aBroadcasterCacheListenersetInvalidateCacheInterval(long invalidateCacheInterval) Set the delay between cache purges.setMaxCacheTime(long maxCacheTime) Set the maximum time a message stays alive in the cache.voidstart()This method is invoked when the Broadcaster is started.voidstop()This method is invoked when the Broadcaster is stopped.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.atmosphere.cpr.BroadcasterCache
addToCache, retrieveFromCache
-
Field Details
-
messages
-
messagesIds
-
readWriteLock
-
scheduledFuture
-
maxCacheTime
protected long maxCacheTime -
invalidateCacheInterval
protected long invalidateCacheInterval -
reaper
-
inspectors
-
emptyList
-
listeners
-
config
-
-
Constructor Details
-
AbstractBroadcasterCache
public AbstractBroadcasterCache()
-
-
Method Details
-
start
public void start()Description copied from interface:BroadcasterCacheThis method is invoked when the Broadcaster is started.- Specified by:
startin interfaceBroadcasterCache
-
cleanup
public void cleanup()Description copied from interface:BroadcasterCacheClean resources associated with this instance. This method is useful when ExecutorServices are shared and some future must be cancelled. This method will always be invoked when aBroadcastergets destroyed.- Specified by:
cleanupin interfaceBroadcasterCache
-
stop
public void stop()Description copied from interface:BroadcasterCacheThis method is invoked when the Broadcaster is stopped.- Specified by:
stopin interfaceBroadcasterCache
-
put
-
get
-
setInvalidateCacheInterval
Set the delay between cache purges.- Parameters:
invalidateCacheInterval- the purge interval in milliseconds- Returns:
- this
-
setMaxCacheTime
Set the maximum time a message stays alive in the cache.- Parameters:
maxCacheTime- the maximum time in milliseconds.- Returns:
- this
-
inspector
Description copied from interface:BroadcasterCacheAdd aBroadcasterCacheInspectorthat will be invoked before a message gets added to the cache.- Specified by:
inspectorin interfaceBroadcasterCache- Parameters:
b- an instance ofBroadcasterCacheInspector- Returns:
- this
-
inspect
-
configure
Description copied from interface:AtmosphereConfigAwareConfigure an AtmosphereFramework object.- Specified by:
configurein interfaceAtmosphereConfigAware- Parameters:
config-AtmosphereConfig
-
clearCache
Description copied from interface:BroadcasterCacheRemove the previously cached message.- Specified by:
clearCachein interfaceBroadcasterCache- Parameters:
broadcasterId- TheBroadcaster.getID()uuid- anAtmosphereResource.uuid()cache- theCacheMessage
-
excludeFromCache
Description copied from interface:BroadcasterCacheAllow an application to exclude, or block, anAtmosphereResourceto received cached message. No new message will get sent to this client except the ones already cached.- Specified by:
excludeFromCachein interfaceBroadcasterCache- Parameters:
broadcasterId- TheBroadcaster.getID()r- anAtmosphereResource- Returns:
- this
-
cacheCandidate
Description copied from interface:BroadcasterCacheAdd aAtmosphereResource.uuid()to the list of activeAtmosphereResourceMessage will be cached for the resource associated with the uuid.- Specified by:
cacheCandidatein interfaceBroadcasterCache- Parameters:
broadcasterId- TheBroadcaster.getID()uuid- anAtmosphereResource.uuid()- Returns:
- this
-
addBroadcasterCacheListener
Description copied from interface:BroadcasterCacheAdd aBroadcasterCacheListener- Specified by:
addBroadcasterCacheListenerin interfaceBroadcasterCache- Parameters:
l- aBroadcasterCacheListener- Returns:
- this
-
removeBroadcasterCacheListener
Description copied from interface:BroadcasterCacheRemove aBroadcasterCacheListener- Specified by:
removeBroadcasterCacheListenerin interfaceBroadcasterCache- Parameters:
l- aBroadcasterCacheListener- Returns:
- this
-