Package org.openbravo.scheduling
Class OBScheduler
- java.lang.Object
-
- org.openbravo.scheduling.OBScheduler
-
- All Implemented Interfaces:
OBSchedulerMBean
public class OBScheduler extends Object implements OBSchedulerMBean
Provides the ability of schedule and unschedule background processes.- Author:
- awolski
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigParameters
getConfigParameters()
Retrieves the Openbravo ConfigParameters from the Scheduler context.ConnectionProvider
getConnection()
Retrieves the Openbravo ConnectionProvider from the Scheduler Context.static OBScheduler
getInstance()
org.quartz.Scheduler
getScheduler()
void
initialize(org.quartz.Scheduler schdlr)
static boolean
isNoExecuteBackgroundPolicy()
Returns whether current node is set with no-execute background policy, which should prevent the scheduler instance from being started.boolean
isSchedulingAllowed()
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.boolean
isStarted()
void
reschedule(String requestId, ProcessBundle bundle)
void
schedule(String requestId, ProcessBundle bundle)
Schedule a process (bundle) with the specified request id.void
schedule(ProcessBundle bundle)
Schedule a new process (bundle) to run immediately in the background, using a random name for the Quartz's JobDetail.void
standby()
void
start()
void
unschedule(String requestId, ProcessContext context)
-
-
-
Field Detail
-
OB_GROUP
public static final String OB_GROUP
- See Also:
- Constant Field Values
-
KEY
public static final String KEY
- See Also:
- Constant Field Values
-
-
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 aServletException
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 namebundle
- 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
-
unschedule
public void unschedule(String requestId, ProcessContext context)
-
initialize
public void initialize(org.quartz.Scheduler schdlr) throws org.quartz.SchedulerException
- Parameters:
schdlr
-- Throws:
org.quartz.SchedulerException
-
isStarted
public boolean isStarted()
- Specified by:
isStarted
in interfaceOBSchedulerMBean
-
start
public void start()
- Specified by:
start
in interfaceOBSchedulerMBean
-
standby
public void standby()
- Specified by:
standby
in interfaceOBSchedulerMBean
-
-