Java Reference
In-Depth Information
static private Logger logger = Logger.getLogger(TwitterMessageProducer.class);
private volatile String userId;
private volatile String password;
private volatile Twitter twitter;
public void tweet(String tweet) {
try {
twitter.updateStatus(tweet);
} catch (TwitterException e) {
logger.debug(ExceptionUtils.getFullStackTrace(e));
}
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Twitter getTwitter() {
return twitter;
}
public void setTwitter(Twitter twitter) {
this.twitter = twitter;
}
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());
}
}
}
Search WWH ::




Custom Search