public class LoggingJobHistoryPlugin extends Object implements ISchedulerPlugin, IJobListener
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:
| 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:
| 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:
| 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:
| 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}"
| Constructor and Description |
|---|
LoggingJobHistoryPlugin() |
| Modifier and Type | Method and Description |
|---|---|
String |
getJobFailedMessage()
Get the message that is logged when a Job fails its execution.
|
String |
getJobSuccessMessage()
Get the message that is logged when a Job successfully completes its
execution.
|
String |
getJobToBeFiredMessage()
Get the message that is logged when a Job is about to execute.
|
String |
getJobWasVetoedMessage()
Get the message that is logged when a Job execution is vetoed by a trigger
listener.
|
String |
getName()
Get the name of the
JobListener. |
void |
initialize(String pname,
IScheduler scheduler,
IClassLoadHelper classLoadHelper)
Called during creation of the
Scheduler in order to give the
SchedulerPlugin a chance to initialize. |
void |
jobExecutionVetoed(IJobExecutionContext context)
Called by the
when a
was about to be executed
(an associated has occurred), but a
vetoed it's execution. |
void |
jobToBeExecuted(IJobExecutionContext context)
Called by the
when a
is about to be executed
(an associated has occurred). |
void |
jobWasExecuted(IJobExecutionContext context,
JobExecutionException jobException)
Called by the
after a
has been executed, and be
for the associated Trigger's triggered(xx) method
has been called. |
void |
setJobFailedMessage(String jobFailedMessage)
Set the message that is logged when a Job fails its execution.
|
void |
setJobSuccessMessage(String jobSuccessMessage)
Set the message that is logged when a Job successfully completes its
execution.
|
void |
setJobToBeFiredMessage(String jobToBeFiredMessage)
Set the message that is logged when a Job is about to execute.
|
void |
setJobWasVetoedMessage(String jobWasVetoedMessage)
Set the message that is logged when a Job execution is vetoed by a trigger
listener.
|
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. |
void |
start()
Called when the associated
Scheduler is started, in order to
let the plug-in know it can now make calls into the scheduler if it needs
to. |
public String getJobSuccessMessage()
public String getJobFailedMessage()
public String getJobToBeFiredMessage()
public void setJobSuccessMessage(String jobSuccessMessage)
jobSuccessMessage - String in java.text.MessageFormat syntax.public void setJobFailedMessage(String jobFailedMessage)
jobFailedMessage - String in java.text.MessageFormat syntax.public void setJobToBeFiredMessage(String jobToBeFiredMessage)
jobToBeFiredMessage - String in java.text.MessageFormat syntax.public String getJobWasVetoedMessage()
public void setJobWasVetoedMessage(String jobWasVetoedMessage)
jobWasVetoedMessage - String in java.text.MessageFormat syntax.public void initialize(String pname, IScheduler scheduler, IClassLoadHelper classLoadHelper) throws SchedulerException
Called during creation of the Scheduler in order to give the
SchedulerPlugin a chance to initialize.
initialize in interface ISchedulerPluginpname - The name by which the plugin is identified.scheduler - The scheduler to which the plugin is registered.classLoadHelper - The classLoadHelper the SchedulerFactory is actually
usingSchedulerException - if there is an error initializing.public void start()
ISchedulerPlugin
Called when the associated Scheduler is started, in order to
let the plug-in know it can now make calls into the scheduler if it needs
to.
start in interface ISchedulerPluginpublic 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.
shutdown in interface ISchedulerPluginpublic String getName()
IJobListener
Get the name of the JobListener.
getName in interface IJobListenerpublic void jobToBeExecuted(IJobExecutionContext context)
IJobListener
Called by the when a
IScheduler is about to be executed
(an associated IJobDetail has occurred).
ITrigger
This method will not be invoked if the execution of the Job was vetoed by a
.
ITriggerListener
jobToBeExecuted in interface IJobListenerIJobListener.jobExecutionVetoed(IJobExecutionContext)public void jobWasExecuted(IJobExecutionContext context, JobExecutionException jobException)
IJobListener
Called by the after a
IScheduler has been executed, and be
for the associated IJobDetailTrigger's triggered(xx) method
has been called.
jobWasExecuted in interface IJobListenerpublic void jobExecutionVetoed(IJobExecutionContext context)
IJobListener
Called by the when a
IScheduler was about to be executed
(an associated IJobDetail has occurred), but a
ITrigger vetoed it's execution.
ITriggerListener
jobExecutionVetoed in interface IJobListenerIJobListener.jobToBeExecuted(IJobExecutionContext)Copyright © 2016–2021 Philip Helger. All rights reserved.