org.ow2.petals.microkernel.api.jbi.management
Class TaskProcessor

java.lang.Object
  extended by org.ow2.petals.microkernel.api.jbi.management.TaskProcessor

public class TaskProcessor
extends Object

The TaskProcessor executes an ordered List of Tasks : it calls the execute method on each Task. It ensures the system state recovery in case of failure during the Tasks processing : it will call the undo method on each allready executed Task before the whole process crash.

Author:
Olivier Fabre - EBM WebSourcing

Field Summary
protected  Context context
           
protected  LoggingUtil log
           
protected  List<Task> taskList
           
 
Constructor Summary
TaskProcessor(Context context, LoggingUtil log)
           
 
Method Summary
 void addTask(Task task)
          Add a new Task in the List of Tasks to execute.
 Throwable process()
          Process each Task previously added to the Processor, in the same order as they have been added to it.
 boolean unprocess()
          Unprocess each Task previously added to the Processor, in the reversed order they have been added to it.
 boolean unprocess(int step)
          Unprocess each Task previously added to the Processor from the step provided, in the reversed order they have been added to it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

taskList

protected List<Task> taskList

context

protected Context context

log

protected LoggingUtil log
Constructor Detail

TaskProcessor

public TaskProcessor(Context context,
                     LoggingUtil log)
Method Detail

addTask

public void addTask(Task task)
Add a new Task in the List of Tasks to execute. Task will be processed in the same order as they have been added to the List.

Parameters:
task - a new Task to process

process

public Throwable process()
Process each Task previously added to the Processor, in the same order as they have been added to it. If an exception occurs during the processing of a Task, the processor will undo this Task and all previously executed Tasks, in the reverse order as they have been executed.

Returns:
The cause of the error if the process has failed, null otherwise

unprocess

public boolean unprocess(int step)
Unprocess each Task previously added to the Processor from the step provided, in the reversed order they have been added to it. If an error occurs during a Task unprocessing, the processor skips it and continues to unprocess other Tasks.

Parameters:
step - . The task number reference into the list to start the reverse processing
Returns:
true if the process is successful, false otherwise

unprocess

public boolean unprocess()
Unprocess each Task previously added to the Processor, in the reversed order they have been added to it. If an error occurs during a Task unprocessing, the processor skips it and continues to unprocess other Tasks.

Returns:
true if the process is successful, false otherwise


Copyright © 2005-2015 Linagora. All Rights Reserved.