Class AbstractRemoteCacheService<K,V> 
java.lang.Object
org.apache.commons.jcs3.auxiliary.remote.http.server.AbstractRemoteCacheService<K,V> 
- All Implemented Interfaces:
- Remote,- ICacheService<K,,- V> - ICacheServiceNonLocal<K,- V> 
- Direct Known Subclasses:
- RemoteHttpCacheService
public abstract class AbstractRemoteCacheService<K,V> 
extends Object
implements ICacheServiceNonLocal<K,V> 
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 SummaryConstructorsConstructorDescriptionAbstractRemoteCacheService(ICompositeCacheManager cacheManager, ICacheEventLogger cacheEventLogger) Creates the super with the needed items.
- 
Method SummaryModifier and TypeMethodDescriptionprotected <T> ICacheEvent<T>createICacheEvent(String cacheName, T key, long requesterId, String eventName) Logs an event if an event logger is configured.protected ICacheEvent<ICacheElement<K,V>> createICacheEvent(ICacheElement<K, V> item, long requesterId, String eventName) Logs an event if an event logger is configured.voidFrees the specified remote cache.voidFrees the specified remote cache.Returns a cache value from the specified remote cache; or null if the cache or key does not exist.Returns a cache bean from the specified cache; or null if the key does not exist.protected ICompositeCacheManagerprotected Stringprotected abstract StringgetExtraInfoForRequesterId(long requesterId) Ip address for the client, if one is stored.Return the keys in this cache.Map<K,ICacheElement<K, V>> getMatching(String cacheName, String pattern) Gets all matching items.Map<K,ICacheElement<K, V>> getMatching(String cacheName, String pattern, long requesterId) Retrieves all matching keys.Map<K,ICacheElement<K, V>> getMultiple(String cacheName, Set<K> keys) Gets multiple items from the cache based on the given set of keys.Map<K,ICacheElement<K, V>> getMultiple(String cacheName, Set<K> keys, long requesterId) Gets multiple items from the cache based on the given set of keys.getStats()Gets the stats attribute of the RemoteCacheServer object.protected voidlogApplicationEvent(String source, String eventName, String optionalDetails) Logs an event if an event logger is configured.protected <T> voidlogICacheEvent(ICacheEvent<T> cacheEvent) Logs an event if an event logger is configured.processGetKeySet(String cacheName) Gets the set of keys of objects currently in the cache.voidRemoves the given key from the specified remote cache.voidRemove the key from the cache region and don't tell the source listener about it.voidRemove all keys from the specified remote cache.voidRemove all keys from the specified remote cache.voidsetCacheEventLogger(ICacheEventLogger cacheEventLogger) Allows it to be injected.protected voidsetCacheManager(ICompositeCacheManager cacheManager) protected voidsetEventLogSourceName(String eventLogSourceName) voidupdate(ICacheElement<K, V> item) Puts a cache item to the cache.voidupdate(ICacheElement<K, V> item, long requesterId) The internal processing is wrapped in event logging calls.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.jcs3.engine.behavior.ICacheServicerelease
- 
Constructor Details- 
AbstractRemoteCacheServicepublic AbstractRemoteCacheService(ICompositeCacheManager cacheManager, ICacheEventLogger cacheEventLogger) Creates the super with the needed items.- Parameters:
- cacheManager-
- cacheEventLogger-
 
 
- 
- 
Method Details- 
updateDescription copied from interface:ICacheServicePuts a cache item to the cache.- Specified by:
- updatein interface- ICacheService<K,- V> 
- Parameters:
- item-
- Throws:
- IOException
 
- 
updateThe internal processing is wrapped in event logging calls.- Specified by:
- updatein interface- ICacheServiceNonLocal<K,- V> 
- Parameters:
- item-
- requesterId-
- Throws:
- IOException
 
- 
getReturns a cache value from the specified remote cache; or null if the cache or key does not exist.- Specified by:
- getin interface- ICacheService<K,- V> 
- Parameters:
- cacheName-
- key-
- Returns:
- ICacheElement
- Throws:
- IOException
 
- 
getReturns 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:
- getin interface- ICacheServiceNonLocal<K,- V> 
- Parameters:
- cacheName-
- key-
- requesterId-
- Returns:
- ICacheElement
- Throws:
- IOException
 
- 
getMatchingGets all matching items.- Specified by:
- getMatchingin interface- ICacheService<K,- V> 
- Parameters:
- cacheName-
- pattern-
- Returns:
- Map of keys and wrapped objects
- Throws:
- IOException
 
- 
getMatchingpublic Map<K,ICacheElement<K, getMatchingV>> (String cacheName, String pattern, long requesterId) throws IOException Retrieves all matching keys.- Specified by:
- getMatchingin interface- ICacheServiceNonLocal<K,- V> 
- Parameters:
- cacheName-
- pattern-
- requesterId-
- Returns:
- Map of keys and wrapped objects
- Throws:
- IOException
 
- 
getMultipleGets multiple items from the cache based on the given set of keys.- Specified by:
- getMultiplein interface- ICacheService<K,- V> 
- Parameters:
- cacheName-
- keys-
- Returns:
- a map of K key to ICacheElement<K, V> element, or an empty map if there is no data in cache for any of these keys
- Throws:
- IOException
 
- 
getMultiplepublic Map<K,ICacheElement<K, getMultipleV>> (String cacheName, Set<K> 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:
- getMultiplein interface- ICacheServiceNonLocal<K,- V> 
- Parameters:
- cacheName-
- keys-
- requesterId-
- Returns:
- a map of K key to ICacheElement<K, V> element, or an empty map if there is no data in cache for any of these keys
- Throws:
- IOException
 
- 
getKeySetReturn the keys in this cache.- Specified by:
- getKeySetin interface- ICacheServiceNonLocal<K,- V> 
- Parameters:
- cacheName- the name of the cache
- Returns:
- a set of the key type TODO This should probably be done in chunks with a range passed in. This will be a problem if someone puts a 1,000,000 or so items in a region.
- See Also:
 
- 
processGetKeySetGets the set of keys of objects currently in the cache.- Parameters:
- cacheName-
- Returns:
- Set
 
- 
removeRemoves the given key from the specified remote cache. Defaults the listener id to 0.- Specified by:
- removein interface- ICacheService<K,- V> 
- Parameters:
- cacheName-
- key-
- Throws:
- IOException
 
- 
removeRemove 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:
- removein interface- ICacheServiceNonLocal<K,- V> 
- Parameters:
- cacheName-
- key-
- requesterId-
- Throws:
- IOException
 
- 
removeAllRemove all keys from the specified remote cache.- Specified by:
- removeAllin interface- ICacheService<K,- V> 
- Parameters:
- cacheName-
- Throws:
- IOException
 
- 
removeAllRemove all keys from the specified remote cache.The internal processing is wrapped in event logging calls. - Specified by:
- removeAllin interface- ICacheServiceNonLocal<K,- V> 
- Parameters:
- cacheName-
- requesterId-
- Throws:
- IOException
 
- 
disposeFrees the specified remote cache.- Specified by:
- disposein interface- ICacheService<K,- V> 
- Parameters:
- cacheName-
- Throws:
- IOException
 
- 
disposeFrees the specified remote cache.- Parameters:
- cacheName-
- requesterId-
- Throws:
- IOException
 
- 
getStatsGets the stats attribute of the RemoteCacheServer object.- Returns:
- The stats value
- Throws:
- IOException
 
- 
createICacheEventprotected ICacheEvent<ICacheElement<K,V>> createICacheEvent(ICacheElement<K, V> item, long requesterId, String eventName) Logs an event if an event logger is configured.- Parameters:
- item-
- requesterId-
- eventName-
- Returns:
- ICacheEvent
 
- 
createICacheEventprotected <T> ICacheEvent<T> createICacheEvent(String cacheName, T key, long requesterId, String eventName) Logs an event if an event logger is configured.- Parameters:
- cacheName-
- key-
- requesterId-
- eventName-
- Returns:
- ICacheEvent
 
- 
logApplicationEventLogs an event if an event logger is configured.- Parameters:
- source-
- eventName-
- optionalDetails-
 
- 
logICacheEventLogs an event if an event logger is configured.- Parameters:
- cacheEvent-
 
- 
getExtraInfoForRequesterIdIp address for the client, if one is stored.Protected for testing. - Parameters:
- requesterId-
- Returns:
- String
 
- 
setCacheEventLoggerAllows it to be injected.- Parameters:
- cacheEventLogger-
 
- 
setCacheManager- Parameters:
- cacheManager- the cacheManager to set
 
- 
getCacheManager- Returns:
- the cacheManager
 
- 
setEventLogSourceName- Parameters:
- eventLogSourceName- the eventLogSourceName to set
 
- 
getEventLogSourceName- Returns:
- the eventLogSourceName
 
 
-