Class TwitterStreamProvider

java.lang.Object
com.northconcepts.datapipeline.twitter.TwitterStreamProvider

public class TwitterStreamProvider extends Object
Streaming Twitter service provider.
  • Field Details

    • consumerKey

      protected final String consumerKey
    • consumerSecret

      protected final String consumerSecret
    • accessToken

      protected final String accessToken
    • accessTokenSecret

      protected final String accessTokenSecret
  • Constructor Details

    • TwitterStreamProvider

      public TwitterStreamProvider(String consumerKey, String consumerSecret)
      Creates a provider that uses application-only (OAuth 2 bearer token) authentication.
    • TwitterStreamProvider

      public TwitterStreamProvider(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret)
      Creates a provider that authenticates with the given user access token, or application-only if it is empty.
  • Method Details

    • getConfig

      public ConfigurationBuilder getConfig()
      Returns the twitter4j configuration applied when the stream is created (when a reader is opened).
    • getHttpProxyHost

      public String getHttpProxyHost()
      Returns the HTTP proxy host, applied when the stream is created (when a reader is opened).
    • setHttpProxyHost

      public TwitterStreamProvider setHttpProxyHost(String httpProxyHost)
      Sets the HTTP proxy host, applied when the stream is created (when a reader is opened).
    • getHttpProxyPort

      public Integer getHttpProxyPort()
      Returns the HTTP proxy port, applied when the stream is created (when a reader is opened).
    • setHttpProxyPort

      public TwitterStreamProvider setHttpProxyPort(Integer httpProxyPort)
      Sets the HTTP proxy port, applied when the stream is created (when a reader is opened).
    • open

      public void open(String rateLimitResource, String rateLimitKey) throws DataException
      Does nothing; the stream is created when a reader is opened.
      Throws:
      DataException
    • close

      public void close() throws DataException
      Shuts down the stream if one was created; a later reader open creates a new one.
      Throws:
      DataException
    • getTwitterStream

      protected TwitterStream getTwitterStream()
      Returns the stream, creating it on first use with the configured credentials and proxy.
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Returns the exception unchanged; subclasses can override to add provider details.