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

java.lang.Object
  extended by org.apache.jcs.auxiliary.lateral.socket.tcp.LateralTCPService
All Implemented Interfaces:
ILateralCacheObserver, ILateralCacheService, ICacheObserver, ICacheService

public class LateralTCPService
extends java.lang.Object
implements ILateralCacheService, ILateralCacheObserver

A lateral cache service implementation. Does not implement getGroupKey


Constructor Summary
LateralTCPService(ITCPLateralCacheAttributes lca)
          Constructor for the LateralTCPService object
 
Method Summary
 void addCacheListener(ICacheListener obj)
          Subscribes to all caches.
 void addCacheListener(java.lang.String cacheName, ICacheListener obj)
          Subscribes to the specified cache.
 void dispose(java.lang.String cacheName)
          Will close the connection.
 java.io.Serializable get(java.lang.String key)
          The service does not get via this method, so this return null.
 ICacheElement get(java.lang.String cacheName, java.io.Serializable key)
          Returns a cache bean from the specified cache; or null if the key does not exist.
 java.util.Set getGroupKeys(java.lang.String cacheName, java.lang.String group)
          Gets the set of keys of objects currently in the group throws UnsupportedOperationException
protected  long getListenerId()
           
 java.util.Map getMatching(java.lang.String cacheName, java.lang.String pattern)
          The service does not get via this method, so this return empty.
 java.util.Map getMultiple(java.lang.String cacheName, java.util.Set keys)
          Gets multiple items from the cache based on the given set of keys.
 ITCPLateralCacheAttributes getTcpLateralCacheAttributes()
           
static void main(java.lang.String[] args)
           
 void release()
          Does nothing.
 void remove(java.lang.String cacheName, java.io.Serializable key)
          Uses the default listener id and calls the next remove method.
 void remove(java.lang.String cacheName, java.io.Serializable key, long requesterId)
          Wraps the key in a LateralElementDescriptor.
 void removeAll(java.lang.String cacheName)
          Remove all keys from the sepcified cache.
 void removeAll(java.lang.String cacheName, long requesterId)
          Remove all keys from the sepcified cache.
 void removeCacheListener(ICacheListener obj)
          Unsubscribes from all caches.
 void removeCacheListener(java.lang.String cacheName, ICacheListener obj)
          Unsubscribes from the specified cache.
protected  void setListenerId(long listernId)
           
 void setTcpLateralCacheAttributes(ITCPLateralCacheAttributes tcpLateralCacheAttributes)
           
 void update(ICacheElement item)
          Puts a cache item to the cache.
 void update(ICacheElement item, long requesterId)
          If put is allowed, we will issue a put.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LateralTCPService

public LateralTCPService(ITCPLateralCacheAttributes lca)
                  throws java.io.IOException
Constructor for the LateralTCPService object

Parameters:
lca - ITCPLateralCacheAttributes
Throws:
java.io.IOException
Method Detail

update

public void update(ICacheElement item)
            throws java.io.IOException
Description copied from interface: ICacheService
Puts a cache item to the cache.

Specified by:
update in interface ICacheService
Parameters:
item -
Throws:
java.io.IOException

update

public void update(ICacheElement item,
                   long requesterId)
            throws java.io.IOException
If put is allowed, we will issue a put. If issue put on remove is configured, we will issue a remove. Either way, we create a lateral element descriptor, which is essentially a JCS TCP packet. It describes what operation the receiver should take when it gets the packet.

Specified by:
update in interface ILateralCacheService
Throws:
java.io.IOException
See Also:
ILateralCacheService.update(org.apache.jcs.engine.behavior.ICacheElement, long)

remove

public void remove(java.lang.String cacheName,
                   java.io.Serializable key)
            throws java.io.IOException
Uses the default listener id and calls the next remove method.

Specified by:
remove in interface ICacheService
Throws:
java.io.IOException
See Also:
ICacheService.remove(java.lang.String, java.io.Serializable)

remove

public void remove(java.lang.String cacheName,
                   java.io.Serializable key,
                   long requesterId)
            throws java.io.IOException
Wraps the key in a LateralElementDescriptor.

Specified by:
remove in interface ILateralCacheService
Throws:
java.io.IOException
See Also:
ILateralCacheService.remove(java.lang.String, java.io.Serializable, long)

release

public void release()
             throws java.io.IOException
Does nothing.
Specified by:
release in interface ICacheService
Throws:
java.io.IOException

dispose

public void dispose(java.lang.String cacheName)
             throws java.io.IOException
Will close the connection.

Specified by:
dispose in interface ICacheService
Parameters:
cacheName -
Throws:
java.io.IOException

get

public java.io.Serializable get(java.lang.String key)
                         throws java.io.IOException
The service does not get via this method, so this return null.

Parameters:
key -
Returns:
always null.
Throws:
java.io.IOException

get

public ICacheElement get(java.lang.String cacheName,
                         java.io.Serializable key)
                  throws java.io.IOException
Description copied from interface: ICacheService
Returns a cache bean from the specified cache; or null if the key does not exist.

Specified by:
get in interface ICacheService
Parameters:
cacheName -
key -
Returns:
ICacheElement if found.
Throws:
java.io.IOException

getMatching

public java.util.Map getMatching(java.lang.String cacheName,
                                 java.lang.String pattern)
                          throws java.io.IOException
The service does not get via this method, so this return empty.

Specified by:
getMatching in interface ILateralCacheService
Specified by:
getMatching in interface ICacheService
Parameters:
cacheName -
pattern -
Returns:
a map of Serializable key to ICacheElement element, or an empty map if there is no data in cache matching the pattern.
Throws:
java.io.IOException

getMultiple

public java.util.Map getMultiple(java.lang.String cacheName,
                                 java.util.Set keys)
                          throws java.io.IOException
Gets multiple items from the cache based on the given set of keys.

Specified by:
getMultiple in interface ICacheService
Parameters:
cacheName -
keys -
Returns:
a map of Serializable key to ICacheElement element, or an empty map if there is no data in cache for any of these keys
Throws:
java.io.IOException

getGroupKeys

public java.util.Set getGroupKeys(java.lang.String cacheName,
                                  java.lang.String group)
Gets the set of keys of objects currently in the group throws UnsupportedOperationException

Specified by:
getGroupKeys in interface ILateralCacheService
Parameters:
cacheName -
group -
Returns:
Set

removeAll

public void removeAll(java.lang.String cacheName)
               throws java.io.IOException
Description copied from interface: ICacheService
Remove all keys from the sepcified cache.

Specified by:
removeAll in interface ICacheService
Parameters:
cacheName -
Throws:
java.io.IOException

removeAll

public void removeAll(java.lang.String cacheName,
                      long requesterId)
               throws java.io.IOException
Description copied from interface: ILateralCacheService
Remove all keys from the sepcified cache.

Specified by:
removeAll in interface ILateralCacheService
Parameters:
cacheName -
requesterId -
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
Parameters:
args -

addCacheListener

public void addCacheListener(java.lang.String cacheName,
                             ICacheListener obj)
                      throws java.io.IOException
Description copied from interface: ICacheObserver
Subscribes to the specified cache.

Specified by:
addCacheListener in interface ICacheObserver
Parameters:
cacheName -
obj -
Throws:
java.io.IOException

addCacheListener

public void addCacheListener(ICacheListener obj)
                      throws java.io.IOException
Description copied from interface: ICacheObserver
Subscribes to all caches.

Specified by:
addCacheListener in interface ICacheObserver
Parameters:
obj -
Throws:
java.io.IOException

removeCacheListener

public void removeCacheListener(java.lang.String cacheName,
                                ICacheListener obj)
                         throws java.io.IOException
Description copied from interface: ICacheObserver
Unsubscribes from the specified cache.

Specified by:
removeCacheListener in interface ICacheObserver
Parameters:
cacheName -
obj -
Throws:
java.io.IOException

removeCacheListener

public void removeCacheListener(ICacheListener obj)
                         throws java.io.IOException
Description copied from interface: ICacheObserver
Unsubscribes from all caches.

Specified by:
removeCacheListener in interface ICacheObserver
Parameters:
obj -
Throws:
java.io.IOException

setListenerId

protected void setListenerId(long listernId)
Parameters:
listernId - The listernId to set.

getListenerId

protected long getListenerId()
Returns:
Returns the listernId.

setTcpLateralCacheAttributes

public void setTcpLateralCacheAttributes(ITCPLateralCacheAttributes tcpLateralCacheAttributes)
Parameters:
tcpLateralCacheAttributes - The tcpLateralCacheAttributes to set.

getTcpLateralCacheAttributes

public ITCPLateralCacheAttributes getTcpLateralCacheAttributes()
Returns:
Returns the tcpLateralCacheAttributes.


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