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 | 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 | |
} |