org.quartz.plugins.history
Class LoggingJobHistoryPlugin

java.lang.Object
  extended byorg.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 execytions via the Jakarta Commons-Logging framework.

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.

TriggerFiredMessage - available message data are:

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}"

TriggerCompleteMessage - available message data are:

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 any thrown JobExecution Exception, or "NO ERRORS".
The default message text is "Job {1}.{0} execution complete at {2, date, HH:mm:ss MM/dd/yyyy} and reports: {8}"

Author:
James House

Constructor Summary
LoggingJobHistoryPlugin()
           
 
Method Summary
 java.lang.String getJobCompleteMessage()
          Get the message that is logged when a Job completes its execution.
 java.lang.String getJobToBeFiredMessage()
          Get the message that is logged when a Job is about to execute.
protected static org.apache.commons.logging.Log getLog()
           
 java.lang.String getName()
          Get the name of the JobListener.
 void initialize(java.lang.String name, Scheduler scheduler)
          Called during creation of the Scheduler in order to give the SchedulerPlugin a chance to initialize.
 void jobToBeExecuted(JobExecutionContext context)
          Called by the Scheduler when a JobDetail is about to be executed (an associated Trigger has occured).
 void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException)
          Called by the Scheduler after a JobDetail has been executed, and be for the associated Trigger's triggered(xx) method has been called.
 void setJobCompleteMessage(java.lang.String jobCompleteMessage)
          Set the message that is logged when a Job completes its execution.
 void setJobToBeFiredMessage(java.lang.String jobToBeFiredMessage)
          Set the message that is logged when a Job is about to execute.
 void shutdown()
          Called in order to inform the SchedulerPlugin that it should free up all of it's resources because the scheduler is shutting down.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingJobHistoryPlugin

public LoggingJobHistoryPlugin()
Method Detail

getLog

protected static org.apache.commons.logging.Log getLog()

getJobCompleteMessage

public java.lang.String getJobCompleteMessage()
Get the message that is logged when a Job completes its execution.

Returns:
String

getJobToBeFiredMessage

public java.lang.String getJobToBeFiredMessage()
Get the message that is logged when a Job is about to execute.

Returns:
String

setJobCompleteMessage

public void setJobCompleteMessage(java.lang.String jobCompleteMessage)
Set the message that is logged when a Job completes its execution.

Parameters:
jobCompleteMessage - 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.

initialize

public void initialize(java.lang.String name,
                       Scheduler scheduler)
                throws SchedulerException

Called during creation of the Scheduler in order to give the SchedulerPlugin a chance to initialize.

Specified by:
initialize in interface SchedulerPlugin
Parameters:
name - The name by which the plugin is identified.
scheduler - The scheduler to which the plugin is registered.
Throws:
SchedulerConfigException - if there is an error initializing.
SchedulerException

shutdown

public void shutdown()

Called in order to inform the SchedulerPlugin that it should free up all of it's resources because the scheduler is shutting down.

Specified by:
shutdown in interface SchedulerPlugin

getName

public java.lang.String getName()
Description copied from interface: JobListener

Get the name of the JobListener.

Specified by:
getName in interface JobListener

jobToBeExecuted

public void jobToBeExecuted(JobExecutionContext context)
Description copied from interface: JobListener

Called by the Scheduler when a JobDetail is about to be executed (an associated Trigger has occured).

Specified by:
jobToBeExecuted in interface JobListener

jobWasExecuted

public void jobWasExecuted(JobExecutionContext context,
                           JobExecutionException jobException)
Description copied from interface: JobListener

Called by the Scheduler after a JobDetail has been executed, and be for the associated Trigger's triggered(xx) method has been called.

Specified by:
jobWasExecuted in interface JobListener


Copyright James House (c) 2001-2004