diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-10 00:35:42 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-10 00:35:42 +0000 |
commit | f0d916a6263878537dde5f76922c6d24913885e2 (patch) | |
tree | f47d13a9a4a245da8ff82f663d021f7f09ab3784 /sandbox | |
parent | 2e8a2ebd0d9f9ffbb7fc6bd9fcb2e0fa06c7f5fb (diff) |
Add code to try memcache
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@823753 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox')
4 files changed, 28 insertions, 3 deletions
diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/DatastoreServiceImpl.java b/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/DatastoreServiceImpl.java index 5d58358b76..05eb40ff2c 100644 --- a/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/DatastoreServiceImpl.java +++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/DatastoreServiceImpl.java @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import org.oasisopen.sca.annotation.Init; import org.oasisopen.sca.annotation.Scope; import org.oasisopen.sca.annotation.Service; @@ -44,6 +45,7 @@ import com.google.appengine.api.datastore.Transaction; public class DatastoreServiceImpl implements DatastoreService { private DatastoreService delegate; + @Init public void init() { delegate = DatastoreServiceFactory.getDatastoreService(); } diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java index 9e19edbf9a..721d93ce8a 100644 --- a/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java +++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java @@ -18,9 +18,8 @@ */ package sample; -import org.oasisopen.sca.annotation.Remotable; -@Remotable + public interface HelloworldService { String sayHello(String name); 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 diff --git a/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/web.composite b/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/web.composite index 6923254bc2..e7f05bb67b 100644 --- a/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/web.composite +++ b/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/web.composite @@ -24,6 +24,7 @@ </service> <reference name="userService" target="UserService"/> <reference name="fetchService" target="URLFetchService"/> + <reference name="memcacheService" target="MemcacheService"/> </component> <component name="UserService"> |