org.speakright.core
Class SRPersistentState

java.lang.Object
  extended by org.speakright.core.SRPersistentState

public class SRPersistentState
extends java.lang.Object

Manages saving & restoring state of an SRInstance. This is done between each HTTP request, since Java servlets are stateless. Uses java serialization.

Author:
Ian Rae

Field Summary
 SRInstance m_run
          The SRInstance that has been saved or restored.
 java.lang.String m_streamId
          a unique key that can be used to find the right saved state.
 
Constructor Summary
SRPersistentState()
           
SRPersistentState(SRInstance run, java.lang.String streamId)
          Constructor used when saving state.
 
Method Summary
 boolean activate(java.io.InputStream inStream)
          Restore the saved state and recreate an SRInstance ready to resume execution.
 boolean passivate(java.io.OutputStream outStream, java.lang.String streamId)
          Saves the state to the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_run

public SRInstance m_run
The SRInstance that has been saved or restored. Contains everything needed to resume execution of the instance.


m_streamId

public java.lang.String m_streamId
a unique key that can be used to find the right saved state. If files are used then the key can simply be the filename.

Constructor Detail

SRPersistentState

public SRPersistentState()

SRPersistentState

public SRPersistentState(SRInstance run,
                         java.lang.String streamId)
Constructor used when saving state.

Parameters:
run - The instance to be saved.
streamId - The stream id that identifies the saved state.
Method Detail

passivate

public boolean passivate(java.io.OutputStream outStream,
                         java.lang.String streamId)
Saves the state to the given output stream.

Parameters:
outStream - output stream (can be a file, memory, etc)
streamId - Stream id that uniquely identifies the saved state.
Returns:
success.

activate

public boolean activate(java.io.InputStream inStream)
Restore the saved state and recreate an SRInstance ready to resume execution.

Parameters:
inStream - The input stream containing the saved state
Returns:
success