Java Reference
In-Depth Information
if (-1 != lastStatusIdRetreived) {
paging.sinceId(lastStatusIdRetreived);
}
try {
List<Status> statuses = twitter.getFriendsTimeline(paging);
Assert.state(cachedStatuses.peek() == null);// size() isn't
// constant time
for (Status status : statuses)
this.cachedStatuses.add(buildTweetFromStatus(status));
} catch (TwitterException e) {
logger.info(ExceptionUtils.getFullStackTrace(e));
throw new RuntimeException(e);
}
}
if (cachedStatuses.peek() != null) {
// size() == 0 would be more obvious
// a test, but size() isn't constant time
Tweet cachedStatus = cachedStatuses.poll();
lastStatusIdRetreived = cachedStatus.getTweetId();
return MessageBuilder.withPayload(cachedStatus).build();
}
return null;
}
public void afterPropertiesSet() throws Exception {
if (twitter == null) {
Assert.state(!StringUtils.isEmpty(userId));
Assert.state(!StringUtils.isEmpty(password));
twitter = new Twitter();
twitter.setUserId(userId);
twitter.setPassword(password);
} else { // it isnt null, in which case it becomes canonical memory
setPassword(twitter.getPassword());
setUserId(twitter.getUserId());
}
cachedStatuses = new ConcurrentLinkedQueue<Tweet>();
lastStatusIdRetreived = -1;
}
public String getUserId() {
return userId;
}
Search WWH ::




Custom Search