Class OBScheduler


  • public class OBScheduler
    extends Object
    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.
      • isNoExecuteBackgroundPolicy

        public static boolean isNoExecuteBackgroundPolicy()
        Returns whether current node is set with no-execute background policy, which should prevent any process scheduling.
      • reschedule

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

        public void unschedule​(String requestId,
                               ProcessContext context)
                        throws org.quartz.SchedulerException
        Throws:
        org.quartz.SchedulerException
      • initialize

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