1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.providers.quartz.jobs; |
12 | |
|
13 | |
import org.mule.extras.client.MuleClient; |
14 | |
import org.mule.providers.NullPayload; |
15 | |
import org.mule.providers.quartz.QuartzConnector; |
16 | |
import org.mule.providers.quartz.i18n.QuartzMessages; |
17 | |
import org.mule.umo.UMOException; |
18 | |
|
19 | |
import org.apache.commons.logging.Log; |
20 | |
import org.apache.commons.logging.LogFactory; |
21 | |
import org.quartz.Job; |
22 | |
import org.quartz.JobDataMap; |
23 | |
import org.quartz.JobExecutionContext; |
24 | |
import org.quartz.JobExecutionException; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | 0 | public class MuleClientDispatchJob implements Job |
30 | |
{ |
31 | |
|
32 | |
|
33 | |
|
34 | 0 | protected transient Log logger = LogFactory.getLog(getClass()); |
35 | |
|
36 | |
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException |
37 | |
{ |
38 | 0 | JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap(); |
39 | 0 | Object payload = jobDataMap.get(QuartzConnector.PROPERTY_PAYLOAD); |
40 | |
|
41 | 0 | if (payload == null) |
42 | |
{ |
43 | 0 | payload = NullPayload.getInstance(); |
44 | |
} |
45 | |
|
46 | 0 | String dispatchEndpoint = jobDataMap.getString(QuartzConnector.PROPERTY_JOB_DISPATCH_ENDPOINT); |
47 | 0 | if (dispatchEndpoint == null) |
48 | |
{ |
49 | 0 | throw new JobExecutionException( |
50 | |
QuartzMessages.missingJobDetail(QuartzConnector.PROPERTY_JOB_DISPATCH_ENDPOINT).getMessage()); |
51 | |
} |
52 | |
|
53 | |
try |
54 | |
{ |
55 | 0 | MuleClient client = new MuleClient(); |
56 | 0 | logger.debug("Dispatching payload on: " + dispatchEndpoint); |
57 | 0 | client.dispatch(dispatchEndpoint, payload, jobDataMap); |
58 | |
} |
59 | 0 | catch (UMOException e) |
60 | |
{ |
61 | 0 | throw new JobExecutionException(e); |
62 | 0 | } |
63 | 0 | } |
64 | |
} |