org.springframework.integration.twitter
Class AbstractInboundTwitterEndpointSupport<T>
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.twitter.AbstractInboundTwitterEndpointSupport<T>
- All Implemented Interfaces:
- BeanFactoryAware, BeanNameAware, InitializingBean, Lifecycle, Phased, SmartLifecycle, NamedComponent
- Direct Known Subclasses:
- AbstractInboundTwitterStatusEndpointSupport, InboundDMStatusEndpoint
public abstract class AbstractInboundTwitterEndpointSupport<T>
- extends AbstractEndpoint
- implements Lifecycle
There are a lot of operations that are common to receiving the various types of messages when using the Twitter API, and this
class abstracts most of them for you. Implementers must take note of runAsAPIRateLimitsPermit(org.springframework.integration.twitter.AbstractInboundTwitterEndpointSupport.ApiCallback)
which will invoke the instance of AbstractInboundTwitterEndpointSupport.ApiCallback
when the rate-limit API
deems that its OK to do so. This class handles keeping tabs on that and on spacing out requests as required.
Simialarly, this class handles keeping track on the latest inbound message its received and avoiding, where possible, redelivery of
common messages. This functionality is enabled using the MetadataPersister
implementation
- Since:
- 2.0
- Author:
- Josh Long
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport |
afterPropertiesSet, getBeanFactory, getComponentName, getComponentType, getConversionService, getRequiredMetadataPersister, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, toString |
configuration
protected volatile OAuthConfiguration configuration
messagingTemplate
protected final MessagingTemplate messagingTemplate
markerId
protected volatile long markerId
twitter
protected twitter4j.Twitter twitter
AbstractInboundTwitterEndpointSupport
public AbstractInboundTwitterEndpointSupport()
setConfiguration
public void setConfiguration(OAuthConfiguration configuration)
markLastStatusId
protected abstract void markLastStatusId(T statusId)
sort
protected abstract List<T> sort(List<T> rl)
forwardAll
protected void forwardAll(twitter4j.ResponseList<T> tResponses)
getMarkerId
public long getMarkerId()
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
forward
protected void forward(T status)
runAsAPIRateLimitsPermit
protected void runAsAPIRateLimitsPermit(AbstractInboundTwitterEndpointSupport.ApiCallback cb)
throws Exception
- Throws:
Exception
handleReceivingRateLimitStatus
protected boolean handleReceivingRateLimitStatus(twitter4j.RateLimitStatus rateLimitStatus)
waitUntilPullAvailable
protected boolean waitUntilPullAvailable()
throws Exception
- Throws:
Exception
hasMarkedStatus
protected boolean hasMarkedStatus()
refresh
protected abstract void refresh()
throws Exception
- Throws:
Exception
onInit
protected void onInit()
throws Exception
- Description copied from class:
IntegrationObjectSupport
- Subclasses may implement this for initialization logic.
- Overrides:
onInit
in class IntegrationObjectSupport
- Throws:
Exception
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
setRequestChannel
public void setRequestChannel(MessageChannel requestChannel)
Copyright © 2010. All Rights Reserved.