org.apache.jcs.auxiliary.remote
Class AbsractRemoteCacheListener

java.lang.Object
  extended by org.apache.jcs.auxiliary.remote.AbsractRemoteCacheListener
All Implemented Interfaces:
java.rmi.Remote, IRemoteCacheListener, ICacheListener
Direct Known Subclasses:
RemoteCacheListener, RemoteHttpClientListener

public abstract class AbsractRemoteCacheListener
extends java.lang.Object
implements IRemoteCacheListener

Shared listener base.


Field Summary
protected  ICompositeCacheManager cacheMgr
          The cache manager used to put items in different regions.
protected  IRemoteCacheAttributes irca
          The remote cache configuration object.
protected  long listenerId
          This is set by the remote cache server.
protected  int puts
          Number of put requests received.
protected  int removes
          Number of remove requests received.
 
Fields inherited from interface org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheListener
CLIENT_LISTENER, SERVER_LISTENER
 
Constructor Summary
AbsractRemoteCacheListener(IRemoteCacheAttributes irca, ICompositeCacheManager cacheMgr)
          Only need one since it does work for all regions, just reference by multiple region names.
 
Method Summary
protected  void ensureCacheManager()
          Gets the cacheManager attribute of the RemoteCacheListener object.
 long getListenerId()
          Gets the listenerId attribute of the RemoteCacheListener object.
 java.lang.String getLocalHostAddress()
          This is for debugging.
 int getRemoteType()
          Gets the remoteType attribute of the RemoteCacheListener object
 void handleDispose(java.lang.String cacheName)
          Notifies the subscribers for freeing up the named cache.
 void handlePut(ICacheElement cb)
          If this is configured to remove on put, then remove the element since it has been updated elsewhere.
 void handleRemove(java.lang.String cacheName, java.io.Serializable key)
          Calls localRemove on the CompositeCache.
 void handleRemoveAll(java.lang.String cacheName)
          Calls localRemoveAll on the CompositeCache.
 void setListenerId(long id)
          Let the remote cache set a listener_id.
 java.lang.String 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.jcs.auxiliary.remote.behavior.IRemoteCacheListener
dispose
 

Field Detail

cacheMgr

protected transient ICompositeCacheManager cacheMgr
The cache manager used to put items in different regions. This is set lazily and should not be sent to the remote server.


irca

protected IRemoteCacheAttributes irca
The remote cache configuration object.


puts

protected int puts
Number of put requests received. For debugging only.


removes

protected int removes
Number of remove requests received. For debugging only.


listenerId

protected long listenerId
This is set by the remote cache server.

Constructor Detail

AbsractRemoteCacheListener

public AbsractRemoteCacheListener(IRemoteCacheAttributes irca,
                                  ICompositeCacheManager cacheMgr)
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 -
cacheMgr -
Method Detail

setListenerId

public void setListenerId(long id)
                   throws java.io.IOException
Let the remote cache set a listener_id. Since there is only one listerenr 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 interface IRemoteCacheListener
Specified by:
setListenerId in interface ICacheListener
Parameters:
id - The new listenerId value
Throws:
java.io.IOException

getListenerId

public long getListenerId()
                   throws java.io.IOException
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 interface IRemoteCacheListener
Specified by:
getListenerId in interface ICacheListener
Returns:
The listenerId value
Throws:
java.io.IOException

getRemoteType

public int getRemoteType()
                  throws java.io.IOException
Gets the remoteType attribute of the RemoteCacheListener object
Specified by:
getRemoteType in interface IRemoteCacheListener
Returns:
The remoteType value
Throws:
java.io.IOException

handlePut

public void handlePut(ICacheElement cb)
               throws java.io.IOException
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 interface ICacheListener
Parameters:
cb -
Throws:
java.io.IOException

handleRemove

public void handleRemove(java.lang.String cacheName,
                         java.io.Serializable key)
                  throws java.io.IOException
Calls localRemove on the CompositeCache.

Specified by:
handleRemove in interface ICacheListener
Parameters:
cacheName -
key -
Throws:
java.io.IOException

handleRemoveAll

public void handleRemoveAll(java.lang.String cacheName)
                     throws java.io.IOException
Calls localRemoveAll on the CompositeCache.

Specified by:
handleRemoveAll in interface ICacheListener
Parameters:
cacheName -
Throws:
java.io.IOException

handleDispose

public void handleDispose(java.lang.String cacheName)
                   throws java.io.IOException
Description copied from interface: ICacheListener
Notifies the subscribers for freeing up the named cache.

Specified by:
handleDispose in interface ICacheListener
Parameters:
cacheName -
Throws:
java.io.IOException

ensureCacheManager

protected void ensureCacheManager()
Gets the cacheManager attribute of the RemoteCacheListener object. This is one of the few places that force the cache to be a singleton.


getLocalHostAddress

public java.lang.String getLocalHostAddress()
                                     throws java.io.IOException
This is for debugging. It allows the remote server to log the address of clients.

Specified by:
getLocalHostAddress in interface IRemoteCacheListener
Returns:
String
Throws:
java.io.IOException

toString

public java.lang.String toString()
For easier debugging.

Overrides:
toString in class java.lang.Object
Returns:
Basic info on this listener.


Copyright © 2002-2010 Apache Software Foundation. All Rights Reserved.