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 | 4 | public class CustomJob implements Job |
32 | |
{ |
33 | |
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException |
34 | |
{ |
35 | 4 | JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap(); |
36 | 4 | Object tempJob = jobDataMap.get(QuartzConnector.PROPERTY_JOB_OBJECT); |
37 | 4 | if (tempJob == null) |
38 | |
{ |
39 | 0 | tempJob = jobDataMap.get(QuartzConnector.PROPERTY_JOB_REF); |
40 | 0 | if (tempJob == null) |
41 | |
{ |
42 | 0 | throw new JobExecutionException(QuartzMessages.invalidPayloadType().getMessage()); |
43 | |
} |
44 | |
else |
45 | |
{ |
46 | 0 | tempJob = RegistryContext.getRegistry().lookupObject((String) tempJob); |
47 | 0 | if(tempJob==null) |
48 | |
{ |
49 | 0 | throw new JobExecutionException("Job not found: " + tempJob); |
50 | |
} |
51 | 0 | if (!(tempJob instanceof Job)) |
52 | |
{ |
53 | 0 | throw new JobExecutionException(QuartzMessages.invalidJobObject().getMessage()); |
54 | |
} |
55 | |
} |
56 | |
} |
57 | 4 | else if (!(tempJob instanceof Job)) |
58 | |
{ |
59 | 0 | throw new JobExecutionException(QuartzMessages.invalidJobObject().toString()); |
60 | |
} |
61 | 4 | ((Job)tempJob).execute(jobExecutionContext); |
62 | 4 | } |
63 | |
} |