org.apache.tuscany.sca.store
Interface Store

All Superinterfaces:
EventPublisher
All Known Implementing Classes:
MemoryStore

public interface Store
extends EventPublisher

Implementations provide a persistent store for runtime data such as conversational state. A persistent store could be implemented in a durable fashion using JDBC or a journaling system, or using a non-durable mechanism such as an in-memory map.


Field Summary
static long DEFAULT_EXPIRATION_OFFSET
           
static long NEVER
           
 
Method Summary
 void insertRecord(RuntimeComponent owner, java.lang.String id, java.lang.Object object, long expiration)
          Adds the given record to the store.
 java.lang.Object readRecord(RuntimeComponent owner, java.lang.String id)
          Returns the deserialized object in the store corresponding to the given id
 void recover(RecoveryListener listener)
          Initiates a recovery operation, for example during restart after a crash
 void removeRecord(RuntimeComponent owner, java.lang.String id)
          Removes a record from the store
 void removeRecords()
          Removes all records from the store
 void updateRecord(RuntimeComponent owner, java.lang.String id, java.lang.Object object, long expiration)
          Updates a given record in the store, overwriting previous information.
 
Methods inherited from interface org.apache.tuscany.sca.event.EventPublisher
addListener, addListener, publish, removeListener
 

Field Detail

DEFAULT_EXPIRATION_OFFSET

static final long DEFAULT_EXPIRATION_OFFSET
See Also:
Constant Field Values

NEVER

static final long NEVER
See Also:
Constant Field Values
Method Detail

insertRecord

void insertRecord(RuntimeComponent owner,
                  java.lang.String id,
                  java.lang.Object object,
                  long expiration)
                  throws StoreWriteException
Adds the given record to the store. Implementations may choose different strategies for writing data such as write-through or write-behind.

Parameters:
owner - the instance owner
id - the unique id of the record
object - the object representing the data to write
expiration - the time in milliseconds when the entry expires
Throws:
StoreWriteException - if an error occurs during the write operation

updateRecord

void updateRecord(RuntimeComponent owner,
                  java.lang.String id,
                  java.lang.Object object,
                  long expiration)
                  throws StoreWriteException
Updates a given record in the store, overwriting previous information.

Parameters:
owner - the instance owner
id - the unique id of the record
object - the object representing the data to write
expiration - the time in milliseconds when the entry expires
Throws:
StoreWriteException

readRecord

java.lang.Object readRecord(RuntimeComponent owner,
                            java.lang.String id)
                            throws StoreReadException
Returns the deserialized object in the store corresponding to the given id

Parameters:
owner - the instance owner
id - the unique id of the record
Returns:
the deserialized object or null if one is not found
Throws:
StoreReadException

removeRecord

void removeRecord(RuntimeComponent owner,
                  java.lang.String id)
                  throws StoreWriteException
Removes a record from the store

Parameters:
owner - the instance owner
id - the unique id of the record
Throws:
StoreWriteException

removeRecords

void removeRecords()
                   throws StoreWriteException
Removes all records from the store

Throws:
StoreWriteException

recover

void recover(RecoveryListener listener)
             throws StoreReadException
Initiates a recovery operation, for example during restart after a crash

Parameters:
listener - the listener to receive recovery callback events
Throws:
StoreReadException