Coverage Report - org.mule.providers.quartz.jobs.MuleClientDispatchJob
 
Classes in this File Line Coverage Branch Coverage Complexity
MuleClientDispatchJob
0%
0/16
0%
0/2
6
 
 1  
 /*
 2  
  * $Id: MuleClientDispatchJob.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.providers.quartz.jobs;
 12  
 
 13  
 import org.mule.extras.client.MuleClient;
 14  
 import org.mule.providers.NullPayload;
 15  
 import org.mule.providers.quartz.QuartzConnector;
 16  
 import org.mule.providers.quartz.i18n.QuartzMessages;
 17  
 import org.mule.umo.UMOException;
 18  
 
 19  
 import org.apache.commons.logging.Log;
 20  
 import org.apache.commons.logging.LogFactory;
 21  
 import org.quartz.Job;
 22  
 import org.quartz.JobDataMap;
 23  
 import org.quartz.JobExecutionContext;
 24  
 import org.quartz.JobExecutionException;
 25  
 
 26  
 /**
 27  
  * Will dispatch to a Mule endpoint using the Mule client.
 28  
  */
 29  0
 public class MuleClientDispatchJob implements Job
 30  
 {
 31  
     /**
 32  
      * The logger used for this class
 33  
      */
 34  0
     protected transient Log logger = LogFactory.getLog(getClass());
 35  
 
 36  
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException
 37  
     {
 38  0
         JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
 39  0
         Object payload = jobDataMap.get(QuartzConnector.PROPERTY_PAYLOAD);
 40  
 
 41  0
         if (payload == null)
 42  
         {
 43  0
             payload = NullPayload.getInstance();
 44  
         }
 45  
 
 46  0
         String dispatchEndpoint = jobDataMap.getString(QuartzConnector.PROPERTY_JOB_DISPATCH_ENDPOINT);
 47  0
         if (dispatchEndpoint == null)
 48  
         {
 49  0
             throw new JobExecutionException(
 50  
                 QuartzMessages.missingJobDetail(QuartzConnector.PROPERTY_JOB_DISPATCH_ENDPOINT).getMessage());
 51  
         }
 52  
 
 53  
         try
 54  
         {
 55  0
             MuleClient client = new MuleClient();
 56  0
             logger.debug("Dispatching payload on: " + dispatchEndpoint);
 57  0
             client.dispatch(dispatchEndpoint, payload, jobDataMap);
 58  
         }
 59  0
         catch (UMOException e)
 60  
         {
 61  0
             throw new JobExecutionException(e);
 62  0
         }
 63  0
     }
 64  
 }