Class LoggingJobHistoryPlugin
- java.lang.Object
-
- org.quartz.plugins.history.LoggingJobHistoryPlugin
-
- All Implemented Interfaces:
JobListener,SchedulerPlugin
public class LoggingJobHistoryPlugin extends java.lang.Object implements SchedulerPlugin, JobListener
Logs a history of all job executions (and execution vetoes) via the slf4j.The logged message is customizable by setting one of the following message properties to a String that conforms to the syntax of
java.util.MessageFormat.JobToBeFiredMessage - available message data are:
List of available data for messages. Element Data Type Description 0 String The Job's Name. 1 String The Job's Group. 2 Date The current time. 3 String The Trigger's name. 4 String The Triggers's group. 5 Date The scheduled fire time. 6 Date The next scheduled fire time. 7 Integer The re-fire count from the JobExecutionContext. The default message text is "Job {1}.{0} fired (by trigger {4}.{3}) at: {2, date, HH:mm:ss MM/dd/yyyy}"
JobSuccessMessage - available message data are:
List of available data for messages. Element Data Type Description 0 String The Job's Name. 1 String The Job's Group. 2 Date The current time. 3 String The Trigger's name. 4 String The Triggers's group. 5 Date The scheduled fire time. 6 Date The next scheduled fire time. 7 Integer The re-fire count from the JobExecutionContext. 8 Object The string value (toString() having been called) of the result (if any) that the Job set on the JobExecutionContext, with on it. "NULL" if no result was set. The default message text is "Job {1}.{0} execution complete at {2, date, HH:mm:ss MM/dd/yyyy} and reports: {8}"
JobFailedMessage - available message data are:
List of available data for messages. Element Data Type Description 0 String The Job's Name. 1 String The Job's Group. 2 Date The current time. 3 String The Trigger's name. 4 String The Triggers's group. 5 Date The scheduled fire time. 6 Date The next scheduled fire time. 7 Integer The re-fire count from the JobExecutionContext. 8 String The message from the thrown JobExecution Exception. The default message text is "Job {1}.{0} execution failed at {2, date, HH:mm:ss MM/dd/yyyy} and reports: {8}"
JobWasVetoedMessage - available message data are:
List of available data for messages. Element Data Type Description 0 String The Job's Name. 1 String The Job's Group. 2 Date The current time. 3 String The Trigger's name. 4 String The Triggers's group. 5 Date The scheduled fire time. 6 Date The next scheduled fire time. 7 Integer The re-fire count from the JobExecutionContext. The default message text is "Job {1}.{0} was vetoed. It was to be fired (by trigger {4}.{3}) at: {2, date, HH:mm:ss MM/dd/yyyy}"
- Author:
- James House
-
-
Constructor Summary
Constructors Constructor Description LoggingJobHistoryPlugin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetJobFailedMessage()Get the message that is logged when a Job fails its execution.java.lang.StringgetJobSuccessMessage()Get the message that is logged when a Job successfully completes its execution.java.lang.StringgetJobToBeFiredMessage()Get the message that is logged when a Job is about to execute.java.lang.StringgetJobWasVetoedMessage()Get the message that is logged when a Job execution is vetoed by a trigger listener.protected org.slf4j.LoggergetLog()java.lang.StringgetName()Get the name of theJobListener.voidinitialize(java.lang.String pname, Scheduler scheduler, ClassLoadHelper classLoadHelper)Called during creation of theSchedulerin order to give theSchedulerPlugina chance to initialize.voidjobExecutionVetoed(JobExecutionContext context)Called by thewhen aSchedulerwas about to be executed (an associatedJobDetailhas occurred), but aTriggervetoed it's execution.TriggerListenervoidjobToBeExecuted(JobExecutionContext context)voidjobWasExecuted(JobExecutionContext context, JobExecutionException jobException)voidsetJobFailedMessage(java.lang.String jobFailedMessage)Set the message that is logged when a Job fails its execution.voidsetJobSuccessMessage(java.lang.String jobSuccessMessage)Set the message that is logged when a Job successfully completes its execution.voidsetJobToBeFiredMessage(java.lang.String jobToBeFiredMessage)Set the message that is logged when a Job is about to execute.voidsetJobWasVetoedMessage(java.lang.String jobWasVetoedMessage)Set the message that is logged when a Job execution is vetoed by a trigger listener.voidshutdown()Called in order to inform theSchedulerPluginthat it should free up all of it's resources because the scheduler is shutting down.voidstart()Called when the associatedScheduleris started, in order to let the plug-in know it can now make calls into the scheduler if it needs to.
-
-
-
Method Detail
-
getLog
protected org.slf4j.Logger getLog()
-
getJobSuccessMessage
public java.lang.String getJobSuccessMessage()
Get the message that is logged when a Job successfully completes its execution.
-
getJobFailedMessage
public java.lang.String getJobFailedMessage()
Get the message that is logged when a Job fails its execution.
-
getJobToBeFiredMessage
public java.lang.String getJobToBeFiredMessage()
Get the message that is logged when a Job is about to execute.
-
setJobSuccessMessage
public void setJobSuccessMessage(java.lang.String jobSuccessMessage)
Set the message that is logged when a Job successfully completes its execution.- Parameters:
jobSuccessMessage- String in java.text.MessageFormat syntax.
-
setJobFailedMessage
public void setJobFailedMessage(java.lang.String jobFailedMessage)
Set the message that is logged when a Job fails its execution.- Parameters:
jobFailedMessage- String in java.text.MessageFormat syntax.
-
setJobToBeFiredMessage
public void setJobToBeFiredMessage(java.lang.String jobToBeFiredMessage)
Set the message that is logged when a Job is about to execute.- Parameters:
jobToBeFiredMessage- String in java.text.MessageFormat syntax.
-
getJobWasVetoedMessage
public java.lang.String getJobWasVetoedMessage()
Get the message that is logged when a Job execution is vetoed by a trigger listener.
-
setJobWasVetoedMessage
public void setJobWasVetoedMessage(java.lang.String jobWasVetoedMessage)
Set the message that is logged when a Job execution is vetoed by a trigger listener.- Parameters:
jobWasVetoedMessage- String in java.text.MessageFormat syntax.
-
initialize
public void initialize(java.lang.String pname, Scheduler scheduler, ClassLoadHelper classLoadHelper) throws SchedulerExceptionCalled during creation of theSchedulerin order to give theSchedulerPlugina chance to initialize.- Specified by:
initializein interfaceSchedulerPlugin- Parameters:
pname- The name by which the plugin is identified.scheduler- The scheduler to which the plugin is registered.classLoadHelper- The classLoadHelper theSchedulerFactoryis actually using- Throws:
SchedulerConfigException- if there is an error initializing.SchedulerException
-
start
public void start()
Description copied from interface:SchedulerPluginCalled when the associated
Scheduleris started, in order to let the plug-in know it can now make calls into the scheduler if it needs to.- Specified by:
startin interfaceSchedulerPlugin
-
shutdown
public void shutdown()
Called in order to inform theSchedulerPluginthat it should free up all of it's resources because the scheduler is shutting down.- Specified by:
shutdownin interfaceSchedulerPlugin
-
getName
public java.lang.String getName()
Description copied from interface:JobListenerGet the name of the
JobListener.- Specified by:
getNamein interfaceJobListener
-
jobToBeExecuted
public void jobToBeExecuted(JobExecutionContext context)
Description copied from interface:JobListenerCalled by the
when aScheduleris about to be executed (an associatedJobDetailhas occurred).TriggerThis method will not be invoked if the execution of the Job was vetoed by a
.TriggerListener- Specified by:
jobToBeExecutedin interfaceJobListener- See Also:
JobListener.jobToBeExecuted(JobExecutionContext)
-
jobWasExecuted
public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException)
Description copied from interface:JobListenerCalled by the
after aSchedulerhas been executed, and be for the associatedJobDetailTrigger'striggered(xx)method has been called.- Specified by:
jobWasExecutedin interfaceJobListener- See Also:
JobListener.jobWasExecuted(JobExecutionContext, JobExecutionException)
-
jobExecutionVetoed
public void jobExecutionVetoed(JobExecutionContext context)
Description copied from interface:JobListenerCalled by the
when aSchedulerwas about to be executed (an associatedJobDetailhas occurred), but aTriggervetoed it's execution.TriggerListener- Specified by:
jobExecutionVetoedin interfaceJobListener- See Also:
JobListener.jobExecutionVetoed(org.quartz.JobExecutionContext)
-
-