Packagecom.rosettastone.library.taskmanager
Classpublic class RetryOnFailureDecoratorTask
InheritanceRetryOnFailureDecoratorTask Inheritance InterruptibleTask Inheritance Task Inheritance flash.events.EventDispatcher
Implements IDecoratorTask

Special Task decorator for Tasks that should be retried on failure. (For example, this could be useful for Tasks that rely on an internet connection in order to complete.) This task allows its decorated Task to fail a couple of times before bubbling the error. A small amount of time is allowed to pass between each retry. This delay allows time for an external monitor to detect a loss of internet connection and pause all Tasks until it is restored. It also allows for a more graceful handling of occasional HTTP failures.



Public Properties
 PropertyDefined By
  data : *
[override] [read-only]
RetryOnFailureDecoratorTask
  decoratedTask : ITask
[read-only] Inner (decorated) Task.
RetryOnFailureDecoratorTask
 Inheritedid : Number
[read-only]
Task
 Inheritedinterruptible : Boolean
[override] [read-only] The current Task can be interrupted.
InterruptibleTask
 InheritedinterruptingTask : ITask
[read-only] The Task currently interrupting the composite Task's execution (or NULL if no such Task exists).
Task
 InheritedisComplete : Boolean
[read-only] The current task has successfully completed execution.
Task
 InheritedisErrored : Boolean
[read-only] The current task failed.
Task
 InheritedisInterrupted : Boolean
[read-only]
Task
 InheritedisRunning : Boolean
[read-only] The task is currently running.
Task
 Inheritedmessage : String
[read-only] Optional message parameter passed to the task complete/error/interruption method.
Task
 InheritednumInternalOperations : int
[read-only] Number of internal operations conducted by this task.
Task
 InheritednumInternalOperationsCompleted : int
[read-only] Number of internal operations that have completed.
Task
 InheritednumInternalOperationsPending : int
[read-only] Number of internal operations not yet completed.
Task
 InheritednumTimesCompleted : int
[read-only] Number of times this task has completed.
Task
 InheritednumTimesErrored : int
[read-only] Number of times this task has errored.
Task
 InheritednumTimesInterrupted : int
[read-only] Number of times this task has been interrupted.
Task
 InheritednumTimesReset : int
[read-only] Number of times this task has been reset.
Task
 InheritednumTimesStarted : int
[read-only] Number of times this task has been started.
Task
 Inheritedrunning : Boolean
[read-only] The task is currently running.
Task
 Inheritedsynchronous : Boolean
[read-only] The current task can be executed synchronously.
Task
 InheritedtaskIdentifier : String
(Optional) human-readable label for task.
Task
 InheriteduniqueID : Number
[read-only] Unique ID for a task.
Task
Protected Properties
 PropertyDefined By
 Inheritedlogger : ILogger
[read-only] Instance of ILogger to be used for any custom Task logging.
Task
Public Methods
 MethodDefined By
  
RetryOnFailureDecoratorTask(decoratedTask:Task, taskIdentifier:String = null)
Constructor.
RetryOnFailureDecoratorTask
 Inherited
and(... chainedTasks):ITask
Executes the specified tasks when the current task is executed.
Task
 Inherited
Task
 Inherited
interrupt():Boolean
[override] Interrupt the current Task.
InterruptibleTask
 Inherited
interruptForTask(interruptingTask:ITask):Boolean
Interrupts the current Task to wait on the Task specified.
Task
 Inherited
or(... chainedTasks):ITask
Executes the specified tasks if the current task fails.
Task
 Inherited
reset():void
Resets the task to it's pre-run state.
Task
 Inherited
Starts a task.
Task
 Inherited
then(... chainedTasks):ITask
Executes the specified tasks once the current task has completed successfully.
Task
 Inherited
withCompleteHandler(completeHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate completion, this method may also be used for notification purposes.
Task
 Inherited
withErrorHandler(errorHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate failure, this method may also be used for notification purposes.
Task
 Inherited
withFinalHandler(finalHandler:Function):ITask
This handler is invoked upon either success or failure of the Task.
Task
 Inherited
withInterruptionHandler(interruptionHandler:Function):ITask
Task
 Inherited
withStartedHandler(startedHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate starting, this method may also be used for notification purposes.
Task
Protected Methods
 MethodDefined By
  
[override] Sub-classes should override this method to implement interruption behavior (removing event listeners, pausing objects, etc.).
RetryOnFailureDecoratorTask
  
[override] Override this method to perform any custom reset operations.
RetryOnFailureDecoratorTask
  
customRun():void
[override] Override this method to give your Task functionality.
RetryOnFailureDecoratorTask
 Inherited
Task
 Inherited
getLoggerString(string:String):String
Returns a string for logging the specified task-state event.
Task
  
shouldFailedTaskBeRetried(failedTask:Task):Boolean
Sub-classes may override this method to determine of a failed Task should be retried.
RetryOnFailureDecoratorTask
 Inherited
taskComplete(message:String, data:* = null):void
This method should be called upon Task completion.
Task
 Inherited
taskError(message:String, data:* = null):void
This method should be called upon Task failure.
Task
 Inherited
taskInterrupted(message:String, data:* = null):void
Call this method to interrupt the currently running Task.
Task
 Inherited
Task
Events
 Event Summary Defined By
 InheritedTask
 InheritedTask
 InheritedTask
 InheritedTask
 InheritedTask
 InheritedTask
Property Detail
dataproperty
data:*  [read-only] [override]


Implementation
    public function get data():*
decoratedTaskproperty 
decoratedTask:ITask  [read-only]

Inner (decorated) Task.


Implementation
    public function get decoratedTask():ITask
DELAY_BEFORE_RETRYING_IN_MSproperty 
TaskPrivateNamespace static var DELAY_BEFORE_RETRYING_IN_MS:int = 1000

The amount of time to delay before resetting and re-running the decorated Task. This value should probably only be overriden for unit test purposes. A value of <= 0 seconds will result in a synchronous retry.

MAX_RETRY_ATTEMPTS_BEFORE_ERRORproperty 
TaskPrivateNamespace static var MAX_RETRY_ATTEMPTS_BEFORE_ERROR:int = 5

Number of times to reset and re-run the decorated Task. This value should probably only be overriden for unit test purposes. A value of <= 0 will cause a single failure to trigger a bubbled failure.

retryAttemptNumberproperty 
retryAttemptNumber:int  [read-only]


Implementation
    TaskPrivateNamespace function get retryAttemptNumber():int
Constructor Detail
RetryOnFailureDecoratorTask()Constructor
public function RetryOnFailureDecoratorTask(decoratedTask:Task, taskIdentifier:String = null)

Constructor.

Parameters
decoratedTask:Task — Ideally this Task should be interruptible; if not it will be wrapped in a InterruptibleDecoratorTask to simulate interruptibility
 
taskIdentifier:String (default = null) — Optional human-readible Task ID (useful for debug purposes only)
Method Detail
customInterrupt()method
override protected function customInterrupt():void

Sub-classes should override this method to implement interruption behavior (removing event listeners, pausing objects, etc.).

customReset()method 
override protected function customReset():void

Override this method to perform any custom reset operations.

customRun()method 
override protected function customRun():void

Override this method to give your Task functionality.

shouldFailedTaskBeRetried()method 
protected function shouldFailedTaskBeRetried(failedTask:Task):Boolean

Sub-classes may override this method to determine of a failed Task should be retried. This decision is separate from the normal max-retry counting logic. By default this function always returns TRUE.

Parameters

failedTask:Task

Returns
Boolean