org.starhope.appius.util
Interface RecordLoader<T extends DataRecord>

Type Parameters:
T - The data record type
All Superinterfaces:
HasSubversionRevision
All Known Subinterfaces:
EventOutcomeRecordLoader, ParentRecordLoader, PassportLoader, SQLLoader<T>, UserHouseRecordLoader, UserRecordLoader
All Known Implementing Classes:
AvatarBodyFormatSQLLoader, AvatarClassSQLLoader, CapabilityRecordsSQLLoader, CurrencySQLLoader, DamageAreaSQLLoader, EnrolmentSQLLoader, EventOutcomeRecordSQLLoader, EventRecordLoader, EventRecordSQLLoader, EventTypeSQLLoader, GenericItemReferenceSQLLoader, InventoryItemSQLLoader, InventoryItemTypeSQLLoader, InventorySQLLoader, ItemCollectionSQLLoader, ItemEffectsTypeSQLLoader, MedalRecordLoader, MedalRecordSQLLoader, NullLoader, ParentRecordSQLLoader, PassportSQLLoader, PeanutLoader, RarityRatingSQLLoader, RoomSQLLoader, SimpleDataEnumSQLLoader, UserBuddyListSQLIterator, UserEnrolmentSQLLoader, UserHouseSQLLoader, UserIgnoreListSQLIterator, UserListGeneralSQLIterator, UserListIterator, UserListSQLIterator, UserRecordSQLLoader, Via, WalletLoaderSocialGold, WalletSQLLoader

public interface RecordLoader<T extends DataRecord>
extends HasSubversionRevision

This interface defines a mechanism for loading and saving data records from an arbitrary storage engine, most likely an SQL database of some kind. The backing store could potentially be something like a file or RPC server as well.

Author:
brpocock@star-hope.org

Method Summary
 void changed(T changedRecord)
          accept a notification from a record that it has been changed.
 void initializeStorage(String storageURL)
          Prepare the RecordLoader for accessing a given storage medium.
 boolean isRealtime()
           
 T loadRecord(int id)
          Load the record with the given ID number from the storage system
 T loadRecord(String identifier)
          Load the data record identified from the storage system.
 void refresh(T record)
          Refreshes the record: Re-read the contents of the database into the given record.
 void removeRecord(T record)
           
 void saveRecord(T record)
          Save a record back to the storage system
 
Methods inherited from interface org.starhope.util.HasSubversionRevision
getSubversionRevision
 

Method Detail

changed

void changed(T changedRecord)
accept a notification from a record that it has been changed.

Parameters:
changedRecord - the record that has been changed

initializeStorage

void initializeStorage(String storageURL)
                       throws NotReadyException
Prepare the RecordLoader for accessing a given storage medium. Usually identifies a URL for the storage mechanism, but can also pull information from AppiusConfig.

Parameters:
storageURL - A URL or identifier of the storage engine. The syntax is specific to the RecordLoader implementation.
Throws:
NotReadyException - if the storage engine can't be initialised

isRealtime

boolean isRealtime()
Returns:
true, if this is a type that requires realtime performance on changes. Note that I/O bound storage such as SQL database saves and file writes will generally return false, whereas RPC mirroring will probably want to return true, unless latency is not an issue.

loadRecord

T loadRecord(int id)
                                throws NotFoundException
Load the record with the given ID number from the storage system

Parameters:
id - the ID number for the record
Returns:
the data record in question
Throws:
NotFoundException - if the record can't be loaded

loadRecord

T loadRecord(String identifier)
                                throws NotFoundException
Load the data record identified from the storage system. The format and interpretation of the identifier is specific to the data record type, but must be a guaranteed-unique

Parameters:
identifier - the identifier for the record
Returns:
the data record in question
Throws:
NotFoundException - if the record can't be loaded

refresh

void refresh(T record)
Refreshes the record: Re-read the contents of the database into the given record. This is a rather cruel hack to work around some of the legacy tools in Tootsvilleâ„¢ that aren't hooked into the game server properly, and might be fiddling around with the SQL backing-store directly. This works together with e.g. SimpleDataRecord.checkStale() to try to reload data when it might have been changed: it's trading elegance and efficiency for expediency, but eventually, it should be removed.

Parameters:
record - the record to be reloaded.

removeRecord

void removeRecord(T record)
Parameters:
record - Record to be deleted/removed

saveRecord

void saveRecord(T record)
Save a record back to the storage system

Parameters:
record - the record to be saved