org.mule.util.store
Class TextFileObjectStore
java.lang.Object
org.mule.util.store.AbstractMonitoredObjectStore
org.mule.util.store.InMemoryObjectStore
org.mule.util.store.TextFileObjectStore
- All Implemented Interfaces:
- Runnable, MuleContextAware, Disposable, Initialisable, ObjectStore
public class TextFileObjectStore
- extends InMemoryObjectStore
A Simple object store that stores String objects by key to a text file. This store is only suitable for storing
simple key value pair strings.
This store is backed by an in-memory store and supports the ability to expire and apply TTL to objects in the store.
Methods inherited from class org.mule.util.store.AbstractMonitoredObjectStore |
getEntryTTL, getExpirationInterval, getMaxEntries, getName, getScheduler, 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 |
fileStore
protected File fileStore
directory
protected String directory
encoding
protected String encoding
TextFileObjectStore
public TextFileObjectStore()
initialise
public void initialise()
throws InitialisationException
- Description copied from interface:
Initialisable
- Method used to perform any initialisation work. If a fatal error occurs during
initialisation an
InitialisationException
should be thrown,
causing the Mule instance to shutdown. If the error is recoverable, say by
retrying to connect, a RecoverableException
should be thrown.
There is no guarantee that by throwing a Recoverable exception that the Mule
instance will not shut down.
- Specified by:
initialise
in interface Initialisable
- Overrides:
initialise
in class AbstractMonitoredObjectStore
- Throws:
InitialisationException
- if a fatal error occurs causing the Mule instance to shutdown
RecoverableException
- if an error occurs that can be recovered from
loadFromStore
protected void loadFromStore()
throws Exception
- Throws:
Exception
storeObject
public boolean storeObject(String id,
Object item)
throws Exception
- Store the given Object.
- Specified by:
storeObject
in interface ObjectStore
- Overrides:
storeObject
in class InMemoryObjectStore
- Parameters:
id
- the ID to storeitem
- 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
getDirectory
public String getDirectory()
setDirectory
public void setDirectory(String directory)
getEncoding
public String getEncoding()
setEncoding
public void setEncoding(String encoding)
dispose
public void dispose()
- Description copied from class:
AbstractMonitoredObjectStore
- A lifecycle method where implementor should free up any resources. If an
exception is thrown it should just be logged and processing should continue.
This method should not throw Runtime exceptions.
- Specified by:
dispose
in interface Disposable
- Overrides:
dispose
in class AbstractMonitoredObjectStore
Copyright © 2003-2009 MuleSource, Inc.. All Rights Reserved.