Tuscany Hello World Celtix Web service Sample

Overview

The Tuscany hello world Celtix Web service sample shows using the Tuscany SCA runtime as a standalone web service.

Location

This sample is located  in the samples\sca\helloworldws-celtix directory.

Setup

This sample depends on the Tuscany runtime, Celtix, and the sample jar, sample-helloworldws-celtix-incubating-M1.jar , all of these must be available on the classpath to run the sample.

Running

In the directory samples/sca/helloworldws-celtix use the JDK 1.5 java command to run the class helloworld.HelloWorldServer
Linux: java -cp ../../../lib/tuscany-runtime-incubating-M1.jar:../../../lib/celtix/tuscany-celtix-incubating-M1.jar:target/sample-helloworldws-celtix-incubating-M1.jar helloworld.HelloWorldServer
Windows: java -cp ../../../lib/tuscany-runtime-incubating-M1.jar;../../../lib/celtix/tuscany-celtix-incubating-M1.jar;target/sample-helloworldws-celtix-incubating-M1.jar helloworld.HelloWorldServer

Code Overview

The source files are physically organized as shown below:
   +---main
   +---java
   ¦   +---helloworld
   ¦           HelloWorldServer.java
   ¦           HelloWorldImpl.java
   ¦           HelloWorldService.java
   +---resources
     ¦   sca.module
     +---wsdl
            helloworld.wsdl
                


HelloWorldServer.java Main method to startup the Tuscany runtime which will startup the services defined in sca.module
HelloWorldService.java Defines the Java interface implemented by the component.
HelloWorldImpl.java Implements the SCA component. Uses the SCA service annotation tag on the class to show what SCA interface is being implemented.
sca.module Defines the SCA module, entryPoint and component. Defines for the HelloWorldServiceComponent component and the Java class that implements the component For the entryPoint it defines WSDL for the service, the Java interface provided by the service, and wires the service to the HelloWorldServiceComponent
helloworld.wsdl WSDL for the service.

Instrumentation

You can instrument Celtix runtime using Celtix management facilities. Information in the Celtix configuration file is used to configure the behavior of Celtix management facilities. When JMX is enabled, Celtix instrumentation info is exported through the JMX MBeanServer. To enable JMX ( JMX is disabled in Celtix by default), you need to pass in a Celtix configuration file by running the sample using command below:

In the directory samples/sca/helloworldws-celtix use the JDK 1.5 java command to run the class helloworld.HelloWorldServer
Linux: java -Dceltix.config.file=file:///<Tuscany-installation-dir>/samples/sca/helloworldws-celtix/server.xml -cp ../../../lib/tuscany-runtime-incubating-M1.jar:../../../lib/celtix/tuscany-celtix-incubating-M1.jar:target/sample-helloworldws-celtix-incubating-M1.jar helloworld.HelloWorldServer
Windows: java -Dceltix.config.file=file:///<Tuscany-installation-dir>/samples/sca/helloworldws-celtix/server.xml -cp ../../../lib/tuscany-runtime-incubating-M1.jar;../../../lib/celtix/tuscany-celtix-incubating-M1.jar;target/sample-helloworldws-celtix-incubating-M1.jar helloworld.HelloWorldServer
<Tuscany-installation-dir> is the location where Tuscany installed.

You can use jconsole, which comes with JDK1.5, to explore the Celtix managed components:
jconsole
The server JMX Service URL is:
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi/server
NOTE: Enter the JMX service URL as above, leave the username and password empty in this sample.

Further information about Celtix instrumentation can be found from Celtix "Using Celtix Management" manual and Celtix management sample.