public class

ObjectStoreModule

extends Object
java.lang.Object
   ↳ org.mule.modules.ObjectStoreModule
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Generic module for accessing Object Stores.

Can be used with Mule default implementations or one can be passed via ref. It allows to store, retrieve and remove objects from the store.

Summary

Fields
private Integer entryTtl TimeToLive for stored values in milliseconds.
private Integer expirationInterval Specifies the expiration check interval in milliseconds.
private Integer maxEntries Specifies the max number of entries.
private ObjectStore objectStore Reference to an Object Store bean.
private ObjectStoreManager objectStoreManager
private String partition Name of the partition in the default in-memory or persistent object stores (this argument has no meaning if the object store is passed by ref using objectStore-ref)
private boolean persistent Specified whenever the required store needs to be persistent or not (this argument has no meaning if the object store is passed by ref using objectStore-ref or no partition name is defined)
private Registry registry
Public Constructors
ObjectStoreModule()
Public Methods
List<Serializable> allKeys()
Returns a list of all the keys in the store.
boolean contains(String key)
Returns whether the object store contains the given key or not
void dualStore(String key, Serializable value, boolean overwrite)
Store value using key, and also store key using value.
Integer getEntryTtl()
Integer getExpirationInterval()
Integer getMaxEntries()
ObjectStore getObjectStore()
ObjectStoreManager getObjectStoreManager()
String getPartition()
Registry getRegistry()
void init()
boolean isPersistent()
Object remove(String key, boolean ignoreNotExists)
Remove the object with key.
Object retrieve(String key, Object defaultValue, String targetProperty, MulePropertyScope targetScope, MuleMessage muleMessage)
Retrieve the given Object.
void setEntryTtl(Integer entryTtl)
void setExpirationInterval(Integer expirationInterval)
void setMaxEntries(Integer maxEntries)
void setObjectStore(ObjectStore objectStore)
void setObjectStoreManager(ObjectStoreManager objectStoreManager)
void setPartition(String partition)
void setPersistent(boolean persistent)
void setRegistry(Registry registry)
void store(String key, Serializable value, boolean overwrite)
Store object

[Expand]
Inherited Methods
From class java.lang.Object

Fields

private Integer entryTtl

TimeToLive for stored values in milliseconds. MaxEntries and ExpirationInterval are mandatory for using this param.

private Integer expirationInterval

Specifies the expiration check interval in milliseconds. EntryTTL and MaxEntries are mandatory for using this param.

private Integer maxEntries

Specifies the max number of entries. EntryTTL and ExpirationInterval are mandatory for using this param.

private ObjectStore objectStore

Reference to an Object Store bean. This is optional and if it is not specified then the default in-memory or persistent store will be used.

private ObjectStoreManager objectStoreManager

private String partition

Name of the partition in the default in-memory or persistent object stores (this argument has no meaning if the object store is passed by ref using objectStore-ref)

private boolean persistent

Specified whenever the required store needs to be persistent or not (this argument has no meaning if the object store is passed by ref using objectStore-ref or no partition name is defined)

private Registry registry

Public Constructors

public ObjectStoreModule ()

Public Methods

public List<Serializable> allKeys ()

Returns a list of all the keys in the store.

IMPORTANT: Not all stores support this method. If the method is not supported a java.lang.UnsupportedOperationException is thrown

Returns
  • a java.util.List with all the keys in the store.
Throws
ObjectStoreException if an exception occurred while collecting the list of all keys.

public boolean contains (String key)

Returns whether the object store contains the given key or not

Parameters
key The identifier of the object to validate.
Returns
  • true if the object store contains the key, or false if it doesn't.
Throws
ObjectStoreException if the provided key is null.

public void dualStore (String key, Serializable value, boolean overwrite)

Store value using key, and also store key using value. If an exception is thrown rolls back both operations.

Parameters
key The identifier of the object to store
value The object to store. If you want this to be the payload then use value-ref="#[payload]".
overwrite True if you want to overwrite the existing object.
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. Only thrown if overwrite is false.

public Integer getEntryTtl ()

public Integer getExpirationInterval ()

public Integer getMaxEntries ()

public ObjectStore getObjectStore ()

public ObjectStoreManager getObjectStoreManager ()

public String getPartition ()

public Registry getRegistry ()

public void init ()

public boolean isPersistent ()

public Object remove (String key, boolean ignoreNotExists)

Remove the object with key.

Parameters
key The identifier of the object to remove.
ignoreNotExists Indicates if the operation will ignore NotExistsException from ObjectStore.
Returns
  • The object that was previously stored for the given key. If the key does not exist and ignoreNotExists is true the operation will return a null object.
Throws
ObjectStoreException if the given key is null or if the store is not available or any other implementation-specific error occurred
ObjectDoesNotExistException if no value for the given key was previously stored.

public Object retrieve (String key, Object defaultValue, String targetProperty, MulePropertyScope targetScope, MuleMessage muleMessage)

Retrieve the given Object.

Parameters
key The identifier of the object to retrieve.
defaultValue The default value if the key does not exists.
targetProperty The Mule Message property where the retrieved value will be stored
targetScope The Mule Message property scope, only used when targetProperty is specified
muleMessage Injected Mule Message
Returns
  • The object associated with the given key. If no object for the given key was found this method throws an org.mule.api.store.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.

public void setEntryTtl (Integer entryTtl)

Parameters
entryTtl

public void setExpirationInterval (Integer expirationInterval)

Parameters
expirationInterval

public void setMaxEntries (Integer maxEntries)

Parameters
maxEntries

public void setObjectStore (ObjectStore objectStore)

Parameters
objectStore

public void setObjectStoreManager (ObjectStoreManager objectStoreManager)

Parameters
objectStoreManager

public void setPartition (String partition)

Parameters
partition

public void setPersistent (boolean persistent)

Parameters
persistent

public void setRegistry (Registry registry)

Parameters
registry

public void store (String key, Serializable value, boolean overwrite)

Store object

Parameters
key The identifier of the object to store
value The object to store. If you want this to be the payload then use value-ref="#[payload]".
overwrite True if you want to overwrite the existing object.
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. Only thrown if overwrite is false.