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