View Javadoc

1   /*
2    * $Id: RssInboundEndpoint.java 19359 2010-09-03 20:03:08Z rossmason $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
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   * TODO
24   */
25  public class RssInboundEndpoint extends DefaultInboundEndpoint
26  {
27      private boolean splitFeed;
28  
29      private Date lastUpdate;
30  
31      private ObjectToRssFeed inTransform = new ObjectToRssFeed();
32  
33      private Set<String> supportedProtocols = new HashSet<String>(2);
34  
35      public RssInboundEndpoint(boolean splitFeed, Date lastUpdate, InboundEndpoint ie)
36      {
37          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          this.splitFeed = splitFeed;
43          this.lastUpdate = lastUpdate;
44      }
45  
46      public boolean isSplitFeed()
47      {
48          return splitFeed;
49      }
50  
51      public Date getLastUpdate()
52      {
53          return lastUpdate;
54      }
55  
56      void registerSupportedProtocol(String protocol)
57      {
58          supportedProtocols.add(protocol);
59      }
60  
61      boolean unregisterProtocol(String protocol)
62      {
63          return supportedProtocols.remove(protocol);
64      }
65  
66      @Override
67      public boolean isProtocolSupported(String protocol)
68      {
69          return supportedProtocols.contains(protocol);
70      }
71  
72      public boolean onMessage(MuleMessage message) throws MuleException
73      {
74          message.applyTransformers(null, inTransform);
75          return true;
76      }
77  }