1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.transport.quartz.jobs; |
8 | |
|
9 | |
import org.mule.api.MuleContext; |
10 | |
import org.mule.api.MuleException; |
11 | |
import org.mule.api.context.MuleContextAware; |
12 | |
import org.mule.api.endpoint.InboundEndpoint; |
13 | |
import org.mule.api.lifecycle.InitialisationException; |
14 | |
import org.mule.api.lifecycle.Lifecycle; |
15 | |
import org.mule.transport.AbstractConnector; |
16 | |
import org.mule.transport.AbstractPollingMessageReceiver; |
17 | |
|
18 | |
import org.quartz.Job; |
19 | |
import org.quartz.JobExecutionContext; |
20 | |
import org.quartz.JobExecutionException; |
21 | |
|
22 | |
public class PollEndpointJob implements Job, Lifecycle, MuleContextAware |
23 | |
{ |
24 | |
private String inboundPollingEndpointName; |
25 | |
private AbstractPollingMessageReceiver receiver; |
26 | |
private MuleContext muleContext; |
27 | |
|
28 | |
public PollEndpointJob(String inboundPollingEndpointName) |
29 | 0 | { |
30 | 0 | this.inboundPollingEndpointName = inboundPollingEndpointName; |
31 | 0 | } |
32 | |
|
33 | |
public void execute(JobExecutionContext context) throws JobExecutionException |
34 | |
{ |
35 | |
try |
36 | |
{ |
37 | 0 | receiver.poll(); |
38 | |
} |
39 | 0 | catch (Exception e) |
40 | |
{ |
41 | 0 | throw new JobExecutionException(e); |
42 | 0 | } |
43 | |
|
44 | 0 | } |
45 | |
|
46 | |
public void initialise() throws InitialisationException |
47 | |
{ |
48 | |
|
49 | 0 | } |
50 | |
|
51 | |
public void start() throws MuleException |
52 | |
{ |
53 | 0 | InboundEndpoint endpoint = (InboundEndpoint) muleContext.getRegistry().lookupObject(this.inboundPollingEndpointName); |
54 | 0 | AbstractConnector connector = (AbstractConnector) endpoint.getConnector(); |
55 | 0 | receiver = (AbstractPollingMessageReceiver) connector.getReceiver(null, endpoint); |
56 | 0 | receiver.disableNativeScheduling(); |
57 | 0 | } |
58 | |
|
59 | |
public void stop() throws MuleException |
60 | |
{ |
61 | |
|
62 | 0 | } |
63 | |
|
64 | |
public void dispose() |
65 | |
{ |
66 | |
|
67 | 0 | } |
68 | |
|
69 | |
public void setMuleContext(MuleContext context) { |
70 | 0 | this.muleContext = context; |
71 | 0 | } |
72 | |
} |