net.sf.mybatchfwk
Interface IBatch


public interface IBatch

The batch class is the class in which tasks are created and provided to a service that executes them.
The batch class must implements the interface IBatch. Each method corresponds to a step of the batch life cycle.
If a BatchException is throw into one of these methods, the method manageFatalError will be called and the batch will be shutdown.

Author:
Jérôme Bertèche (cyberteche@users.sourceforge.net)
See Also:
ITask

Method Summary
 void end(ExecutionReport report)
          Called at the end of the batch execution.
 void endOfExecution(ITask task, java.lang.Throwable exception)
          Called after the end of the execution of a task.
 void execute(ITaskExecutor executor)
          Execution method of the batch.
 void init(BatchConfiguration configuration)
          Initialization method of the batch.
 void manageFatalError(ExecutionReport report, java.lang.Throwable throwable)
          Called if a fatal error occurred.
 void pause()
          Called then the batch execution has been put into waking through the call of the corresponding JMX operation.
 void resume()
          Called then the batch execution has been resumed through the call of the corresponding JMX operation.
 

Method Detail

init

void init(BatchConfiguration configuration)
          throws BatchException
Initialization method of the batch.
The batch configuration (loading from the configuration file in the automatic mode) can be modified here to change the behavior of the batch before it is launched.
Use: init JDBC connections pool, read proprietary configuration, sending of a notification mail, ...

Parameters:
configuration - the configuration of the batch
Throws:
BatchException - if throw, then the batch is stopped

execute

void execute(ITaskExecutor executor)
             throws BatchException
Execution method of the batch.
Tasks must be given to the executor service at this time. Called one time, or more if the batch is schedule for a number of loop or at fixed period.
Note: the building tasks are of type ITask. Each task must provides an unique identifier to differentiate them.
Use: build of tasks that are provided to the executor service.

Parameters:
executor - the tasks executor
Throws:
BatchException - if throw, then the batch is stopped
See Also:
ITask

pause

void pause()
           throws BatchException
Called then the batch execution has been put into waking through the call of the corresponding JMX operation. No more tasks are executed by the executor service at this time.
Use: free connections of the JDBC connections pool,...

Throws:
BatchException - if throw, then the batch is stopped

resume

void resume()
            throws BatchException
Called then the batch execution has been resumed through the call of the corresponding JMX operation. The executor service takes back the tasks execution. Use: re-establish the connections of the JDBC connections pool, ...

Throws:
BatchException - if throw, then the batch is stopped

end

void end(ExecutionReport report)
         throws BatchException
Called at the end of the batch execution.
The execution report contains the start date of the execution, the end date, a list of ids of tasks for which the execution has been a success and an another for the tasks for which the execution has failed. Use: destroy of the JDBC connections pool, sending of a report mail, log of the execution report, ...

Parameters:
report - the execution report
Throws:
BatchException - if throw, then the batch is stopped

endOfExecution

void endOfExecution(ITask task,
                    java.lang.Throwable exception)
Called after the end of the execution of a task.
Warning: called by a worker thread (the content must be ThreadSafe)

Parameters:
task - the failed task
exception - the cause of the failure

manageFatalError

void manageFatalError(ExecutionReport report,
                      java.lang.Throwable throwable)
Called if a fatal error occurred. In this case, the batch will be stopped just after this call.
A fatal error is an exception throws into one of the batch class method.
Use: sending of a notification mail, ...
Warning: called by a worker thread.

Parameters:
report - the execution report
throwable - the cause of the error


Copyright © 2006 null. All Rights Reserved.