Created
January 24, 2012 11:31
-
-
Save mathieuancelin/1669729 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ApplicationScoped | |
public class TwitterClient implements Serializable { | |
@Inject Twitter twitter; | |
private List<User> users; | |
private List<Status> statuses; | |
private QueryResult search; | |
public void loadTweets() throws TwitterException { | |
statuses = twitter.getFriendsTimeline(); | |
} | |
public void loadFriends() throws TwitterException { | |
IDs followersIDs = twitter.getFollowersIDs(-1); | |
users = twitter.lookupUsers(followersIDs.getIDs()); | |
} | |
public void loadSearch() throws TwitterException { | |
Query query = new Query("#BreizhJUG"); | |
search = twitter.search(query); | |
} | |
// getters | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WelcomeController < ActionController::Base | |
protect_from_forgery | |
include TorqueBox::Injectors | |
include_class "com.foo.bar.TwitterClient" | |
def index | |
@rails_msg = "Hello from Rails!" | |
end | |
def followers | |
twitter = inject(com.foo.bar.TwitterClient) | |
@twitter_followers = twitter.get_users | |
end | |
def search | |
twitter = inject(com.foo.bar.TwitterClient) | |
@twitter_search = twitter.get_search | |
end | |
def tweets | |
twitter = inject(com.foo.bar.TwitterClient) | |
@twitter_tweets = twitter.get_statuses | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment