diff options
Diffstat (limited to 'sandbox/rfeng/helloworld-jsp-google-appengine/src/sample')
-rw-r--r-- | sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java | 3 | ||||
-rw-r--r-- | sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldServiceImpl.java | 30 |
2 files changed, 31 insertions, 2 deletions
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 53ff7a5ca1..9e19edbf9a 100644 --- a/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java +++ b/sandbox/rfeng/helloworld-jsp-google-appengine/src/sample/HelloworldService.java @@ -18,6 +18,9 @@ */ 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 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..."); } } |