Interface BatchJobStepInterface
-
- All Superinterfaces:
- com.ibm.batch.api.BatchJobStepInterface
- All Known Subinterfaces:
- BatchJobStepLocalInterface
public interface BatchJobStepInterface extends com.ibm.batch.api.BatchJobStepInterface
The BatchJobStepInterface describes the business methods that a Batch Job Step entity bean (Batch Step Bean) implements. These methods are callbacks that allow a Batch Execution Environment (BEE) to manage the Batch Step Bean. The business interface of a Batch Step Bean has to be the BatchJobStepLocalInterface class which extends the BatchJobStepInterface class. The home interface of the Batch Step Bean must be the BatchJobStepLocalHomeInterface class and the primary key class of a Batch Step Bean has to be the BatchJobStepKey class.
When the batch job is ready to be dispatched, the Batch Execution Environment (BEE) will lookup the Batch Step Bean home interface of the first step specified in the job xJCL and will create an instance of the step bean. BEE will then call the setProperties method to make any properties that were specified in the xJCL available to the step bean. Then the BEE will call the createJobStep. BEE will then keep on calling processJobStep in a batch loop until the return code (look at
BatchConstants
) of the processJobStep method indicates that the step has finished. The processJobStep method should contain all the business logic for the batch step. The BEE ensures that the processJobStep method invocations (batch loop) run under a global transaction; the lifecycle of the global transaction is managed by the Checkpoint policy that is applied to this batch job. Any transactional work within the processJobStep method should inherit the global transaction context that is provided by the BEE. When the processJobStep method return code indicates that the step has finished processing, BEE will call the destroyJobStep. The BEE will then continue to process the next Batch Job Step specified in the xJCL.Environment
The batch job step bean is a local entity bean that will be called by the Batch Execution Environment.- Transactional environment: The processJobStep method runs under a global transaction that is managed by the BEE, hence it must have a transaction attribute of TX_REQUIRED. The Checkpoint policy that is applied to the batch job manages the behavior of the global transaction. If calls to other transactional work are made in processJobStep, it is the responsibility of the author to ensure that those calls inherit the transaction context that exists under processJobStep.
-
-
Method Summary
Methods Modifier and Type Method and Description void
createJobStep()
createJobStep is called by the Batch Execution Environment before calling processJobStep.int
destroyJobStep()
destroyJobStep is called when the Batch Execution Environment has finished processing the job step.java.util.Properties
getProperties()
Returns the properties specified in the xJCL for the batch job step.int
processJobStep()
processJobStep should contain all the business logic for the batch job step.void
setProperties(java.util.Properties properties)
Called by the Batch Execution Environment to make the properties specified in the xJCL available to the batch job step
-
-
-
Method Detail
-
setProperties
void setProperties(java.util.Properties properties)
Called by the Batch Execution Environment to make the properties specified in the xJCL available to the batch job step- Specified by:
setProperties
in interfacecom.ibm.batch.api.BatchJobStepInterface
- Parameters:
properties
- - the properties specified in xJCL are available in this Properties object.
-
getProperties
java.util.Properties getProperties()
Returns the properties specified in the xJCL for the batch job step.- Specified by:
getProperties
in interfacecom.ibm.batch.api.BatchJobStepInterface
- Returns:
-
createJobStep
void createJobStep()
createJobStep is called by the Batch Execution Environment before calling processJobStep. Any initialization logic, such as retrieving a BDS property, can be placed in this method.- Specified by:
createJobStep
in interfacecom.ibm.batch.api.BatchJobStepInterface
-
processJobStep
int processJobStep() throws java.lang.Exception
processJobStep should contain all the business logic for the batch job step. It is called by the Batch Execution Environment (BEE) in a batch loop. The return code of the processJobStep indicates to the BEE whether it should exit the batch loop or not. These return codes are specified in the
BatchConstants
api. For example, if processJobStep returns with return code BatchConstants.STEP_CONTINUE, the BEE will not exit the batch loop and will call processJobStep again in the next iteration of the batch loop; however, if the processJobStep returns with return code BatchConstants.STEP_COMPLETE, the BEE will exit the batch loop and hence stop calling the processJobStep method.The processJobStep method runs under a global transaction that is managed by the Batch Execution Environment (BEE). Hence, it is recommended to have a transaction policy of TX_REQUIRED. The Checkpoint policy that is applied to the batch job (via xJCL) determines when the BEE should commit the global transaction. It is the responsibility of the Batch Step Bean author to ensure that any transaction sensitive calls made in the processJobStep method, (e.g. a call to another entity EJB) should inherit the global transaction under which processJobStep runs.
TODO: make BatchApplicationException part of api.
- Specified by:
processJobStep
in interfacecom.ibm.batch.api.BatchJobStepInterface
- Returns:
- a return code specified in BatchConstants
- Throws:
java.lang.Exception
-
destroyJobStep
int destroyJobStep()
destroyJobStep is called when the Batch Execution Environment has finished processing the job step. Any clean up code can be added here. The return code returned by destroyJobStep will be the return code of this Batch Step.- Specified by:
destroyJobStep
in interfacecom.ibm.batch.api.BatchJobStepInterface
- Returns:
- a return code for this Batch Step.
-
-