org.springframework.batch.core
Class JobExecution

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

public class JobExecution
extends Entity

Batch domain object representing the execution of a job.

Author:
Lucas Ward
See Also:
Serialized Form

Constructor Summary
JobExecution(JobInstance job)
          Constructor for transient (unsaved) instances.
JobExecution(JobInstance job, Long id)
          Because a JobExecution isn't valid unless the job is set, this constructor is the only valid one from a modelling point of view.
 
Method Summary
 StepExecution createStepExecution(Step step)
          Register a step execution with the current job execution.
 Date getCreateTime()
           
 Date getEndTime()
           
 ExecutionContext getExecutionContext()
          Returns the ExecutionContext for this execution
 ExitStatus getExitStatus()
           
 Long getJobId()
          Convenience getter for for the id of the enclosing job.
 JobInstance getJobInstance()
           
 Date getStartTime()
           
 BatchStatus getStatus()
           
 Collection getStepExecutions()
          Accessor for the step executions.
 boolean isRunning()
          Test if this JobExecution indicates that it is running.
 boolean isStopping()
          Test if this JobExecution indicates that it has been signalled to stop.
 void setCreateTime(Date createTime)
           
 void setEndTime(Date endTime)
           
 void setExecutionContext(ExecutionContext executionContext)
          Sets the ExecutionContext for this execution
 void setExitStatus(ExitStatus exitStatus)
           
 void setStartTime(Date startTime)
           
 void setStatus(BatchStatus status)
           
 void stop()
          Signal the JobExecution to stop.
 String toString()
           
 
Methods inherited from class org.springframework.batch.core.Entity
equals, getId, getVersion, hashCode, incrementVersion, setId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JobExecution

public JobExecution(JobInstance job,
                    Long id)
Because a JobExecution isn't valid unless the job is set, this constructor is the only valid one from a modelling point of view.

Parameters:
job - the job of which this execution is a part

JobExecution

public JobExecution(JobInstance job)
Constructor for transient (unsaved) instances.

Parameters:
job - the enclosing JobInstance
Method Detail

getEndTime

public Date getEndTime()

setEndTime

public void setEndTime(Date endTime)

getStartTime

public Date getStartTime()

setStartTime

public void setStartTime(Date startTime)

getStatus

public BatchStatus getStatus()

setStatus

public void setStatus(BatchStatus status)

getJobId

public Long getJobId()
Convenience getter for for the id of the enclosing job. Useful for DAO implementations.

Returns:
the id of the enclosing job

setExitStatus

public void setExitStatus(ExitStatus exitStatus)
Parameters:
exitStatus -

getExitStatus

public ExitStatus getExitStatus()
Returns:
the exitCode

getJobInstance

public JobInstance getJobInstance()
Returns:
the Job that is executing.

getStepExecutions

public Collection getStepExecutions()
Accessor for the step executions.

Returns:
the step executions that were registered

createStepExecution

public StepExecution createStepExecution(Step step)
Register a step execution with the current job execution.


toString

public String toString()
Overrides:
toString in class Entity

isRunning

public boolean isRunning()
Test if this JobExecution indicates that it is running. It should be noted that this does not necessarily mean that it has been persisted as such yet.

Returns:
true if the end time is null

isStopping

public boolean isStopping()
Test if this JobExecution indicates that it has been signalled to stop.

Returns:
true if the status is BatchStatus.STOPPING

stop

public void stop()
Signal the JobExecution to stop. Iterates through the associated StepExecutions, calling StepExecution.setTerminateOnly().


setExecutionContext

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

Parameters:
executionContext - the context

getExecutionContext

public ExecutionContext getExecutionContext()
Returns the ExecutionContext for this execution

Returns:
the context

getCreateTime

public Date getCreateTime()
Returns:
the time when this execution was created.

setCreateTime

public void setCreateTime(Date createTime)
Parameters:
createTime - creation time of this execution.


Copyright © 2009 SpringSource. All Rights Reserved.