org.mule.util.store
Class TextFileObjectStore

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

public class TextFileObjectStore
extends InMemoryObjectStore<String>

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<T>
 
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.
 boolean isPersistent()
          Is this store persistent?
protected  void loadFromStore()
           
 void setDirectory(String directory)
           
 void setEncoding(String encoding)
           
 void store(Serializable id, String item)
          Store the given Object.
 
Methods inherited from class org.mule.util.store.InMemoryObjectStore
contains, expire, remove, retrieve, toString
 
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, wait, wait, wait
 

Field Detail

fileStore

protected File fileStore

directory

protected String directory

encoding

protected String encoding
Constructor Detail

TextFileObjectStore

public TextFileObjectStore()
Method Detail

isPersistent

public boolean isPersistent()
Is this store persistent?

Specified by:
isPersistent in interface ObjectStore<String>
Overrides:
isPersistent in class InMemoryObjectStore<String>
Returns:
true if this store is persistent

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

store

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

Specified by:
store in interface ObjectStore<String>
Overrides:
store in class InMemoryObjectStore<String>
Parameters:
id - the identifier for value
item - 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.

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 interface: Disposable
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<String>


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