List of usage examples for twitter4j StatusListener onStatus
void onStatus(Status status);
From source file:com.finders.twitter.commands.TwitterRunnerOffline.java
License:Apache License
/** * Feed events from the stream to the engine * @param ksession//from w w w . jav a 2 s. c o m * @param ep */ private void feedEvents(final KieSession ksession, final EntryPoint ep) { try { StatusListener listener = new TwitterStatusListener(ep); ObjectInputStream in = new ObjectInputStream(getClass().getResourceAsStream("/twitterstream.dump")); SessionPseudoClock clock = ksession.getSessionClock(); for (int i = 0;; i++) { try { // Read an event Status st = (Status) in.readObject(); // Using the pseudo clock, advance the clock clock.advanceTime(st.getCreatedAt().getTime() - clock.getCurrentTime(), TimeUnit.MILLISECONDS); // call the listener listener.onStatus(st); if (this.dumpListener != null) { this.dumpListener.onStatus(st); } ksession.getEntryPoint("twitter").insert(st); } catch (IOException ioe) { break; } } in.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.drools.examples.twittercbr.guvnor.TwitterCBRGuvnor.java
License:Apache License
/** * Feed events from the stream to the engine * @param ksession//from www. j a va 2 s .c om * @param ep */ private static void feedEvents(final StatefulKnowledgeSession ksession, final WorkingMemoryEntryPoint ep) { try { StatusListener listener = new TwitterStatusListener(ep); ObjectInputStream in = new ObjectInputStream( new FileInputStream("src/main/resources/twitterstream.dump")); SessionPseudoClock clock = ksession.getSessionClock(); for (int i = 0;; i++) { try { // Read an event Status st = (Status) in.readObject(); // Using the pseudo clock, advance the clock clock.advanceTime(st.getCreatedAt().getTime() - clock.getCurrentTime(), TimeUnit.MILLISECONDS); // call the listener listener.onStatus(st); } catch (IOException ioe) { break; } } in.close(); } catch (Exception e) { e.printStackTrace(); } }