Class OBScheduler

  • All Implemented Interfaces:
    OBSchedulerMBean

    public class OBScheduler
    extends Object
    implements OBSchedulerMBean
    Provides the ability of schedule and unschedule background processes.
    Author:
    awolski
    • Method Detail

      • getInstance

        public static final OBScheduler getInstance()
        Returns:
        the singleton instance of this class
      • getScheduler

        public org.quartz.Scheduler getScheduler()
        Returns:
        The Quartz Scheduler instance used by OBScheduler.
      • getConnection

        public ConnectionProvider getConnection()
        Retrieves the Openbravo ConnectionProvider from the Scheduler Context.
        Returns:
        A ConnectionProvider
      • getConfigParameters

        public ConfigParameters getConfigParameters()
        Retrieves the Openbravo ConfigParameters from the Scheduler context.
        Returns:
        Openbravo ConfigParameters
      • schedule

        public void schedule​(ProcessBundle bundle)
                      throws org.quartz.SchedulerException,
                             javax.servlet.ServletException
        Schedule a new process (bundle) to run immediately in the background, using a random name for the Quartz's JobDetail. This will create a new record in AD_PROCESS_REQUEST. This method throws a ServletException if there is an error creating the AD_PROCESS_REQUEST information.
        Throws:
        org.quartz.SchedulerException
        javax.servlet.ServletException
        See Also:
        schedule(String, ProcessBundle)
      • schedule

        public void schedule​(String requestId,
                             ProcessBundle bundle)
                      throws org.quartz.SchedulerException
        Schedule a process (bundle) with the specified request id. The request id is used in Quartz as the JobDetail's name. The details must be saved to AD_PROCESS_REQUEST before reaching this method.
        Parameters:
        requestId - the id of the process request used as the Quartz jobDetail name
        bundle - The bundle with all of the process' details
        Throws:
        org.quartz.SchedulerException - If something goes wrong with the trigger creation or with the process scheduling.
      • isSchedulingAllowed

        public boolean isSchedulingAllowed()
                                    throws org.quartz.SchedulerException
        Returns if scheduling is allowed in the current instance It is allowed when there's any scheduler active in one of the instances of the cluster. An active scheduler means that it's policy is not no-execute and it is allowed to schedule new jobs.
        Returns:
        true if allowed to schedule, false otherwise
        Throws:
        org.quartz.SchedulerException
      • isNoExecuteBackgroundPolicy

        public static boolean isNoExecuteBackgroundPolicy()
        Returns whether current node is set with no-execute background policy, which should prevent the scheduler instance from being started. If this instance is not started later and no other scheduler instances are active, then it should also prevent scheduling processes.
      • reschedule

        public void reschedule​(String requestId,
                               ProcessBundle bundle)
                        throws org.quartz.SchedulerException
        Parameters:
        requestId -
        bundle -
        Throws:
        org.quartz.SchedulerException
      • initialize

        public void initialize​(org.quartz.Scheduler schdlr)
                        throws org.quartz.SchedulerException
        Parameters:
        schdlr -
        Throws:
        org.quartz.SchedulerException