View Javadoc

1   /*
2    * $Id: AtomInboundEndpoint.java 20321 2010-11-24 15:21:24Z dfeist $
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  
11  package org.mule.module.atom.endpoint;
12  
13  import org.mule.api.MuleException;
14  import org.mule.api.MuleMessage;
15  import org.mule.api.endpoint.InboundEndpoint;
16  import org.mule.endpoint.DefaultInboundEndpoint;
17  import org.mule.module.atom.transformers.ObjectToFeed;
18  
19  import java.util.Date;
20  import java.util.HashSet;
21  import java.util.Set;
22  
23  /**
24   * An ATOM endpoint is used for polling an ATOM feed and processing the feed entries
25   */
26  public class AtomInboundEndpoint extends DefaultInboundEndpoint 
27  {
28      private boolean splitFeed;
29  
30      private Date lastUpdate;
31  
32      private ObjectToFeed inTransform = new ObjectToFeed();
33  
34      private Set<String> supportedProtocols = new HashSet<String>(2);
35  
36      public AtomInboundEndpoint(boolean splitFeed, Date lastUpdate, InboundEndpoint ie)
37      {
38          super(ie.getConnector(), ie.getEndpointURI(), ie.getName(),
39                  ie.getProperties(), ie.getTransactionConfig(), ie.isDeleteUnacceptedMessages(),
40                  ie.getExchangePattern(), ie.getResponseTimeout(), ie.getInitialState(),
41                  ie.getEncoding(), ie.getEndpointBuilderName(), ie.getMuleContext(), ie.getRetryPolicyTemplate(), 
42                  ie.getMessageProcessorsFactory(), ie.getMessageProcessors(), ie.getResponseMessageProcessors(), ie.isDisableTransportTransformer(), ie.getMimeType());
43          this.splitFeed = splitFeed;
44          this.lastUpdate = lastUpdate;
45      }
46  
47      public boolean isSplitFeed()
48      {
49          return splitFeed;
50      }
51  
52      public Date getLastUpdate()
53      {
54          return lastUpdate;
55      }
56  
57      void registerSupportedProtocol(String protocol)
58      {
59          supportedProtocols.add(protocol);
60      }
61  
62      boolean unregisterProtocol(String protocol)
63      {
64          return supportedProtocols.remove(protocol);
65      }
66  
67      @Override
68      public boolean isProtocolSupported(String protocol)
69      {
70          return supportedProtocols.contains(protocol);
71      }
72  
73      public boolean onMessage(MuleMessage message) throws MuleException
74      {
75          message.applyTransformers(null, inTransform);
76          return true;
77      }
78  }