View Javadoc

1   /*
2    * $Id: HttpPollingConnector.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  package org.mule.transport.http;
11  
12  import org.mule.api.MuleContext;
13  import org.mule.api.config.MuleProperties;
14  
15  import java.util.Properties;
16  
17  /**
18   * The HttpPollingConnectors allows for inbound Http endpoints to be configured with an address which it shall use
19   * to poll for a result. If a result is received it becomes the inbound event for the component.  This connector is
20   * useful for interacting with services that provide pull-only support for obtaining data.  This is typical for many
21   * web-based services.
22   */
23  public class HttpPollingConnector extends HttpConnector
24  {
25      /**
26       * How long to wait in milliseconds between make a new request
27       */
28      private long pollingFrequency = 1000L;
29  
30      /**
31       * If a zero-length content is returned should the message be discarded
32       */
33      private boolean discardEmptyContent = true;
34  
35      /**
36       * Should the ETag header get honoured if it is present.
37       */
38      private boolean checkEtag = true;
39  
40      public HttpPollingConnector(MuleContext context)
41      {
42          super(context);
43          serviceOverrides = new Properties();
44          serviceOverrides.setProperty(MuleProperties.CONNECTOR_MESSAGE_RECEIVER_CLASS, PollingHttpMessageReceiver.class.getName());
45      }
46  
47      public boolean isDiscardEmptyContent()
48      {
49          return discardEmptyContent;
50      }
51  
52      public void setDiscardEmptyContent(boolean discardEmptyContent)
53      {
54          this.discardEmptyContent = discardEmptyContent;
55      }
56  
57      public long getPollingFrequency()
58      {
59          return pollingFrequency;
60      }
61  
62      public void setPollingFrequency(long pollingFrequency)
63      {
64          this.pollingFrequency = pollingFrequency;
65      }
66  
67      public boolean isCheckEtag()
68      {
69          return checkEtag;
70      }
71  
72      public void setCheckEtag(boolean checkEtag)
73      {
74          this.checkEtag = checkEtag;
75      }
76  }