Package com.helger.schedule.quartz
Class GlobalQuartzScheduler
- java.lang.Object
-
- com.helger.scope.singleton.AbstractSingleton
-
- com.helger.scope.singleton.AbstractGlobalSingleton
-
- com.helger.schedule.quartz.GlobalQuartzScheduler
-
- All Implemented Interfaces:
com.helger.scope.IScopeDestructionAware
public final class GlobalQuartzScheduler extends com.helger.scope.singleton.AbstractGlobalSingletonGlobal scheduler instance.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static StringGROUP_NAME
-
Constructor Summary
Constructors Constructor Description GlobalQuartzScheduler()Deprecated.Called viagetInstance()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddJobListener(com.helger.quartz.IJobListener aJobListener)Add a job listener for all jobs.StringgetGroupName()static GlobalQuartzSchedulergetInstance()com.helger.quartz.ISchedulergetScheduler()protected voidonDestroy(com.helger.scope.IScope aScopeInDestruction)voidpauseJob(com.helger.quartz.TriggerKey aTriggerKey)Pause the job with the specified trigger key as returned fromscheduleJob(String, JDK8TriggerBuilder, Class, Map).voidresumeJob(com.helger.quartz.TriggerKey aTriggerKey)Resume the job with the specified trigger key as returned fromscheduleJob(String, JDK8TriggerBuilder, Class, Map).com.helger.quartz.TriggerKeyscheduleJob(String sJobName, JDK8TriggerBuilder<? extends com.helger.quartz.ITrigger> aTriggerBuilder, Class<? extends com.helger.quartz.IJob> aJobClass, Map<String,? extends Object> aJobData)This method is only for testing purposes.com.helger.quartz.TriggerKeyscheduleJobNowOnce(String sJobName, Class<? extends com.helger.quartz.IJob> aJobClass, Map<String,? extends Object> aJobData)Schedule a new job that should be executed now and only once.voidsetGroupName(String sGroupName)Set the Quartz internal group name.voidshutdown()Shutdown the scheduler and wait for all jobs to complete.com.helger.commons.state.EChangeunscheduleJob(com.helger.quartz.TriggerKey aTriggerKey)Unschedule the job with the specified trigger key as returned fromscheduleJob(String, JDK8TriggerBuilder, Class, Map).-
Methods inherited from class com.helger.scope.singleton.AbstractGlobalSingleton
getAllGlobalSingletons, getGlobalSingleton, getGlobalSingletonIfInstantiated, isGlobalSingletonInstantiated
-
Methods inherited from class com.helger.scope.singleton.AbstractSingleton
getAllSingletons, getSingleton, getSingletonIfInstantiated, getSingletonScopeKey, isDestroyed, isInDestruction, isInInstantiation, isInPreDestruction, isInstantiated, isSingletonInstantiated, isUsableObject, onAfterInstantiation, onBeforeDestroy, onBeforeScopeDestruction, onScopeDestruction, readAbstractSingletonFields, setDestroyed, setInDestruction, setInInstantiation, setInPreDestruction, setInstantiated, toString, writeAbstractSingletonFields
-
-
-
-
Field Detail
-
GROUP_NAME
public static final String GROUP_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GlobalQuartzScheduler
@Deprecated @UsedViaReflection public GlobalQuartzScheduler()
Deprecated.Called viagetInstance()
-
-
Method Detail
-
getInstance
@Nonnull public static GlobalQuartzScheduler getInstance()
-
getGroupName
@Nonnull @Nonempty public String getGroupName()
- Returns:
- The Quartz internal group name to be used. Defaults to
GROUP_NAME.
-
setGroupName
public void setGroupName(@Nonnull @Nonempty String sGroupName)
Set the Quartz internal group name.- Parameters:
sGroupName- The new group name to be used. May neither benullnor empty.
-
addJobListener
public void addJobListener(@Nonnull com.helger.quartz.IJobListener aJobListener)
Add a job listener for all jobs.- Parameters:
aJobListener- The job listener to be added. May not benull.
-
getScheduler
@Nonnull public com.helger.quartz.IScheduler getScheduler()
- Returns:
- The underlying Quartz scheduler object. Never
null.
-
scheduleJob
@Nonnull public com.helger.quartz.TriggerKey scheduleJob(@Nonnull String sJobName, @Nonnull JDK8TriggerBuilder<? extends com.helger.quartz.ITrigger> aTriggerBuilder, @Nonnull Class<? extends com.helger.quartz.IJob> aJobClass, @Nullable Map<String,? extends Object> aJobData)
This method is only for testing purposes.- Parameters:
sJobName- Name of the job. Needs to be unique since no two job details with the same name may exist.aTriggerBuilder- The trigger builder instance to schedule the jobaJobClass- Class to executeaJobData- Additional parameters. May benull.- Returns:
- The created trigger key for further usage. Never
null.
-
scheduleJobNowOnce
@Nonnull public com.helger.quartz.TriggerKey scheduleJobNowOnce(@Nonnull String sJobName, @Nonnull Class<? extends com.helger.quartz.IJob> aJobClass, @Nullable Map<String,? extends Object> aJobData)
Schedule a new job that should be executed now and only once.- Parameters:
sJobName- Name of the job - must be unique within the whole system!aJobClass- The Job class to be executed.aJobData- Optional job data map.- Returns:
- The created trigger key for further usage. Never
null.
-
unscheduleJob
@Nonnull public com.helger.commons.state.EChange unscheduleJob(@Nonnull com.helger.quartz.TriggerKey aTriggerKey)
Unschedule the job with the specified trigger key as returned fromscheduleJob(String, JDK8TriggerBuilder, Class, Map).- Parameters:
aTriggerKey- Trigger key to use. May not benull.- Returns:
EChange.
-
pauseJob
public void pauseJob(@Nonnull com.helger.quartz.TriggerKey aTriggerKey)
Pause the job with the specified trigger key as returned fromscheduleJob(String, JDK8TriggerBuilder, Class, Map).- Parameters:
aTriggerKey- Trigger key to use. May not benull.- See Also:
resumeJob(TriggerKey)
-
resumeJob
public void resumeJob(@Nonnull com.helger.quartz.TriggerKey aTriggerKey)
Resume the job with the specified trigger key as returned fromscheduleJob(String, JDK8TriggerBuilder, Class, Map).- Parameters:
aTriggerKey- Trigger key to use. May not benull.
-
shutdown
public void shutdown() throws com.helger.quartz.SchedulerExceptionShutdown the scheduler and wait for all jobs to complete.- Throws:
com.helger.quartz.SchedulerException- If something goes wrong
-
-