Announcement Announcement Module
No announcement yet.
Some confirmation is this is "Safe" to do ? request scoped Providers Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Some confirmation is this is "Safe" to do ? request scoped Providers

    I'm still somewhat new to Spring and Spring MVC so I want to be sure there aren't threading issues to be concerned with here.

    I'm pushing some functionality to a SocialUtils class to abstract way making the posts to different providers the user is connected to. The idea is in a controller (or bean used by a controller) you could make call like:


    SocialUtils then might look something like:

    public class SocialUtils {
    	private Facebook facebook;
    	public boolean hasFacebookConnection() {
            return facebook != null && facebook.isAuthorized();
    	public void postGameComplete() {
    		 if (hasFacebookConnection) {
    		 	facebook.feedOperations().updateStatus("Game complete");
    (Per another thread I realize I should probably inject ConnectionRepository as well and do a test for a Connection that way vs isAuthorized but that's a different subject.)

    My question is I assume since Facebook and Twitter or set with Request scope in my config
            @Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES)
    	public Facebook facebook()
    that this means any calls to Facebook within a singleton (SocialUtils) will be safe even if multiple threads are hitting the SocialUtils? (Same thing would be the case for using ConnectionRepository since its Request scoped as well.)

    I'm pretty sure that's the case but just wanted to double check (I know it's more of a Spring thing in general.)

  • #2
    I think I'll give my SocialUtils class Request scope in its bean definition to be safe also.