com.revusky.oreo
Interface MutableDataSource

All Superinterfaces:
DataSource, java.rmi.Remote
All Known Subinterfaces:
TransactionalDataSource
All Known Implementing Classes:
AbstractMutableDataSource

public interface MutableDataSource
extends DataSource

Interface implemented by objects that manage a collection of records.

Author:
Jonathan Revusky

Method Summary
 void addDataListener(DataListener dl)
          Add a listener that gets notified if ever a record is inserted, updated or deleted.
 void delete(Record rec)
          Delete a record
 void insert(Record rec)
          Adds a new record to the managed pool.
 void playEvent(DataEvent event)
          "play" an event This will be mostly used in restarting an app and reconstructing the state of the data from logs.
 void removeDataListener(DataListener dl)
          Remove a listener that gets notified if ever a record is inserted, updated or deleted.
 java.util.List select(RecordFilter filter)
          Fetches a list of records matching filter.
 void update(Record oldRec, Record newRec)
          Replaces an existing version of a record with a new updated version.
 
Methods inherited from interface com.revusky.oreo.DataSource
close, get, get, getName, getRecords, init, keys, keys, wipeCache
 

Method Detail

insert

public void insert(Record rec)
            throws java.io.IOException
Adds a new record to the managed pool.
Parameters:
rec - the record to add
Throws:
DuplicateRecordException - if another record already exists with same primary key as 'rec'.
java.io.IOException - if the record cannot be initialized (i.e. has missing fields or invalid field values, etc.), or in case of a low-level error.

update

public void update(Record oldRec,
                   Record newRec)
            throws java.io.IOException
Replaces an existing version of a record with a new updated version. Some implementations may use the oldRec parameter to guarantee that there are no concurrency issues. In such case, it would throw a ConcurrentModificationException
Parameters:
oldRec - the record to replace.
newRec - the new record.
Throws:
java.io.IOException - thrown in case of any other database or communication error.

delete

public void delete(Record rec)
            throws java.io.IOException
Delete a record
Parameters:
the - record to delete.

select

public java.util.List select(RecordFilter filter)
                      throws java.io.IOException
Fetches a list of records matching filter. If filter is null, returns all the records in the container.
Parameters:
filter - the record filter, or null.
Returns:
a List of all the records that are an instance of a given class. If no records match the filter, an empty List.

playEvent

public void playEvent(DataEvent event)
               throws java.io.IOException
"play" an event This will be mostly used in restarting an app and reconstructing the state of the data from logs. Note that data listeners are not notified.

addDataListener

public void addDataListener(DataListener dl)
                     throws java.io.IOException
Add a listener that gets notified if ever a record is inserted, updated or deleted.
Parameters:
dl - the listener

removeDataListener

public void removeDataListener(DataListener dl)
                        throws java.io.IOException
Remove a listener that gets notified if ever a record is inserted, updated or deleted.
Parameters:
dl - the listener