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