1 17 package org.quartz.simpl; 18 19 import org.apache.commons.logging.Log; 20 import org.apache.commons.logging.LogFactory; 21 import org.quartz.Job; 22 import org.quartz.JobDetail; 23 import org.quartz.SchedulerException; 24 import org.quartz.spi.JobFactory; 25 import org.quartz.spi.TriggerFiredBundle; 26 27 36 public class SimpleJobFactory implements JobFactory { 37 38 private final Log log = LogFactory.getLog(getClass()); 39 40 protected Log getLog() { 41 return log; 42 } 43 44 public Job newJob(TriggerFiredBundle bundle) throws SchedulerException { 45 46 JobDetail jobDetail = bundle.getJobDetail(); 47 Class jobClass = jobDetail.getJobClass(); 48 try { 49 if(log.isDebugEnabled()) { 50 log.debug( 51 "Producing instance of Job '" + jobDetail.getFullName() + 52 "', class=" + jobClass.getName()); 53 } 54 55 return (Job) jobClass.newInstance(); 56 } catch (Exception e) { 57 SchedulerException se = new SchedulerException( 58 "Problem instantiating class '" 59 + jobDetail.getJobClass().getName() + "'", e); 60 throw se; 61 } 62 } 63 } | Popular Tags |