org.mule.util.store
Class TextFileObjectStore

java.lang.Object
  extended by org.mule.util.store.AbstractMonitoredObjectStore
      extended by org.mule.util.store.InMemoryObjectStore
          extended by 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.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.mule.util.store.InMemoryObjectStore
InMemoryObjectStore.StoredObject
 
Field Summary
protected  String directory
           
protected  String encoding
           
protected  File fileStore
           
 
Fields inherited from class org.mule.util.store.InMemoryObjectStore
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
TextFileObjectStore()
           
 
Method Summary
 void dispose()
          A lifecycle method where implementor should free up any resources.
 String getDirectory()
           
 String getEncoding()
           
 void initialise()
          Method used to perform any initialisation work.
protected  void loadFromStore()
           
 void setDirectory(String directory)
           
 void setEncoding(String encoding)
           
 boolean storeObject(String id, Object item)
          Store the given Object.
 
Methods inherited from class org.mule.util.store.InMemoryObjectStore
containsObject, expire, removeObject, retrieveObject
 
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
 

Field Detail

fileStore

protected File fileStore

directory

protected String directory

encoding

protected String encoding
Constructor Detail

TextFileObjectStore

public TextFileObjectStore()
Method Detail

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 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

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.