View Javadoc

1   /*
2    * $Id: HttpPollingConnector.java 11983 2008-06-10 15:16:36Z rossmason $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.lifecycle.InitialisationException;
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()
41      {
42          serviceOverrides = new Properties();
43          serviceOverrides.setProperty(MuleProperties.CONNECTOR_MESSAGE_RECEIVER_CLASS, PollingHttpMessageReceiver.class.getName());
44      }
45  
46      public boolean isDiscardEmptyContent()
47      {
48          return discardEmptyContent;
49      }
50  
51      public void setDiscardEmptyContent(boolean discardEmptyContent)
52      {
53          this.discardEmptyContent = discardEmptyContent;
54      }
55  
56      public long getPollingFrequency()
57      {
58          return pollingFrequency;
59      }
60  
61      public void setPollingFrequency(long pollingFrequency)
62      {
63          this.pollingFrequency = pollingFrequency;
64      }
65  
66      public boolean isCheckEtag()
67      {
68          return checkEtag;
69      }
70  
71      public void setCheckEtag(boolean checkEtag)
72      {
73          this.checkEtag = checkEtag;
74      }
75  }