Class GlobalQuartzScheduler

  • All Implemented Interfaces:
    com.helger.scope.IScopeDestructionAware

    public final class GlobalQuartzScheduler
    extends com.helger.scope.singleton.AbstractGlobalSingleton
    Global scheduler instance.
    Author:
    Philip Helger
    • Constructor Detail

      • GlobalQuartzScheduler

        @Deprecated
        @UsedViaReflection
        public GlobalQuartzScheduler()
        Deprecated.
        Called via getInstance()
    • Method Detail

      • 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 be null nor 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 be null.
      • 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 job
        aJobClass - Class to execute
        aJobData - Additional parameters. May be null.
        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 from scheduleJob(String, JDK8TriggerBuilder, Class, Map).
        Parameters:
        aTriggerKey - Trigger key to use. May not be null.
        Returns:
        EChange.
      • shutdown

        public void shutdown()
                      throws com.helger.quartz.SchedulerException
        Shutdown the scheduler and wait for all jobs to complete.
        Throws:
        com.helger.quartz.SchedulerException - If something goes wrong
      • onDestroy

        protected void onDestroy​(@Nonnull
                                 com.helger.scope.IScope aScopeInDestruction)
                          throws Exception
        Overrides:
        onDestroy in class com.helger.scope.singleton.AbstractSingleton
        Throws:
        Exception