org.clapper.curn
Class DataPersister

java.lang.Object
  extended by org.clapper.curn.DataPersister
Direct Known Subclasses:
XMLDataPersister

public abstract class DataPersister
extends java.lang.Object

Persists data to the curn persistent data store, whatever that may be.

Version:
$Revision: 6498 $

Nested Class Summary
static interface DataPersister.LoadedDataHandler
          Used to define a callback for handling loaded data.
 
Constructor Summary
protected DataPersister()
           
 
Method Summary
 void addPersistentDataClient(PersistentDataClient client)
          Register a PersistentDataClient object with this registry.
protected abstract  void doLoad(DataPersister.LoadedDataHandler loadedDataHandler)
          The actual load method; only called if the object is enabled.
protected abstract  void endLoadOperation()
          Called at the end of the load operation to close files, clean up, etc.
protected abstract  void endSaveOperation()
          Called at the end of the actual save operation to flush files, clean up, etc.
abstract  void init(CurnConfig curnConfig)
          Called when the DataPersister is first instantiated.
protected abstract  boolean isEnabled()
          Determine whether the data persister subclass is enabled or not (i.e., whether or not metadata is to be loaded and saved).
 void loadData(FeedCache feedCache)
          Load the cache and metadata.
 void saveData(FeedCache feedCache)
          Save the feed metadata.
protected abstract  void saveExtraMetadata(java.util.Collection<PersistentMetadataGroup> metadata)
          Save any extra metadata (i.e., metadata that isn't attached to a specific feed or a specific item).
protected abstract  void saveFeedData(PersistentFeedData feedData)
          Save the data for one feed, including the items.
protected abstract  void startLoadOperation()
          Called at the beginning of the load operation to initialize the load.
protected abstract  void startSaveOperation()
          Called at the beginning of the actual save operation to initialize the save, etc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataPersister

protected DataPersister()
Method Detail

saveData

public final void saveData(FeedCache feedCache)
                    throws CurnException
Save the feed metadata. The configuration is passed in, so that the persister can obtain, from the configuration, whatever data it needs to find the persisted metadata to read.

Parameters:
feedCache - FeedCache object to save
Throws:
CurnException - on error

loadData

public void loadData(FeedCache feedCache)
              throws CurnException
Load the cache and metadata.

Parameters:
feedCache - the FeedCache object to fill
Throws:
CurnException - on error

addPersistentDataClient

public final void addPersistentDataClient(PersistentDataClient client)
Register a PersistentDataClient object with this registry. When data for that client is read, this object will call the client's process methods. When it's time to save the metadata, this object will call the client's get methods. Multiple PersistentDataClient objects may be registered with this object.

Parameters:
client - the PersistentDataClient object

init

public abstract void init(CurnConfig curnConfig)
                   throws CurnException
Called when the DataPersister is first instantiated. Useful for retrieving configuration values, etc.

Parameters:
curnConfig - the configuration
Throws:
CurnException - on error

isEnabled

protected abstract boolean isEnabled()
Determine whether the data persister subclass is enabled or not (i.e., whether or not metadata is to be loaded and saved). The configuration usually determines whether or not the data persister is enabled.

Returns:
true if enabled, false if disabled.

startLoadOperation

protected abstract void startLoadOperation()
                                    throws CurnException
Called at the beginning of the load operation to initialize the load.

Throws:
CurnException - on error

endLoadOperation

protected abstract void endLoadOperation()
                                  throws CurnException
Called at the end of the load operation to close files, clean up, etc.

Throws:
CurnException - on error

doLoad

protected abstract void doLoad(DataPersister.LoadedDataHandler loadedDataHandler)
                        throws CurnException
The actual load method; only called if the object is enabled.

Parameters:
loadedDataHandler - object to receive data as it's loaded
Throws:
CurnException - on error

startSaveOperation

protected abstract void startSaveOperation()
                                    throws CurnException
Called at the beginning of the actual save operation to initialize the save, etc.

Throws:
CurnException - on error

endSaveOperation

protected abstract void endSaveOperation()
                                  throws CurnException
Called at the end of the actual save operation to flush files, clean up, etc.

Throws:
CurnException - on error

saveFeedData

protected abstract void saveFeedData(PersistentFeedData feedData)
                              throws CurnException
Save the data for one feed, including the items.

Parameters:
feedData - the feed data to be saved
Throws:
CurnException - on error

saveExtraMetadata

protected abstract void saveExtraMetadata(java.util.Collection<PersistentMetadataGroup> metadata)
                                   throws CurnException
Save any extra metadata (i.e., metadata that isn't attached to a specific feed or a specific item).

Parameters:
metadata - the collection of metadata items
Throws:
CurnException - on error


Copyright © 2004-2006 Brian M. Clapper. All Rights Reserved.