org.szegedi.spring.web.jsflow.support
Class FlowStateSerializer
java.lang.Object
org.szegedi.spring.web.jsflow.support.FlowStateSerializer
- All Implemented Interfaces:
- org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
- AbstractFlowStateStorage, HttpSessionFlowStateStorage
public abstract class FlowStateSerializer
- extends java.lang.Object
- implements org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
A class able to serialize and deserialize a continuation within a specified
application context.
- Version:
- $Id: $
- Author:
- Attila Szegedi
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FlowStateSerializer
public FlowStateSerializer()
setScriptStorage
public void setScriptStorage(ScriptStorage scriptStorage)
getScriptStorage
public ScriptStorage getScriptStorage()
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
- Specified by:
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
afterPropertiesSet
public void afterPropertiesSet()
throws java.lang.Exception
- Specified by:
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
- Throws:
java.lang.Exception
serializeContinuation
protected byte[] serializeContinuation(org.mozilla.javascript.NativeContinuation state,
java.util.Map stubbedFunctions,
FlowStateSerializer.StubProvider stubProvider)
throws java.lang.Exception
- Serializes a continuation. All script function object references as well
as all references to objects defined in the application context will be
replaced by named stubs. Additionally, a digital fingerprint of the
internal JS bytecode representation of all JS functions on the
continuation's stack is written.
- Parameters:
state
- the continuation to serializestubbedFunctions
- a map that'll receive all mappings of stubs to
functions. Can be used to locally deserialize a continuation and
reconnect it with exact same functions that were current during
serialization (thus making continuations immune to script reloading
within a single JVM run). Can be null if tracking of stubs is not
required.
- Returns:
- the serialized form
- Throws:
java.lang.Exception
deserializeContinuation
protected org.mozilla.javascript.NativeContinuation deserializeContinuation(byte[] b,
FlowStateSerializer.StubResolver stubResolver)
throws java.lang.Exception
- Deserializes a continuation. All stubs written during serialization are
resolved to appropriate objects within this application context.
Additionally, digital fingerprints of the functions on the
continuation's stack are matched to the fingerprints of the same
functions currently in the memory. If they don't match (i.e. the script
was modified since the continuation was serialized), an exception is
thrown to prevent undefined behaviour as the continuation's stack might
now contain invalid return addresses.
- Parameters:
b
- the serialized continuation
- Returns:
- the deserialized continuation
- Throws:
java.lang.Exception