org.springframework.batch.retry.policy
Class MapRetryContextCache

java.lang.Object
  extended by org.springframework.batch.retry.policy.MapRetryContextCache
All Implemented Interfaces:
RetryContextCache

public class MapRetryContextCache
extends Object
implements RetryContextCache

Map-based implementation of RetryContextCache. The map backing the cache of contexts is synchronized.

Author:
Dave Syer

Field Summary
static int DEFAULT_CAPACITY
          Default value for maximum capacity of the cache.
 
Constructor Summary
MapRetryContextCache()
          Create a MapRetryContextCache with default capacity.
MapRetryContextCache(int defaultCapacity)
           
 
Method Summary
 boolean containsKey(Object key)
           
 RetryContext get(Object key)
           
 void put(Object key, RetryContext context)
           
 void remove(Object key)
           
 void setCapacity(int capacity)
          Public setter for the capacity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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
Constructor Detail

MapRetryContextCache

public MapRetryContextCache()
Create a MapRetryContextCache with default capacity.


MapRetryContextCache

public MapRetryContextCache(int defaultCapacity)
Parameters:
defaultCapacity -
Method Detail

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.