Announcement Announcement Module
Collapse
No announcement yet.
correct way to use a provider template in controller/service Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • correct way to use a provider template in controller/service

    I have successfully connected via connect controller to service provider. In another controller I want to access the API. Can i inject the ProviderTemplate class and use it? What is the proper way to now consume this API? I have been digging through the docs but its not clear to me.

    so for example in my service I want to:

    @Autorwired:
    private FacebookTemplate fbTemplate;

    @RequestMethod(value={},RequestMethod.GET){
    public String doSomethingWithAPI(){
    return fbTemplate.likeOperations.doSomething;
    }
    }
    Thanks,
    Barry

  • #2
    Yes, that's correct, so long as the FacebookTemplate bean is configured as request-scoped (which it will be if you're using the XML namespace or the @EnableFacebook annotation...it's up to you to make sure it's request-scoped if you are manually configuring it).

    Comment


    • #3
      IDE is complaining it can't autowire. No beans of my service provider type found. Using xml configuration in my project and custom namespace to do serviceprovider:config to define my template (or that was my understanding)

      I am not familiar with writing my own custom xml tags but I closely followed what LinkedIn/Facebook projects were doing and I was able to integrate my service provider into the spring social showcase xml app and test it out.

      Now I am trying to integrate spring social/my service provider client into project and in a certain controller I want to access the service provider and this popped up.

      Comment


      • #4
        disregard. Had my own spring configuration issue.

        Comment


        • #5
          Using the 1.1 XML 'helpers' where I define providers like :
          <facebook:config app-id="${facebook.clientId}" app-secret="${facebook.clientSecret}" app-namespace="socialshowcase" />

          when I try to autowire FacebookTemplate into my own service - it complains at run time that it can't find qualifying bean of type etc.

          I am using the connect controller to 'connect' and then later on in the app on a certain screen I want to make a restful call to my own controller/ service that has the template autorwired so I can call service provider on users behalf. Is that the right approach? or do I need to utilze the connection repository? It is unclear to me.

          Comment


          • #6
            What ended up working for me was injecting the connection repository into my service layer. From there I could then call repo.findPrimaryConnection(ServiceProvider.class) and then get the API from the connection.

            Comment


            • #7
              Originally posted by bkern View Post
              Using the 1.1 XML 'helpers' where I define providers like :
              <facebook:config app-id="${facebook.clientId}" app-secret="${facebook.clientSecret}" app-namespace="socialshowcase" />

              when I try to autowire FacebookTemplate into my own service - it complains at run time that it can't find qualifying bean of type etc.

              I am using the connect controller to 'connect' and then later on in the app on a certain screen I want to make a restful call to my own controller/ service that has the template autorwired so I can call service provider on users behalf. Is that the right approach? or do I need to utilze the connection repository? It is unclear to me.
              You'll want to inject the "Facebook" bean, not the "FacebookTemplate" bean. In other words, inject by the interface not by the implementation.

              Spring Social Showcase (XML edition) at https://github.com/SpringSource/spri...l-showcase-xml does exactly what you describe. Have a look.

              Comment

              Working...
              X