org.apache.jcs.auxiliary.lateral.socket.tcp
Class LateralTCPListener

java.lang.Object
  extended byorg.apache.jcs.auxiliary.lateral.socket.tcp.LateralTCPListener
All Implemented Interfaces:
ICacheListener, ILateralCacheListener, java.io.Serializable

public class LateralTCPListener
extends java.lang.Object
implements ILateralCacheListener, java.io.Serializable

Listens for connections from other TCP lateral caches and handles them.

Version:
$Id: LateralTCPListener.java,v 1.5 2003/08/22 11:57:18 mpoeschl Exp $
Author:
Aaron Smuts
See Also:
Serialized Form

Nested Class Summary
 class LateralTCPListener.ConnectionHandler
          Separate thread run when a command comes into the LateralTCPReceiver.
 class LateralTCPListener.ListenerThread
          Processes commands from the server socket.
 
Field Summary
private static int acceptTimeOut
          How long the server will block on an accept().
protected static CompositeCacheManager cacheMgr
          The CacheHub this listener is associated with
private  ILateralCacheAttributes ilca
           
protected static java.util.HashMap instances
          Map of available instances, keyed by port
private static org.apache.commons.logging.Log log
           
private  EDU.oswego.cs.dl.util.concurrent.PooledExecutor pooledExecutor
           
private  int port
           
private  LateralTCPListener.ListenerThread receiver
          The socket listener
 
Constructor Summary
protected LateralTCPListener(ILateralCacheAttributes ilca)
          Only need one since it does work for all regions, just reference by multiple region names.
 
Method Summary
protected  CompositeCache getCache(java.lang.String name)
          Gets the cacheManager attribute of the LateralCacheTCPListener object
static ILateralCacheListener getInstance(ILateralCacheAttributes ilca)
          Gets the instance attribute of the LateralCacheTCPListener class
 byte getListenerId()
          Gets the listenerId attribute of the LateralCacheTCPListener object
 void handleDispose(java.lang.String cacheName)
          Notifies the subscribers for freeing up the named cache.
 java.io.Serializable handleGet(java.lang.String cacheName, java.io.Serializable key)
           
 void handlePut(ICacheElement element)
          Notifies the subscribers for a cache entry update.
 void handleRemove(java.lang.String cacheName, java.io.Serializable key)
          Notifies the subscribers for a cache entry removal.
 void handleRemoveAll(java.lang.String cacheName)
          Notifies the subscribers for a cache remove-all.
 void init()
          Description of the Method
 void setListenerId(byte id)
          let the lateral cache set a listener_id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

acceptTimeOut

private static final int acceptTimeOut
How long the server will block on an accept(). 0 is infinte.

See Also:
Constant Field Values

cacheMgr

protected static transient CompositeCacheManager cacheMgr
The CacheHub this listener is associated with


instances

protected static final java.util.HashMap instances
Map of available instances, keyed by port


receiver

private LateralTCPListener.ListenerThread receiver
The socket listener


ilca

private ILateralCacheAttributes ilca

port

private int port

pooledExecutor

private EDU.oswego.cs.dl.util.concurrent.PooledExecutor pooledExecutor
Constructor Detail

LateralTCPListener

protected LateralTCPListener(ILateralCacheAttributes ilca)
Only need one since it does work for all regions, just reference by multiple region names.

Parameters:
ilca -
Method Detail

getInstance

public static ILateralCacheListener getInstance(ILateralCacheAttributes ilca)
Gets the instance attribute of the LateralCacheTCPListener class

Returns:
The instance value

init

public void init()
Description of the Method

Specified by:
init in interface ILateralCacheListener

setListenerId

public void setListenerId(byte id)
                   throws java.io.IOException
let the lateral 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 ICacheListener
Parameters:
id - The new listenerId value
Throws:
java.io.IOException

getListenerId

public byte getListenerId()
                   throws java.io.IOException
Gets the listenerId attribute of the LateralCacheTCPListener object

Specified by:
getListenerId in interface ICacheListener
Returns:
The listenerId value
Throws:
java.io.IOException

handlePut

public void handlePut(ICacheElement element)
               throws java.io.IOException
Description copied from interface: ICacheListener
Notifies the subscribers for a cache entry update.

Specified by:
handlePut in interface ICacheListener
Throws:
java.io.IOException

handleRemove

public void handleRemove(java.lang.String cacheName,
                         java.io.Serializable key)
                  throws java.io.IOException
Description copied from interface: ICacheListener
Notifies the subscribers for a cache entry removal.

Specified by:
handleRemove in interface ICacheListener
Throws:
java.io.IOException

handleRemoveAll

public void handleRemoveAll(java.lang.String cacheName)
                     throws java.io.IOException
Description copied from interface: ICacheListener
Notifies the subscribers for a cache remove-all.

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

handleGet

public java.io.Serializable handleGet(java.lang.String cacheName,
                                      java.io.Serializable key)
                               throws java.io.IOException
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
Throws:
java.io.IOException

getCache

protected CompositeCache getCache(java.lang.String name)
Gets the cacheManager attribute of the LateralCacheTCPListener object