org.mule.util.store
Class InMemoryObjectStore<T extends Serializable>

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

public class InMemoryObjectStore<T extends Serializable>
extends AbstractMonitoredObjectStore<T>

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.


Nested Class Summary
protected static class InMemoryObjectStore.StoredObject<T>
          Represents the object stored in the store.
 
Field Summary
protected  ConcurrentSkipListMap<Long,InMemoryObjectStore.StoredObject<T>> 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 contains(Serializable key)
          Check whether the given Object is already registered with this store.
 void expire()
           
 boolean isPersistent()
          Is this store persistent?
 T remove(Serializable key)
          Remove the object with key.
 T retrieve(Serializable key)
          Retrieve the given Object.
 void store(Serializable id, T value)
          Store the given Object.
 String toString()
           
 
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, wait, wait, wait
 

Field Detail

store

protected ConcurrentSkipListMap<Long,InMemoryObjectStore.StoredObject<T extends Serializable>> store
Constructor Detail

InMemoryObjectStore

public InMemoryObjectStore()
Method Detail

isPersistent

public boolean isPersistent()
Description copied from interface: ObjectStore
Is this store persistent?

Returns:
true if this store is persistent

contains

public boolean contains(Serializable key)
                 throws ObjectStoreException
Description copied from interface: ObjectStore
Check whether the given Object is already registered with this store.

Parameters:
key - the identifier of the object to check
Returns:
true if the key is stored or false no value was stored for the key.
Throws:
ObjectStoreException - if the given key is null.
ObjectStoreNotAvaliableException - if any implementation-specific error occured, e.g. when the store is not available

store

public void store(Serializable id,
                  T value)
           throws ObjectStoreException
Description copied from interface: ObjectStore
Store the given Object.

Parameters:
id - the identifier for value
value - the Object to store with key
Throws:
ObjectStoreException - if the given key cannot be stored or is null.
ObjectStoreNotAvaliableException - if the store is not available or any other implementation-specific error occured.
ObjectAlreadyExistsException - if an attempt is made to store an object for a key that already has an object associated.

retrieve

public T retrieve(Serializable key)
                                throws ObjectStoreException
Description copied from interface: ObjectStore
Retrieve the given Object.

Parameters:
key - the identifier of the object to retrieve.
Returns:
the object associated with the given key. If no object for the given key was found this method throws an ObjectDoesNotExistException.
Throws:
ObjectStoreException - if the given key is null.
ObjectStoreNotAvaliableException - if the store is not available or any other implementation-specific error occured.
ObjectDoesNotExistException - if no value for the given key was previously stored.

remove

public T remove(Serializable key)
                              throws ObjectStoreException
Description copied from interface: ObjectStore
Remove the object with key.

Parameters:
key - the identifier of the object to remove.
Returns:
the object that was previously stored for the given key
Throws:
ObjectStoreException - if the given key is null or if the store is not available or any other implementation-specific error occured
ObjectDoesNotExistException - if no value for the given key was previously stored.

expire

public void expire()
Specified by:
expire in class AbstractMonitoredObjectStore<T extends Serializable>

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.