Announcement Announcement Module
Collapse
No announcement yet.
Questions about ConnectController Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Questions about ConnectController

    Hi,

    I am trying to post tweets on twitter and links on facebook using ConnectController but I have a problem with the Provider for the constructor, which is supposed to be a javax.inject.Provider, from what maven dependancy or library is it?

    Also I really don't need such a complicated implementation, I mean I don't care about having persisting connections, I just need to post a tweet or a link on FB after a specific action from the user, so as long as he authorized my facebook or twitter application I guess I don't need to store anything or keep stuff in session, right?

    What is the easiest way to do that with Spring Social, I mean for instance post a tweet automatically after the user did something on my website?

    Thanks!

  • #2
    Have you reviewed the samples and the reference documentation? There you'll see that when Spring is used to instantiate and wire the ConnectController, it will automatically construct a javax.inject.Provider for the current user's ConnectionRepository. This is part of the Java @Inject standard (JSR-330). You can see the javax.inject dependency included in the spring-social-showcase pom.xml.

    We inject a javax.inject.Provider<ConnectionRepository> instead of a direct reference to a ConnectionRepository because the current user's ConnectionRepository is a request-scoped bean, not a traditional singleton bean.

    Even though Spring Social has just a few dependencies on other libraries, in general, we need to be a lot more specific about what dependencies Spring Social does require (and optionally supports) in the reference manual. The reference manual doesn't spell this out yet and it should. We'll make sure to address this in the next release (watch https://jira.springsource.org/browse/SOCIAL-150).

    We're also generally evaluating the reusability and flexibility of ConnectController, since we've also had requests for tapping into it from another environments besides Spring MVC e.g. via a filter.

    As far as not persisting the connection--if you're ok with having the user authorize each time, then you could write your own little ConnectController implementation that does what you need. Alternatively, you could consider injecting a ConnectionRepository implementation that doesn't do anything. We could consider adding support for such non-persistent web-client-driven connections, but I'm not sure how generally useful this is. It would be a pain if users have to connect each time they wish to share something on Twitter or Facebook.

    Keith
    Last edited by Keith Donald; May 8th, 2011, 07:22 PM.

    Comment


    • #3
      I opened https://jira.springsource.org/browse/SOCIAL-155 related to ConnectController improvements. Please comment if there are additional things you'd like to see.

      Comment


      • #4
        Hi Keith,

        Yes I read the reference doc and if I am asking where is the Provider it's because in spite of the fact that I added the dependencies spring-social-core, spring-social-web, spring-social-facebook, spring-social-twitter, I get this error in Eclipse: "The type javax.inject.Provider cannot be resolved" for the ConnectControllerConfig class, or a similar error when I package my project with maven, if I use the xml config instead of a class.
        As you say the reference manual should contain this kind of info, also that would be great to have "better" snippets of code, containing the imports, etc., or maybe just an example project to download.

        So what is the maven dependency I have to add to my project to make it work? (I am also using spring-webmvc 3.0.5).

        About persisting the connection, actually I started using spring social with connection factories, OAuth2Operations, etc. then habuma advised me to use ConnectController. The thing is with my stuff users don't have to log in each time as long as the application is authorized (and I guess as long as they are connected to their twitter or facebook account), or maybe you were talking about OAuth authorization?
        Anyway I thought that was possible to do the same thing with ConnectController...

        Thank you.

        Comment


        • #5
          The samples are available on github:
          https://github.com/SpringSource/spring-social-samples

          Comment

          Working...
          X