Package org.silverpeas.core.scheduler
Class SchedulerEvent
- java.lang.Object
-
- org.silverpeas.core.scheduler.SchedulerEvent
-
public class SchedulerEvent extends Object
A scheduler event represents an event that is generated within the scheduling system and that is dispatched by schedulers to registered event listeners. A scheduler event is generated each time a state change occurs in the scheduling system machinery and the event carries information about this state change. A state change occurs in the scheduling system in the following situation:- A trigger fires the execution of a job: the scheduling system then runs the job within a dedicated thread;
- A job terminates abnormally: the job execution throws an exception that is catched by the scheduling system; the failover handler is running.
- A job terminates correctly: the job termination handler is running.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SchedulerEvent.Type
The different possible types of an event send by the scheduler.
-
Constructor Summary
Constructors Modifier Constructor Description protected
SchedulerEvent(SchedulerEvent.Type aType, JobExecutionContext aContext)
Constructs a scheduler event.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JobExecutionContext
getJobExecutionContext()
Gets the context of a job execution.Throwable
getJobThrowable()
Gets the throwable object that was thrown during a job execution and that carries the job failure.SchedulerEvent.Type
getType()
This method returns the event typeboolean
isExceptionThrown()
Is an exception thrown during a job execution?static SchedulerEvent
jobFailed(JobExecutionContext context, Throwable throwable)
Creates a new scheduler event about a failure of a job execution.static SchedulerEvent
jobSucceeded(JobExecutionContext context)
Creates a new scheduler event about a success of a job execution.protected void
setThrowable(Throwable aThrowable)
static SchedulerEvent
triggerFired(JobExecutionContext context)
Creates a new scheduler event about a trigger firing.
-
-
-
Constructor Detail
-
SchedulerEvent
protected SchedulerEvent(SchedulerEvent.Type aType, JobExecutionContext aContext)
Constructs a scheduler event.- Parameters:
aType
- the type of the eventaContext
- the context of the job execution.
-
-
Method Detail
-
triggerFired
public static SchedulerEvent triggerFired(JobExecutionContext context)
Creates a new scheduler event about a trigger firing.- Parameters:
context
- the context of the job to be executed.- Returns:
- the scheduler event fired by the firing of a trigger.
-
jobSucceeded
public static SchedulerEvent jobSucceeded(JobExecutionContext context)
Creates a new scheduler event about a success of a job execution.- Parameters:
context
- the context of the completed execution of a job.- Returns:
- the scheduler event fired by the job completion.
-
jobFailed
public static SchedulerEvent jobFailed(JobExecutionContext context, Throwable throwable)
Creates a new scheduler event about a failure of a job execution.- Parameters:
context
- the context of the failed execution of a job.throwable
- the Throwable object carrying the job failure.- Returns:
- the scheduler event fired by a job failure.
-
getType
public SchedulerEvent.Type getType()
This method returns the event type- Returns:
- The type of the event
-
isExceptionThrown
public boolean isExceptionThrown()
Is an exception thrown during a job execution?- Returns:
- true if an exception was thrown during the execution of a job, false otherwise.
-
getJobThrowable
public Throwable getJobThrowable()
Gets the throwable object that was thrown during a job execution and that carries the job failure.- Returns:
- the throwable raised during a job execution or null if the job completed successfully.
-
getJobExecutionContext
public JobExecutionContext getJobExecutionContext()
Gets the context of a job execution.- Returns:
- a JobExecutionContext instance as it is or it will passed to a job execution.
-
setThrowable
protected void setThrowable(Throwable aThrowable)
-
-