|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.szegedi.spring.web.jsflow.support.FlowStateSerializer org.szegedi.spring.web.jsflow.support.AbstractFlowStateStorage
public abstract class AbstractFlowStateStorage
A flow state storage that serializes the flow states. It requires access to a
script storage. If none is configured, then the
FlowController
will pass it its own
script storage - this is usually the intention.
When creating the serialized flowstates, it stubs all the application context beans and script function objects, thus minimizing the size of the serialized state. When deserializing, it will reattach the deserialized state to stubbed objects, resolving them by name. This way, it is allowed to have references to application context objects in the reachability graph of the serialized state, as they will get stubbed and resolved correctly. It is however strongly not advised to have references to any other external objects in the running scripts or objects referenced by them, as they will either fail serialization, or - lacking stubbing - cause duplicate instances to be created upon deserialization.
As a safety feature, the MD5 fingerprint of each function's code that is on the continuation's call stack is stored along with the continuation, and matched upon retrieval, with an exception being thrown if they don't match. In case that the underlying script changed since the continuation last run (i.e. because you restarted the servlet context and reloaded a changed script) this causes clean fast failure, instead of unpredictable behavior caused by invalid return addresses in the continuation stack frames.
The class supports setting a
BinaryStateCodec
, enabling
pluggable compression, encryption, and/or digital signing of the serialized
state. This is most useful with the
ClientSideFlowStateStorage
subclass
where the client is entrusted with storing the flowstates, so you might wish
to ensure they're resistant to tampering.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.szegedi.spring.web.jsflow.support.FlowStateSerializer |
---|
FlowStateSerializer.StubProvider, FlowStateSerializer.StubResolver |
Constructor Summary | |
---|---|
AbstractFlowStateStorage()
|
Method Summary | |
---|---|
protected abstract byte[] |
getSerializedState(javax.servlet.http.HttpServletRequest request,
java.lang.String id)
Implement in subclasses to retrieve the serialized state. |
org.mozilla.javascript.NativeContinuation |
getState(javax.servlet.http.HttpServletRequest request,
java.lang.String id)
Retrieves the state associated with a request |
void |
setBinaryStateCodec(BinaryStateCodec binaryStateCodec)
|
protected abstract java.lang.String |
storeSerializedState(javax.servlet.http.HttpServletRequest request,
byte[] state)
Implement in subclasses to store the serialized state. |
java.lang.String |
storeState(javax.servlet.http.HttpServletRequest request,
org.mozilla.javascript.NativeContinuation state)
Stores the state associated with the current request |
Methods inherited from class org.szegedi.spring.web.jsflow.support.FlowStateSerializer |
---|
afterPropertiesSet, deserializeContinuation, getScriptStorage, serializeContinuation, setApplicationContext, setScriptStorage |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractFlowStateStorage()
Method Detail |
---|
public void setBinaryStateCodec(BinaryStateCodec binaryStateCodec)
public org.mozilla.javascript.NativeContinuation getState(javax.servlet.http.HttpServletRequest request, java.lang.String id)
FlowStateStorage
getState
in interface FlowStateStorage
request
- the HTTP requestid
- the unique identifier for the flow state
protected abstract byte[] getSerializedState(javax.servlet.http.HttpServletRequest request, java.lang.String id) throws java.lang.Exception
request
- the HTTP request that triggered the retrieval. Can be used
to implement session-private storages for states.id
- the id of the state
java.lang.Exception
public java.lang.String storeState(javax.servlet.http.HttpServletRequest request, org.mozilla.javascript.NativeContinuation state)
FlowStateStorage
storeState
in interface FlowStateStorage
request
- the HTTP requeststate
- the state
protected abstract java.lang.String storeSerializedState(javax.servlet.http.HttpServletRequest request, byte[] state) throws java.lang.Exception
request
- the HTTP request that triggered the store operation. Can
be used to implement session-private storages for states.state
- byte array representing the serialized state
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |