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 ICompositeCacheManager
Gets the cacheManager attribute of the RemoteCacheListener object.long
Gets the listenerId attribute of the RemoteCacheListener object.This is for debugging.Gets the remoteType attribute of the RemoteCacheListener objectvoid
handleDispose
(String cacheName) Notifies the subscribers for freeing up the named cache.void
handlePut
(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.void
handleRemove
(String cacheName, K key) Calls localRemove on the CompositeCache.void
handleRemoveAll
(String cacheName) Calls localRemoveAll on the CompositeCache.void
setListenerId
(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, wait
Methods 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:
setListenerId
in interfaceICacheListener<K,
V> - Specified by:
setListenerId
in 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:
getListenerId
in interfaceICacheListener<K,
V> - Specified by:
getListenerId
in interfaceIRemoteCacheListener<K,
V> - Returns:
- The listenerId value
- Throws:
IOException
-
getRemoteType
Gets the remoteType attribute of the RemoteCacheListener object- Specified by:
getRemoteType
in 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:
handlePut
in interfaceICacheListener<K,
V> - Specified by:
handlePut
in interfaceIRemoteCacheListener<K,
V> - Parameters:
cb
-- Throws:
IOException
-
handleRemove
Calls localRemove on the CompositeCache.- Specified by:
handleRemove
in interfaceICacheListener<K,
V> - Specified by:
handleRemove
in interfaceIRemoteCacheListener<K,
V> - Parameters:
cacheName
-key
-- Throws:
IOException
-
handleRemoveAll
Calls localRemoveAll on the CompositeCache.- Specified by:
handleRemoveAll
in interfaceICacheListener<K,
V> - Specified by:
handleRemoveAll
in interfaceIRemoteCacheListener<K,
V> - Parameters:
cacheName
-- Throws:
IOException
-
handleDispose
Description copied from interface:IRemoteCacheListener
Notifies the subscribers for freeing up the named cache.- Specified by:
handleDispose
in interfaceICacheListener<K,
V> - Specified by:
handleDispose
in 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:
getLocalHostAddress
in interfaceIRemoteCacheListener<K,
V> - Returns:
- String
- Throws:
IOException
-
toString
For easier debugging.
-