1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.quartz.jobs;
12
13 import org.mule.RegistryContext;
14 import org.mule.transport.quartz.QuartzConnector;
15 import org.mule.transport.quartz.i18n.QuartzMessages;
16
17 import org.quartz.Job;
18 import org.quartz.JobDataMap;
19 import org.quartz.JobExecutionContext;
20 import org.quartz.JobExecutionException;
21
22
23
24
25
26
27
28
29
30
31 public class CustomJob implements Job
32 {
33 public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException
34 {
35 JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
36 Object tempJob = jobDataMap.get(QuartzConnector.PROPERTY_JOB_OBJECT);
37 if (tempJob == null)
38 {
39 tempJob = jobDataMap.get(QuartzConnector.PROPERTY_JOB_REF);
40 if (tempJob == null)
41 {
42 throw new JobExecutionException(QuartzMessages.invalidPayloadType().getMessage());
43 }
44 else
45 {
46 tempJob = RegistryContext.getRegistry().lookupObject((String) tempJob);
47 if(tempJob==null)
48 {
49 throw new JobExecutionException("Job not found: " + tempJob);
50 }
51 if (!(tempJob instanceof Job))
52 {
53 throw new JobExecutionException(QuartzMessages.invalidJobObject().getMessage());
54 }
55 }
56 }
57 else if (!(tempJob instanceof Job))
58 {
59 throw new JobExecutionException(QuartzMessages.invalidJobObject().toString());
60 }
61 ((Job)tempJob).execute(jobExecutionContext);
62 }
63 }