Tuscany SamplesThe Tuscany Samples are shipped with Tuscany binary and source releases. If you are using tuscany from a release distribution then make sure you are looking at the documentation that corresponds to the samples as they stood at the time of the release ... [2.0-beta-Samples documentation|2.0-beta-Samples documentation]If however you are working with a snapshot distribution, or using samples code from the trunk of our source repository, then you've come to the right place, as the documentation here reflects the curtrent status of the samples in the trunk of our source tree. In a distribution, the samples source code is found in either a binary or source code distribution in the samples directory, directly under the root directory. The following sections are laid out to match the structure of the samples directory and its subdirectories. getting-startedThe basic package of SCA application artifacts is a contribution which for this simple sample is found in contribution-helloworld. There's also a directory which contains all you need to make a web application archive which can be deployed to a web container such as Tomcat, so that the sayHello service can be run in the web container. contribution-helloworldIn this folder you'll find the simplest contribution, implemented in Java, that implements the "business logic" of saying hello to a person whose name is supplied as input to the service. This contribution contains Java implementation code offering the service String sayHello(String name), where the implementation of the service prepends "Hello" to the name and prints the result to the console. helloworld-webappTODO It's not at all clear how this is supposed to work once it is in the web container - I have asked on the dev list running-tuscanyRunning something in Tuscany requires one or more contributions, and a method of launching the contributions to make them available as services. In the sections below is described various means of launching contributions into an executing tuscany runtime. launcher-command-lineTo execute a sample contribution from the command line on Windows, from a command prompt in the samples directory, run the command ... ..\bin\tuscany.bat "contribution-name" for example ..\bin\tuscany.bat contribution-binding-sca-calculator or on *nix platforms, from a shell prompt in the samples directory, run the command ... ../bin/tuscany.sh contribution-binding-sca-calculator launcher-embedded-jseThis directory contains sample java launchers for the ant run-<contributionname> where run-<contributionname> is one of the targets in the build.xml file To use this sample launcher to run all of the contributions as junit test cases, execute the command "mvn" in the launcher directory. launcher-embedded-osgiThe launchers implemented in the src/main/java/launchers directory each launch a specific contribution into the OSGI runtime. ant run-<contributionname> where run-<contributionname> is one of the targets in the build.xml file To use this sample launcher to run all of the contributions as junit test cases, mvn in the launcher directory. launcher-mavenTo execute a sample contribution from Maven look for contributions that have the following configuration in their pom.xml file: <plugin> For contributions that have this, for example, learning-more/binding-sca/contribution-calculator, do the following cd samples/learning-more/binding-sca/contribution-calculator This will launch the contribution in the Tuscany runtime and then wait. At this point you can use launcher-osgiThe Tuscany runtime can be run in and OSGi container. Running in Equinox On Windows, run java \-jar ..\..\modules\osgi-3.5.0-v20090520.jar \-configuration ..\..\features\configuration \-clean \-console On *Unix, run java \-jar ../../modules/osgi-3.5.0-v20090520.jar \-configuration ../../features/configuration \-clean \-console You should see the osgi console: osgi> osgi> Jun 22, 2009 1:32:27 PM org.apache.tuscany.sca.extensibility.equinox.EquinoxServiceDiscoveryActivator start INFO: Equinox-based service discoverer is now configured. You can run "ss" command under the osgi> to see the status of the bundles. osgi> ss Then you can install and start contributions as bundles by doing the following: osgi> install file:./path/to/contribution_bundle.jar Note that contribution_bundle.jar will need an activator in order to register the bundle as a SCA contribution see samples/???? Running on Felix See http://tuscany.apache.org/documentation-2x/running-tuscany-sca-2x-with-equinox-and-felix.html launcher-shellThis directory contains a sample shell program supporting simple commands to To build the sample shell do this: mvn install To run it: ./sca at the prompt: start myNode ../../applications/store/target/sample-store.jar or: start myNode http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.jar also try: status stop myNode bye Starting and stopping composites is pretty fast. To see that, try the following ./sca <scripts/test.txt or ./sca <scripts/test-remote.txt The shell can also run as a Webapp. To try it install target/scashell.war in launcher-webappTo execute sample webapp based contributions (contributions that have webapp at the end of their name) you For example, for binding-jsonrpc/contribution-calculator-webapp, do the following cd samples/binding-jsonrpc/contribution-calculator-webapp mvn cp target/sample-contribution-binding-jsonrpc-calculator-webapp.war your_container_deployment-dir As an alternative sample webapp based contributions can be run within Jetty directly from Maven, look for <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.18</version> </plugin> For contributions that have this, for example, binding-jsonrpc/contribution-calculator-webapp, do the following cd samples/binding-sca/contribution-calculator mvn jetty:run This will launch the contribution in the Jetty runtime and then wait. At this point you can use http://localhost:8080/sample-contribution-binding-jsonrpc-calculator-webapp/ learning-moreThe samples found in the contributions below illustrate how to get more of of SCA and Tuscany's features. contributionsTODO helloworld-bpelTODO check instructions work and fix up This sample demonstrates an SCA service implemented by a BPEL process. If you just want to run it to see what happens open a command prompt, navigate ant compile run OR if you don't have ant, on Windows do mkdir target\classes mkdir target\wsdl2java-source java -cp ..\..\lib\tuscany-sca-manifest.jar org.apache.tuscany.sdo.generate.XSD2JavaGenerator -targetDirectory target/wsdl2java-source -prefix HelloWorld -noContainment -noUnsettable src/main/resources/helloworld.wsdl java -cp ..\..\lib\tuscany-sca-manifest.jar org.apache.tuscany.tools.wsdl2java.generate.WSDL2JavaGenerator -targetDirectory target/wsdl2java-source src/main/resources/helloworld.wsdl unzip ..\..\lib\ode-dao-jpa-ojpa-derby-1.1.zip -d target\database javac -d target\classes -cp target\classes;..\..\lib\tuscany-sca-manifest.jar -sourcepath src\main\java;target\wsdl2java-source -target 1.5 -g -source 1.5 src\main\java\helloworld\BPELClient.java copy src\main\resources\* target\classes java -cp ..\..\lib\tuscany-sca-manifest.jar;target\classes;target\database helloworld.BPELClient and on *nix do mkdir target/classes mkdir target/wsdl2java-source java -cp ../../lib/tuscany-sca-manifest.jar org.apache.tuscany.sdo.generate.XSD2JavaGenerator -targetDirectory target/wsdl2java-source -prefix HelloWorld -noContainment -noUnsettable src/main/resources/helloworld.wsdl java -cp ../../lib/tuscany-sca-manifest.jar org.apache.tuscany.tools.wsdl2java.generate.WSDL2JavaGenerator -targetDirectory target/wsdl2java-source src/main/resources/helloworld.wsdl unzip ../../lib/ode-dao-jpa-ojpa-derby-1.1.zip -d target/database javac -d target/classes -cp target/classes;../../lib/tuscany-sca-manifest.jar -sourcepath src/main/java;target/wsdl2java-source -target 1.5 -g -source 1.5 src/main/java/helloworld/BPELClient.java cp src/main/resources/* target/classes java -cp ../../lib/tuscany-sca-manifest.jar:target/classes:target/database helloworld.BPELClient The sample will start an embedded BPEL engine, deploy a process and invoke it. Sample Overview The sample provides a single component that is wired to a service with a helloworld-bpel/ src/ main/ java/ helloworld/ BPELClient.java - client application for BEPELHelloWorldComponent resources/ deploy.xml - ODE deployment descriptor helloworld.bpel - helloworld bpel process helloworld.componentType - helloworld bpel service description helloworld.composite - the SCA assembly for this sample helloworld.wsdl - the service description that describes the bpel process log4j.properties - logging configuration test/ java/ helloworld/ BPELHelloWorldTestCase.java - JUnit test case helloworld-bpel.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 as cd helloworld-bpel ant compile ant run You should see the following output from the run target. run: [java] Starting BPELHelloWorldComponent [java] >>> Deploying : D:\temp\SCA1.1-RC1\tuscany-sca-1.1-incubating\samples\helloworld-bpel\target\classes [java] ::arg:::::: <?xml version="1.0" encoding="UTF-8"?> [java] <hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"><message xmlns="http://tuscany.apache.org/implementation/bpel/exampl e/helloworld.wsdl">Hello</message></hello> [java] ::message:: <?xml version="1.0" encoding="UTF-8"?> [java] <message><TestPart><hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"><message xmlns="http://tuscany.apache.org/impleme ntation/bpel/example/helloworld.wsdl">Hello</message></hello></TestPart></message> [java] Status: RESPONSE [java] Response: <?xml version="1.0" encoding="UTF-8"?> [java] <message><TestPart><hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl">Hello World</hello></TestPart></message> [java] Hello World [java] Stopping BPELHelloWorldComponent [java] Stopped !!! BUILD SUCCESSFUL Total time: 36 seconds Building And Running The Sample Using Maven With either the binary or source distributions the sample can be built and run cd helloworld-bpel mvn You should see the following output from the test phase. ------------------------------------------------------- T E S T S ------------------------------------------------------- Running helloworld.BPELHelloWorldTestCase Starting BPELHelloWorldComponent >>> Deploying : D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\classes ::arg:::::: <?xml version="1.0" encoding="UTF-8"?> <hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"><message xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld .wsdl">Hello</message></hello> ::message:: <?xml version="1.0" encoding="UTF-8"?> <message><TestPart><hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl"><message xmlns="http://tuscany.apache.org/implementation/bpel /example/helloworld.wsdl">Hello</message></hello></TestPart></message> Status: RESPONSE Response: <?xml version="1.0" encoding="UTF-8"?> <message><TestPart><hello xmlns="http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl">Hello World</hello></TestPart></message> Stopping BPELHelloWorldComponent Stopped !!! Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 18.656 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [jar:jar] [INFO] Building jar: D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\sample-helloworld-bpel.jar [INFO] [install:install] [INFO] Installing D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\sample-helloworld-bpel.jar to C:\Documents and Settings\lresend e\.m2\repository\org\apache\tuscany\sca\sample-helloworld-bpel\1.1-incubating-SNAPSHOT\sample-helloworld-bpel-1.1-incubating-SNAPSHOT.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 53 seconds [INFO] Finished at: Sun Jan 13 09:54:39 PST 2008 [INFO] Final Memory: 24M/43M [INFO] ------------------------------------------------------------------------ This shows that the Junit test cases have run successfully. helloworld-recursiveTODO Understand and Document helloworld-recursive-wsTODO Understand and Document helloworld-scaclientTODO Understand and Document helloworld-springTODO Understand and Document helloworld-ws-sdoTODO Understand and Document webappsThe contributions in the following sections may be deployed to a web container, for example Tomcat. To create the web archive for deployment to the container, run the command mvn in the root directory of the contributions directory structure, then deploy the resulting .war file to your web container. Should this be "See the instructions for webapps in the "running tuscany" section? helloworld-bpelhelloworld-jaxrshelloworld-jmshelloworld-js-clienthelloworld-jsfhelloworld-jsphelloworld-servlethelloworld-springhelloworld-stripesasyncTODO document embedded-jse-async-sample-launchersample-contribution-implementation-java-calculator-asyncbinding-cometTODO Understand and Document binding-jsonrpcTODO Understand and Document contribution-calculatorTODO Understand and Document contribution-calculator-webappTODO Understand and Document binding-rmiIn this example the caluclator function is split over two contyributions in order to demonstrate the remote method invocation binding. TODO Document contribution-calculator-referenceTODO Document contribution-calculator-serviceTODO Document binding-scaTODO Understand and Document contribution-calculatorTODO Understand and Document binding-wsTODO Understand and Document contribution-calculatordistributed-osgiThese samples demonstrate the execution of Tuscany contributions in a distributed OSGI environment. dynamicThe OSGI samples in this section dynamically configure of the OSGI environment. dosgi-dynamic-calculatordosgi-dynamic-calculator-operationsimplementation.osgiThe OSGI samples in this section have explicit configuration of the OSGI environment. dosgi-calculatordosgi-calculator-operationsTODO Understand and Document implementation-extensionTODO Understand and Document implementation-javaTODO Understand and Document contribution-calculatorTODO Understand and Document implementation-scriptTODO Understand and Document contribution-calculatorTODO Understand and Document logging-scribeTODO Understand and Document maven-osgi-junitTODO Understand and Document calculator-osgiTODO Understand and Document calculator-rest-osgiTODO Understand and Document sca-clientTODO Understand and Document calculator-scaclientTODO Understand and Document applicationsTODO Understand and Document storeTODO Understand and Document TODO Understand and Document store-webappTODO Understand and Document |