org.apache.jcs.auxiliary
Class AbstractAuxiliaryCache<K extends Serializable,V extends Serializable>

java.lang.Object
  extended by org.apache.jcs.auxiliary.AbstractAuxiliaryCache<K,V>
All Implemented Interfaces:
AuxiliaryCache<K,V>, ICache<K,V>, ICacheType
Direct Known Subclasses:
AbstractAuxiliaryCacheEventLogging, AbstractRemoteCacheNoWaitFacade, LateralCacheNoWait, LateralCacheNoWaitFacade, RemoteCacheNoWait

public abstract class AbstractAuxiliaryCache<K extends Serializable,V extends Serializable>
extends Object
implements AuxiliaryCache<K,V>

This holds convenience methods used by most auxiliary caches.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.jcs.engine.behavior.ICacheType
ICacheType.CacheType
 
Field Summary
protected  ICacheEventLogger cacheEventLogger
          An optional event logger
protected  IElementSerializer elementSerializer
          The serializer.
protected  IKeyMatcher<K> keyMatcher
          Key matcher used by the getMatching API
 
Constructor Summary
AbstractAuxiliaryCache()
           
 
Method Summary
protected  ICacheEvent<K> createICacheEvent(ICacheElement<K,V> item, String eventName)
          Logs an event if an event logger is configured.
protected
<T extends Serializable>
ICacheEvent<T>
createICacheEvent(String regionName, T key, String eventName)
          Logs an event if an event logger is configured.
 ICacheEventLogger getCacheEventLogger()
          Allows it to be injected.
 IElementSerializer getElementSerializer()
          Allows it to be injected.
abstract  String getEventLoggingExtraInfo()
          Gets the extra info for the event log.
 IKeyMatcher<K> getKeyMatcher()
          Returns the key matcher used by get matching.
protected  void logApplicationEvent(String source, String eventName, String optionalDetails)
          Logs an event if an event logger is configured.
protected  void logError(String source, String eventName, String errorMessage)
          Logs an event if an event logger is configured.
protected
<T extends Serializable>
void
logICacheEvent(ICacheEvent<T> cacheEvent)
          Logs an event if an event logger is configured.
 void setCacheEventLogger(ICacheEventLogger cacheEventLogger)
          Allows it to be injected.
 void setElementSerializer(IElementSerializer elementSerializer)
          Allows you to inject a custom serializer.
 void setKeyMatcher(IKeyMatcher<K> keyMatcher)
          Sets the key matcher used by get matching.
 
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.auxiliary.AuxiliaryCache
getAuxiliaryCacheAttributes, getGroupKeys, getGroupNames, getStatistics
 
Methods inherited from interface org.apache.jcs.engine.behavior.ICache
dispose, get, getCacheName, getMatching, getMultiple, getSize, getStats, getStatus, remove, removeAll, update
 
Methods inherited from interface org.apache.jcs.engine.behavior.ICacheType
getCacheType
 

Field Detail

cacheEventLogger

protected ICacheEventLogger cacheEventLogger
An optional event logger


elementSerializer

protected IElementSerializer elementSerializer
The serializer. Uses a standard serializer by default.


keyMatcher

protected IKeyMatcher<K extends Serializable> keyMatcher
Key matcher used by the getMatching API

Constructor Detail

AbstractAuxiliaryCache

public AbstractAuxiliaryCache()
Method Detail

createICacheEvent

protected ICacheEvent<K> createICacheEvent(ICacheElement<K,V> item,
                                           String eventName)
Logs an event if an event logger is configured.

Parameters:
item -
eventName -
Returns:
ICacheEvent

createICacheEvent

protected <T extends Serializable> ICacheEvent<T> createICacheEvent(String regionName,
                                                                    T key,
                                                                    String eventName)
Logs an event if an event logger is configured.

Parameters:
regionName -
key -
eventName -
Returns:
ICacheEvent

logICacheEvent

protected <T extends Serializable> void logICacheEvent(ICacheEvent<T> cacheEvent)
Logs an event if an event logger is configured.

Parameters:
cacheEvent -

logApplicationEvent

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

Parameters:
source -
eventName -
optionalDetails -

logError

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

Parameters:
source -
eventName -
errorMessage -

getEventLoggingExtraInfo

public abstract String getEventLoggingExtraInfo()
Gets the extra info for the event log.

Returns:
IP, or disk location, etc.

setCacheEventLogger

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

Specified by:
setCacheEventLogger in interface AuxiliaryCache<K extends Serializable,V extends Serializable>
Parameters:
cacheEventLogger -

getCacheEventLogger

public ICacheEventLogger getCacheEventLogger()
Allows it to be injected.

Returns:
cacheEventLogger

setElementSerializer

public void setElementSerializer(IElementSerializer elementSerializer)
Allows you to inject a custom serializer. A good example would be a compressing standard serializer.

Does not allow you to set it to null.

Specified by:
setElementSerializer in interface AuxiliaryCache<K extends Serializable,V extends Serializable>
Parameters:
elementSerializer -

getElementSerializer

public IElementSerializer getElementSerializer()
Allows it to be injected.

Returns:
elementSerializer

setKeyMatcher

public void setKeyMatcher(IKeyMatcher<K> keyMatcher)
Sets the key matcher used by get matching.

Specified by:
setKeyMatcher in interface ICache<K extends Serializable,V extends Serializable>
Parameters:
keyMatcher -

getKeyMatcher

public IKeyMatcher<K> getKeyMatcher()
Returns the key matcher used by get matching.

Returns:
keyMatcher


Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.