Package org.oddjob.persist
Class FilePersister
java.lang.Object
org.oddjob.persist.PersisterBase
org.oddjob.persist.FilePersister
- All Implemented Interfaces:
OddjobPersister
- Author:
- Rob Gordon.
Description
Persist and load jobs from and to a file. The file the job is persisted to is the jobs id with a .ser extension.A new sub directory is created for each nested Oddjob with an id. The job of the nested Oddjob are persisted to the sub directory. Thus the directory structure mirrors the structure of the Oddjobs.
Example
Using a file persister with Oddjob. The persist directory is passed in as an argument from the command line. The state of child jobs will be saved in a child directory relative to the given directory of the name 'important-jobs'.
<oddjob id="this">
<job>
<oddjob id="important-jobs" file="${this.dir}/FilePersisterExampleInner.xml">
<persister>
<file-persister dir="${this.args[0]}"/>
</persister>
</oddjob>
</job>
</oddjob>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidRemove a possibly previously persisted object.getDir()Get the directory, files are being persisted in.protected String[]protected voidProvided by subclasses to do the persisting.protected voidRemove a possibly previously persisted object.protected Objectrestore(Path path, String id, ClassLoader classLoader) Restore a previously persisted Component or it's Proxy.voidSet the directory to save files in.toString()Methods inherited from class org.oddjob.persist.PersisterBase
persisterFor, setPath
-
Constructor Details
-
FilePersister
public FilePersister()
-
-
Method Details
-
setDir
Set the directory to save files in.- Parameters:
dir- The directory.
-
getDir
Get the directory, files are being persisted in.- Returns:
- The directory.
-
persist
Description copied from class:PersisterBaseProvided by subclasses to do the persisting.- Specified by:
persistin classPersisterBase- Parameters:
path- The path as a string. Never null.id- The id. Never Null.o- The component or it's proxy.- Throws:
ComponentPersistException
-
remove
Description copied from class:PersisterBaseRemove a possibly previously persisted object.- Specified by:
removein classPersisterBase- Parameters:
path- The path.id- The id.- Throws:
ComponentPersistException
-
restore
protected Object restore(Path path, String id, ClassLoader classLoader) throws ComponentPersistException Description copied from class:PersisterBaseRestore a previously persisted Component or it's Proxy.- Specified by:
restorein classPersisterBase- Parameters:
path- The path. Never Null.id- The id. Never Null.classLoader- The classLoader.- Returns:
- The component or it's proxy. Null if nothing had previously been persisted for this path and id.
- Throws:
ComponentPersistException
-
list
- Specified by:
listin classPersisterBase- Throws:
ComponentPersistException
-
clear
Description copied from class:PersisterBaseRemove a possibly previously persisted object.- Specified by:
clearin classPersisterBase- Parameters:
path- The path.
-
toString
-