Class PersistentQuartzScheduler
- java.lang.Object
-
- org.silverpeas.core.scheduler.quartz.QuartzScheduler
-
- org.silverpeas.core.scheduler.quartz.PersistentQuartzScheduler
-
- All Implemented Interfaces:
Initialization
,Scheduler
@Service @Singleton @PersistentScheduling public class PersistentQuartzScheduler extends QuartzScheduler
A persistent scheduler implementation using Quartz as scheduling backend. It wraps a Quartz scheduler and delegates to it all of the calls after transforming the parameters into their Quartz counterparts. The Quartz scheduler is configured to use a JDBC Job store instead of a RAM Job store so that all the jobs being scheduled are also persisted and then can be retrieved after a restart of the scheduling backend. Because of the persistence of the jobs and of the triggers, the scheduler mechanism is more weighty and takes more time to fire jobs. This is why such scheduler should be use with care and only for very short-time jobs.- Author:
- mmoquillon
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PersistentQuartzScheduler.PersistentJobExecutor
-
Nested classes/interfaces inherited from class org.silverpeas.core.scheduler.quartz.QuartzScheduler
QuartzScheduler.SchedulingTask<T>
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PersistentQuartzScheduler()
Constructs a new persistent scheduler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
encodeEventListener(SchedulerEventListener listener)
Encodes the specified scheduler event listener into an object ready to be handled by the job executor related to this scheduler.protected String
encodeJob(Job job)
Encodes the specified job into an object ready to be handled by the job executor related to this scheduler.protected <T> void
execute(QuartzScheduler.SchedulingTask<T> schedulingTask)
Executes the specified task.protected Class<PersistentQuartzScheduler.PersistentJobExecutor>
getJobExecutor()
Gets the job executor related to this scheduler.void
init()
Initializes some resources required by the services or performs some initialization processes at Silverpeas startup.void
release()
Releases the previously initialized resources at Silverpeas shutdown.-
Methods inherited from class org.silverpeas.core.scheduler.quartz.QuartzScheduler
getPriority, getScheduledJob, isJobScheduled, scheduleJob, scheduleJob, scheduleJob, shutdown, unscheduleJob
-
-
-
-
Method Detail
-
init
public void init()
Description copied from interface:Initialization
Initializes some resources required by the services or performs some initialization processes at Silverpeas startup.
-
release
public void release() throws Exception
Description copied from interface:Initialization
Releases the previously initialized resources at Silverpeas shutdown. The implementation of this method is optional. By default it does nothing.- Throws:
Exception
- if an error occurs during the shutdown process. In this case, a log will be outputed and the shutdown goes one.
-
encodeJob
protected String encodeJob(Job job)
Description copied from class:QuartzScheduler
Encodes the specified job into an object ready to be handled by the job executor related to this scheduler. Each type of scheduler has its own way to encode a job in order to be retrieved by the job executor related by the scheduler.- Specified by:
encodeJob
in classQuartzScheduler
- Parameters:
job
- the job to encode for the job executor related to this scheduler.- Returns:
- the encoded job.
-
encodeEventListener
protected String encodeEventListener(SchedulerEventListener listener)
Description copied from class:QuartzScheduler
Encodes the specified scheduler event listener into an object ready to be handled by the job executor related to this scheduler. Each type of scheduler has its own way to encode an event listener in order to be retrieved by the job executor related by the scheduler.- Specified by:
encodeEventListener
in classQuartzScheduler
- Parameters:
listener
- the event listener to encode for the job executor related to this scheduler.- Returns:
- the encoded scheduler event listener.
-
getJobExecutor
protected Class<PersistentQuartzScheduler.PersistentJobExecutor> getJobExecutor()
Description copied from class:QuartzScheduler
Gets the job executor related to this scheduler. Each type of scheduler has its own job executor that knows how to handle jobs and event listeners.- Specified by:
getJobExecutor
in classQuartzScheduler
- Returns:
- the class of the job executor.
-
execute
protected <T> void execute(QuartzScheduler.SchedulingTask<T> schedulingTask) throws org.quartz.SchedulerException
Description copied from class:QuartzScheduler
Executes the specified task. The execution of the task is delegated to this method that can wraps the task execution within a peculiar execution context like a transaction for example for persistent jobs.- Specified by:
execute
in classQuartzScheduler
- Parameters:
schedulingTask
- the scheduling task to execute.- Throws:
org.quartz.SchedulerException
-
-