1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.config.spring.factories; |
12 | |
|
13 | |
import org.mule.api.config.ConfigurationException; |
14 | |
import org.mule.api.endpoint.EndpointFactory; |
15 | |
import org.mule.api.processor.MessageProcessor; |
16 | |
import org.mule.config.i18n.MessageFactory; |
17 | |
import org.mule.endpoint.URIBuilder; |
18 | |
import org.mule.transport.AbstractConnector; |
19 | |
import org.mule.transport.polling.MessageProcessorPollingMessageReceiver; |
20 | |
|
21 | 0 | public class PollingMessageSourceFactoryBean extends InboundEndpointFactoryBean |
22 | |
{ |
23 | |
|
24 | |
protected MessageProcessor messageProcessor; |
25 | |
protected Long frequency; |
26 | |
|
27 | |
public Object doGetObject() throws Exception |
28 | |
{ |
29 | 0 | uriBuilder = new URIBuilder("polling://" + hashCode(), muleContext); |
30 | 0 | properties.put(MessageProcessorPollingMessageReceiver.SOURCE_MESSAGE_PROCESSOR_PROPERTY_NAME, messageProcessor); |
31 | 0 | properties.put(AbstractConnector.PROPERTY_POLLING_FREQUENCY, frequency); |
32 | 0 | EndpointFactory ef = muleContext.getRegistry().lookupEndpointFactory(); |
33 | 0 | if (ef != null) |
34 | |
{ |
35 | 0 | return ef.getInboundEndpoint(this); |
36 | |
} |
37 | |
else |
38 | |
{ |
39 | 0 | throw new ConfigurationException( |
40 | |
MessageFactory.createStaticMessage("EndpointFactory not found in Registry")); |
41 | |
} |
42 | |
} |
43 | |
|
44 | |
public void setMessageProcessor(MessageProcessor messageProcessor) |
45 | |
{ |
46 | 0 | this.messageProcessor = messageProcessor; |
47 | 0 | } |
48 | |
|
49 | |
public void setFrequency(Long frequency) |
50 | |
{ |
51 | 0 | this.frequency = frequency; |
52 | 0 | } |
53 | |
|
54 | |
} |