Java Code Examples for org.quartz.spi.TriggerFiredBundle#getJobDetail()
The following examples show how to use
org.quartz.spi.TriggerFiredBundle#getJobDetail() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleJobFactory.java From lams with GNU General Public License v2.0 | 6 votes |
public Job newJob(TriggerFiredBundle bundle, Scheduler Scheduler) throws SchedulerException { JobDetail jobDetail = bundle.getJobDetail(); Class<? extends Job> jobClass = jobDetail.getJobClass(); try { if(log.isDebugEnabled()) { log.debug( "Producing instance of Job '" + jobDetail.getKey() + "', class=" + jobClass.getName()); } return jobClass.newInstance(); } catch (Exception e) { SchedulerException se = new SchedulerException( "Problem instantiating class '" + jobDetail.getJobClass().getName() + "'", e); throw se; } }
Example 2
Source File: JobExecutionContextImpl.java From lams with GNU General Public License v2.0 | 6 votes |
/** * <p> * Create a JobExcecutionContext with the given context data. * </p> */ public JobExecutionContextImpl(Scheduler scheduler, TriggerFiredBundle firedBundle, Job job) { this.scheduler = scheduler; this.trigger = firedBundle.getTrigger(); this.calendar = firedBundle.getCalendar(); this.jobDetail = firedBundle.getJobDetail(); this.job = job; this.recovering = firedBundle.isRecovering(); this.fireTime = firedBundle.getFireTime(); this.scheduledFireTime = firedBundle.getScheduledFireTime(); this.prevFireTime = firedBundle.getPrevFireTime(); this.nextFireTime = firedBundle.getNextFireTime(); this.jobDataMap = new JobDataMap(); this.jobDataMap.putAll(jobDetail.getJobDataMap()); this.jobDataMap.putAll(trigger.getJobDataMap()); }
Example 3
Source File: SimpleJobFactory.java From AsuraFramework with Apache License 2.0 | 6 votes |
public Job newJob(TriggerFiredBundle bundle) throws SchedulerException { JobDetail jobDetail = bundle.getJobDetail(); Class jobClass = jobDetail.getJobClass(); try { if(log.isDebugEnabled()) { log.debug( "Producing instance of Job '" + jobDetail.getFullName() + "', class=" + jobClass.getName()); } return (Job) jobClass.newInstance(); } catch (Exception e) { SchedulerException se = new SchedulerException( "Problem instantiating class '" + jobDetail.getJobClass().getName() + "'", e); throw se; } }
Example 4
Source File: JobExecutionContext.java From AsuraFramework with Apache License 2.0 | 6 votes |
/** * <p> * Create a JobExcecutionContext with the given context data. * </p> */ public JobExecutionContext(Scheduler scheduler, TriggerFiredBundle firedBundle, Job job) { this.scheduler = scheduler; this.trigger = firedBundle.getTrigger(); this.calendar = firedBundle.getCalendar(); this.jobDetail = firedBundle.getJobDetail(); this.job = job; this.recovering = firedBundle.isRecovering(); this.fireTime = firedBundle.getFireTime(); this.scheduledFireTime = firedBundle.getScheduledFireTime(); this.prevFireTime = firedBundle.getPrevFireTime(); this.nextFireTime = firedBundle.getNextFireTime(); this.jobDataMap = new JobDataMap(); this.jobDataMap.putAll(jobDetail.getJobDataMap()); this.jobDataMap.putAll(trigger.getJobDataMap()); }
Example 5
Source File: GuiceJobFactory.java From Raigad with Apache License 2.0 | 5 votes |
@Override public Job newJob(TriggerFiredBundle bundle) throws SchedulerException { JobDetail jobDetail = bundle.getJobDetail(); Class<?> jobClass = jobDetail.getJobClass(); Job job = (Job) guice.getInstance(jobClass); guice.injectMembers(job); return job; }
Example 6
Source File: RAMJobStore.java From lams with GNU General Public License v2.0 | 4 votes |
/** * <p> * Inform the <code>JobStore</code> that the scheduler is now firing the * given <code>Trigger</code> (executing its associated <code>Job</code>), * that it had previously acquired (reserved). * </p> */ public List<TriggerFiredResult> triggersFired(List<OperableTrigger> firedTriggers) { synchronized (lock) { List<TriggerFiredResult> results = new ArrayList<TriggerFiredResult>(); for (OperableTrigger trigger : firedTriggers) { TriggerWrapper tw = triggersByKey.get(trigger.getKey()); // was the trigger deleted since being acquired? if (tw == null || tw.trigger == null) { continue; } // was the trigger completed, paused, blocked, etc. since being acquired? if (tw.state != TriggerWrapper.STATE_ACQUIRED) { continue; } Calendar cal = null; if (tw.trigger.getCalendarName() != null) { cal = retrieveCalendar(tw.trigger.getCalendarName()); if(cal == null) continue; } Date prevFireTime = trigger.getPreviousFireTime(); // in case trigger was replaced between acquiring and firing timeTriggers.remove(tw); // call triggered on our copy, and the scheduler's copy tw.trigger.triggered(cal); trigger.triggered(cal); //tw.state = TriggerWrapper.STATE_EXECUTING; tw.state = TriggerWrapper.STATE_WAITING; TriggerFiredBundle bndle = new TriggerFiredBundle(retrieveJob( tw.jobKey), trigger, cal, false, new Date(), trigger.getPreviousFireTime(), prevFireTime, trigger.getNextFireTime()); JobDetail job = bndle.getJobDetail(); if (job.isConcurrentExectionDisallowed()) { ArrayList<TriggerWrapper> trigs = getTriggerWrappersForJob(job.getKey()); for (TriggerWrapper ttw : trigs) { if (ttw.state == TriggerWrapper.STATE_WAITING) { ttw.state = TriggerWrapper.STATE_BLOCKED; } if (ttw.state == TriggerWrapper.STATE_PAUSED) { ttw.state = TriggerWrapper.STATE_PAUSED_BLOCKED; } timeTriggers.remove(ttw); } blockedJobs.add(job.getKey()); } else if (tw.trigger.getNextFireTime() != null) { synchronized (lock) { timeTriggers.add(tw); } } results.add(new TriggerFiredResult(bndle)); } return results; } }
Example 7
Source File: RAMJobStore.java From AsuraFramework with Apache License 2.0 | 4 votes |
/** * <p> * Inform the <code>JobStore</code> that the scheduler is now firing the * given <code>Trigger</code> (executing its associated <code>Job</code>), * that it had previously acquired (reserved). * </p> */ public TriggerFiredBundle triggerFired(SchedulingContext ctxt, Trigger trigger) { synchronized (lock) { TriggerWrapper tw = (TriggerWrapper) triggersByFQN.get(TriggerWrapper .getTriggerNameKey(trigger)); // was the trigger deleted since being acquired? if (tw == null || tw.trigger == null) { return null; } // was the trigger completed, paused, blocked, etc. since being acquired? if (tw.state != TriggerWrapper.STATE_ACQUIRED) { return null; } Calendar cal = null; if (tw.trigger.getCalendarName() != null) { cal = retrieveCalendar(ctxt, tw.trigger.getCalendarName()); if(cal == null) return null; } Date prevFireTime = trigger.getPreviousFireTime(); // in case trigger was replaced between acquiring and firering timeTriggers.remove(tw); // call triggered on our copy, and the scheduler's copy tw.trigger.triggered(cal); trigger.triggered(cal); //tw.state = TriggerWrapper.STATE_EXECUTING; tw.state = TriggerWrapper.STATE_WAITING; TriggerFiredBundle bndle = new TriggerFiredBundle(retrieveJob(ctxt, trigger.getJobName(), trigger.getJobGroup()), trigger, cal, false, new Date(), trigger.getPreviousFireTime(), prevFireTime, trigger.getNextFireTime()); JobDetail job = bndle.getJobDetail(); if (job.isStateful()) { ArrayList trigs = getTriggerWrappersForJob(job.getName(), job .getGroup()); Iterator itr = trigs.iterator(); while (itr.hasNext()) { TriggerWrapper ttw = (TriggerWrapper) itr.next(); if(ttw.state == TriggerWrapper.STATE_WAITING) { ttw.state = TriggerWrapper.STATE_BLOCKED; } if(ttw.state == TriggerWrapper.STATE_PAUSED) { ttw.state = TriggerWrapper.STATE_PAUSED_BLOCKED; } timeTriggers.remove(ttw); } blockedJobs.add(JobWrapper.getJobNameKey(job)); } else if (tw.trigger.getNextFireTime() != null) { synchronized (lock) { timeTriggers.add(tw); } } return bndle; } }
Example 8
Source File: HK2JobFactory.java From dropwizard-experiment with MIT License | 4 votes |
@Override public Job newJob(TriggerFiredBundle triggerFiredBundle, Scheduler scheduler) throws SchedulerException { JobDetail jobDetail = triggerFiredBundle.getJobDetail(); Class<? extends Job> jobClass = jobDetail.getJobClass(); return locator.getService(jobClass); }
Example 9
Source File: ReportJobFactory.java From AisAbnormal with GNU Lesser General Public License v3.0 | 4 votes |
@Override public Job newJob(TriggerFiredBundle triggerFiredBundle, Scheduler scheduler) throws SchedulerException { JobDetail jobDetail = triggerFiredBundle.getJobDetail(); Class jobClass = jobDetail.getJobClass(); return (Job) injector.getInstance(jobClass); }