From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/samples/sca/helloworldjsonrpc/readme.htm | 139 +++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 tags/java-M1-20060518/java/samples/sca/helloworldjsonrpc/readme.htm (limited to 'tags/java-M1-20060518/java/samples/sca/helloworldjsonrpc/readme.htm') diff --git a/tags/java-M1-20060518/java/samples/sca/helloworldjsonrpc/readme.htm b/tags/java-M1-20060518/java/samples/sca/helloworldjsonrpc/readme.htm new file mode 100644 index 0000000000..51c3dd2249 --- /dev/null +++ b/tags/java-M1-20060518/java/samples/sca/helloworldjsonrpc/readme.htm @@ -0,0 +1,139 @@ + + + + + + + + Tuscany Hello World JSON-RPC Sample + + + +

Tuscany Hello World JSON-RPC Sample

+ +

Overview

+ +

The Tuscany hello world JSON-RPC sample shows using the Tuscany SCA + runtime in a Tomcat environment being accessed from a JavaScript program running in the client browser that + implements the classic introductory hello world example.

+ + +

Setup

Set up your server as described in the Tomcat + Setup.  If you are not configuring with the acceptance test the server, you will need to add sample-helloworldjsonrpc-incubating-M1.war to your tomcat's webapp directory.
+ +

Running

+ +Once you've started your web server, use your browse to view the +following URL: http://localhost:8080/sample-helloworldjsonrpc/ +
+ +You should see a form you can supply your name and a button. + Once you click the button the JavaScript program locates the SCA component to execute +the greeting service. +
+Note, unlike the J2SE or JSP clients the Tuscany runtime is automatically +initialized and running. +

Results

+ +

The page should be updated with the greeting displayed below + the form.
+ +

+ +

Code Overview

+ +The source files are physically organized as shown below:
+ + + + + + +
+
+---main
¦ +---java
¦ ¦ sca.module + +---org
¦ +---apache
¦ +---tuscany
¦ +---samples
¦ +---helloworldjsonrpc + ¦ HelloWorldService.java + ¦ HelloWorldServiceComponentImpl.java
+---webapp + ¦ helloworld.js + ¦ HelloWorldJSONRPC.html + +---WEB-INF
¦ web.xml
+
+
+
+ +

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
sca.moduleDefines the SCA module, entryPoint and component. Defines an entryPoint with an JSON-RPC binding, and the + HelloWorldService component and the Java class that + implements that component
HelloWorldService.javaDefines the Java interface implemented by the component.
HelloWorldServiceComponentImpl.javaImplements the SCA component. Uses the SCA service + annotation tag on the class to show what SCA interface is being + implemented.
helloworld.jsHandles invoking the HelloWorld SCA service. Gets the value entered in the text field on the web page, invokes the SCA component and puts the result in the output field on the web page. +
The interesting part of the script is  SCA.HelloWorldService.getGreetings(who)  . + In the SCA JSON-RPC environment all entryPoints with an JSON-RPC binding are bound to the automatically defined script variable  SCA. . +
HelloWorldJSONRPC.htmlThe HTML page for the sample. Creates a text box for the user to enter their name, a button to click to get the greeting, and a text field to show the response. + The helloworld.js script function getGreeting is used to invoke the SCA service when the button is clicked. + To initialize the SCA environment the sca.js script must be defined as the first script in the HTML with the following line:
+ <script type="text/javascript" src="SCA/scripts/sca.js"> + +
web.xmlStandard J2EE web application's web.xml
+ +
+ + -- cgit v1.2.3