Interface JobExecutionContext
- All Known Implementing Classes:
JobExecutionContextImpl
JobDetail instance as it is executed, and to a
Trigger instance after the execution completes.
The JobDataMap found on this object (via the getMergedJobDataMap()
method) 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 back onto a StatefulJob
's own JobDataMap.
JobExecutionContext s are also returned from the
Scheduler.getCurrentlyExecutingJobs() method. These are the same instances as those passed
into the jobs that are currently executing within the scheduler. The exception to this is when
your application is using Quartz remotely (i.e. via RMI) - in which case you get a clone of the
JobExecutionContexts, and their references to the Scheduler and
Job instances have been lost (a clone of the JobDetail is still available -
just not a handle to the job instance that is running).
- Author:
- James House
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionGet a handle to theCalendarreferenced by theTriggerinstance that fired theJob.The actual time the trigger fired.Get theJobDetailassociated with theJob.Get the instance of theJobthat was created for this execution.longThe amount of time the job ran for (in milliseconds).Get the convenienceJobDataMapof this execution context.intReturns the result (if any) that theJobset before its execution completed (the type of object set as the result is entirely up to the particular job).The scheduled time the trigger fired for.Get a handle to theSchedulerinstance that fired theJob.Get a handle to theTriggerinstance that fired theJob.booleanIf theJobis being re-executed because of a 'recovery' situation, this method will returntrue.voidSet the result (if any) of theJob's execution (the type of object set as the result is entirely up to the particular job).
-
Method Details
-
getScheduler
Scheduler getScheduler()Get a handle to theSchedulerinstance that fired theJob. -
getTrigger
Trigger getTrigger()Get a handle to theTriggerinstance that fired theJob. -
getCalendar
Calendar getCalendar()Get a handle to theCalendarreferenced by theTriggerinstance that fired theJob. -
isRecovering
boolean isRecovering()If theJobis being re-executed because of a 'recovery' situation, this method will returntrue. -
getRefireCount
int getRefireCount() -
getMergedJobDataMap
JobDataMap getMergedJobDataMap()Get the convenienceJobDataMapof this execution context.The
JobDataMapfound on this object serves as a convenience - it is a merge of theJobDataMapfound on theJobDetailand the one found on theTrigger, 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 back onto a
StatefulJob's own JobDataMap.Attempts to change the contents of this map typically result in an
IllegalStateException. -
getJobDetail
JobDetail getJobDetail()Get theJobDetailassociated with theJob. -
getJobInstance
Job getJobInstance()Get the instance of theJobthat was created for this execution.Note: The Job instance is not available through remote scheduler interfaces.
-
getFireTime
Date getFireTime()The actual time the trigger fired. For instance the scheduled time may have been 10:00:00 but the actual fire time may have been 10:00:03 if the scheduler was too busy.- Returns:
- Returns the fireTime.
- See Also:
-
getScheduledFireTime
Date getScheduledFireTime()The scheduled time the trigger fired for. For instance the scheduled time may have been 10:00:00 but the actual fire time may have been 10:00:03 if the scheduler was too busy.- Returns:
- Returns the scheduledFireTime.
- See Also:
-
getPreviousFireTime
Date getPreviousFireTime() -
getNextFireTime
Date getNextFireTime() -
getResult
Object getResult()Returns the result (if any) that theJobset 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
orJobListenersthat are watching the job's execution.TriggerListeners- Returns:
- Returns the result.
-
setResult
Set the result (if any) of theJob'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
orJobListenersthat are watching the job's execution.TriggerListeners -
getJobRunTime
long getJobRunTime()The amount of time the job ran for (in milliseconds). The returned value will be -1 until the job has actually completed (or thrown an exception), and is therefore generally only useful toJobListeners andTriggerListeners.- Returns:
- Returns the jobRunTime.
-