1 10 11 package org.mule.providers.quartz.jobs; 12 13 import org.apache.commons.logging.Log; 14 import org.apache.commons.logging.LogFactory; 15 import org.mule.config.i18n.Message; 16 import org.mule.extras.client.MuleClient; 17 import org.mule.providers.NullPayload; 18 import org.mule.providers.quartz.QuartzConnector; 19 import org.mule.umo.UMOException; 20 import org.quartz.Job; 21 import org.quartz.JobDataMap; 22 import org.quartz.JobExecutionContext; 23 import org.quartz.JobExecutionException; 24 25 28 public class MuleClientDispatchJob implements Job 29 { 30 33 protected transient Log logger = LogFactory.getLog(getClass()); 34 35 public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException 36 { 37 JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap(); 38 Object payload = jobDataMap.get(QuartzConnector.PROPERTY_PAYLOAD); 39 if (payload == null) 40 { 41 payload = new NullPayload(); 42 } 43 String dispatchEndpoint = jobDataMap.getString(QuartzConnector.PROPERTY_JOB_DISPATCH_ENDPOINT); 44 if (dispatchEndpoint == null) 45 { 46 throw new JobExecutionException(new Message("quartz", 4, 47 QuartzConnector.PROPERTY_JOB_DISPATCH_ENDPOINT).getMessage()); 48 } 49 try 50 { 51 MuleClient client = new MuleClient(); 52 logger.debug("Dispatching payload on: " + dispatchEndpoint); 53 client.dispatch(dispatchEndpoint, payload, jobDataMap); 54 } 55 catch (UMOException e) 56 { 57 throw new JobExecutionException(e); 58 } 59 } 60 } 61 | Popular Tags |