com.revusky.oreo.inmemory
Class CrudeDataPersister
java.lang.Object
|
+--com.revusky.oreo.inmemory.CrudeDataPersister
- All Implemented Interfaces:
- DataListener, java.util.EventListener
- public class CrudeDataPersister
- extends java.lang.Object
- implements DataListener
A data listener that persists using an extremely
crude scheme. When a record is added,
it appends it to the flat file. When a record is deleted,
it appends an AntiRecord (dummy record)
to a flat file.
Periodically, it writes the entire flat file from scratch.
At that time, obsolete records are not written effectively purging all
knowlege of their existence.
This can be a decent first pass while working
up an application, but is not scaleable, of course.
The flat files use a readable ASCII format, not the usual
Java serialised object format.
- Author:
- Jonathan Revusky
Constructor Summary |
CrudeDataPersister(MutableDataSource dataSource,
java.lang.String filename,
int persistFrequency)
This constructor automatically
adds this object to the list of listeners
of the specified DataSource |
Method Summary |
void |
handleEvent(DataEvent event)
handle the event when the MutableDataSource we are listening
to has modified data |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CrudeDataPersister
public CrudeDataPersister(MutableDataSource dataSource,
java.lang.String filename,
int persistFrequency)
throws java.io.IOException
- This constructor automatically
adds this object to the list of listeners
of the specified DataSource
- Parameters:
dataSource
- the DataSource whose events to
listen for and persist.filename
- the flat file to persist to.
handleEvent
public void handleEvent(DataEvent event)
throws java.io.IOException
- Description copied from interface:
DataListener
- handle the event when the MutableDataSource we are listening
to has modified data
- Specified by:
handleEvent
in interface DataListener