org.apache.jcs.auxiliary.remote.http.server
Class AbstractRemoteCacheService

java.lang.Object
  extended by org.apache.jcs.auxiliary.remote.http.server.AbstractRemoteCacheService
All Implemented Interfaces:
Remote, IRemoteCacheService, ICacheService, ICacheServiceNonLocal
Direct Known Subclasses:
RemoteHttpCacheService

public abstract class AbstractRemoteCacheService
extends Object
implements IRemoteCacheService

This class contains common methods for remote cache services. Eventually I hope to extract out much of the RMI server to use this as well. I'm starting with the Http service.


Constructor Summary
AbstractRemoteCacheService(ICompositeCacheManager cacheManager, ICacheEventLogger cacheEventLogger)
          Creates the super with the needed items.
 
Method Summary
protected  ICacheEvent createICacheEvent(ICacheElement item, long requesterId, String eventName)
          Logs an event if an event logger is configured.
protected  ICacheEvent createICacheEvent(String cacheName, Serializable key, long requesterId, String eventName)
          Logs an event if an event logger is configured.
 void dispose(String cacheName)
          Frees the specified remote cache.
 void dispose(String cacheName, long requesterId)
          Frees the specified remote cache.
 ICacheElement get(String cacheName, Serializable key)
          Returns a cache value from the specified remote cache; or null if the cache or key does not exist.
 ICacheElement get(String cacheName, Serializable key, long requesterId)
          Returns a cache bean from the specified cache; or null if the key does not exist.
protected  ICompositeCacheManager getCacheManager()
           
protected  String getEventLogSourceName()
           
protected abstract  String getExtraInfoForRequesterId(long requesterId)
          Ip address for the client, if one is stored.
 Set getGroupKeys(String cacheName, String group)
          Gets the set of keys of objects currently in the group.
 Map getMatching(String cacheName, String pattern)
          Gets all matching items.
 Map getMatching(String cacheName, String pattern, long requesterId)
          Retrieves all matching keys.
 Map getMultiple(String cacheName, Set keys)
          Gets multiple items from the cache based on the given set of keys.
 Map getMultiple(String cacheName, Set keys, long requesterId)
          Gets multiple items from the cache based on the given set of keys.
 String getStats()
          Gets the stats attribute of the RemoteCacheServer object.
protected  void logApplicationEvent(String source, String eventName, String optionalDetails)
          Logs an event if an event logger is configured.
protected  void logICacheEvent(ICacheEvent cacheEvent)
          Logs an event if an event logger is configured.
 Set processGetGroupKeys(String cacheName, String groupName)
          Gets the set of keys of objects currently in the group.
 void remove(String cacheName, Serializable key)
          Removes the given key from the specified remote cache.
 void remove(String cacheName, Serializable key, long requesterId)
          Remove the key from the cache region and don't tell the source listener about it.
 void removeAll(String cacheName)
          Remove all keys from the specified remote cache.
 void removeAll(String cacheName, long requesterId)
          Remove all keys from the specified remote cache.
 void setCacheEventLogger(ICacheEventLogger cacheEventLogger)
          Allows it to be injected.
protected  void setCacheManager(CompositeCacheManager cacheManager)
           
protected  void setEventLogSourceName(String eventLogSourceName)
           
 void update(ICacheElement item)
          Puts a cache item to the cache.
 void update(ICacheElement item, long requesterId)
          The internal processing is wrapped in event logging calls.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jcs.engine.behavior.ICacheService
release
 

Constructor Detail

AbstractRemoteCacheService

public AbstractRemoteCacheService(ICompositeCacheManager cacheManager,
                                  ICacheEventLogger cacheEventLogger)
Creates the super with the needed items.

Parameters:
cacheManager -
cacheEventLogger -
Method Detail

update

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

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

update

public void update(ICacheElement item,
                   long requesterId)
            throws IOException
The internal processing is wrapped in event logging calls.

Specified by:
update in interface ICacheServiceNonLocal
Parameters:
item -
requesterId -
Throws:
IOException

get

public ICacheElement get(String cacheName,
                         Serializable key)
                  throws IOException
Returns a cache value from the specified remote cache; or null if the cache or key does not exist.

Specified by:
get in interface ICacheService
Parameters:
cacheName -
key -
Returns:
ICacheElement
Throws:
IOException

get

public ICacheElement get(String cacheName,
                         Serializable key,
                         long requesterId)
                  throws IOException
Returns a cache bean from the specified cache; or null if the key does not exist.

Adding the requestor id, allows the cache to determine the source of the get.

The internal processing is wrapped in event logging calls.

Specified by:
get in interface ICacheServiceNonLocal
Parameters:
cacheName -
key -
requesterId -
Returns:
ICacheElement
Throws:
IOException

getMatching

public Map getMatching(String cacheName,
                       String pattern)
                throws IOException
Gets all matching items.

Specified by:
getMatching in interface ICacheService
Parameters:
cacheName -
pattern -
Returns:
Map of keys and wrapped objects
Throws:
IOException

getMatching

public Map getMatching(String cacheName,
                       String pattern,
                       long requesterId)
                throws IOException
Retrieves all matching keys.

Specified by:
getMatching in interface ICacheServiceNonLocal
Parameters:
cacheName -
pattern -
requesterId -
Returns:
Map of keys and wrapped objects
Throws:
IOException

getMultiple

public Map getMultiple(String cacheName,
                       Set keys)
                throws 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:
IOException

getMultiple

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

The internal processing is wrapped in event logging calls.

Specified by:
getMultiple in interface ICacheServiceNonLocal
Parameters:
cacheName -
keys -
requesterId -
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:
IOException

getGroupKeys

public Set getGroupKeys(String cacheName,
                        String group)
Gets the set of keys of objects currently in the group.

Specified by:
getGroupKeys in interface ICacheServiceNonLocal
Parameters:
cacheName -
group -
Returns:
A Set of group keys

processGetGroupKeys

public Set processGetGroupKeys(String cacheName,
                               String groupName)
Gets the set of keys of objects currently in the group.

Parameters:
cacheName -
groupName -
Returns:
Set

remove

public void remove(String cacheName,
                   Serializable key)
            throws IOException
Removes the given key from the specified remote cache. Defaults the listener id to 0.

Specified by:
remove in interface ICacheService
Parameters:
cacheName -
key -
Throws:
IOException

remove

public void remove(String cacheName,
                   Serializable key,
                   long requesterId)
            throws IOException
Remove the key from the cache region and don't tell the source listener about it.

The internal processing is wrapped in event logging calls.

Specified by:
remove in interface ICacheServiceNonLocal
Parameters:
cacheName -
key -
requesterId -
Throws:
IOException

removeAll

public void removeAll(String cacheName)
               throws IOException
Remove all keys from the specified remote cache.

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

removeAll

public void removeAll(String cacheName,
                      long requesterId)
               throws IOException
Remove all keys from the specified remote cache.

The internal processing is wrapped in event logging calls.

Specified by:
removeAll in interface ICacheServiceNonLocal
Parameters:
cacheName -
requesterId -
Throws:
IOException

dispose

public void dispose(String cacheName)
             throws IOException
Frees the specified remote cache.

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

dispose

public void dispose(String cacheName,
                    long requesterId)
             throws IOException
Frees the specified remote cache.

Parameters:
cacheName -
requesterId -
Throws:
IOException

getStats

public String getStats()
                throws IOException
Gets the stats attribute of the RemoteCacheServer object.

Returns:
The stats value
Throws:
IOException

createICacheEvent

protected ICacheEvent createICacheEvent(ICacheElement item,
                                        long requesterId,
                                        String eventName)
Logs an event if an event logger is configured.

Parameters:
item -
requesterId -
eventName -
Returns:
ICacheEvent

createICacheEvent

protected ICacheEvent createICacheEvent(String cacheName,
                                        Serializable key,
                                        long requesterId,
                                        String eventName)
Logs an event if an event logger is configured.

Parameters:
cacheName -
key -
requesterId -
eventName -
Returns:
ICacheEvent

logApplicationEvent

protected void logApplicationEvent(String source,
                                   String eventName,
                                   String optionalDetails)
Logs an event if an event logger is configured.

Parameters:
source -
eventName -
optionalDetails -

logICacheEvent

protected void logICacheEvent(ICacheEvent cacheEvent)
Logs an event if an event logger is configured.

Parameters:
cacheEvent -

getExtraInfoForRequesterId

protected abstract String getExtraInfoForRequesterId(long requesterId)
Ip address for the client, if one is stored.

Protected for testing.

Parameters:
requesterId -
Returns:
String

setCacheEventLogger

public void setCacheEventLogger(ICacheEventLogger cacheEventLogger)
Allows it to be injected.

Parameters:
cacheEventLogger -

setCacheManager

protected void setCacheManager(CompositeCacheManager cacheManager)
Parameters:
cacheManager - the cacheManager to set

getCacheManager

protected ICompositeCacheManager getCacheManager()
Returns:
the cacheManager

setEventLogSourceName

protected void setEventLogSourceName(String eventLogSourceName)
Parameters:
eventLogSourceName - the eventLogSourceName to set

getEventLogSourceName

protected String getEventLogSourceName()
Returns:
the eventLogSourceName


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