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

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

    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

  • habuma
    replied
    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.

    Leave a comment:


  • bkern
    replied
    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.

    Leave a comment:


  • bkern
    replied
    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.

    Leave a comment:


  • bkern
    replied
    disregard. Had my own spring configuration issue.

    Leave a comment:


  • bkern
    replied
    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.

    Leave a comment:


  • habuma
    replied
    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).

    Leave a comment:

Working...
X