You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2009/10/10 02:35:42 UTC
svn commit: r823753 - in
/tuscany/sandbox/rfeng/helloworld-jsp-google-appengine:
src/org/apache/tuscany/sca/gae/services/DatastoreServiceImpl.java
src/sample/HelloworldService.java src/sample/HelloworldServiceImpl.java
war/WEB-INF/web.composite
Author: rfeng
Date: Sat Oct 10 00:35:42 2009
New Revision: 823753
URL: http://svn.apache.org/viewvc?rev=823753&view=rev
Log:
Add code to try memcache
Modified:
tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/DatastoreServiceImpl.java
tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java
tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java
tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/web.composite
Modified: tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/DatastoreServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/DatastoreServiceImpl.java?rev=823753&r1=823752&r2=823753&view=diff
==============================================================================
--- tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/DatastoreServiceImpl.java (original)
+++ tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/org/apache/tuscany/sca/gae/services/DatastoreServiceImpl.java Sat Oct 10 00:35:42 2009
@@ -23,6 +23,7 @@
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 @@
public class DatastoreServiceImpl implements DatastoreService {
private DatastoreService delegate;
+ @Init
public void init() {
delegate = DatastoreServiceFactory.getDatastoreService();
}
Modified: tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java?rev=823753&r1=823752&r2=823753&view=diff
==============================================================================
--- tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java (original)
+++ tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java Sat Oct 10 00:35:42 2009
@@ -18,9 +18,8 @@
*/
package sample;
-import org.oasisopen.sca.annotation.Remotable;
-@Remotable
+
public interface HelloworldService {
String sayHello(String name);
Modified: tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java?rev=823753&r1=823752&r2=823753&view=diff
==============================================================================
--- tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java (original)
+++ tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java Sat Oct 10 00:35:42 2009
@@ -20,12 +20,16 @@
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 @@
@EagerInit
@Scope("COMPOSITE")
+@Service(HelloworldService.class)
public class HelloworldServiceImpl implements HelloworldService {
@Reference
protected UserService userService;
@@ -40,9 +45,20 @@
@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 @@
} 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
Modified: tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/web.composite
URL: http://svn.apache.org/viewvc/tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/web.composite?rev=823753&r1=823752&r2=823753&view=diff
==============================================================================
--- tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/web.composite (original)
+++ tuscany/sandbox/rfeng/helloworld-jsp-google-appengine/war/WEB-INF/web.composite Sat Oct 10 00:35:42 2009
@@ -24,6 +24,7 @@
</service>
<reference name="userService" target="UserService"/>
<reference name="fetchService" target="URLFetchService"/>
+ <reference name="memcacheService" target="MemcacheService"/>
</component>
<component name="UserService">