diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-12 08:34:50 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-12 08:34:50 +0000 |
commit | 42f6010685593eb05e63b57c13f3dfc444059540 (patch) | |
tree | 96f875c93f1dd8414e51ce6e1b6cfef0bdebab9c /sca-java-2.x/tags/2.0-M4-RC1/samples/webapps/helloworld-rest/src/main/java/helloworldrest | |
parent | 5a7c3427072be7d7f49992c8eb1028e0c1855a91 (diff) |
Delete RC tag
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835300 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
4 files changed, 0 insertions, 194 deletions
diff --git a/sca-java-2.x/tags/2.0-M4-RC1/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientJavaTestService.java b/sca-java-2.x/tags/2.0-M4-RC1/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientJavaTestService.java deleted file mode 100644 index 8b19af7a52..0000000000 --- a/sca-java-2.x/tags/2.0-M4-RC1/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientJavaTestService.java +++ /dev/null @@ -1,29 +0,0 @@ -package helloworldrest; - -import org.apache.tuscany.sca.node.Node; -import org.apache.tuscany.sca.node.NodeFactory; - -/* - * To test, simply run the program - * Access the service by invoking the getName() method of HelloWorldService - */ - -public class ClientJavaTestService { - - /** - * @param args - */ - public static void main(String[] args) { - NodeFactory factory = NodeFactory.newInstance(); - Node node = factory.createNode("rest.composite", ClientJavaTestService.class.getClassLoader()).start(); - HelloWorldService helloService = node.getService(HelloWorldService.class, "HelloWorldRESTServiceComponent"); - - //HelloWorldService helloService = new HelloWorldServiceImpl(); - System.out.println("### Message from REST service " + helloService.getName()); - - node.stop(); - node.destroy(); - factory.destroy(); - } - -} diff --git a/sca-java-2.x/tags/2.0-M4-RC1/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientTestServiceWebapp.java b/sca-java-2.x/tags/2.0-M4-RC1/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientTestServiceWebapp.java deleted file mode 100644 index fb83b26315..0000000000 --- a/sca-java-2.x/tags/2.0-M4-RC1/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientTestServiceWebapp.java +++ /dev/null @@ -1,108 +0,0 @@ -package helloworldrest; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.Formatter; - -/** - * - * To test, deploy the application as a webapp. - * Then, run this file to access the REST web service by making HTTP GET/POST requests - * - */ -public class ClientTestServiceWebapp { - - final static String UrlBase = "http://localhost:8080/helloworld-rest-webapp/HelloWorldService"; - - final static class HttpResponse { - Object content; - int code; - String message; - } - - static HttpResponse makeHttpGetRequest(String method, String url, String contentType) throws Exception { - HttpResponse response = new HttpResponse(); - URL urlAddress = new URL(url); - HttpURLConnection huc = (HttpURLConnection)urlAddress.openConnection(); - huc.setRequestMethod(method); - huc.setRequestProperty("Content-type", contentType); - huc.connect(); - InputStreamReader isr = new InputStreamReader(huc.getInputStream()); - - BufferedReader in = new BufferedReader(isr); - String uline = in.readLine(); - response.content = uline; - - // huc.disconnect(); - // System.out.println("#### huc disconnected ###"); - - return response; - } - - static HttpResponse makeHttpRequest(String method, String url, String contentType, InputStream is) throws Exception { - HttpResponse response = new HttpResponse(); - URL urlAddress = new URL(url); - HttpURLConnection huc = (HttpURLConnection)urlAddress.openConnection(); - huc.setRequestMethod(method); - if (null != is) { - huc.setDoOutput(true); - huc.setRequestProperty("Content-Type", contentType); - OutputStream os = huc.getOutputStream(); - byte[] buf = new byte[1024]; - int read; - while ((read = is.read(buf)) != -1) { - os.write(buf, 0, read); - } - } - InputStreamReader isr = new InputStreamReader(huc.getInputStream()); - BufferedReader in = new BufferedReader(isr); - String uline = in.readLine(); - response.content = uline; - return response; - } - - static HttpResponse makeHttpGetRequest(String method, String url, String contentType, String content) - throws Exception { - return makeHttpRequest(method, url, contentType, new ByteArrayInputStream(content.getBytes("UTF-8"))); - } - - static HttpResponse makeHttpRequest(String method, String url) throws Exception { - return makeHttpRequest(method, url, null, (InputStream)null); - } - - public static void main(String[] args) { - try { - - HttpResponse response; - - System.out.println("Getting the name *BEFORE* setting it:"); - response = makeHttpGetRequest("GET", UrlBase + "/helloworld/getname", "text/plain"); - System.out.println(new Formatter().format("---- Received String:\n%s", response.content.toString())); - - System.out.println("Setting the name:"); - String newText = "Morpheus"; - InputStream inputStream = new ByteArrayInputStream(newText.getBytes()); - response = makeHttpRequest("PUT", UrlBase + "/helloworld/setname", "text/plain", inputStream); - - System.out.println("Getting the name *AFTER* setting it:"); - response = makeHttpGetRequest("GET", UrlBase + "/helloworld/getname", "text/plain"); - System.out.println(new Formatter().format("---- Received String:\n%s", response.content.toString())); - - System.out.println("POST Operation:"); - response = makeHttpGetRequest("POST", UrlBase + "/helloworld/postoperation/prateek", "text/plain"); - //System.out.println(new Formatter().format("---- Received String:\n%s", response.content.toString())); - - System.out.println("Getting the name *AFTER* the POST operation:"); - response = makeHttpGetRequest("GET", UrlBase + "/helloworld/getname", "text/plain"); - System.out.println(new Formatter().format("---- Received String:\n%s", response.content.toString())); - } catch (Exception e) { - System.out.println("TEST FAILED! :-("); - e.printStackTrace(System.out); - } - } -} diff --git a/sca-java-2.x/tags/2.0-M4-RC1/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldService.java b/sca-java-2.x/tags/2.0-M4-RC1/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldService.java deleted file mode 100644 index fb9d3e2f82..0000000000 --- a/sca-java-2.x/tags/2.0-M4-RC1/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldService.java +++ /dev/null @@ -1,13 +0,0 @@ -package helloworldrest; - -import org.oasisopen.sca.annotation.Remotable; - -@Remotable -public interface HelloWorldService { - - public void setName(String name); - - public String getName(); - - public void postOperationTest(String name); -} diff --git a/sca-java-2.x/tags/2.0-M4-RC1/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldServiceImpl.java b/sca-java-2.x/tags/2.0-M4-RC1/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldServiceImpl.java deleted file mode 100644 index cacb88b5e3..0000000000 --- a/sca-java-2.x/tags/2.0-M4-RC1/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldServiceImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -package helloworldrest; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; - -import org.oasisopen.sca.annotation.Scope; -import org.oasisopen.sca.annotation.Service; - -@Service(HelloWorldService.class) -@Scope("Composite") -@Path("/helloworld") -public class HelloWorldServiceImpl implements HelloWorldService { - - private String name = new String("original!"); - - @Path("/setname") - @PUT - @Consumes("text/plain") - public void setName(String name) { - this.name = name; - - } - - //http://<host>:<port>/helloworld-rest-webapp/HelloWorldService/helloworld/getname - @Path("/getname") - @GET - @Produces("text/plain") - public String getName() { - return this.name; - } - - @POST - @Path("/postoperation/{name}/") - @Consumes("text/plain") - public void postOperationTest(@PathParam("name") String name) { - this.name = name; - } - -} |