org.apache.jcs.auxiliary.remote
Class RemoteCache

java.lang.Object
  extended byorg.apache.jcs.auxiliary.remote.RemoteCache
All Implemented Interfaces:
ICache, ICacheType, java.io.Serializable

public class RemoteCache
extends java.lang.Object
implements ICache

Client proxy for an RMI remote cache.

Author:
asmuts
See Also:
Serialized Form

Field Summary
(package private)  IElementAttributes attr
           
(package private)  java.lang.String cacheName
           
private  IRemoteCacheAttributes irca
           
private static org.apache.commons.logging.Log log
           
private  IRemoteCacheService remote
           
 
Fields inherited from interface org.apache.jcs.engine.behavior.ICacheType
CACHE_HUB, DISK_CACHE, LATERAL_CACHE, REMOTE_CACHE
 
Constructor Summary
RemoteCache(IRemoteCacheAttributes cattr, IRemoteCacheService remote)
          Constructor for the RemoteCache object
 
Method Summary
 void dispose()
          Synchronously dispose the remote cache; if failed, replace the remote handle with a zombie.
 void fixCache(IRemoteCacheService remote)
          Replaces the current remote cache service handle with the given handle.
 ICacheElement get(java.io.Serializable key)
          Synchronously get from the remote cache; if failed, replace the remote handle with a zombie.
 java.lang.String getCacheName()
          Gets the cacheName attribute of the RemoteCache object
 int getCacheType()
          Gets the cacheType attribute of the RemoteCache object
 IElementAttributes getElementAttributes()
          Gets the attributes attribute of the RemoteCache object
 java.util.Set getGroupKeys(java.lang.String groupName)
           
 int getSize()
          Returns the current cache size.
 java.lang.String getStats()
          Gets the stats attribute of the RemoteCache object
 int getStatus()
          Returns the cache status.
private  void handleException(java.lang.Exception ex, java.lang.String msg)
          Handles exception by disabling the remote cache service before re-throwing the exception in the form of an IOException.
 boolean remove(java.io.Serializable key)
          Synchronously remove from the remote cache; if failed, replace the remote handle with a zombie.
 void removeAll()
          Synchronously removeAll from the remote cache; if failed, replace the remote handle with a zombie.
private  java.io.Serializable sanitized(java.io.Serializable s)
          Wraps a non JDK object into a MarshalledObject, so that we can avoid unmarshalling the real object on the remote side.
 void setElementAttributes(IElementAttributes attr)
          Sets the attributes attribute of the RemoteCache object
 java.lang.String toString()
          Description of the Method
 void update(ICacheElement ce)
          Description of the Method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

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

cacheName

final java.lang.String cacheName

remote

private IRemoteCacheService remote

irca

private IRemoteCacheAttributes irca

attr

IElementAttributes attr
Constructor Detail

RemoteCache

public RemoteCache(IRemoteCacheAttributes cattr,
                   IRemoteCacheService remote)
Constructor for the RemoteCache object

Parameters:
cattr -
remote -
Method Detail

toString

public java.lang.String toString()
Description of the Method


setElementAttributes

public void setElementAttributes(IElementAttributes attr)
Sets the attributes attribute of the RemoteCache object

Parameters:
attr - The new attributes value

getElementAttributes

public IElementAttributes getElementAttributes()
Gets the attributes attribute of the RemoteCache object

Returns:
The attributes value

update

public void update(ICacheElement ce)
            throws java.io.IOException
Description of the Method

Specified by:
update in interface ICache
Throws:
java.io.IOException

get

public ICacheElement get(java.io.Serializable key)
                  throws java.io.IOException
Synchronously get from the remote cache; if failed, replace the remote handle with a zombie.

Specified by:
get in interface ICache
Throws:
java.io.IOException

getGroupKeys

public java.util.Set getGroupKeys(java.lang.String groupName)
                           throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

sanitized

private java.io.Serializable sanitized(java.io.Serializable s)
                                throws java.io.IOException
Wraps a non JDK object into a MarshalledObject, so that we can avoid unmarshalling the real object on the remote side. This technique offers the benefit of surviving incompatible class versions without the need to restart the remote cache server.

Throws:
java.io.IOException

remove

public boolean remove(java.io.Serializable key)
               throws java.io.IOException
Synchronously remove from the remote cache; if failed, replace the remote handle with a zombie.

Specified by:
remove in interface ICache
Throws:
java.io.IOException

removeAll

public void removeAll()
               throws java.io.IOException
Synchronously removeAll from the remote cache; if failed, replace the remote handle with a zombie.

Specified by:
removeAll in interface ICache
Throws:
java.io.IOException

dispose

public void dispose()
             throws java.io.IOException
Synchronously dispose the remote cache; if failed, replace the remote handle with a zombie.

Specified by:
dispose in interface ICache
Throws:
java.io.IOException

getStatus

public int getStatus()
Returns the cache status. An error status indicates the remote connection is not available.

Specified by:
getStatus in interface ICache
Returns:
The status value

getStats

public java.lang.String getStats()
Gets the stats attribute of the RemoteCache object

Returns:
The stats value

getSize

public int getSize()
Returns the current cache size.

Specified by:
getSize in interface ICache
Returns:
The size value

getCacheType

public int getCacheType()
Gets the cacheType attribute of the RemoteCache object

Specified by:
getCacheType in interface ICacheType
Returns:
The cacheType value

getCacheName

public java.lang.String getCacheName()
Gets the cacheName attribute of the RemoteCache object

Specified by:
getCacheName in interface ICache
Returns:
The cacheName value

fixCache

public void fixCache(IRemoteCacheService remote)
Replaces the current remote cache service handle with the given handle.


handleException

private void handleException(java.lang.Exception ex,
                             java.lang.String msg)
                      throws java.io.IOException
Handles exception by disabling the remote cache service before re-throwing the exception in the form of an IOException.

Throws:
java.io.IOException