public void scheduleJobs ( Scheduler sched ) throws SchedulerException { List < JobDetail > jobs = new LinkedList < JobDetail > ( getLoadedJobs ( ) ) ; List < OperableTrigger > triggers = new LinkedList < OperableTrigger > ( getLoadedTriggers ( ) ) ; logger . info ( "Adding " + jobs . size ( ) + " jobs, " + triggers . size ( ) + " triggers." ) ; for ( JobDetail jobDetail : jobs ) { logger . info ( "Scheduled job: {} " , jobDetail ) ; sched . addJob ( jobDetail ) ; } for ( OperableTrigger trigger : triggers ) { logger . info ( "Scheduled trigger: {}" , trigger ) ; if ( trigger . getStartTime ( ) == null ) { trigger . setStartTime ( new Date ( ) ) ; } Trigger dupeT = sched . getTrigger ( trigger . getName ( ) ) ; if ( dupeT != null ) { // if trigger with name already exists if ( ! dupeT . getJobName ( ) . equals ( trigger . getJobName ( ) ) ) { logger . warn ( "Possibly duplicately named ({}) triggers in jobs xml file! " , trigger . getName ( ) ) ; } sched . rescheduleJob ( trigger . getName ( ) , trigger ) ; } else { logger . debug ( "Scheduling job: " + trigger . getJobName ( ) + " with trigger: " + trigger . getName ( ) ) ; try { sched . scheduleJob ( trigger ) ; } catch ( ObjectAlreadyExistsException e ) { logger . debug ( "Adding trigger: " + trigger . getName ( ) + " for job: " + trigger . getJobName ( ) + " failed because the trigger already existed." ) ; } } } }
Schedules the given sets of jobs and triggers .