public class LoggingTriggerHistoryPlugin extends Object implements SchedulerPlugin, TriggerListener
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. |
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. |
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. |
Constructor and Description |
---|
LoggingTriggerHistoryPlugin() |
Modifier and Type | Method and Description |
---|---|
protected org.slf4j.Logger |
getLog() |
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,
Scheduler scheduler,
ClassLoadHelper 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(Trigger trigger,
JobExecutionContext context,
Trigger.CompletedExecutionInstruction triggerInstructionCode)
|
void |
triggerFired(Trigger trigger,
JobExecutionContext context)
|
void |
triggerMisfired(Trigger trigger)
|
boolean |
vetoJobExecution(Trigger trigger,
JobExecutionContext context)
|
protected org.slf4j.Logger getLog()
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, Scheduler scheduler, ClassLoadHelper classLoadHelper) throws SchedulerException
Called during creation of the Scheduler
in order to give
the SchedulerPlugin
a chance to initialize.
initialize
in interface SchedulerPlugin
pname
- The name by which the plugin is identified.scheduler
- The scheduler to which the plugin is registered.classLoadHelper
- The classLoadHelper the SchedulerFactory
is
actually usingSchedulerConfigException
- if there is an error initializing.SchedulerConfigException
- if there is an error initializing.SchedulerException
public void start()
SchedulerPlugin
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 SchedulerPlugin
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.
shutdown
in interface SchedulerPlugin
public String getName()
TriggerListener
Get the name of the TriggerListener
.
getName
in interface TriggerListener
public void triggerFired(Trigger trigger, JobExecutionContext context)
TriggerListener
Called by the
when a Scheduler
has fired, and it's associated Trigger
is about to be executed.
JobDetail
It is called before the vetoJobExecution(..)
method of this
interface.
triggerFired
in interface TriggerListener
trigger
- The Trigger
that has fired.context
- The JobExecutionContext
that will be passed to
the Job
'sexecute(xx)
method.public void triggerMisfired(Trigger trigger)
TriggerListener
Called by the
when a Scheduler
has misfired.
Trigger
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 TriggerListener
trigger
- The Trigger
that has misfired.public void triggerComplete(Trigger trigger, JobExecutionContext context, Trigger.CompletedExecutionInstruction triggerInstructionCode)
TriggerListener
Called by the
when a Scheduler
has fired, it's associated Trigger
has been executed, and it's JobDetail
triggered(xx)
method has been
called.
triggerComplete
in interface TriggerListener
trigger
- 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(Trigger trigger, JobExecutionContext context)
TriggerListener
Called by the
when a Scheduler
has fired, and it's associated Trigger
is about to be executed. If the implementation vetos the execution (via
returning JobDetail
true
), the job's execute method will not be called.
It is called after the triggerFired(..)
method of this
interface.
vetoJobExecution
in interface TriggerListener
trigger
- The Trigger
that has fired.context
- The JobExecutionContext
that will be passed to
the Job
'sexecute(xx)
method.Copyright 2001-2019, Terracotta, Inc.