public class LoggingTriggerHistoryPlugin extends Object implements ISchedulerPlugin, ITriggerListener
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 Trigger's Name. |
| 1 | String | The Trigger's Group. |
| 2 | Date | The scheduled fire time. |
| 3 | Date | The next scheduled fire time. |
| 4 | Date | The actual fire time. |
| 5 | String | The Job's name. |
| 6 | String | The Job's group. |
| 7 | Integer | The re-fire count from the JobExecutionContext. |
The default message text is "Trigger {1}.{0} fired job {6}.{5} at: {4, date, HH:mm:ss MM/dd/yyyy}"
TriggerMisfiredMessage - available message data are:
| Element | Data Type | Description |
|---|---|---|
| 0 | String | The Trigger's Name. |
| 1 | String | The Trigger's Group. |
| 2 | Date | The scheduled fire time. |
| 3 | Date | The next scheduled fire time. |
| 4 | Date | The actual fire time. (the time the misfire was detected/handled) |
| 5 | String | The Job's name. |
| 6 | String | The Job's group. |
The default message text is "Trigger {1}.{0} misfired job {6}.{5} at: {4, date, HH:mm:ss MM/dd/yyyy}. Should have fired at: {3, date, HH:mm:ss MM/dd/yyyy}"
TriggerCompleteMessage - available message data are:
| Element | Data Type | Description |
|---|---|---|
| 0 | String | The Trigger's Name. |
| 1 | String | The Trigger's Group. |
| 2 | Date | The scheduled fire time. |
| 3 | Date | The next scheduled fire time. |
| 4 | Date | The job completion time. |
| 5 | String | The Job's name. |
| 6 | String | The Job's group. |
| 7 | Integer | The re-fire count from the JobExecutionContext. |
| 8 | Integer | The trigger's resulting instruction code. |
| 9 | String | A human-readable translation of the trigger's resulting instruction code. |
The default message text is "Trigger {1}.{0} completed firing job {6}.{5} at {4, date, HH:mm:ss MM/dd/yyyy} with resulting trigger instruction code: {9}"
| Constructor and Description |
|---|
LoggingTriggerHistoryPlugin() |
| Modifier and Type | Method and Description |
|---|---|
String |
getName()
Get the name of the
TriggerListener. |
String |
getTriggerCompleteMessage()
Get the message that is printed upon the completion of a trigger's firing.
|
String |
getTriggerFiredMessage()
Get the message that is printed upon a trigger's firing.
|
String |
getTriggerMisfiredMessage()
Get the message that is printed upon a trigger's mis-firing.
|
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 |
setTriggerCompleteMessage(String triggerCompleteMessage)
Set the message that is printed upon the completion of a trigger's firing.
|
void |
setTriggerFiredMessage(String triggerFiredMessage)
Set the message that is printed upon a trigger's firing.
|
void |
setTriggerMisfiredMessage(String triggerMisfiredMessage)
Set the message that is printed upon a trigger's firing.
|
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. |
void |
triggerComplete(ITrigger trigger,
IJobExecutionContext context,
ITrigger.ECompletedExecutionInstruction triggerInstructionCode)
Called by the
when a
has fired, it's associated
has been executed, and
it's triggered(xx) method has been called. |
void |
triggerFired(ITrigger trigger,
IJobExecutionContext context)
Called by the
when a
has fired, and it's associated
is about to be executed. |
void |
triggerMisfired(ITrigger trigger)
Called by the
when a
has misfired. |
boolean |
vetoJobExecution(ITrigger trigger,
IJobExecutionContext context)
Called by the
when a
has fired, and it's associated
is about to be executed. |
public String getTriggerCompleteMessage()
public String getTriggerFiredMessage()
public String getTriggerMisfiredMessage()
public void setTriggerCompleteMessage(String triggerCompleteMessage)
triggerCompleteMessage - String in java.text.MessageFormat syntax.public void setTriggerFiredMessage(String triggerFiredMessage)
triggerFiredMessage - String in java.text.MessageFormat syntax.public void setTriggerMisfiredMessage(String triggerMisfiredMessage)
triggerMisfiredMessage - 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()
ITriggerListenerTriggerListener.getName in interface ITriggerListenerpublic void triggerFired(ITrigger trigger, IJobExecutionContext context)
ITriggerListener
Called by the when a
IScheduler has fired, and it's associated
ITrigger is about to be executed.
IJobDetail
It is called before the vetoJobExecution(..) method of this
interface.
triggerFired in interface ITriggerListenertrigger - The Trigger that has fired.context - The JobExecutionContext that will be passed to the
Job'sexecute(xx) method.public void triggerMisfired(ITrigger trigger)
ITriggerListener
Called by the when a
IScheduler has misfired.
ITrigger
Consideration should be given to how much time is spent in this method, as it will affect all triggers that are misfiring. If you have lots of triggers misfiring at once, it could be an issue it this method does a lot.
triggerMisfired in interface ITriggerListenertrigger - The Trigger that has misfired.public void triggerComplete(ITrigger trigger, IJobExecutionContext context, ITrigger.ECompletedExecutionInstruction triggerInstructionCode)
ITriggerListener
Called by the when a
IScheduler has fired, it's associated
ITrigger has been executed, and
it's IJobDetailtriggered(xx) method has been called.
triggerComplete in interface ITriggerListenertrigger - The Trigger that was fired.context - The JobExecutionContext that was passed to the
Job'sexecute(xx) method.triggerInstructionCode - the result of the call on the
Trigger'striggered(xx) method.public boolean vetoJobExecution(ITrigger trigger, IJobExecutionContext context)
ITriggerListener
Called by the when a
IScheduler has fired, and it's associated
ITrigger is about to be executed.
If the implementation vetos the execution (via returning
IJobDetailtrue), the job's execute method will not be called.
It is called after the triggerFired(..) method of this
interface.
vetoJobExecution in interface ITriggerListenertrigger - The Trigger that has fired.context - The JobExecutionContext that will be passed to the
Job'sexecute(xx) method.Copyright © 2016–2021 Philip Helger. All rights reserved.