When a job execution starts, a JobExecution is created for it. This object contains information about the current execution.
You will often want to access this object or one of its child to :
- access provided user parameters in your components
- leave some information on the job execution: logs, summary, warning...
To do that, your component will need to implement an interface, telling the library that you need something.
The JobExecutionAwareInterface will allow you to gain access to the current JobExecution.
note: this interface is covered by JobExecutionAwareTrait for a default implementation that is most of the time sufficient.
The JobParametersAwareInterface will allow you to gain access to the JobParameters of the current execution.
note: this interface is covered by JobParametersAwareTrait for a default implementation that is most of the time sufficient.
The SummaryAwareInterface will allow you to gain access to the Summary of the current execution.
note: this interface is covered by SummaryAwareTrait for a default implementation that is most of the time sufficient.
There is no magic involved here, every component is responsible for propagating the context through these interfaces.
In the library, you will find that :
- ItemJob is propagating context to ItemReaderInterface, ItemProcessorInterface and ItemWriterInterface.7
- Every ItemReaderInterface, ItemProcessorInterface and ItemWriterInterface acting as a decorator, is propagating context to their decorated element.
You can add this interface to any class, but you are responsible for the context propagation.