Example usage for twitter4j.conf PropertyConfiguration PropertyConfiguration

List of usage examples for twitter4j.conf PropertyConfiguration PropertyConfiguration

Introduction

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

Prototype

PropertyConfiguration(String treePath) 

Source Link

Usage

From source file:com.github.jcustenborder.kafka.connect.twitter.TwitterSourceConnectorConfig.java

License:Apache License

public Configuration configuration() {
    Properties properties = new Properties();
    /*/*w  w  w .jav  a 2 s  . co  m*/
      Grab all of the key/values that have a key that starts with twitter. This will strip 'twitter.' from beginning of
      each key. This aligns with what the twitter4j framework is expecting.
     */
    properties.putAll(this.originalsWithPrefix("twitter."));
    return new PropertyConfiguration(properties);
}

From source file:com.mothsoft.integration.twitter.TwitterServiceImpl.java

License:Apache License

public TwitterServiceImpl(final Properties properties) {
    this.configuration = new PropertyConfiguration(properties);
    this.factory = new TwitterFactory(this.configuration);
}

From source file:com.springsource.greenhouse.connect.providers.Twitter4JServiceProvider.java

License:Apache License

protected Twitter createServiceOperations(OAuthToken accessToken) {
    TwitterFactory twitterFactory = new TwitterFactory();
    AccessToken oauthToken = new AccessToken(accessToken.getValue(), accessToken.getSecret());
    Configuration configuration = new PropertyConfiguration(new Properties());
    Authorization authorization = new OAuthAuthorization(configuration, getApiKey(), getSecret(), oauthToken);
    return accessToken != null ? twitterFactory.getInstance(authorization) : twitterFactory.getInstance();
}

From source file:fr.ybonnel.TwitterUtil.java

License:Apache License

public static PropertyConfiguration getPropertyConfigurator() {
    return new PropertyConfiguration(
            TwitterUtil.class.getResourceAsStream("/twitter4j-" + (random.nextInt(3) + 1) + ".properties"));
}

From source file:org.rhq.plugins.twitter.FeedComponent.java

License:Open Source License

/**
 * Start the resource connection/*from   w  w w.jav a2 s.co  m*/
 * @see org.rhq.core.pluginapi.inventory.ResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)
 */
public void start(ResourceContext<TwitterComponent> context)
        throws InvalidPluginConfigurationException, Exception {

    Configuration conf = context.getPluginConfiguration();
    String kind = conf.getSimpleValue("kind", "user");
    if (kind.equals("search"))
        isSearch = true;
    keyword = conf.getSimpleValue("keyword", "Jopr"); // Jopr is fallback .. just in case

    String serverUrl = context.getParentResourceComponent().getServerUrl();
    String searchBase = context.getParentResourceComponent().getSearchUrl();

    eventContext = context.getEventContext();
    eventPoller = new TwitterEventPoller(TOPIC_EVENT);
    eventContext.registerEventPoller(eventPoller, 63);

    Properties props = new Properties();
    //props.put(PropertyConfiguration.SOURCE,"Jopr");
    props.put(PropertyConfiguration.HTTP_USER_AGENT, "Jopr");
    props.put(PropertyConfiguration.SEARCH_BASE_URL, searchBase);
    props.put(PropertyConfiguration.REST_BASE_URL, serverUrl);
    twitter4j.conf.Configuration tconf = new PropertyConfiguration(props);

    tFactory = new TwitterFactory(tconf);
}

From source file:org.rhq.plugins.twitter.TwitterComponent.java

License:Open Source License

/**
 * Start the resource connection/*from  ww w .j  av  a  2 s .c o m*/
 * @see org.rhq.core.pluginapi.inventory.ResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)
 */
public void start(ResourceContext context) throws Exception {

    Configuration conf = context.getPluginConfiguration();
    username = conf.getSimpleValue("user", null);
    password = conf.getSimpleValue("password", null);
    String url = conf.getSimpleValue("baseurl", HTTP_TWITTER_COM);
    if (!url.endsWith("/"))
        url = url + "/";
    try {
        new URL(url);
        serverUrl = url;
    } catch (MalformedURLException e) {
        throw new InvalidPluginConfigurationException(e.getMessage());
    }
    url = conf.getSimpleValue("searchBaseUrl", "http://search.twitter.com/");
    if (!url.endsWith("/"))
        url = url + "/";
    try {
        new URL(url);
        searchBaseUrl = url;
    } catch (MalformedURLException e) {
        throw new InvalidPluginConfigurationException(e.getMessage());
    }

    eventContext = context.getEventContext();
    eventPoller = new TwitterEventPoller(TWIT_EVENT);
    eventContext.registerEventPoller(eventPoller, 53);
    Properties props = new Properties();
    //props.put(PropertyConfiguration.SOURCE,"Jopr");
    props.put(PropertyConfiguration.HTTP_USER_AGENT, "Jopr");
    props.put(PropertyConfiguration.SEARCH_BASE_URL, searchBaseUrl);
    props.put(PropertyConfiguration.REST_BASE_URL, serverUrl);
    twitter4j.conf.Configuration tconf = new PropertyConfiguration(props);

    tFactory = new TwitterFactory(tconf);

}

From source file:org.rhq.plugins.twitter.TwitterComponent.java

License:Open Source License

private Twitter createTwitterInstance() {
    Properties props = new Properties();
    props.setProperty(PropertyConfiguration.USER, username);
    props.setProperty(PropertyConfiguration.PASSWORD, password);
    PropertyConfiguration propConfig = new PropertyConfiguration(props);
    return tFactory.getInstance(AuthorizationFactory.getInstance(propConfig));
}

From source file:org.springframework.social.showcase.twitter.connect.TwitterServiceProvider.java

License:Apache License

@Override
public Twitter getApi(String accessToken, String secret) {
    Properties props = new Properties();
    props.setProperty(PropertyConfiguration.OAUTH_CONSUMER_KEY, getConsumerKey());
    props.setProperty(PropertyConfiguration.OAUTH_CONSUMER_SECRET, getConsumerSecret());
    props.setProperty(PropertyConfiguration.OAUTH_ACCESS_TOKEN, accessToken);
    props.setProperty(PropertyConfiguration.OAUTH_ACCESS_TOKEN_SECRET, secret);
    Configuration conf = new PropertyConfiguration(props);
    return new TwitterFactory(conf).getInstance();
}

From source file:org.springframework.social.showcase.twitter.Twitter4JServiceProvider.java

License:Apache License

@Override
protected Twitter getApi(String consumerKey, String consumerSecret, String accessToken, String secret) {
    Properties props = new Properties();
    props.setProperty(PropertyConfiguration.OAUTH_CONSUMER_KEY, consumerKey);
    props.setProperty(PropertyConfiguration.OAUTH_CONSUMER_SECRET, consumerSecret);
    props.setProperty(PropertyConfiguration.OAUTH_ACCESS_TOKEN, accessToken);
    props.setProperty(PropertyConfiguration.OAUTH_ACCESS_TOKEN_SECRET, secret);
    Configuration conf = new PropertyConfiguration(props);
    return new TwitterFactory(conf).getInstance();
}

From source file:org.taverna.server.master.notification.TwitterDispatcher.java

private Twitter getTwitter(String key, String secret) throws Exception {
    if (key.isEmpty() || secret.isEmpty())
        throw new NoCredentialsException();

    Properties p = getConfig();/*  ww w . jav a2  s .c o  m*/
    p.setProperty(OAUTH_CONSUMER_KEY, key);
    p.setProperty(OAUTH_CONSUMER_SECRET, secret);

    Configuration config = new PropertyConfiguration(p);
    TwitterFactory factory = new TwitterFactory(config);
    Twitter t = factory.getInstance(AuthorizationFactory.getInstance(config));
    // Verify that we can connect!
    t.getOAuthAccessToken();
    return t;
}