org.mule.util.store
Class InMemoryObjectStore

java.lang.Object
  extended by org.mule.util.store.AbstractMonitoredObjectStore
      extended by org.mule.util.store.InMemoryObjectStore
All Implemented Interfaces:
Runnable, MuleContextAware, Disposable, Initialisable, ObjectStore
Direct Known Subclasses:
TextFileObjectStore

public class InMemoryObjectStore
extends AbstractMonitoredObjectStore

InMemoryObjectStore implements an optionally bounded in-memory store for message IDs with periodic expiry of old entries. The bounded size is a soft limit and only enforced periodically by the expiry process; this means that the store may temporarily exceed its maximum size between expiry runs, but will eventually shrink to its configured size.DO


Nested Class Summary
protected static class InMemoryObjectStore.StoredObject
          Represents the object stored in the store.
 
Field Summary
protected  edu.emory.mathcs.backport.java.util.concurrent.ConcurrentSkipListMap store
           
 
Fields inherited from class org.mule.util.store.AbstractMonitoredObjectStore
context, entryTTL, expirationInterval, logger, maxEntries, name, scheduler
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
InMemoryObjectStore()
           
 
Method Summary
 boolean containsObject(String id)
          Check whether the given Object is already registered with this store.
 void expire()
           
 boolean removeObject(String id)
           
 Object retrieveObject(String id)
          Retrieve the given Object.
 boolean storeObject(String id, Object item)
          Store the given Object.
 
Methods inherited from class org.mule.util.store.AbstractMonitoredObjectStore
dispose, getEntryTTL, getExpirationInterval, getMaxEntries, getName, getScheduler, initialise, run, setEntryTTL, setExpirationInterval, setMaxEntries, setMuleContext, setName, setScheduler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

store

protected edu.emory.mathcs.backport.java.util.concurrent.ConcurrentSkipListMap store
Constructor Detail

InMemoryObjectStore

public InMemoryObjectStore()
Method Detail

containsObject

public boolean containsObject(String id)
                       throws Exception
Check whether the given Object is already registered with this store.

Parameters:
id - the ID to check
Returns:
true if the ID is stored or false if it could not be found
Throws:
IllegalArgumentException - if the given ID is null
Exception - if any implementation-specific error occured, e.g. when the store is not available

storeObject

public boolean storeObject(String id,
                           Object item)
                    throws Exception
Store the given Object.

Parameters:
id - the ID to store
item - the Object to store with the id
Returns:
true if the ID was stored properly, or false if it already existed
Throws:
IllegalArgumentException - if the given ID cannot be stored or is null
Exception - if the store is not available or any other implementation-specific error occured

retrieveObject

public Object retrieveObject(String id)
                      throws Exception
Retrieve the given Object.

Parameters:
id - the ID to store
Returns:
the object instance associated with this id or null if there was no entry for the supplied id.
Throws:
IllegalArgumentException - if the given ID cannot be stored or is null
Exception - if the store is not available or any other implementation-specific error occured

removeObject

public boolean removeObject(String id)
                     throws Exception
Throws:
Exception

expire

public final void expire()
Specified by:
expire in class AbstractMonitoredObjectStore


Copyright © 2003-2009 MuleSource, Inc.. All Rights Reserved.