Package io.mangoo.scheduler
Class Scheduler
- java.lang.Object
-
- io.mangoo.scheduler.Scheduler
-
public class Scheduler extends Object
Convenient class for interacting with the quartz scheduler- Author:
- svenkubiak
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangeState(String jobName)Changes the state of a normally running job from pause to resume or resume to pausevoiddeleteJob(String name)Delete a job by a given namevoidexecuteJob(String jobName)Executes a single Quartz Scheduler job right away only onceList<org.quartz.JobKey>getAllJobKeys()Retrieves a list of all JobKeys from the Quartz SchedulerList<Job>getAllJobs()Retrieves a list of all jobs and their current statusorg.quartz.JobKeygetJobKey(String name)Retrieves a JobKey by it given nameorg.quartz.SchedulergetQuartzScheduler()Returns the current quartz scheduler instancevoidinitialize()Initializes the scheduler by booting up QuartzbooleanisInitialize()Checks if the scheduler has been initializedbooleanisStarted()Checks if the scheduler is initialized and startedvoidpauseJob(String name)Pauses a job by a given namevoidresumeJob(String name)Resume a job by a given namevoidschedule(org.quartz.JobDetail jobDetail, org.quartz.Trigger trigger)Adds a new job with a given JobDetail and Trigger to the schedulervoidshutdown()voidstandby()voidstart()
-
-
-
Constructor Detail
-
Scheduler
@Inject public Scheduler(Config config)
-
-
Method Detail
-
initialize
public void initialize()
Initializes the scheduler by booting up Quartz
-
isInitialize
public boolean isInitialize()
Checks if the scheduler has been initialized- Returns:
- True if the scheduler has been initializes, false otherwise
-
isStarted
public boolean isStarted() throws MangooSchedulerExceptionChecks if the scheduler is initialized and started- Returns:
- true if the scheduler is started, false otherwise
- Throws:
MangooSchedulerException- if an error occurred accessing the scheduler
-
getQuartzScheduler
public org.quartz.Scheduler getQuartzScheduler()
Returns the current quartz scheduler instance- Returns:
- Scheduler instance, null if scheduler is not initialize or started
-
start
public void start() throws MangooSchedulerException- Throws:
MangooSchedulerException
-
shutdown
public void shutdown() throws MangooSchedulerException- Throws:
MangooSchedulerException
-
standby
public void standby() throws MangooSchedulerException- Throws:
MangooSchedulerException
-
schedule
public void schedule(org.quartz.JobDetail jobDetail, org.quartz.Trigger trigger) throws MangooSchedulerExceptionAdds a new job with a given JobDetail and Trigger to the scheduler- Parameters:
jobDetail- The JobDetail for the Jobtrigger- The Trigger for the job- Throws:
MangooSchedulerException- when accessing the scheduler results in an error
-
getAllJobs
public List<Job> getAllJobs() throws MangooSchedulerException
Retrieves a list of all jobs and their current status- Returns:
- List of io.mangoo.models.Job objects
- Throws:
MangooSchedulerException- if an error occurs during access to the Quartz Scheduler
-
pauseJob
public void pauseJob(String name) throws MangooSchedulerException
Pauses a job by a given name- Parameters:
name- The name of the job to pause- Throws:
MangooSchedulerException- when pausing fails
-
resumeJob
public void resumeJob(String name) throws MangooSchedulerException
Resume a job by a given name- Parameters:
name- The name of the job to resume- Throws:
MangooSchedulerException- if resuming fails
-
deleteJob
public void deleteJob(String name) throws MangooSchedulerException
Delete a job by a given name- Parameters:
name- The name of the job to delete- Throws:
MangooSchedulerException- if deletion fails
-
getJobKey
public org.quartz.JobKey getJobKey(String name) throws MangooSchedulerException
Retrieves a JobKey by it given name- Parameters:
name- The name of the Job in the Scheduler- Returns:
- Optional of JobKey
- Throws:
MangooSchedulerException- if retrieving the job fails
-
executeJob
public void executeJob(String jobName) throws MangooSchedulerException
Executes a single Quartz Scheduler job right away only once- Parameters:
jobName- The name of the job to execute- Throws:
MangooSchedulerException- if an error occurs during execution of the job
-
getAllJobKeys
public List<org.quartz.JobKey> getAllJobKeys() throws MangooSchedulerException
Retrieves a list of all JobKeys from the Quartz Scheduler- Returns:
- List of all JobKey objects
- Throws:
MangooSchedulerException- if an errors occurs during access to the scheduler
-
changeState
public void changeState(String jobName) throws MangooSchedulerException
Changes the state of a normally running job from pause to resume or resume to pause- Parameters:
jobName- The name of the job- Throws:
MangooSchedulerException- if an error occurs during access to the quartz scheduler
-
-