Coverage Report - org.mule.providers.quartz.jobs.DelegatingJob
 
Classes in this File Line Coverage Branch Coverage Complexity
DelegatingJob
0%
0/17
0%
0/4
10
 
 1  
 /*
 2  
  * $Id: DelegatingJob.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.MuleManager;
 14  
 import org.mule.providers.quartz.QuartzConnector;
 15  
 import org.mule.providers.quartz.i18n.QuartzMessages;
 16  
 import org.mule.umo.manager.ObjectNotFoundException;
 17  
 
 18  
 import org.quartz.Job;
 19  
 import org.quartz.JobDataMap;
 20  
 import org.quartz.JobExecutionContext;
 21  
 import org.quartz.JobExecutionException;
 22  
 
 23  
 /**
 24  
  * Extracts the Job object to invoke from the context. The Job itself can be
 25  
  * scheduled by dispatching an event over a quartz endpoint. The job can either be
 26  
  * set as a property on the event (this property can be a container reference or the
 27  
  * actual job object) or the payload of the event can be the Job (in which case when
 28  
  * the job is fired it will have a NullPayload)
 29  
  * 
 30  
  * @see org.mule.providers.NullPayload
 31  
  */
 32  0
 public class DelegatingJob implements Job
 33  
 {
 34  
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException
 35  
     {
 36  0
         JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
 37  0
         Object tempJob = jobDataMap.get(QuartzConnector.PROPERTY_JOB_OBJECT);
 38  0
         if (tempJob == null)
 39  
         {
 40  0
             tempJob = jobDataMap.get(QuartzConnector.PROPERTY_JOB_REF);
 41  0
             if (tempJob == null)
 42  
             {
 43  0
                 throw new JobExecutionException(QuartzMessages.invalidPayloadType().getMessage());
 44  
             }
 45  
             else
 46  
             {
 47  
                 try
 48  
                 {
 49  0
                     tempJob = MuleManager.getInstance().getContainerContext().getComponent(tempJob);
 50  
                 }
 51  0
                 catch (ObjectNotFoundException e)
 52  
                 {
 53  0
                     throw new JobExecutionException(e);
 54  0
                 }
 55  0
                 if (!(tempJob instanceof Job))
 56  
                 {
 57  0
                     throw new JobExecutionException(QuartzMessages.invalidJobObject().getMessage());
 58  
                 }
 59  
             }
 60  
         }
 61  0
         else if (!(tempJob instanceof Job))
 62  
         {
 63  0
             throw new JobExecutionException(QuartzMessages.invalidJobObject().toString());
 64  
         }
 65  0
         ((Job)tempJob).execute(jobExecutionContext);
 66  0
     }
 67  
 }