Class InlineItemCache
- java.lang.Object
-
- com.adaptris.core.fs.InlineItemCache
-
- All Implemented Interfaces:
ComponentLifecycle
,ProcessedItemCache
- Direct Known Subclasses:
MarshallingItemCache
public class InlineItemCache extends java.lang.Object implements ProcessedItemCache
In memory cache of items that have been processed.In the adapter configuration file this class is aliased as fs-inline-processed-item-cache which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,ProcessedItem>
cache
protected org.slf4j.Logger
logR
-
Constructor Summary
Constructors Constructor Description InlineItemCache()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear the cache.void
close()
Closes the component.boolean
contains(java.lang.String key)
Query the cache for this key.void
evict()
evict any items in the cache that require it..ProcessedItem
get(java.lang.String key)
Get the TrackedItem associated with the key.TimeInterval
getAgeBeforeEviction()
void
init()
Initialises the component.void
save()
Explicitly save the state of the cache.void
setAgeBeforeEviction(TimeInterval interval)
Specify the age of an entry in the cache before it is evicted.int
size()
Return the number of items in the cache.void
start()
Starts the component.void
stop()
Stop the componentvoid
update(ProcessedItem i)
Update the cache with the tracked item.void
update(ProcessedItemList list)
Update the cache with the associated list of entries.
-
-
-
Field Detail
-
cache
protected transient java.util.Map<java.lang.String,ProcessedItem> cache
-
logR
protected transient org.slf4j.Logger logR
-
-
Method Detail
-
contains
public boolean contains(java.lang.String key)
Description copied from interface:ProcessedItemCache
Query the cache for this key.- Specified by:
contains
in interfaceProcessedItemCache
- Parameters:
key
- the key- Returns:
- true if the item exists.
-
get
public ProcessedItem get(java.lang.String key)
Description copied from interface:ProcessedItemCache
Get the TrackedItem associated with the key.- Specified by:
get
in interfaceProcessedItemCache
- Parameters:
key
- the key- Returns:
- the TrackedItem or null if it does not exist.
-
update
public void update(ProcessedItem i)
Description copied from interface:ProcessedItemCache
Update the cache with the tracked item.- Specified by:
update
in interfaceProcessedItemCache
- Parameters:
i
- the tracked item.
-
clear
public void clear()
Description copied from interface:ProcessedItemCache
Clear the cache.- Specified by:
clear
in interfaceProcessedItemCache
-
size
public int size()
Description copied from interface:ProcessedItemCache
Return the number of items in the cache.- Specified by:
size
in interfaceProcessedItemCache
- Returns:
- the number of items in the cache.
-
close
public void close()
Description copied from interface:ComponentLifecycle
Closes the component.A closed component should release any connections it uses, etc. and clean up completely. Throwing a
RuntimeException
may cause unintended consequences- Specified by:
close
in interfaceComponentLifecycle
-
init
public void init() throws CoreException
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Specified by:
init
in interfaceComponentLifecycle
- Throws:
CoreException
- wrapping any underlyingException
s
-
start
public void start() throws CoreException
Description copied from interface:ComponentLifecycle
Starts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling start will begin message delivery.- Specified by:
start
in interfaceComponentLifecycle
- Throws:
CoreException
- wrapping any underlyingException
s
-
stop
public void stop()
Description copied from interface:ComponentLifecycle
Stop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling stop will pause message delivery. Throwing aRuntimeException
may cause unintended consequences- Specified by:
stop
in interfaceComponentLifecycle
-
save
public void save()
Description copied from interface:ProcessedItemCache
Explicitly save the state of the cache.- Specified by:
save
in interfaceProcessedItemCache
-
evict
public void evict()
Description copied from interface:ProcessedItemCache
evict any items in the cache that require it..- Specified by:
evict
in interfaceProcessedItemCache
-
update
public void update(ProcessedItemList list)
Description copied from interface:ProcessedItemCache
Update the cache with the associated list of entries.- Specified by:
update
in interfaceProcessedItemCache
- Parameters:
list
- a list of tracked items
-
getAgeBeforeEviction
public TimeInterval getAgeBeforeEviction()
-
setAgeBeforeEviction
public void setAgeBeforeEviction(TimeInterval interval)
Specify the age of an entry in the cache before it is evicted.- Parameters:
interval
- the time before eviction to set, default 12 hours
-
-