diff options
Diffstat (limited to '')
-rw-r--r-- | sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java | 25 |
1 files changed, 24 insertions, 1 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 69227b1750..d7867c6a45 100644 --- a/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java +++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java @@ -20,12 +20,16 @@ package sample; import java.io.IOException; import java.net.URL; +import java.util.Date; +import java.util.Stack; 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 org.oasisopen.sca.annotation.Service; +import com.google.appengine.api.memcache.MemcacheService; import com.google.appengine.api.urlfetch.HTTPResponse; import com.google.appengine.api.urlfetch.URLFetchService; import com.google.appengine.api.users.User; @@ -33,6 +37,7 @@ import com.google.appengine.api.users.UserService; @EagerInit @Scope("COMPOSITE") +@Service(HelloworldService.class) public class HelloworldServiceImpl implements HelloworldService { @Reference protected UserService userService; @@ -40,9 +45,20 @@ public class HelloworldServiceImpl implements HelloworldService { @Reference protected URLFetchService fetchService; + @Reference + protected MemcacheService memcacheService; + public String sayHello(String name) { User user = userService.getCurrentUser(); String id = (user == null) ? "" : user.getUserId(); + + Stack<String> stack = (Stack<String>)memcacheService.get("history"); + if (stack == null) { + stack = new Stack<String>(); + } + stack.push(new Date().toString() + ": " + name); + memcacheService.put("history", stack); + String content = ""; try { HTTPResponse response = fetchService.fetch(new URL("http://tuscany.apache.org")); @@ -53,7 +69,14 @@ public class HelloworldServiceImpl implements HelloworldService { } catch (IOException e) { e.printStackTrace(); } - return "[" + id + "] Hello " + name + "<hr><h1>Content from Tuscany Web Site</h1><p>" + content; + return "[" + id + + "] Hello " + + name + + "<hr><h1>Content from Tuscany Web Site</h1><p>" + + content + + "<p>History<hr>" + + stack + + "</p>"; } @Init |