org.springframework.integration.twitter.inbound
Class AbstractTwitterMessageSource<T>

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.endpoint.AbstractEndpoint
          extended by org.springframework.integration.twitter.inbound.AbstractTwitterMessageSource<T>
All Implemented Interfaces:
BeanFactoryAware, BeanNameAware, InitializingBean, Lifecycle, Phased, SmartLifecycle, NamedComponent, MessageSource, TrackableComponent
Direct Known Subclasses:
DirectMessageReceivingMessageSource, MentionReceivingMessageSource, TimelineUpdateReceivingMessageSource

public abstract class AbstractTwitterMessageSource<T>
extends AbstractEndpoint
implements MessageSource, TrackableComponent

Abstract class that defines common operations for receiving various types of messages when using the Twitter API. This class also handles keeping track of the latest inbound message it has received and avoiding, where possible, redelivery of common messages. This functionality is enabled using the MetadataStore strategy.

Since:
2.0

Field Summary
protected  OAuthConfiguration configuration
           
protected  long markerId
           
protected  int prefetchThreshold
           
protected  java.util.Queue<java.lang.Object> tweets
           
protected  twitter4j.Twitter twitter
           
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Constructor Summary
AbstractTwitterMessageSource()
           
 
Method Summary
protected  void doStart()
          Subclasses must implement this method with the start behavior.
protected  void doStop()
          Subclasses must implement this method with the stop behavior.
protected  void forward(T tweet)
           
protected  void forwardAll(java.util.List<T> tResponses)
           
protected  java.util.Comparator getComparator()
           
 long getMarkerId()
           
protected  boolean hasMarkedStatus()
           
protected  void markLastStatusId(long statusId)
           
protected  void onInit()
          Subclasses may implement this for initialization logic.
 Message<?> receive()
          Retrieve the next available message from this source.
 void setConfiguration(OAuthConfiguration configuration)
           
 void setShouldTrack(boolean shouldTrack)
           
 
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
getPhase, isAutoStartup, isRunning, setAutoStartup, setPhase, setTaskScheduler, start, stop, stop
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getComponentType, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.integration.context.NamedComponent
getComponentName, getComponentType
 

Field Detail

configuration

protected volatile OAuthConfiguration configuration

tweets

protected final java.util.Queue<java.lang.Object> tweets

prefetchThreshold

protected volatile int prefetchThreshold

markerId

protected volatile long markerId

twitter

protected twitter4j.Twitter twitter
Constructor Detail

AbstractTwitterMessageSource

public AbstractTwitterMessageSource()
Method Detail

setConfiguration

public void setConfiguration(OAuthConfiguration configuration)

setShouldTrack

public void setShouldTrack(boolean shouldTrack)
Specified by:
setShouldTrack in interface TrackableComponent

getMarkerId

public long getMarkerId()

hasMarkedStatus

protected boolean hasMarkedStatus()

onInit

protected void onInit()
               throws java.lang.Exception
Description copied from class: IntegrationObjectSupport
Subclasses may implement this for initialization logic.

Overrides:
onInit in class IntegrationObjectSupport
Throws:
java.lang.Exception

forwardAll

protected void forwardAll(java.util.List<T> tResponses)

getComparator

protected java.util.Comparator getComparator()

doStart

protected void doStart()
Description copied from class: AbstractEndpoint
Subclasses must implement this method with the start behavior. This method will be invoked while holding the AbstractEndpoint.lifecycleLock.

Specified by:
doStart in class AbstractEndpoint

doStop

protected void doStop()
Description copied from class: AbstractEndpoint
Subclasses must implement this method with the stop behavior. This method will be invoked while holding the AbstractEndpoint.lifecycleLock.

Specified by:
doStop in class AbstractEndpoint

receive

public Message<?> receive()
Description copied from interface: MessageSource
Retrieve the next available message from this source. Returns null if no message is available.

Specified by:
receive in interface MessageSource

forward

protected void forward(T tweet)

markLastStatusId

protected void markLastStatusId(long statusId)