org.exist.scheduler
Class Scheduler

java.lang.Object
  extended by org.exist.scheduler.Scheduler

public class Scheduler
extends Object

A Scheduler to trigger Startup, System and User defined jobs

Author:
Adam Retter

Field Summary
static String CONFIGURATION_ELEMENT_NAME
           
static String CONFIGURATION_JOB_ELEMENT_NAME
           
static String CONFIGURATION_JOB_PARAMETER_ELEMENT_NAME
           
static String JOB_CLASS_ATTRIBUTE
           
static String JOB_CRON_TRIGGER_ATTRIBUTE
           
static String JOB_DELAY_ATTRIBUTE
           
static String JOB_NAME_ATTRIBUTE
           
static String JOB_PERIOD_ATTRIBUTE
           
static String JOB_REPEAT_ATTRIBUTE
           
static String JOB_TYPE_ATTRIBUTE
           
static String JOB_TYPE_STARTUP
           
static String JOB_TYPE_SYSTEM
           
static String JOB_TYPE_USER
           
static String JOB_XQUERY_ATTRIBUTE
           
static String PROPERTY_SCHEDULER_JOBS
           
 
Constructor Summary
Scheduler(BrokerPool brokerpool, Configuration config)
          Create and Start a new Scheduler
 
Method Summary
 boolean createCronJob(String cronExpression, JobDescription job)
           
 boolean createCronJob(String cronExpression, JobDescription job, Properties params)
           
 boolean createPeriodicJob(long period, JobDescription job, long delay)
           
 boolean createPeriodicJob(long period, JobDescription job, long delay, Properties params)
           
 boolean createPeriodicJob(long period, JobDescription job, long delay, Properties params, int repeatCount)
           
 boolean deleteJob(String jobName, String jobGroup)
          Removes a Job from the Scheduler
 void executeStartupJobs()
          Executes all startup jobs
 ScheduledJobInfo[] getExecutingJobs()
          Gets information about currently Executing Jobs
 String[] getJobGroupNames()
          Gets the names of the Job groups
 ScheduledJobInfo[] getScheduledJobs()
          Gets information about currently Scheduled Jobs
 boolean isShutdown()
           
 boolean pauseJob(String jobName, String jobGroup)
          Pauses a Job with the Scheduler
 boolean resumeJob(String jobName, String jobGroup)
          Resume a Job with the Scheduler
 void run()
           
 void setupConfiguredJobs()
          Set's up all the jobs that are listed in conf.xml and loaded through org.exist.util.Configuration
 void shutdown(boolean waitForJobsToComplete)
          Shutdown the running Scheduler Asynchronous method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGURATION_ELEMENT_NAME

public static final String CONFIGURATION_ELEMENT_NAME
See Also:
Constant Field Values

CONFIGURATION_JOB_ELEMENT_NAME

public static final String CONFIGURATION_JOB_ELEMENT_NAME
See Also:
Constant Field Values

JOB_TYPE_ATTRIBUTE

public static final String JOB_TYPE_ATTRIBUTE
See Also:
Constant Field Values

JOB_CLASS_ATTRIBUTE

public static final String JOB_CLASS_ATTRIBUTE
See Also:
Constant Field Values

JOB_XQUERY_ATTRIBUTE

public static final String JOB_XQUERY_ATTRIBUTE
See Also:
Constant Field Values

JOB_CRON_TRIGGER_ATTRIBUTE

public static final String JOB_CRON_TRIGGER_ATTRIBUTE
See Also:
Constant Field Values

JOB_PERIOD_ATTRIBUTE

public static final String JOB_PERIOD_ATTRIBUTE
See Also:
Constant Field Values

JOB_DELAY_ATTRIBUTE

public static final String JOB_DELAY_ATTRIBUTE
See Also:
Constant Field Values

JOB_REPEAT_ATTRIBUTE

public static final String JOB_REPEAT_ATTRIBUTE
See Also:
Constant Field Values

CONFIGURATION_JOB_PARAMETER_ELEMENT_NAME

public static final String CONFIGURATION_JOB_PARAMETER_ELEMENT_NAME
See Also:
Constant Field Values

PROPERTY_SCHEDULER_JOBS

public static final String PROPERTY_SCHEDULER_JOBS
See Also:
Constant Field Values

JOB_TYPE_USER

public static final String JOB_TYPE_USER
See Also:
Constant Field Values

JOB_TYPE_STARTUP

public static final String JOB_TYPE_STARTUP
See Also:
Constant Field Values

JOB_TYPE_SYSTEM

public static final String JOB_TYPE_SYSTEM
See Also:
Constant Field Values

JOB_NAME_ATTRIBUTE

public static final String JOB_NAME_ATTRIBUTE
See Also:
Constant Field Values
Constructor Detail

Scheduler

public Scheduler(BrokerPool brokerpool,
                 Configuration config)
          throws EXistException
Create and Start a new Scheduler

Parameters:
brokerpool - The brokerpool for which this scheduler is intended
Throws:
EXistException
Method Detail

run

public void run()

shutdown

public void shutdown(boolean waitForJobsToComplete)
Shutdown the running Scheduler Asynchronous method. use isShutdown() to determine if the Scheduler has Shutdown


isShutdown

public boolean isShutdown()

executeStartupJobs

public void executeStartupJobs()
Executes all startup jobs


createPeriodicJob

public boolean createPeriodicJob(long period,
                                 JobDescription job,
                                 long delay)
Parameters:
period - The period, in milliseconds.
job - The job to trigger after each period
delay - <= 0, start now, otherwise start in specified number of milliseconds
Returns:
true if the job was successfully scheduled, false otherwise

createPeriodicJob

public boolean createPeriodicJob(long period,
                                 JobDescription job,
                                 long delay,
                                 Properties params)
Parameters:
period - The period, in milliseconds.
job - The job to trigger after each period
delay - <= 0, start now, otherwise start in specified number of milliseconds
params - Any parameters to pass to the job
Returns:
true if the job was successfully scheduled, false otherwise

createPeriodicJob

public boolean createPeriodicJob(long period,
                                 JobDescription job,
                                 long delay,
                                 Properties params,
                                 int repeatCount)
Parameters:
period - The period, in milliseconds.
job - The job to trigger after each period
delay - <= 0, start now, otherwise start in specified number of milliseconds
params - Any parameters to pass to the job
repeatCount - Number of times to repeat this job.
Returns:
true if the job was successfully scheduled, false otherwise

createCronJob

public boolean createCronJob(String cronExpression,
                             JobDescription job)
Parameters:
cronExpression - The Cron scheduling expression
job - The job to trigger after each period
Returns:
true if the job was successfully scheduled, false otherwise

createCronJob

public boolean createCronJob(String cronExpression,
                             JobDescription job,
                             Properties params)
Parameters:
cronExpression - The Cron scheduling expression
job - The job to trigger after each period
params - Any parameters to pass to the job
Returns:
true if the job was successfully scheduled, false otherwise

deleteJob

public boolean deleteJob(String jobName,
                         String jobGroup)
Removes a Job from the Scheduler

Parameters:
jobName - The name of the Job
jobGroup - The group that the Job was Scheduled in
Returns:
true if the job was deleted, false otherwise

pauseJob

public boolean pauseJob(String jobName,
                        String jobGroup)
Pauses a Job with the Scheduler

Parameters:
jobName - The name of the Job
jobGroup - The group that the Job was Scheduled in

resumeJob

public boolean resumeJob(String jobName,
                         String jobGroup)
Resume a Job with the Scheduler

Parameters:
jobName - The name of the Job
jobGroup - The group that the Job was Scheduled in

getJobGroupNames

public String[] getJobGroupNames()
Gets the names of the Job groups

Returns:
String array of the Job group names

getScheduledJobs

public ScheduledJobInfo[] getScheduledJobs()
Gets information about currently Scheduled Jobs

Returns:
An array of ScheduledJobInfo

getExecutingJobs

public ScheduledJobInfo[] getExecutingJobs()
Gets information about currently Executing Jobs

Returns:
An array of ScheduledJobInfo

setupConfiguredJobs

public void setupConfiguredJobs()
Set's up all the jobs that are listed in conf.xml and loaded through org.exist.util.Configuration



Copyright (C) Wolfgang Meier. All rights reserved.