org.apache.camel.processor.idempotent
Class MemoryIdempotentRepository

java.lang.Object
  extended by org.apache.camel.processor.idempotent.MemoryIdempotentRepository
All Implemented Interfaces:
IdempotentRepository<String>

public class MemoryIdempotentRepository
extends Object
implements IdempotentRepository<String>

A memory based implementation of IdempotentRepository.

Care should be taken to use a suitable underlying Map to avoid this class being a memory leak.

Version:
$Revision: 723743 $

Constructor Summary
MemoryIdempotentRepository()
           
MemoryIdempotentRepository(Map<String,Object> set)
           
 
Method Summary
 boolean add(String messageId)
          Adds the key to the repository.
 boolean contains(String key)
          Returns true if this repository contains the specified element.
 Map<String,Object> getCache()
           
static IdempotentRepository<String> memoryIdempotentRepository()
          Creates a new memory based repository using a LRUCache with a default of 1000 entries in the cache.
static IdempotentRepository<String> memoryIdempotentRepository(int cacheSize)
          Creates a new memory based repository using a LRUCache.
static IdempotentRepository<String> memoryIdempotentRepository(Map<String,Object> cache)
          Creates a new memory based repository using the given Map to use to store the processed message ids.
 void setCache(Map<String,Object> cache)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryIdempotentRepository

public MemoryIdempotentRepository()

MemoryIdempotentRepository

public MemoryIdempotentRepository(Map<String,Object> set)
Method Detail

memoryIdempotentRepository

public static IdempotentRepository<String> memoryIdempotentRepository()
Creates a new memory based repository using a LRUCache with a default of 1000 entries in the cache.


memoryIdempotentRepository

public static IdempotentRepository<String> memoryIdempotentRepository(int cacheSize)
Creates a new memory based repository using a LRUCache.

Parameters:
cacheSize - the cache size

memoryIdempotentRepository

public static IdempotentRepository<String> memoryIdempotentRepository(Map<String,Object> cache)
Creates a new memory based repository using the given Map to use to store the processed message ids.

Care should be taken to use a suitable underlying Map to avoid this class being a memory leak.

Parameters:
cache - the cache

add

public boolean add(String messageId)
Description copied from interface: IdempotentRepository
Adds the key to the repository.

Specified by:
add in interface IdempotentRepository<String>
Parameters:
messageId - the key of the message for duplicate test
Returns:
true if this repository did not already contain the specified element

contains

public boolean contains(String key)
Description copied from interface: IdempotentRepository
Returns true if this repository contains the specified element.

Specified by:
contains in interface IdempotentRepository<String>
Parameters:
key - the key of the message
Returns:
true if this repository contains the specified element

getCache

public Map<String,Object> getCache()

setCache

public void setCache(Map<String,Object> cache)


Copyright © 2009 Apache Software Foundation. All Rights Reserved.