1
2
3
4
5
6
7
8
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
25
26
27
28
29
30
31
32 public class DelegatingJob implements Job
33 {
34 public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException
35 {
36 JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
37 Object tempJob = jobDataMap.get(QuartzConnector.PROPERTY_JOB_OBJECT);
38 if (tempJob == null)
39 {
40 tempJob = jobDataMap.get(QuartzConnector.PROPERTY_JOB_REF);
41 if (tempJob == null)
42 {
43 throw new JobExecutionException(QuartzMessages.invalidPayloadType().getMessage());
44 }
45 else
46 {
47 try
48 {
49 tempJob = MuleManager.getInstance().getContainerContext().getComponent(tempJob);
50 }
51 catch (ObjectNotFoundException e)
52 {
53 throw new JobExecutionException(e);
54 }
55 if (!(tempJob instanceof Job))
56 {
57 throw new JobExecutionException(QuartzMessages.invalidJobObject().getMessage());
58 }
59 }
60 }
61 else if (!(tempJob instanceof Job))
62 {
63 throw new JobExecutionException(QuartzMessages.invalidJobObject().toString());
64 }
65 ((Job)tempJob).execute(jobExecutionContext);
66 }
67 }