diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-07 05:43:41 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-07 05:43:41 +0000 |
commit | 06c50953447e38b332fbfab8064115e3b30c7d7e (patch) | |
tree | bdfd91b8297823ab19a23d56d1e1100c341640b2 /sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java | |
parent | fa19b51cbc4e4859924f57ffe0bbc374b2b6900c (diff) |
Add POJO components to represent GAE services
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@822594 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java')
-rw-r--r-- | sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java index d69e578698..69227b1750 100644 --- a/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java +++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java @@ -18,21 +18,47 @@ */ package sample; +import java.io.IOException; +import java.net.URL; + import org.oasisopen.sca.annotation.EagerInit; import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Reference; import org.oasisopen.sca.annotation.Scope; +import com.google.appengine.api.urlfetch.HTTPResponse; +import com.google.appengine.api.urlfetch.URLFetchService; +import com.google.appengine.api.users.User; +import com.google.appengine.api.users.UserService; + @EagerInit @Scope("COMPOSITE") public class HelloworldServiceImpl implements HelloworldService { + @Reference + protected UserService userService; + + @Reference + protected URLFetchService fetchService; public String sayHello(String name) { - return "Hello " + name; + User user = userService.getCurrentUser(); + String id = (user == null) ? "" : user.getUserId(); + String content = ""; + try { + HTTPResponse response = fetchService.fetch(new URL("http://tuscany.apache.org")); + content = new String(response.getContent(), 0, 1024); + content = content.replace("<", "<"); + content = content.replace(">", ">"); + content = content.replace("\"", """); + } catch (IOException e) { + e.printStackTrace(); + } + return "[" + id + "] Hello " + name + "<hr><h1>Content from Tuscany Web Site</h1><p>" + content; } @Init public void init() { - System.out.println("Starting..." + sayHello("world")); + System.out.println("Starting..."); } } |