org.springframework.batch.retry.policy
Class SoftReferenceMapRetryContextCache
java.lang.Object
org.springframework.batch.retry.policy.SoftReferenceMapRetryContextCache
- All Implemented Interfaces:
- RetryContextCache
public class SoftReferenceMapRetryContextCache
- extends Object
- implements RetryContextCache
Map-based implementation of RetryContextCache
. The map backing the
cache of contexts is synchronized and its entries are soft-referenced, so may
be garbage collected under pressure.
- Author:
- Dave Syer
- See Also:
for non-soft referenced version
Field Summary |
static int |
DEFAULT_CAPACITY
Default value for maximum capacity of the cache. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITY
- Default value for maximum capacity of the cache. This is set to a
reasonably low value (4096) to avoid users inadvertently filling the
cache with item keys that are inconsistent.
- See Also:
- Constant Field Values
SoftReferenceMapRetryContextCache
public SoftReferenceMapRetryContextCache()
- Create a
SoftReferenceMapRetryContextCache
with default capacity.
SoftReferenceMapRetryContextCache
public SoftReferenceMapRetryContextCache(int defaultCapacity)
- Parameters:
defaultCapacity
-
setCapacity
public void setCapacity(int capacity)
- Public setter for the capacity. Prevents the cache from growing
unboundedly if items that fail are misidentified and two references to an
identical item actually do not have the same key. This can happen when
users implement equals and hashCode based on mutable fields, for
instance.
- Parameters:
capacity
- the capacity to set
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interface RetryContextCache
get
public RetryContext get(Object key)
- Specified by:
get
in interface RetryContextCache
put
public void put(Object key,
RetryContext context)
- Specified by:
put
in interface RetryContextCache
remove
public void remove(Object key)
- Specified by:
remove
in interface RetryContextCache
Copyright © 2013 SpringSource. All Rights Reserved.