org.springframework.batch.core
Class StepExecution

java.lang.Object
  extended by org.springframework.batch.core.Entity
      extended by org.springframework.batch.core.StepExecution
All Implemented Interfaces:
Serializable

public class StepExecution
extends Entity

Batch domain object representation the execution of a step. Unlike JobExecution, there are four additional properties: itemCount, commitCount, rollbackCount and execution context. These values represent how many items the step has processed, how many times it has been committed and rolled back, and any other information the developer wishes to store, respectively.

Author:
Lucas Ward, Dave Syer
See Also:
Serialized Form

Constructor Summary
StepExecution(String stepName, JobExecution jobExecution)
          Constructor that substitutes in null for the execution id
StepExecution(String stepName, JobExecution jobExecution, Long id)
          Constructor with mandatory properties.
 
Method Summary
 void apply(StepContribution contribution)
          On successful execution just before a chunk commit, this method should be called.
 StepContribution createStepContribution()
          Factory method for StepContribution.
 boolean equals(Object obj)
          Attempt to establish identity based on id if both exist.
 Integer getCommitCount()
          Returns the current number of commits for this execution
 Date getEndTime()
          Returns the time that this execution ended
 ExecutionContext getExecutionContext()
          Returns the ExecutionContext for this execution
 ExitStatus getExitStatus()
           
 Integer getItemCount()
          Returns the current number of items processed for this execution
 JobExecution getJobExecution()
          Accessor for the execution context information of the enclosing job.
 Long getJobExecutionId()
          Accessor for the job execution id.
 JobParameters getJobParameters()
          Convenience method to get the current job parameters.
 Integer getReadSkipCount()
           
 Integer getRollbackCount()
          Returns the current number of rollbacks for this execution
 int getSkipCount()
           
 Date getStartTime()
          Gets the time this execution started
 BatchStatus getStatus()
          Returns the current status of this step
 String getStepName()
           
 Integer getWriteSkipCount()
           
 int hashCode()
          Use ID if it exists to establish hash code, otherwise fall back to Object.hashCode().
 void incrementReadSkipCountBy(int count)
           
 void incrementWriteSkipCountBy(int count)
           
 boolean isTerminateOnly()
           
 void rollback()
          On unsuccessful execution after a chunk has rolled back.
 void setCommitCount(int commitCount)
          Sets the current number of commits for this execution
 void setEndTime(Date endTime)
          Sets the time that this execution ended
 void setExecutionContext(ExecutionContext executionContext)
          Sets the ExecutionContext for this execution
 void setExitStatus(ExitStatus exitStatus)
           
 void setItemCount(int itemCount)
          Sets the current number of processed items for this execution
 void setReadSkipCount(int readSkipCount)
           
 void setRollbackCount(int rollbackCount)
          Setter for number of rollbacks for this execution
 void setStartTime(Date startTime)
          Sets the time this execution started
 void setStatus(BatchStatus status)
          Sets the current status of this step
 void setTerminateOnly()
          Set a flag that will signal to an execution environment that this execution (and its surrounding job) wishes to exit.
 void setWriteSkipCount(int writeSkipCount)
           
 String toString()
           
 
Methods inherited from class org.springframework.batch.core.Entity
getId, getVersion, incrementVersion, setId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StepExecution

public StepExecution(String stepName,
                     JobExecution jobExecution,
                     Long id)
Constructor with mandatory properties.

Parameters:
stepName - the step to which this execution belongs
jobExecution - the current job execution
id - the id of this execution

StepExecution

public StepExecution(String stepName,
                     JobExecution jobExecution)
Constructor that substitutes in null for the execution id

Parameters:
stepName - the step to which this execution belongs
jobExecution - the current job execution
Method Detail

getExecutionContext

public ExecutionContext getExecutionContext()
Returns the ExecutionContext for this execution

Returns:
the attributes

setExecutionContext

public void setExecutionContext(ExecutionContext executionContext)
Sets the ExecutionContext for this execution

Parameters:
executionContext - the attributes

getCommitCount

public Integer getCommitCount()
Returns the current number of commits for this execution

Returns:
the current number of commits

setCommitCount

public void setCommitCount(int commitCount)
Sets the current number of commits for this execution

Parameters:
commitCount - the current number of commits

getEndTime

public Date getEndTime()
Returns the time that this execution ended

Returns:
the time that this execution ended

setEndTime

public void setEndTime(Date endTime)
Sets the time that this execution ended

Parameters:
endTime - the time that this execution ended

getItemCount

public Integer getItemCount()
Returns the current number of items processed for this execution

Returns:
the current number of items processed for this execution

setItemCount

public void setItemCount(int itemCount)
Sets the current number of processed items for this execution

Parameters:
itemCount - the current number of processed items for this execution

getRollbackCount

public Integer getRollbackCount()
Returns the current number of rollbacks for this execution

Returns:
the current number of rollbacks for this execution

setRollbackCount

public void setRollbackCount(int rollbackCount)
Setter for number of rollbacks for this execution


getStartTime

public Date getStartTime()
Gets the time this execution started

Returns:
the time this execution started

setStartTime

public void setStartTime(Date startTime)
Sets the time this execution started

Parameters:
startTime - the time this execution started

getStatus

public BatchStatus getStatus()
Returns the current status of this step

Returns:
the current status of this step

setStatus

public void setStatus(BatchStatus status)
Sets the current status of this step

Parameters:
status - the current status of this step

getStepName

public String getStepName()
Returns:
the name of the step

getJobExecutionId

public Long getJobExecutionId()
Accessor for the job execution id.

Returns:
the jobExecutionId

equals

public boolean equals(Object obj)
Description copied from class: Entity
Attempt to establish identity based on id if both exist. If either id does not exist use Object.equals().

Overrides:
equals in class Entity
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Description copied from class: Entity
Use ID if it exists to establish hash code, otherwise fall back to Object.hashCode(). Based on the same information as equals, so if that changes, this will. N.B. this follows the contract of Object.hashCode(), but will cause problems for anyone adding an unsaved Entity to a Set because Set.contains() will almost certainly return false for the Entity after it is saved. Spring Batch does not store any of its entities in Sets as a matter of course, so internally this is consistent. Clients should not be exposed to unsaved entities.

Overrides:
hashCode in class Entity
See Also:
Object.hashCode()

toString

public String toString()
Overrides:
toString in class Entity

setExitStatus

public void setExitStatus(ExitStatus exitStatus)
Parameters:
exitStatus -

getExitStatus

public ExitStatus getExitStatus()
Returns:
the exitCode

getJobExecution

public JobExecution getJobExecution()
Accessor for the execution context information of the enclosing job.

Returns:
the JobExecution that was used to start this step execution.

createStepContribution

public StepContribution createStepContribution()
Factory method for StepContribution.

Returns:
a new StepContribution

apply

public void apply(StepContribution contribution)
On successful execution just before a chunk commit, this method should be called. Synchronizes access to the StepExecution so that changes are atomic.

Parameters:
contribution -

rollback

public void rollback()
On unsuccessful execution after a chunk has rolled back.


isTerminateOnly

public boolean isTerminateOnly()
Returns:
flag to indicate that an execution should halt

setTerminateOnly

public void setTerminateOnly()
Set a flag that will signal to an execution environment that this execution (and its surrounding job) wishes to exit.


getSkipCount

public int getSkipCount()

incrementReadSkipCountBy

public void incrementReadSkipCountBy(int count)

incrementWriteSkipCountBy

public void incrementWriteSkipCountBy(int count)

getJobParameters

public JobParameters getJobParameters()
Convenience method to get the current job parameters.

Returns:
the JobParameters from the enclosing job, or empty if that is null

getReadSkipCount

public Integer getReadSkipCount()

getWriteSkipCount

public Integer getWriteSkipCount()

setReadSkipCount

public void setReadSkipCount(int readSkipCount)

setWriteSkipCount

public void setWriteSkipCount(int writeSkipCount)


Copyright © 2009 SpringSource. All Rights Reserved.