1 16 17 package org.springframework.scheduling.quartz; 18 19 import org.quartz.Job; 20 import org.quartz.JobExecutionContext; 21 import org.quartz.JobExecutionException; 22 import org.quartz.SchedulerException; 23 24 import org.springframework.beans.BeanWrapper; 25 import org.springframework.beans.BeanWrapperImpl; 26 import org.springframework.beans.MutablePropertyValues; 27 28 68 public abstract class QuartzJobBean implements Job { 69 70 75 public final void execute(JobExecutionContext context) throws JobExecutionException { 76 try { 77 BeanWrapper bw = new BeanWrapperImpl(this); 78 MutablePropertyValues pvs = new MutablePropertyValues(); 79 pvs.addPropertyValues(context.getScheduler().getContext()); 80 pvs.addPropertyValues(context.getMergedJobDataMap()); 81 bw.setPropertyValues(pvs, true); 82 } 83 catch (SchedulerException ex) { 84 throw new JobExecutionException(ex); 85 } 86 executeInternal(context); 87 } 88 89 95 protected abstract void executeInternal(JobExecutionContext context) throws JobExecutionException; 96 97 } 98 | Popular Tags |