List of usage examples for twitter4j StatusAdapter StatusAdapter
StatusAdapter
From source file:com.chimpler.example.TwitterStatusProducer.java
License:Apache License
public synchronized void startSample(String username, String password) { if (twitterStream != null) { return;/*from w w w . j a v a 2 s . com*/ } TwitterStreamFactory factory = new TwitterStreamFactory( new ConfigurationBuilder().setUser(username).setPassword(password).build()); twitterStream = factory.getInstance(); twitterStream.addListener(new StatusAdapter() { public void onStatus(Status status) { Map<String, Object> map = new HashMap<String, Object>(); map.put("status", "OK"); map.put("createdAt", status.getCreatedAt().toString()); map.put("username", status.getUser().getName()); map.put("profileImageUrl", status.getUser().getMiniProfileImageURL()); map.put("text", status.getText()); cometTwitterService.publishMessage(map, Long.toString(status.getId())); } @Override public void onException(Exception ex) { Map<String, Object> map = new HashMap<String, Object>(); map.put("status", "ERR"); map.put("text", ex.getMessage()); cometTwitterService.publishMessage(map, "-1"); stopSample(); } }); logger.log(Level.INFO, "Starting listening to twitter sample"); twitterStream.sample(); }
From source file:net.nokok.twitduke.core.twitter.LambdaTwitterStream.java
License:Open Source License
public void onDeletionNotice(Event<StatusDeletionNotice> s) { this.twitterStream.addListener(new StatusAdapter() { @Override/*from w w w.ja v a2 s . com*/ public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) { s.onEvent(statusDeletionNotice); } }); }
From source file:net.nokok.twitduke.core.twitter.LambdaTwitterStream.java
License:Open Source License
@Override public void onException(ThrowableReceivable receiver) { this.twitterStream.addListener(new StatusAdapter() { @Override// w w w . j ava2 s . c o m public void onException(Exception ex) { if (ex.getClass().equals(ClassCastException.class)) { return; } receiver.onError(ex); } }); }
From source file:net.nokok.twitduke.core.twitter.LambdaTwitterStream.java
License:Open Source License
public void ScrubGeo(Event2<Long, Long> s) { this.twitterStream.addListener(new StatusAdapter() { @Override// ww w .j a v a 2 s . co m public void onScrubGeo(long userId, long upToStatusId) { s.onEvent(userId, upToStatusId); } }); }
From source file:net.nokok.twitduke.core.twitter.LambdaTwitterStream.java
License:Open Source License
public void onStallWarning(Event<StallWarning> w) { this.twitterStream.addListener(new StatusAdapter() { @Override// ww w. ja va 2 s. c o m public void onStallWarning(StallWarning warning) { w.onEvent(warning); } }); }
From source file:net.nokok.twitduke.core.twitter.LambdaTwitterStream.java
License:Open Source License
public void onStatus(Event<Status> s) { this.twitterStream.addListener(new StatusAdapter() { @Override/* ww w . j av a 2s .c o m*/ public void onStatus(Status status) { s.onEvent(status); } }); }
From source file:net.nokok.twitduke.core.twitter.LambdaTwitterStream.java
License:Open Source License
public void onStatusUser(Event<User> u) { this.twitterStream.addListener(new StatusAdapter() { @Override/*from w w w . j ava2 s . co m*/ public void onStatus(Status status) { u.onEvent(status.getUser()); } }); }
From source file:net.nokok.twitduke.core.twitter.LambdaTwitterStream.java
License:Open Source License
public void onStatusScreenName(Event<String> s) { this.twitterStream.addListener(new StatusAdapter() { @Override//from ww w. j av a 2s .c o m public void onStatus(Status status) { s.onEvent(status.getUser().getScreenName()); } }); }
From source file:net.nokok.twitduke.core.twitter.LambdaTwitterStream.java
License:Open Source License
public void onTrackLimitationNotice(Event<Integer> i) { this.twitterStream.addListener(new StatusAdapter() { @Override/*from www . j a v a 2s . c o m*/ public void onTrackLimitationNotice(int numberOfLimitedStatuses) { i.onEvent(numberOfLimitedStatuses); } }); }
From source file:org.mule.twitter.TwitterConnector.java
License:Open Source License
private TwitterStream listenToStatues(final SourceCallback callback_) { initStream();//from w w w . ja v a 2 s .c om final SoftCallback callback = new SoftCallback(callback_); stream.addListener(new StatusAdapter() { @Override public void onException(Exception ex) { logger.warn("An exception occured while processing status stream", ex); } @Override public void onStatus(Status status) { try { callback.process(status); } catch (Exception e) { logger.error(e.getMessage(), e); } } }); return stream; }