org.oddjob.persist
Class PersisterBase

java.lang.Object
  extended by org.oddjob.persist.PersisterBase
All Implemented Interfaces:
OddjobPersister
Direct Known Subclasses:
FilePersister, MapPersister

public abstract class PersisterBase
extends Object
implements OddjobPersister

Description

This provides common implementation for persisting job state.
Author:
Rob Gordon

Constructor Summary
  PersisterBase()
          Constructor.
protected PersisterBase(Path path)
          Constructor used for nested persisters.
 
Method Summary
protected abstract  void clear(Path path)
          Remove a possibly previously persisted object.
protected abstract  String[] list(Path path)
           
protected abstract  void persist(Path path, String id, Object component)
          Provided by subclasses to do the persisting.
 ComponentPersister persisterFor(String id)
          Provide a ComponentPersiter which may or may not require the id.
protected abstract  void remove(Path path, String id)
          Remove a possibly previously persisted object.
protected abstract  Object restore(Path path, String id, ClassLoader classLoader)
          Restore a previously persisted Component or it's Proxy.
 void setPath(String path)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersisterBase

public PersisterBase()
Constructor.


PersisterBase

protected PersisterBase(Path path)
Constructor used for nested persisters.

Parameters:
path - The path.
Method Detail

setPath

public void setPath(String path)

persisterFor

public ComponentPersister persisterFor(String id)
Description copied from interface: OddjobPersister
Provide a ComponentPersiter which may or may not require the id. If an id is required but not provided null will be returned.

Specified by:
persisterFor in interface OddjobPersister
Parameters:
id - An Id which may be used for a path. May be Null.
Returns:
A ComponentPersister. May be null.

persist

protected abstract void persist(Path path,
                                String id,
                                Object component)
                         throws ComponentPersistException
Provided by subclasses to do the persisting.

Parameters:
path - The path as a string. Never null.
id - The id. Never Null.
component - The component or it's proxy.
Throws:
ComponentPersistException

restore

protected abstract Object restore(Path path,
                                  String id,
                                  ClassLoader classLoader)
                           throws ComponentPersistException
Restore a previously persisted Component or it's Proxy.

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

protected abstract String[] list(Path path)
                          throws ComponentPersistException
Throws:
ComponentPersistException

remove

protected abstract void remove(Path path,
                               String id)
                        throws ComponentPersistException
Remove a possibly previously persisted object.

Parameters:
path - The path.
id - The id.
Throws:
ComponentPersistException

clear

protected abstract void clear(Path path)
                       throws ComponentPersistException
Remove a possibly previously persisted object.

Parameters:
path - The path.
id - The id.
Throws:
ComponentPersistException