Class AbstractRemoteCacheListener<K,V>
java.lang.Object
org.apache.commons.jcs3.auxiliary.remote.AbstractRemoteCacheListener<K,V>
- All Implemented Interfaces:
Remote,IRemoteCacheListener<K,,V> ICacheListener<K,V>
- Direct Known Subclasses:
RemoteCacheListener,RemoteHttpClientListener
public abstract class AbstractRemoteCacheListener<K,V>
extends Object
implements IRemoteCacheListener<K,V>
Shared listener base.
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractRemoteCacheListener(IRemoteCacheAttributes irca, ICompositeCacheManager cacheMgr, IElementSerializer elementSerializer) Only need one since it does work for all regions, just reference by multiple region names. -
Method Summary
Modifier and TypeMethodDescriptionprotected ICompositeCacheManagerGets the cacheManager attribute of the RemoteCacheListener object.longGets the listenerId attribute of the RemoteCacheListener object.This is for debugging.Gets the remoteType attribute of the RemoteCacheListener objectvoidhandleDispose(String cacheName) Notifies the subscribers for freeing up the named cache.voidhandlePut(ICacheElement<K, V> cb) If this is configured to remove on put, then remove the element since it has been updated elsewhere. cd should be incomplete for faster transmission.voidhandleRemove(String cacheName, K key) Calls localRemove on the CompositeCache.voidhandleRemoveAll(String cacheName) Calls localRemoveAll on the CompositeCache.voidsetListenerId(long id) Let the remote cache set a listener_id.toString()For easier debugging.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.jcs3.auxiliary.remote.behavior.IRemoteCacheListener
dispose
-
Constructor Details
-
AbstractRemoteCacheListener
public AbstractRemoteCacheListener(IRemoteCacheAttributes irca, ICompositeCacheManager cacheMgr, IElementSerializer elementSerializer) Only need one since it does work for all regions, just reference by multiple region names.The constructor exports this object, making it available to receive incoming calls. The callback port is anonymous unless a local port value was specified in the configuration.
- Parameters:
irca- cache configurationcacheMgr- the cache hubelementSerializer- a custom serializer
-
-
Method Details
-
setListenerId
Let the remote cache set a listener_id. Since there is only one listener for all the regions and every region gets registered? the id shouldn't be set if it isn't zero. If it is we assume that it is a reconnect.- Specified by:
setListenerIdin interfaceICacheListener<K,V> - Specified by:
setListenerIdin interfaceIRemoteCacheListener<K,V> - Parameters:
id- The new listenerId value- Throws:
IOException
-
getListenerId
Gets the listenerId attribute of the RemoteCacheListener object. This is stored in the object. The RemoteCache object contains a reference to the listener and get the id this way.- Specified by:
getListenerIdin interfaceICacheListener<K,V> - Specified by:
getListenerIdin interfaceIRemoteCacheListener<K,V> - Returns:
- The listenerId value
- Throws:
IOException
-
getRemoteType
Gets the remoteType attribute of the RemoteCacheListener object- Specified by:
getRemoteTypein interfaceIRemoteCacheListener<K,V> - Returns:
- The remoteType value
- Throws:
IOException
-
handlePut
If this is configured to remove on put, then remove the element since it has been updated elsewhere. cd should be incomplete for faster transmission. We don't want to pass data only invalidation. The next time it is used the local cache will get the new version from the remote store.If remove on put is not configured, then update the item.
- Specified by:
handlePutin interfaceICacheListener<K,V> - Specified by:
handlePutin interfaceIRemoteCacheListener<K,V> - Parameters:
cb-- Throws:
IOException
-
handleRemove
Calls localRemove on the CompositeCache.- Specified by:
handleRemovein interfaceICacheListener<K,V> - Specified by:
handleRemovein interfaceIRemoteCacheListener<K,V> - Parameters:
cacheName-key-- Throws:
IOException
-
handleRemoveAll
Calls localRemoveAll on the CompositeCache.- Specified by:
handleRemoveAllin interfaceICacheListener<K,V> - Specified by:
handleRemoveAllin interfaceIRemoteCacheListener<K,V> - Parameters:
cacheName-- Throws:
IOException
-
handleDispose
Description copied from interface:IRemoteCacheListenerNotifies the subscribers for freeing up the named cache.- Specified by:
handleDisposein interfaceICacheListener<K,V> - Specified by:
handleDisposein interfaceIRemoteCacheListener<K,V> - Parameters:
cacheName-- Throws:
IOException
-
getCacheManager
Gets the cacheManager attribute of the RemoteCacheListener object. This is one of the few places that force the cache to be a singleton. -
getLocalHostAddress
This is for debugging. It allows the remote server to log the address of clients.- Specified by:
getLocalHostAddressin interfaceIRemoteCacheListener<K,V> - Returns:
- String
- Throws:
IOException
-
toString
For easier debugging.
-