summaryrefslogtreecommitdiffstats
path: root/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java
diff options
context:
space:
mode:
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.java30
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("<", "&lt;");
+ content = content.replace(">", "&gt;");
+ content = content.replace("\"", "&quot;");
+ } 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...");
}
}