Example usage for twitter4j.conf ConfigurationBuilder setUserStreamRepliesAllEnabled

List of usage examples for twitter4j.conf ConfigurationBuilder setUserStreamRepliesAllEnabled

Introduction

In this page you can find the example usage for twitter4j.conf ConfigurationBuilder setUserStreamRepliesAllEnabled.

Prototype

public ConfigurationBuilder setUserStreamRepliesAllEnabled(boolean enabled) 

Source Link

Usage

From source file:org.primeoservices.cfgateway.twitter.railo.RailoTwitterUserStreamGateway.java

License:Apache License

/**
 * Initializes this gateway/* w  ww  .  ja v  a 2  s.c o  m*/
 */
@Override
@SuppressWarnings("rawtypes")
public void init(final GatewayEngine engine, final String id, final String cfcPath, final Map config)
        throws IOException {
    try {
        this.argType = ArgumentType.fromConfigValue((String) config.get(ARGUMENT_TYPE));
        final ConfigurationBuilder cb = new ConfigurationBuilder();
        cb.setOAuthConsumerKey((String) config.get(OAUTH_CONSUMER_KEY));
        cb.setOAuthConsumerSecret((String) config.get(OAUTH_CONSUMER_SECRET));
        cb.setOAuthAccessToken((String) config.get(OAUTH_ACCESS_TOKEN));
        cb.setOAuthAccessTokenSecret((String) config.get(OAUTH_ACCESS_SECRET));
        cb.setUserStreamRepliesAllEnabled(Boolean.valueOf((String) config.get(ALL_REPLIES)));
        cb.setJSONStoreEnabled(ArgumentType.JSON.equals(this.argType));
        super.init(engine, id, new TwitterUserStream(this, cb.build()));
    } catch (Throwable t) {
        final IOException ex = new IOException("Unable to initialize gateway", t);
        this.onException(ex);
        throw ex;
    }
}

From source file:org.vsepml.storm.twitter.StormTwitterStreamSpout.java

License:Apache License

@Override
public void open(Map map, TopologyContext topologyContext, SpoutOutputCollector spoutOutputCollector) {
    this.collector = spoutOutputCollector;
    queue = new LinkedBlockingQueue<Status>(1000);

    StatusListener listener = new StatusListener() {
        public void onStatus(Status status) {
            queue.offer(status);/*from  ww w .  java2  s . co m*/
        }

        @Override
        public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
        }

        @Override
        public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
        }

        @Override
        public void onScrubGeo(long l, long l1) {
        }

        @Override
        public void onStallWarning(StallWarning stallWarning) {
        }

        public void onException(Exception ex) {
            ex.printStackTrace();
        }
    };

    ConfigurationBuilder twitterConf = new ConfigurationBuilder();
    twitterConf.setIncludeEntitiesEnabled(true);
    twitterConf.setUseSSL(true);
    twitterConf.setUserStreamRepliesAllEnabled(true);
    twitterConf.setOAuthAccessToken(accessToken);
    twitterConf.setOAuthAccessTokenSecret(accessTokenSecret);
    twitterConf.setOAuthConsumerKey(consumerKey);
    twitterConf.setOAuthConsumerSecret(consumerSecret);

    twitterStream = new TwitterStreamFactory(twitterConf.build()).getInstance();
    twitterStream.addListener(listener);
    // sample() method internally creates a thread which manipulates TwitterStream and calls these adequate listener methods continuously.
    twitterStream.sample();
}