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.
The page should be updated with the greeting displayed below
the form.
+---main |
sca.module | Defines 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.java | Defines the Java interface implemented by the component. |
HelloWorldServiceComponentImpl.java | Implements the SCA component. Uses the SCA service annotation tag on the class to show what SCA interface is being implemented. |
helloworld.js | Handles 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.html | The 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.xml | Standard J2EE web application's web.xml |