Package com.adaptris.core.services.cache
Class AddValueToCache
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.services.cache.CacheServiceImpl
-
- com.adaptris.core.services.cache.SingleKeyCacheService
-
- com.adaptris.core.services.cache.SingleKeyValueCacheImpl
-
- com.adaptris.core.services.cache.AddValueToCache
-
- All Implemented Interfaces:
AdaptrisComponent,ComponentLifecycle,ComponentLifecycleExtension,ConnectedService,MessageEventGenerator,Service,StateManagedComponent
@ComponentProfile(summary="Add a single key/value to the configured cache cache", since="3.9.2", tag="service,cache", recommended=CacheConnection.class) public class AddValueToCache extends SingleKeyValueCacheImplVersion ofAddToCacheServicethat doesn't useCacheEntryEvaluator.Most of the time, you only want to add a single item to the cache rather than a list of items; this simplified service allows you to do just that. It does not have a list of entries that are evaluated, you simply specify a key and a
CacheValueTranslatorwhich is used to extract the value for storing in the cache; no checking is done of the resulting serializable-ness (or not) of the value, it is simply inserted into the cache.In the adapter configuration file this class is aliased as add-single-value-to-cache which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description AddValueToCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddoService(AdaptrisMessage msg)Apply the service to the message.java.lang.StringgetExpiry()voidsetExpiry(java.lang.String s)Set the cache expiry for any value added to the cache (if any).<T extends AddValueToCache>
TwithExpiry(java.lang.String s)-
Methods inherited from class com.adaptris.core.services.cache.SingleKeyValueCacheImpl
getValueTranslator, prepare, setValueTranslator, withValueTranslator
-
Methods inherited from class com.adaptris.core.services.cache.SingleKeyCacheService
getKey, setKey, withKey
-
Methods inherited from class com.adaptris.core.services.cache.CacheServiceImpl
closeService, getConnection, initService, retrieveCache, setConnection, start, stop, withConnection
-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
Methods inherited from interface com.adaptris.core.Service
continueOnFailure, isBranching, setUniqueId
-
Methods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
-
-
-
Method Detail
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
Description copied from interface:ServiceApply the service to the message.
- Parameters:
msg- theAdaptrisMessageto process- Throws:
ServiceException- wrapping any underlyingExceptions
-
withExpiry
public <T extends AddValueToCache> T withExpiry(java.lang.String s)
-
getExpiry
public java.lang.String getExpiry()
-
setExpiry
public void setExpiry(java.lang.String s)
Set the cache expiry for any value added to the cache (if any).The rules once the value has been resolved are :
- If the value is numeric and less than
System.currentTimeMillis()then it is treated as relative tonow(); expiry is in milliseconds - If the value is numberic and greater than
System.currentTimeMillis()then it is treated as absolute; expiry is in milliseconds - If the value is a recognised value from
DateFormatUtil.parse(String)then it is treated as absolute - If it can't be resolved by any of those means, then it is ignored (i.e. treated as though there is no expiry).
- Parameters:
s- the expiry, which supports the%message{}syntax to resolve metadata.
- If the value is numeric and less than
-
-