StateManagermanages the state of an object and provides all of the basic support mechanisms required by an object for state management purposes. Some operations must be defined by the class developer. These operations are:
boolean save_state (OutputObjectState state, int ObjectType)
- Invoked whenever the state of an object might need to be saved for future use - primarily for recovery or persistence purposes. The
ObjectTypeparameter indicates the reason that
save_statewas invoked by TxCore. This enables the programmer to save different pieces of information into the
OutputObjectStatesupplied as the first parameter depending upon whether the state is needed for recovery or persistence purposes. For example, pointers to other TxCore objects might be saved simply as pointers for recovery purposes but as Uid’s for persistence purposes. As shown earlier, the
OutputObjectStateclass provides convenient operations to allow the saving of instances of all of the basic types in Java. In order to support crash recovery for persistent objects it is necessary for all
save_statemethods to call
save_stateassumes that an object is internally consistent and that all variables saved have valid values. It is the programmer's responsibility to ensure that this is the case.
boolean restore_state (InputObjectState state, int ObjectType)
- Invoked whenever the state of an object needs to be restored to the one supplied. Once again the second parameter allows different interpretations of the supplied state. In order to support crash recovery for persistent objects it is necessary for all
restore_statemethods to call
String type ()
- The TxCore persistence mechanism requires a means of determining the type of an object as a string so that it can save/restore the state of the object into/from the object store. By convention this information indicates the position of the class in the hierarchy. For example, “/
NoteThe type method is used to determine the location in the object store where the state of instances of that class will be saved and ultimately restored. This can actually be any valid string. However, you should avoid using the hash character (#) as this is reserved for special directories that TxCore requires.