From 3c7c4a749baafcf375f4785a7668d3a25c9063e3 Mon Sep 17 00:00:00 2001 From: lresende Date: Fri, 13 Nov 2009 01:42:27 +0000 Subject: Moving 1.x trunk git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835700 13f79535-47bb-0310-9956-ffa450edef68 --- sca-java-1.x/trunk/samples/web-resource/README | 76 ++++++++ sca-java-1.x/trunk/samples/web-resource/build.xml | 72 ++++++++ sca-java-1.x/trunk/samples/web-resource/pom.xml | 79 +++++++++ .../src/main/java/web/resource/SampleServer.java | 44 +++++ .../src/main/resources/WebResource.composite | 32 ++++ .../src/main/resources/myContent/index.html | 49 +++++ .../trunk/samples/web-resource/web-resource.png | Bin 0 -> 8418 bytes .../trunk/samples/web-resource/web-resource.svg | 197 +++++++++++++++++++++ 8 files changed, 549 insertions(+) create mode 100644 sca-java-1.x/trunk/samples/web-resource/README create mode 100644 sca-java-1.x/trunk/samples/web-resource/build.xml create mode 100644 sca-java-1.x/trunk/samples/web-resource/pom.xml create mode 100644 sca-java-1.x/trunk/samples/web-resource/src/main/java/web/resource/SampleServer.java create mode 100644 sca-java-1.x/trunk/samples/web-resource/src/main/resources/WebResource.composite create mode 100644 sca-java-1.x/trunk/samples/web-resource/src/main/resources/myContent/index.html create mode 100644 sca-java-1.x/trunk/samples/web-resource/web-resource.png create mode 100644 sca-java-1.x/trunk/samples/web-resource/web-resource.svg (limited to 'sca-java-1.x/trunk/samples/web-resource') diff --git a/sca-java-1.x/trunk/samples/web-resource/README b/sca-java-1.x/trunk/samples/web-resource/README new file mode 100644 index 0000000000..56bffba6a3 --- /dev/null +++ b/sca-java-1.x/trunk/samples/web-resource/README @@ -0,0 +1,76 @@ +Web Resource Component Sample +====================================== +This sample demonstrates an SCA Web resource component. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +If you just want to run it to see what happens open a command prompt, navigate +to this sample directory and do: + +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-web-resource.jar web.resource.SampleServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-web-resource.jar web.resource.SampleServer + +Now the server is started you can point your Web browser to the URL of the Web resource. + +Sample Overview +--------------- +The sample provides a single component exposing a Web resource. + +web-resource/ + src/ + main/ + java/ + web/resource/ + SampleServer.java - starts the SCA Runtime and + deploys the WebResource.composite + resources/ + myContent/ + index.html - a Web HTML resource + WebResource.composite - the SCA assembly for this sample + web-resource.png - a pictorial representation of the + sample .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant using the +following commands + +cd web-resource +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 14-Jan-2008 14:28:07 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8080/myWeb/* + [java] Sample server started (press enter to shutdown) + [java] + [java] To get the Web resource, point your Web browser to the following add +ress: + [java] http://localhost:8080/myWeb/index.html + [java] + +As this point the Web resource is exposed by a web server started automatically +by the SCA runtime. To stop the server just press enter. + +Building The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built using +Maven as follows. + +cd web-resource +mvn + diff --git a/sca-java-1.x/trunk/samples/web-resource/build.xml b/sca-java-1.x/trunk/samples/web-resource/build.xml new file mode 100644 index 0000000000..5f6b6091e7 --- /dev/null +++ b/sca-java-1.x/trunk/samples/web-resource/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/trunk/samples/web-resource/pom.xml b/sca-java-1.x/trunk/samples/web-resource/pom.xml new file mode 100644 index 0000000000..5164c1f219 --- /dev/null +++ b/sca-java-1.x/trunk/samples/web-resource/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.6-SNAPSHOT + ../../pom.xml + + sample-web-resource + Apache Tuscany SCA Sample Web Resource + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-resource-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/trunk/samples/web-resource/src/main/java/web/resource/SampleServer.java b/sca-java-1.x/trunk/samples/web-resource/src/main/java/web/resource/SampleServer.java new file mode 100644 index 0000000000..9410de08c4 --- /dev/null +++ b/sca-java-1.x/trunk/samples/web-resource/src/main/java/web/resource/SampleServer.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package web.resource; + +import java.io.IOException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class SampleServer { + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("WebResource.composite"); + + try { + System.out.println("Sample server started (press enter to shutdown)"); + System.out.println(); + System.out.println("To get the Web resource, point your Web browser to the following address:"); + System.out.println("http://localhost:8080/myWeb/index.html"); + System.out.println(); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + scaDomain.close(); + System.out.println("Sample server stopped"); + } +} diff --git a/sca-java-1.x/trunk/samples/web-resource/src/main/resources/WebResource.composite b/sca-java-1.x/trunk/samples/web-resource/src/main/resources/WebResource.composite new file mode 100644 index 0000000000..66b8f25e17 --- /dev/null +++ b/sca-java-1.x/trunk/samples/web-resource/src/main/resources/WebResource.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/trunk/samples/web-resource/src/main/resources/myContent/index.html b/sca-java-1.x/trunk/samples/web-resource/src/main/resources/myContent/index.html new file mode 100644 index 0000000000..55de048373 --- /dev/null +++ b/sca-java-1.x/trunk/samples/web-resource/src/main/resources/myContent/index.html @@ -0,0 +1,49 @@ + + + + Tuscany Sample Web Resource + + + +

A Sample Web Resource

+ +

Tuscany allows you to publish Web resources using SCA components declared with an + <implementation.resource> component implementation type and made available + to HTTP clients using a <binding.http> binding.

+ +

Here is the SCA composite that publishes this page:

+ +
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+  targetNamespace="http://web"
+  name="WebResource">
+
+  <component name="myWeb">
+    <implementation.resource location="myContent"/>
+    <service name="Resource">
+      <binding.http/>
+    </service>
+  </component>      
+
+</composite>
+  	
+ + + diff --git a/sca-java-1.x/trunk/samples/web-resource/web-resource.png b/sca-java-1.x/trunk/samples/web-resource/web-resource.png new file mode 100644 index 0000000000..7259447b65 Binary files /dev/null and b/sca-java-1.x/trunk/samples/web-resource/web-resource.png differ diff --git a/sca-java-1.x/trunk/samples/web-resource/web-resource.svg b/sca-java-1.x/trunk/samples/web-resource/web-resource.svg new file mode 100644 index 0000000000..0d1257316c --- /dev/null +++ b/sca-java-1.x/trunk/samples/web-resource/web-resource.svg @@ -0,0 +1,197 @@ + + + + + + + + + + image/svg+xml + + + + + + + + WebResource + + + myWeb + implementation.resource + + File System + ./myContent /index.html + + binding.http + + -- cgit v1.2.3