Skip to content

Commit

Permalink
SEAMSOCIAL-12 : support of 2 way to inject a service bean. Either with
Browse files Browse the repository at this point in the history
@RelatedTo annotation on the OAuthService Interface or with the
@default annotation on the actual service Interface
  • Loading branch information
antoinesd committed May 22, 2011
1 parent 454fc4c commit c83d796
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
Expand Up @@ -18,13 +18,16 @@
package org.jboss.seam.social.facebook;

import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.New;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;

import org.jboss.seam.social.facebook.model.UserJackson;
import org.jboss.seam.social.oauth.HttpResponse;
import org.jboss.seam.social.oauth.JsonMapper;
import org.jboss.seam.social.oauth.OAuth2ServiceScribe;
import org.jboss.seam.social.oauth.OAuthService;
import org.jboss.seam.social.oauth.OAuthServiceSettings;
import org.jboss.seam.social.oauth.RelatedTo;
import org.jboss.seam.social.oauth.RestVerb;
Expand Down Expand Up @@ -55,6 +58,14 @@ public void setSettings(@RelatedTo(Service.Facebook) OAuthServiceSettings settin
super.setSettings(settings);

}


@Produces
@RelatedTo(Service.Facebook)
protected OAuthService qualifiedProducer(@New FacebookScribe facebook)
{
return facebook;
}

/**
*
Expand Down
Expand Up @@ -20,6 +20,8 @@

import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.New;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
import javax.xml.bind.JAXBContext;
Expand All @@ -31,6 +33,7 @@
import org.jboss.seam.social.linkedin.model.Update;
import org.jboss.seam.social.linkedin.model.UpdateJaxb;
import org.jboss.seam.social.oauth.HttpResponse;
import org.jboss.seam.social.oauth.OAuthService;
import org.jboss.seam.social.oauth.OAuthServiceScribe;
import org.jboss.seam.social.oauth.OAuthServiceSettings;
import org.jboss.seam.social.oauth.RelatedTo;
Expand Down Expand Up @@ -77,6 +80,14 @@ public void setSettings(@RelatedTo(Service.LinkedIn) OAuthServiceSettings settin
super.setSettings(settings);

}


@Produces
@RelatedTo(Service.LinkedIn)
protected OAuthService qualifiedProducer(@New LinkedInScribe linkedIn)
{
return linkedIn;
}

/*
* (non-Javadoc)
Expand Down
Expand Up @@ -21,12 +21,15 @@
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.New;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;

import org.jboss.logging.Logger;
import org.jboss.seam.social.oauth.HttpResponse;
import org.jboss.seam.social.oauth.JsonMapper;
import org.jboss.seam.social.oauth.OAuthService;
import org.jboss.seam.social.oauth.OAuthServiceScribe;
import org.jboss.seam.social.oauth.OAuthServiceSettings;
import org.jboss.seam.social.oauth.RelatedTo;
Expand All @@ -42,7 +45,7 @@
/**
* @author Antoine Sabot-Durand
*/
@RelatedTo(Service.Twitter)

public class TwitterScribe extends OAuthServiceScribe implements Twitter {

private static final long serialVersionUID = 6806035986656777834L;
Expand All @@ -67,6 +70,13 @@ public void setSettings(@RelatedTo(Service.Twitter) OAuthServiceSettings setting
super.setSettings(settings);

}

@Produces
@RelatedTo(Service.Twitter)
protected OAuthService qualifiedProducer(@New TwitterScribe twitter)
{
return twitter;
}

@Override
public Tweet updateStatus(String message) {
Expand Down

0 comments on commit c83d796

Please sign in to comment.