1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
package org.mule.module.rss.endpoint; |
11 | |
|
12 | |
import org.mule.api.MuleException; |
13 | |
import org.mule.api.MuleMessage; |
14 | |
import org.mule.api.endpoint.InboundEndpoint; |
15 | |
import org.mule.endpoint.DefaultInboundEndpoint; |
16 | |
import org.mule.module.rss.transformers.ObjectToRssFeed; |
17 | |
|
18 | |
import java.util.Date; |
19 | |
import java.util.HashSet; |
20 | |
import java.util.Set; |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
public class RssInboundEndpoint extends DefaultInboundEndpoint |
26 | |
{ |
27 | |
private boolean splitFeed; |
28 | |
|
29 | |
private Date lastUpdate; |
30 | |
|
31 | 0 | private ObjectToRssFeed inTransform = new ObjectToRssFeed(); |
32 | |
|
33 | 0 | private Set<String> supportedProtocols = new HashSet<String>(2); |
34 | |
|
35 | |
public RssInboundEndpoint(boolean splitFeed, Date lastUpdate, InboundEndpoint ie) |
36 | |
{ |
37 | 0 | super(ie.getConnector(), ie.getEndpointURI(), ie.getName(), |
38 | |
ie.getProperties(), ie.getTransactionConfig(), ie.isDeleteUnacceptedMessages(), |
39 | |
ie.getExchangePattern(), ie.getResponseTimeout(), ie.getInitialState(), |
40 | |
ie.getEncoding(), ie.getEndpointBuilderName(), ie.getMuleContext(), ie.getRetryPolicyTemplate(), |
41 | |
ie.getMessageProcessorsFactory(), ie.getMessageProcessors(), ie.getResponseMessageProcessors(), ie.isDisableTransportTransformer(), ie.getMimeType()); |
42 | 0 | this.splitFeed = splitFeed; |
43 | 0 | this.lastUpdate = lastUpdate; |
44 | 0 | } |
45 | |
|
46 | |
public boolean isSplitFeed() |
47 | |
{ |
48 | 0 | return splitFeed; |
49 | |
} |
50 | |
|
51 | |
public Date getLastUpdate() |
52 | |
{ |
53 | 0 | return lastUpdate; |
54 | |
} |
55 | |
|
56 | |
void registerSupportedProtocol(String protocol) |
57 | |
{ |
58 | 0 | supportedProtocols.add(protocol); |
59 | 0 | } |
60 | |
|
61 | |
boolean unregisterProtocol(String protocol) |
62 | |
{ |
63 | 0 | return supportedProtocols.remove(protocol); |
64 | |
} |
65 | |
|
66 | |
@Override |
67 | |
public boolean isProtocolSupported(String protocol) |
68 | |
{ |
69 | 0 | return supportedProtocols.contains(protocol); |
70 | |
} |
71 | |
|
72 | |
public boolean onMessage(MuleMessage message) throws MuleException |
73 | |
{ |
74 | 0 | message.applyTransformers(null, inTransform); |
75 | 0 | return true; |
76 | |
} |
77 | |
} |