org.quartz.spi.TriggerFiredBundle Java Examples
The following examples show how to use
org.quartz.spi.TriggerFiredBundle.
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: CdiAwareJobFactory.java From deltaspike with Apache License 2.0 | 6 votes |
@Override public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException { Job result = null; try { Class<? extends Job> jobClass = bundle.getJobDetail().getJobClass(); result = BeanProvider.getContextualReference(jobClass); scheduler.getContext().put(jobClass.getName(), Boolean.TRUE); } catch (Exception e) { if (result == null) { result = defaultFactory.newJob(bundle, scheduler); } } return result; }
Example #2
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 #3
Source File: JobStoreSupport.java From AsuraFramework with Apache License 2.0 | 6 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> * * @return null if the trigger or its job or calendar no longer exist, or * if the trigger was not successfully put into the 'executing' * state. */ public TriggerFiredBundle triggerFired( final SchedulingContext ctxt, final Trigger trigger) throws JobPersistenceException { return (TriggerFiredBundle)executeInNonManagedTXLock( LOCK_TRIGGER_ACCESS, new TransactionCallback() { public Object execute(Connection conn) throws JobPersistenceException { try { return triggerFired(conn, ctxt, trigger); } catch (JobPersistenceException jpe) { // If job didn't exisit, we still want to commit our work and return null. if (jpe.getErrorCode() == SchedulerException.ERR_PERSISTENCE_JOB_DOES_NOT_EXIST) { return null; } else { throw jpe; } } } }); }
Example #4
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 #5
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 #6
Source File: SpringBeanJobFactory.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Create the job instance, populating it with property values taken * from the scheduler context, job data map and trigger data map. */ @Override protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { Object job = super.createJobInstance(bundle); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job); if (isEligibleForPropertyPopulation(bw.getWrappedInstance())) { MutablePropertyValues pvs = new MutablePropertyValues(); if (this.schedulerContext != null) { pvs.addPropertyValues(this.schedulerContext); } pvs.addPropertyValues(bundle.getJobDetail().getJobDataMap()); pvs.addPropertyValues(bundle.getTrigger().getJobDataMap()); if (this.ignoredUnknownProperties != null) { for (String propName : this.ignoredUnknownProperties) { if (pvs.contains(propName) && !bw.isWritableProperty(propName)) { pvs.removePropertyValue(propName); } } bw.setPropertyValues(pvs); } else { bw.setPropertyValues(pvs, true); } } return job; }
Example #7
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 #8
Source File: GlassJobFactory.java From quartz-glass with Apache License 2.0 | 6 votes |
private void setTargetObject(Job job, TriggerFiredBundle bundle, boolean forceCreateObject) throws Exception { PojoJobMeta pojoJobMeta = getPojoJobMeta(bundle.getJobDetail()); if (pojoJobMeta == null) return; if (pojoJobMeta.getTargetObject() != null && !forceCreateObject) return; Object targetObject; Class targetClass = pojoJobMeta.getTargetClass(); try { targetObject = beanFactory.getBean(targetClass); } catch (NoSuchBeanDefinitionException e) { targetObject = targetClass.newInstance(); beanFactory.autowireBean(targetObject); } populateJobDataMapTargetObject(bundle, targetObject); pojoJobMeta.setTargetObject(targetObject); MethodInvokingJobDetailFactoryBean methodInvoker = createMethodInvoker(pojoJobMeta); methodInvoker.setTargetObject(targetObject); MethodInvokingJob methodInvokingJob = (MethodInvokingJob) job; methodInvokingJob.setMethodInvoker(methodInvoker); }
Example #9
Source File: SpringBeanJobFactory.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Create the job instance, populating it with property values taken * from the scheduler context, job data map and trigger data map. */ @Override protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { Object job = super.createJobInstance(bundle); if (isEligibleForPropertyPopulation(job)) { BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job); MutablePropertyValues pvs = new MutablePropertyValues(); if (this.schedulerContext != null) { pvs.addPropertyValues(this.schedulerContext); } pvs.addPropertyValues(bundle.getJobDetail().getJobDataMap()); pvs.addPropertyValues(bundle.getTrigger().getJobDataMap()); if (this.ignoredUnknownProperties != null) { for (String propName : this.ignoredUnknownProperties) { if (pvs.contains(propName) && !bw.isWritableProperty(propName)) { pvs.removePropertyValue(propName); } } bw.setPropertyValues(pvs); } else { bw.setPropertyValues(pvs, true); } } return job; }
Example #10
Source File: AutowiringSpringBeanJobFactory.java From syncope with Apache License 2.0 | 6 votes |
@Override protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception { Object job = beanFactory.getBean(bundle.getJobDetail().getKey().getName()); if (isEligibleForPropertyPopulation(job)) { BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job); MutablePropertyValues pvs = new MutablePropertyValues(); if (this.schedulerContext != null) { pvs.addPropertyValues(this.schedulerContext); } pvs.addPropertyValues(bundle.getJobDetail().getJobDataMap()); pvs.addPropertyValues(bundle.getTrigger().getJobDataMap()); if (this.ignoredUnknownProperties != null) { for (String propName : this.ignoredUnknownProperties) { if (pvs.contains(propName) && !bw.isWritableProperty(propName)) { pvs.removePropertyValue(propName); } } bw.setPropertyValues(pvs); } else { bw.setPropertyValues(pvs, true); } } return job; }
Example #11
Source File: JTAAnnotationAwareJobRunShellFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * <p> * Called by the <class>{@link org.quartz.core.QuartzSchedulerThread} * </code> to obtain instances of <code> * {@link org.quartz.core.JobRunShell}</code>. * </p> */ public JobRunShell createJobRunShell(TriggerFiredBundle bundle) throws SchedulerException { ExecuteInJTATransaction jtaAnnotation = ClassUtils.getAnnotation(bundle.getJobDetail().getJobClass(), ExecuteInJTATransaction.class); if(jtaAnnotation == null) return new JobRunShell(scheduler, bundle); else { int timeout = jtaAnnotation.timeout(); if (timeout >= 0) { return new JTAJobRunShell(scheduler, bundle, timeout); } else { return new JTAJobRunShell(scheduler, bundle); } } }
Example #12
Source File: SpringBeanJobFactory.java From JuniperBot with GNU General Public License v3.0 | 5 votes |
@Override protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { Object jobInstance = super.createJobInstance(bundle); context.getAutowireCapableBeanFactory().autowireBean(jobInstance); return jobInstance; }
Example #13
Source File: QuartzConfig.java From sk-admin with Apache License 2.0 | 5 votes |
@Override protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { //调用父类的方法 Object jobInstance = super.createJobInstance(bundle); capableBeanFactory.autowireBean(jobInstance); return jobInstance; }
Example #14
Source File: AdaptableJobFactory.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException { try { Object jobObject = createJobInstance(bundle); return adaptJob(jobObject); } catch (Exception ex) { throw new SchedulerException("Job instantiation failed", ex); } }
Example #15
Source File: JobFactory.java From ehousechina with Apache License 2.0 | 5 votes |
@Override protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { //调用父类的方法 Object jobInstance = super.createJobInstance(bundle); //进行注入 capableBeanFactory.autowireBean(jobInstance); return jobInstance; }
Example #16
Source File: AuroraCronJobFactory.java From attic-aurora with Apache License 2.0 | 5 votes |
@Override public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException { checkState(AuroraCronJob.class.equals(bundle.getJobDetail().getJobClass()), "Quartz tried to run a type of job we don't know about: %s", bundle.getJobDetail().getJobClass()); return auroraCronJobProvider.get(); }
Example #17
Source File: SpringBeanJobFactory.java From java-technology-stack with MIT License | 5 votes |
/** * Create the job instance, populating it with property values taken * from the scheduler context, job data map and trigger data map. */ @Override protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { Object job = (this.applicationContext != null ? this.applicationContext.getAutowireCapableBeanFactory().createBean( bundle.getJobDetail().getJobClass(), AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false) : super.createJobInstance(bundle)); if (isEligibleForPropertyPopulation(job)) { BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job); MutablePropertyValues pvs = new MutablePropertyValues(); if (this.schedulerContext != null) { pvs.addPropertyValues(this.schedulerContext); } pvs.addPropertyValues(bundle.getJobDetail().getJobDataMap()); pvs.addPropertyValues(bundle.getTrigger().getJobDataMap()); if (this.ignoredUnknownProperties != null) { for (String propName : this.ignoredUnknownProperties) { if (pvs.contains(propName) && !bw.isWritableProperty(propName)) { pvs.removePropertyValue(propName); } } bw.setPropertyValues(pvs); } else { bw.setPropertyValues(pvs, true); } } return job; }
Example #18
Source File: JobFactory.java From Almost-Famous with MIT License | 5 votes |
@Override protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { //调用父类的方法 Object jobInstance = super.createJobInstance(bundle); //进行注入 capableBeanFactory.autowireBean(jobInstance); return jobInstance; }
Example #19
Source File: PropertySettingJobFactory.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException { Job job = super.newJob(bundle, scheduler); JobDataMap jobDataMap = new JobDataMap(); jobDataMap.putAll(scheduler.getContext()); jobDataMap.putAll(bundle.getJobDetail().getJobDataMap()); jobDataMap.putAll(bundle.getTrigger().getJobDataMap()); setBeanProps(job, jobDataMap); return job; }
Example #20
Source File: DynamicJobFactory.java From hsweb-framework with Apache License 2.0 | 5 votes |
@Override public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException { Map<String, Object> data = bundle.getJobDetail().getJobDataMap(); String jobId = (String) data.get(JOB_ID_KEY); if (null == jobId || bundle.getJobDetail().getJobClass() != DynamicJob.class) { return defaultFactory.newJob(bundle, scheduler); } return context -> scheduleJobExecutor.doExecuteJob(jobId, data); }
Example #21
Source File: AdaptableJobFactory.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException { try { Object jobObject = createJobInstance(bundle); return adaptJob(jobObject); } catch (Exception ex) { throw new SchedulerException("Job instantiation failed", ex); } }
Example #22
Source File: AutoWiringSpringBeanJobFactory.java From mojito with Apache License 2.0 | 5 votes |
@Override protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception { try { final Object job = super.createJobInstance(bundle); beanFactory.autowireBean(job); return job; } catch (Throwable t) { logger.error("Can't create a Quartz job instance, this is a critical error", t); throw t; } }
Example #23
Source File: MyJobFactory.java From spring-boot-cookbook with Apache License 2.0 | 5 votes |
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception { //调用父类的方法 Object jobInstance = super.createJobInstance(bundle); //进行注入,这属于Spring的技术,不清楚的可以查看Spring的API. capableBeanFactory.autowireBean(jobInstance); return jobInstance; }
Example #24
Source File: AutowiringSpringBeanJobFactory.java From quartz-manager with Apache License 2.0 | 5 votes |
@Override protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception { final Object job = super.createJobInstance(bundle); beanFactory.autowireBean(job); return job; }
Example #25
Source File: GlassJobFactory.java From quartz-glass with Apache License 2.0 | 5 votes |
private void populateTriggerDataMapTargetObject(TriggerFiredBundle bundle, Job job) { PojoJobMeta pojoJobMeta = getPojoJobMeta(bundle.getJobDetail()); Object targetObject = pojoJobMeta == null ? job : pojoJobMeta.getTargetObject(); MutablePropertyValues pvs = new MutablePropertyValues(); pvs.addPropertyValues(bundle.getTrigger().getJobDataMap()); buildAccessor(targetObject).setPropertyValues(pvs, true); }
Example #26
Source File: AutowiringJobFactory.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
@Override public Job newJob (TriggerFiredBundle bundle, Scheduler scheduler) throws SchedulerException { Job job = super.newJob (bundle, scheduler); beanFactory.autowireBean (job); return job; }
Example #27
Source File: SchedulerFactory.java From mangooio with Apache License 2.0 | 5 votes |
@Override public Job newJob(TriggerFiredBundle triggerFiredBundle, Scheduler scheduler) { Objects.requireNonNull(triggerFiredBundle, Required.TRIGGER_FIRE_BUNDLE.toString()); Objects.requireNonNull(scheduler, Required.SCHEDULER.toString()); return getInstance(triggerFiredBundle.getJobDetail().getJobClass()); }
Example #28
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 #29
Source File: MockScheduler.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Override public Date scheduleJob(JobDetail jobDetail, Trigger trigger) throws SchedulerException { TriggerFiredBundle tfb = new TriggerFiredBundle(jobDetail, (OperableTrigger) trigger, null, // cal false, // jobIsRecovering null, // fireTime null, // scheduledFireTime null, // prevFireTime null // nextFireTime) ); JobExecutionContextImpl jec = new JobExecutionContextImpl(this, tfb, null); jobs.put(trigger, jec); return new Date(); }
Example #30
Source File: AutoWiringSpringBeanJobFactory.java From tutorials with MIT License | 5 votes |
@Override protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception { final Object job = super.createJobInstance(bundle); beanFactory.autowireBean(job); return job; }