public class JobExecutionContext extends Object implements IJobExecutionContext
| Constructor and Description |
|---|
JobExecutionContext(IScheduler scheduler,
TriggerFiredBundle firedBundle,
IJob job)
Create a JobExcecutionContext with the given context data.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
get(Object key)
Get the value with the given key from the context's data map.
|
ICalendar |
getCalendar()
Get a handle to the
Calendar referenced by the
Trigger instance that fired the Job. |
String |
getFireInstanceId()
Get the unique Id that identifies this particular firing instance of the
trigger that triggered this job execution.
|
Date |
getFireTime()
The actual time the trigger fired.
|
IJobDetail |
getJobDetail()
Get the
JobDetail associated with the Job. |
IJob |
getJobInstance()
Get the instance of the
Job that was created for this
execution. |
long |
getJobRunTime()
The amount of time the job ran for (in milliseconds).
|
JobDataMap |
getMergedJobDataMap()
Get the convenience
JobDataMap of this execution context. |
Date |
getNextFireTime() |
Date |
getPreviousFireTime() |
TriggerKey |
getRecoveringTriggerKey()
Return the
TriggerKey of the originally scheduled and now
recovering job. |
int |
getRefireCount() |
Object |
getResult()
Returns the result (if any) that the
Job set before its
execution completed (the type of object set as the result is entirely up to
the particular job). |
Date |
getScheduledFireTime()
The scheduled time the trigger fired for.
|
IScheduler |
getScheduler()
Get a handle to the
Scheduler instance that fired the
Job. |
ITrigger |
getTrigger()
Get a handle to the
Trigger instance that fired the
Job. |
void |
incrementRefireCount() |
boolean |
isRecovering()
If the
Job is being re-executed because of a 'recovery'
situation, this method will return true. |
void |
put(Object key,
Object value)
Put the specified value into the context's data map with the given key.
|
void |
setJobRunTime(long jobRunTime) |
void |
setResult(Object result)
Set the result (if any) of the
Job's execution (the type of
object set as the result is entirely up to the particular job). |
String |
toString() |
public JobExecutionContext(IScheduler scheduler, TriggerFiredBundle firedBundle, IJob job)
public IScheduler getScheduler()
Get a handle to the Scheduler instance that fired the
Job.
getScheduler in interface IJobExecutionContextpublic ITrigger getTrigger()
Get a handle to the Trigger instance that fired the
Job.
getTrigger in interface IJobExecutionContextpublic ICalendar getCalendar()
Get a handle to the Calendar referenced by the
Trigger instance that fired the Job.
getCalendar in interface IJobExecutionContextpublic boolean isRecovering()
If the Job is being re-executed because of a 'recovery'
situation, this method will return true.
isRecovering in interface IJobExecutionContextpublic TriggerKey getRecoveringTriggerKey()
IJobExecutionContextTriggerKey of the originally scheduled and now
recovering job.
When recovering a previously failed job execution this method returns the
identity of the originally firing trigger. This recovering job will have
been scheduled for the same firing time as the original job, and so is
available via the IJobExecutionContext.getScheduledFireTime() method. The original
firing time of the job can be accessed via the
IScheduler.FAILED_JOB_ORIGINAL_TRIGGER_FIRETIME_IN_MILLISECONDS
element of this job's JobDataMap.
getRecoveringTriggerKey in interface IJobExecutionContextpublic void incrementRefireCount()
public int getRefireCount()
getRefireCount in interface IJobExecutionContextpublic JobDataMap getMergedJobDataMap()
Get the convenience JobDataMap of this execution context.
The JobDataMap found on this object serves as a convenience -
it is a merge of the JobDataMap found on the
JobDetail and the one found on the Trigger, with
the value in the latter overriding any same-named values in the former.
It is thus considered a 'best practice' that the execute code of a Job
retrieve data from the JobDataMap found on this object.
NOTE: Do not expect value 'set' into this JobDataMap to somehow be set or
persisted back onto a job's own JobDataMap - even if it has the
@PersistJobDataAfterExecution annotation.
Attempts to change the contents of this map typically result in an
IllegalStateException.
getMergedJobDataMap in interface IJobExecutionContextpublic IJobDetail getJobDetail()
Get the JobDetail associated with the Job.
getJobDetail in interface IJobExecutionContextpublic IJob getJobInstance()
Get the instance of the Job that was created for this
execution.
Note: The Job instance is not available through remote scheduler interfaces.
getJobInstance in interface IJobExecutionContextpublic Date getFireTime()
getFireTime in interface IJobExecutionContextIJobExecutionContext.getScheduledFireTime()public Date getScheduledFireTime()
getScheduledFireTime in interface IJobExecutionContextIJobExecutionContext.getFireTime()public Date getPreviousFireTime()
getPreviousFireTime in interface IJobExecutionContextpublic Date getNextFireTime()
getNextFireTime in interface IJobExecutionContextpublic Object getResult()
Job set before its
execution completed (the type of object set as the result is entirely up to
the particular job).
The result itself is meaningless to Quartz, but may be informative to
or
IJobListeners that are watching the job's
execution.
ITriggerListeners
getResult in interface IJobExecutionContextpublic void setResult(Object result)
Job's execution (the type of
object set as the result is entirely up to the particular job).
The result itself is meaningless to Quartz, but may be informative to
or
IJobListeners that are watching the job's
execution.
ITriggerListeners
setResult in interface IJobExecutionContextpublic long getJobRunTime()
JobListeners and
TriggerListeners.getJobRunTime in interface IJobExecutionContextpublic void setJobRunTime(long jobRunTime)
jobRunTime - The jobRunTime to set.public void put(Object key, Object value)
NOTE: this data is volatile - it is lost after the job execution completes, and all TriggerListeners and JobListeners have been notified.
put in interface IJobExecutionContextkey - the key for the associated valuevalue - the value to storepublic Object get(Object key)
get in interface IJobExecutionContextkey - the key for the desired valuepublic String getFireInstanceId()
getFireInstanceId in interface IJobExecutionContextIScheduler.interrupt(String)Copyright © 2016–2021 Philip Helger. All rights reserved.