org.szegedi.spring.web.jsflow.support
Class RandomFlowStateIdGenerator

java.lang.Object
  extended by org.szegedi.spring.web.jsflow.support.RandomFlowStateIdGenerator
All Implemented Interfaces:
FlowStateIdGenerator

public class RandomFlowStateIdGenerator
extends java.lang.Object
implements FlowStateIdGenerator

Default implementation of flow state id generator that uses a random number generator.

Version:
$Id: $
Author:
Attila Szegedi

Constructor Summary
RandomFlowStateIdGenerator()
           
 
Method Summary
 boolean dependsOnContinuation()
          Returns true if the return value of FlowStateIdGenerator.generateStateId(NativeContinuation) depends on the passed state (that is, for a given state object, it will always return the same ID).
 java.lang.Long generateStateId(org.mozilla.javascript.NativeContinuation c)
          Generate the flow state id for the specified state.
 void setRandom(java.util.Random random)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomFlowStateIdGenerator

public RandomFlowStateIdGenerator()
Method Detail

setRandom

public void setRandom(java.util.Random random)

generateStateId

public java.lang.Long generateStateId(org.mozilla.javascript.NativeContinuation c)
Description copied from interface: FlowStateIdGenerator
Generate the flow state id for the specified state.

Specified by:
generateStateId in interface FlowStateIdGenerator
Returns:
the new ID. Must not be negative.

dependsOnContinuation

public boolean dependsOnContinuation()
Description copied from interface: FlowStateIdGenerator
Returns true if the return value of FlowStateIdGenerator.generateStateId(NativeContinuation) depends on the passed state (that is, for a given state object, it will always return the same ID). Implementations of the interface that implement counters or random generators will return false. Implementations that use some information contained in the continuation will return true. If an implementation returns true, then returning an ID equal to an existing state's ID might cause the user of the class to overwrite the existing ID. If an implementation returns false, the user of the class is encouraged to invoke the FlowStateIdGenerator.generateStateId(NativeContinuation) method repeatedly until it receives a non-conflicting ID.

Specified by:
dependsOnContinuation in interface FlowStateIdGenerator
Returns:
whether this generator generates IDs that depend on the state.