Permalink
Browse files

Adding LinkedIn Support

Refactoring of @Setted mecanism to support 2+ social services
Refactoring of web example to prepare it supporting 2+ social services
  • Loading branch information...
1 parent 421b040 commit d93609bb0d3cc9f0397f01f72ab607496ef0c7c8 @antoinesd committed Feb 24, 2011
Showing with 26 additions and 141 deletions.
  1. +0 −111 ...ples/twitter-web-client/src/main/java/org/jboss/seam/social/example/twitterweb/TwitterClient.java
  2. 0 examples/{twitter-web-client → web-client}/bin/pom.xml
  3. BIN ...ient → web-client}/bin/src/main/java/org/jboss/seam/social/example/twitterweb/TwitterClient.class
  4. 0 examples/{twitter-web-client → web-client}/bin/src/main/resources/META-INF/beans.xml
  5. 0 examples/{twitter-web-client → web-client}/bin/src/main/webapp/META-INF/MANIFEST.MF
  6. 0 examples/{twitter-web-client → web-client}/bin/src/main/webapp/META-INF/context.xml
  7. 0 examples/{twitter-web-client → web-client}/bin/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia
  8. 0 examples/{twitter-web-client → web-client}/bin/src/main/webapp/WEB-INF/faces-config.xml
  9. 0 examples/{twitter-web-client → web-client}/bin/src/main/webapp/WEB-INF/templates/default.xhtml
  10. 0 examples/{twitter-web-client → web-client}/bin/src/main/webapp/WEB-INF/web.xml
  11. +3 −3 examples/{twitter-web-client → web-client/bin}/src/main/webapp/callback.xhtml
  12. +1 −1 examples/{twitter-web-client → web-client/bin}/src/main/webapp/home.xhtml
  13. 0 examples/{twitter-web-client → web-client}/bin/src/main/webapp/index.jsp
  14. 0 examples/{twitter-web-client → web-client}/bin/src/main/webapp/resources/css/screen.css
  15. BIN examples/{twitter-web-client → web-client}/bin/src/main/webapp/resources/gfx/banner.png
  16. BIN examples/{twitter-web-client → web-client}/bin/src/main/webapp/resources/gfx/weld.png
  17. +2 −2 examples/{twitter-web-client → web-client}/bin/src/main/webapp/timeline.xhtml
  18. +1 −1 examples/{twitter-web-client → web-client}/pom.xml
  19. +1 −1 examples/{twitter-web-client → web-client}/src/main/resources/META-INF/beans.xml
  20. 0 examples/{twitter-web-client → web-client}/src/main/webapp/META-INF/MANIFEST.MF
  21. 0 examples/{twitter-web-client → web-client}/src/main/webapp/META-INF/context.xml
  22. 0 examples/{twitter-web-client → web-client}/src/main/webapp/WEB-INF/.faces-config.xml.jsfdia
  23. 0 examples/{twitter-web-client → web-client}/src/main/webapp/WEB-INF/faces-config.xml
  24. 0 examples/{twitter-web-client → web-client}/src/main/webapp/WEB-INF/templates/default.xhtml
  25. 0 examples/{twitter-web-client → web-client}/src/main/webapp/WEB-INF/web.xml
  26. +3 −3 examples/{twitter-web-client/bin → web-client}/src/main/webapp/callback.xhtml
  27. +1 −1 examples/{twitter-web-client/bin → web-client}/src/main/webapp/home.xhtml
  28. 0 examples/{twitter-web-client → web-client}/src/main/webapp/index.jsp
  29. 0 examples/{twitter-web-client → web-client}/src/main/webapp/resources/css/screen.css
  30. BIN examples/{twitter-web-client → web-client}/src/main/webapp/resources/gfx/banner.png
  31. BIN examples/{twitter-web-client → web-client}/src/main/webapp/resources/gfx/weld.png
  32. +4 −4 examples/{twitter-web-client → web-client}/src/main/webapp/timeline.xhtml
  33. +0 −1 impl/src/main/java/org/jboss/seam/social/oauth/OAuthServiceSettingsImpl.java
  34. +4 −11 impl/src/main/java/org/jboss/seam/social/twitter/TwitterProducer.java
  35. +5 −1 impl/src/main/resources/META-INF/beans.xml
  36. +1 −1 pom.xml
@@ -1,111 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.seam.social.example.twitterweb;
-
-import java.io.Serializable;
-
-import javax.enterprise.context.SessionScoped;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.jboss.seam.social.oauth.Setted;
-import org.jboss.seam.social.twitter.Twitter;
-import org.jboss.seam.social.twitter.TwitterHandler;
-import org.jboss.seam.social.twitter.domain.Credential;
-
-
-
-@Named("twitterClient")
-@SessionScoped
-public class TwitterClient implements Serializable
-{
-
- private String status;
-
- private Credential cred;
-
- public String getAccessToken()
- {
- return service.getAccessToken();
- }
-
- public String getVerifier()
- {
- return service.getVerifier();
- }
-
- public void setVerifier(String verifier)
- {
- service.setVerifier(verifier);
- }
-
- /**
- *
- */
- private static final long serialVersionUID = 3723552335163650582L;
-
- @Inject
- @Setted(apiKey="FQzlQC49UhvbMZoxUIvHTQ", apiSecret="VQ5CZHG4qUoAkUUmckPn4iN4yyjBKcORTW0wnok4r1k",callback="http://localhost:8080/seam-social-twitter-web-client/callback.jsf")
- TwitterHandler service;
-
-
- public String getAuthorizationURL()
- {
- return service.getAuthorizationUrl();
- }
-
- public void initAccessToken()
- {
- service.initAccessToken();
- }
-
-/**
- * @param status the status to set
- */
-public void setStatus(String status)
-{
- this.status = status;
-}
-
-/**
- * @return the status
- */
-public String getStatus()
-{
- return status;
-}
-
-public String updateStatus()
-{
- service.updateStatus(status);
- return "ok";
-}
-
-public Credential getCred()
-{
- if (cred==null)
- cred=service.verifyCrendentials();
- return cred;
-}
-
-
-
-
-
-
-
-}
@@ -6,16 +6,16 @@
template="/WEB-INF/templates/default.xhtml">
<ui:define name="content">
<f:metadata>
- <f:viewParam name="oauth_verifier" value="#{twitterClient.verifier}"
+ <f:viewParam name="oauth_verifier" value="#{socialClient.verifier}"
required="true"
requiredMessage="We didn't get the authorization from Twitter. Please go back and Try Again !" />
- <f:event type="preRenderView" listener="#{twitterClient.initAccessToken}" />
+ <f:event type="preRenderView" listener="#{socialClient.initAccessToken}" />
</f:metadata>
<h:messages />
<h1>Seam Social Twitter client Example</h1>
<p>Getting Authorization from Twitter</p>
- You're back and your verifier is #{twitterClient.verifier} !
+ You're back and your verifier is #{socialClient.verifier} !
<br/>
You're ready to use Seam Social <h:link outcome="openclient">Twitter client</h:link>
@@ -8,7 +8,7 @@
<h1>Seam Social Twitter client Example</h1>
<p>Please click the URL Below to Authorize Seam Social to use your twitter account</p>
- <a href="#{twitterClient.authorizationURL}">#{twitterClient.authorizationURL}</a>
+ <a href="#{socialClient.authorizationURL}">#{socialClient.authorizationURL}</a>
</ui:define>
</ui:composition>
@@ -9,8 +9,8 @@
<h1>Seam Social Twitter client Example</h1>
<p>Your (future) Timeline</p>
<h:form>
- <h:inputTextarea value="#{twitterClient.status}" cols="80" rows="5" />
- <h:commandButton action="#{twitterClient.updateStatus}"
+ <h:inputTextarea value="#{socialClient.status}" cols="80" rows="5" />
+ <h:commandButton action="#{socialClient.updateStatus}"
value="Update your status" />
</h:form>
</ui:define>
@@ -25,7 +25,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.seam</groupId>
- <artifactId>seam-social-twitter-web-client</artifactId>
+ <artifactId>seam-social-web-client</artifactId>
<packaging>war</packaging>
<name>twitter-web-client</name>
<version>3.0.0-SNAPSHOT</version>
@@ -24,7 +24,7 @@
<o:Twitter />
<o:apiKey>FQzlQC49UhvbMZoxUIvHTQ</o:apiKey>
<o:apiSecret>VQ5CZHG4qUoAkUUmckPn4iN4yyjBKcORTW0wnok4r1k</o:apiSecret>
- <o:callback>http://localhost:8080/seam-social-twitter-web-client/callback.jsf
+ <o:callback>http://localhost:8080/seam-social-web-client/callback.jsf
</o:callback>
</o:OAuthServiceSettingsImpl>
-->
@@ -6,16 +6,16 @@
template="/WEB-INF/templates/default.xhtml">
<ui:define name="content">
<f:metadata>
- <f:viewParam name="oauth_verifier" value="#{twitterClient.verifier}"
+ <f:viewParam name="oauth_verifier" value="#{socialClient.verifier}"
required="true"
requiredMessage="We didn't get the authorization from Twitter. Please go back and Try Again !" />
- <f:event type="preRenderView" listener="#{twitterClient.initAccessToken}" />
+ <f:event type="preRenderView" listener="#{socialClient.initAccessToken}" />
</f:metadata>
<h:messages />
<h1>Seam Social Twitter client Example</h1>
<p>Getting Authorization from Twitter</p>
- You're back and your verifier is #{twitterClient.verifier} !
+ You're back and your verifier is #{socialClient.verifier} !
<br/>
You're ready to use Seam Social <h:link outcome="openclient">Twitter client</h:link>
@@ -8,7 +8,7 @@
<h1>Seam Social Twitter client Example</h1>
<p>Please click the URL Below to Authorize Seam Social to use your twitter account</p>
- <a href="#{twitterClient.authorizationURL}">#{twitterClient.authorizationURL}</a>
+ <a href="#{socialClient.authorizationURL}">#{socialClient.authorizationURL}</a>
</ui:define>
</ui:composition>
@@ -9,10 +9,10 @@
<h1>Seam Social Twitter client Example</h1>
<p>Your (future) Timeline</p>
<h:form>
- Welcome #{twitterClient.cred.name}<br/>
- <img src="#{twitterClient.cred.profileImageUrl}" />
- <h:inputTextarea value="#{twitterClient.status}" cols="80" rows="5" />
- <h:commandButton action="#{twitterClient.updateStatus}"
+ Welcome #{socialClient.cred.name}<br/>
+ <img src="#{socialClient.cred.profileImageUrl}" />
+ <h:inputTextarea value="#{socialClient.status}" cols="80" rows="5" />
+ <h:commandButton action="#{socialClient.updateStatus}"
value="Update your status" />
</h:form>
</ui:define>
@@ -45,7 +45,6 @@ public String getApiKey()
public void setApiKey(String apiKey)
{
this.apiKey = apiKey;
- System.out.println("****** " +apiKey+" *********");
}
public String getApiSecret()
@@ -16,29 +16,22 @@
*/
package org.jboss.seam.social.twitter;
-import javax.enterprise.inject.New;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
-import org.jboss.seam.social.oauth.OAuthServiceSettingsImpl;
import org.jboss.seam.social.oauth.Setted;
+import org.jboss.seam.social.oauth.SettedHandlerProducer;
/**
* @author antoine
*
*/
-public class TwitterProducer
+public class TwitterProducer extends SettedHandlerProducer
{
@Produces @Setted
- public TwitterHandler produceTwitterHandler(InjectionPoint ip, TwitterHandler twitterHdl)
+ public TwitterHandler produceTwitterHandler(InjectionPoint ip, TwitterHandler hdl)
{
- Setted setted=ip.getAnnotated().getAnnotation(Setted.class);
-
- String apiKey=setted.apiKey();
- String apiSecret=setted.apiSecret();
- String callback=setted.callback();
- twitterHdl.setSettings(new OAuthServiceSettingsImpl(apiKey,apiSecret,callback));
- return twitterHdl;
+ return setService(ip, hdl);
}
}
@@ -17,10 +17,14 @@
-->
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:s="urn:java:ee"
- xmlns:o="urn:java:org.jboss.seam.social.oauth:java:org.jboss.seam.social.twitter">
+ xmlns:o="urn:java:org.jboss.seam.social.oauth:java:org.jboss.seam.social.twitter:java:org.jboss.seam.social.linkedin">
<o:OAuthServiceSettingsImpl>
<s:modifies />
<o:Twitter />
</o:OAuthServiceSettingsImpl>
+ <o:OAuthServiceSettingsImpl>
+ <s:modifies />
+ <o:LinkedIn />
+ </o:OAuthServiceSettingsImpl>
</beans>
View
@@ -40,7 +40,7 @@
<module>api</module>
<module>impl</module>
<module>combined</module>
- <module>examples/twitter-web-client</module>
+ <module>examples/web-client</module>
</modules>
<properties>

0 comments on commit d93609b

Please sign in to comment.