类 JobContext
- java.lang.Object
- org.springframework.batch.repeat.context.SynchronizedAttributeAccessor
- org.springframework.batch.core.scope.context.JobContext
- 所有已实现的接口:
org.springframework.core.AttributeAccessor
public class JobContext extends SynchronizedAttributeAccessor
A context object that can be used to interrogate the currentJobExecution
and some of its associated properties using expressions based on bean paths. Has public getters for the job execution and convenience methods for accessing commonly used properties like theExecutionContext
associated with the job execution.- 从以下版本开始:
- 3.0
- 作者:
- Dave Syer, Jimmy Praet (create JobContext based on
StepContext
), Mahmoud Ben Hassine
构造器概要
构造器 构造器 说明 JobContext(JobExecution jobExecution)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
close()
Clean up the context at the end of a step execution.boolean
equals(java.lang.Object other)
Extend the base class method to include the job execution itself as a key (i.e. two contexts are only equal if their job executions are the same).java.lang.String
getId()
JobExecution
getJobExecution()
The currentJobExecution
that is active in this context.java.util.Map<java.lang.String,java.lang.Object>
getJobExecutionContext()
java.lang.String
getJobName()
Convenient accessor for current job name identifier.java.util.Map<java.lang.String,java.lang.Object>
getJobParameters()
java.util.Properties
getSystemProperties()
Convenient accessor for System properties to make it easy to access them from placeholder expressions.int
hashCode()
Overrides the default behaviour to provide a hash code based only on the job execution.void
registerDestructionCallback(java.lang.String name, java.lang.Runnable callback)
Allow clients to register callbacks for clean up on close.java.lang.Object
removeAttribute(java.lang.String name)
Override base class behaviour to ensure destruction callbacks are unregistered as well as the default behaviour.java.lang.String
toString()
从类继承的方法 org.springframework.batch.repeat.context.SynchronizedAttributeAccessor
attributeNames, getAttribute, hasAttribute, setAttribute, setAttributeIfAbsent
构造器详细资料
JobContext
public JobContext(JobExecution jobExecution)
方法详细资料
getJobName
public java.lang.String getJobName()
Convenient accessor for current job name identifier.- 返回:
- the job name identifier of the enclosing
JobInstance
associated with the currentJobExecution
getSystemProperties
public java.util.Properties getSystemProperties()
Convenient accessor for System properties to make it easy to access them from placeholder expressions.- 返回:
- the current System properties
getJobExecutionContext
public java.util.Map<java.lang.String,java.lang.Object> getJobExecutionContext()
- 返回:
- a map containing the items from the job
ExecutionContext
getJobParameters
public java.util.Map<java.lang.String,java.lang.Object> getJobParameters()
- 返回:
- a map containing the items from the
JobParameters
registerDestructionCallback
public void registerDestructionCallback(java.lang.String name, java.lang.Runnable callback)
Allow clients to register callbacks for clean up on close.- 参数:
name
- the callback id (unique attribute key in this context)callback
- a callback to execute on close
removeAttribute
@Nullable public java.lang.Object removeAttribute(java.lang.String name)
Override base class behaviour to ensure destruction callbacks are unregistered as well as the default behaviour.- 指定者:
removeAttribute
在接口中org.springframework.core.AttributeAccessor
- 覆盖:
removeAttribute
在类中SynchronizedAttributeAccessor
- 另请参阅:
SynchronizedAttributeAccessor.removeAttribute(String)
close
public void close()
Clean up the context at the end of a step execution. Must be called once at the end of a step execution to honour the destruction callback contract from theStepScope
.
getJobExecution
public JobExecution getJobExecution()
The currentJobExecution
that is active in this context.- 返回:
- the current
JobExecution
getId
public java.lang.String getId()
- 返回:
- unique identifier for this context based on the step execution
equals
public boolean equals(java.lang.Object other)
Extend the base class method to include the job execution itself as a key (i.e. two contexts are only equal if their job executions are the same).
hashCode
public int hashCode()
Overrides the default behaviour to provide a hash code based only on the job execution.
toString
public java.lang.String toString()