net.sf.asyncobjects.util
Class Seq<R>

java.lang.Object
  extended by net.sf.asyncobjects.util.RunDispatcher
      extended by net.sf.asyncobjects.util.Seq<R>
Type Parameters:
R - A result type
All Implemented Interfaces:
ExplicitSharing

public abstract class Seq<R>
extends RunDispatcher

A sequence control construct. This construct ensures that next actions is executed only if previous finished one way or another. If one of actions fails, next are not executed. Seq is sequeduled to be executed on some later turn because it reuses when construct. This also means that constructor completes before construct is executed. The control construct attempts to execute as much as possible in the single turn.

Author:
const

Field Summary
 
Fields inherited from class net.sf.asyncobjects.util.RunDispatcher
NO_FURTHER_ACTIONS
 
Constructor Summary
protected Seq()
          A constructor.
 
Method Summary
protected  Promise<?> finallyDo()
          This method is executed when all actions are finished.
 Promise<R> promise()
           
protected  Promise<R> smashed(int action, Throwable problem)
          Handle fault on one of actions.
 
Methods inherited from class net.sf.asyncobjects.util.RunDispatcher
run1, run10, run11, run12, run13, run14, run15, run16, run2, run3, run4, run5, run6, run7, run8, run9, runNext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Seq

protected Seq()
A constructor. Constructors schedule execution of this seq construct.

Method Detail

smashed

protected Promise<R> smashed(int action,
                             Throwable problem)
                      throws Throwable
Handle fault on one of actions. By default just fail.

Parameters:
action - action number
problem - a problem
Returns:
a result to be returned
Throws:
Throwable - a problem that is used to smash result promise.

finallyDo

protected Promise<?> finallyDo()
                        throws Throwable
This method is executed when all actions are finished. The method does not affect return value, however it can generate a fault that will be reflected in execution result.

Returns:
a promise or null which means that there is no finally action
Throws:
Throwable - that will be result of Seq

promise

public Promise<R> promise()
Returns:
a promise for this sequence of actions


Copyright 2002-2007 Constantine Plotnikov. All Rights Reserved.