Tuscany Samples
The Tuscany Samples samples are shipped with Tuscany binary and source releases. If you are using tuscany from a release distribution then To make sure that you are 're looking at the documentation that corresponds to the samples as they stood at the time of the release.
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 current 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.
In the following code snippets text enclosed in <> means you have to replace it with whatever is appropriate in your environment. For example <tuscany_bin_distro> means the directory in which you install the Tuscany binary distribution.
Table of Contents | ||||
---|---|---|---|---|
|
getting-started
SCA defines a concept called a Contribution which is the way that SCA composite applications are packed for deployment. See sca introduction for more information on SCA concepts.
The getting-started samples consist of simple SCA contributions that you can build and run as your first step to getting up and running with the Tuscany SCA Java runtime.
You can build the sample contributions with either Maven or Ant and the running-tuscany directory contains information about the various ways you can start Tuscany and run these contributions.
helloworld-contribution
This is the simplest contribution. This contribution describes a composite application with a single component implemented in Java. The component's Java implementation provides service "business logic" for saying hello to a person whose name is supplied as input to the service.
To build this contribution using Maven do the following:
Code Block |
---|
cd helloworld-contribution
mvn
|
This will produce the contribution as follows:
Code Block |
---|
helloworld-contribution/target/helloworld-contribution.jar
|
You can run the contribution using Maven by doing the following:
Code Block |
---|
cd helloworld-contribution
mvn tuscany:run
|
Note | ||
---|---|---|
| ||
And then what? |
Note | ||
---|---|---|
| ||
need description of structure and operation this application once we've decided what that should be |
For more information on getting started with the Apache Tuscany SCA Java runtime see the getting started page.
helloworld-webapp
This sample is not a contribution in it's own right but demonstrates how to run the helloworld-contribution inside a web application.
To build this contribution using Maven do the following:
Code Block |
---|
cd helloworld-webapp
mvn
|
This will produce a webapp as follows:
Code Block |
---|
helloworld-webapp/target/helloworld.war
|
You can run this webapp by deploying it to you're favourite webapp container. For example, you can deploy to Tomcat and run as follows:
Code Block |
---|
cp helloworld-webapp/target/helloworld.war my_tomcat_install/webapps
my_tomcat_install/bin/catalina run
|
Note | ||
---|---|---|
| ||
This sample webapp doesn't provide any web pages so how to make it do something? |
Note | ||
---|---|---|
| ||
need description of structure and operation this application once we've decided what that should be |
Note | ||
---|---|---|
| ||
For more information on creating webapps to run SCA contributions with Tuscany see - ? |
callback-api
Note | ||
---|---|---|
| ||
This feels like a learning-more sample. I wouldn't focus on callbacks with the first time user |
sca-scopes
Note | ||
---|---|---|
| ||
This feels like a learning-more sample. I wouldn't focus on scopes with the first time user |
sca-include-contribution
Note | ||
---|---|---|
| ||
This feels like a learning-more sample. I wouldn't focus on inclusion with the first time user |
running-tuscany
Running something in Tuscany requires one or more contributions, and a method of launching the contributions to make the services they provide available. The sections below describes various means of launching contributions with the Tuscany SCA Java runtime. It's not important that you try all of these but they show you what's possible and hopefully show you how to use Tuscany in an environment that makes sense to you.
Some of the running-tuscany sub-directories just contain a README that gives you instructions. For example, maven just tells you how to configure and run contributions using the maven-tuscany-plugin. Others contain code. For example, embedded-jse contains simple Java launchers that show you how to start some of the sample contributions from a Java program.
The sample contributions in getting-started and learning-more should work regardless of which approach you adopt. However some approaches, like embedded-jse, don't have launchers for every single sample contribution.
command-line
You can execute a sample contribution from the command line on Windows or Linux.
Note | ||
---|---|---|
| ||
Waiting for tuscany.bat to be reworked before correcting |
To execute a sample contribution from the command line
on Windows, from a command prompt in the samples directory, run the command ...
Code Block |
---|
<tuscany_din_distro>\bin\tuscany.bat "contribution-name"
|
for example
Code Block |
---|
cd <tuscany_din_distro>\samples\learning-more\binding-sca\calculator-contribution
<tuscany_din_distro>\bin\tuscany.bat sample-binding-sca-calculator-contribution.jar
|
or on *nix platforms, from a shell prompt in the samples directory, run the command ...
Code Block |
---|
cd <tuscany_din_distro>/samples/learning-more/binding-sca/calculator-contribution
<tuscany_din_distro>/bin/tuscany.sh sample-binding-sca-calculator-contribution.jar
|
eclipse
To import sample contributions into Eclipse you first need to import the Tuscany runtime. You then need to import the sample contribution into Eclipse as a project. Instructions for doing both of these things can be found here
http://tuscany.apache.org/import-existing-tuscany-sca-projects-into-eclipse.html
Note. these instructions refer to our 1.x code base but it holds true for our 2.x code base.
Once you have a contribution imported into Eclipse and cleanly compiling against the Tuscany runtime jars you probably want to be able to run and debug it. The easiest way to do this is with a simple Java launcher. If you import the running-tuscany/embedded-jse project into Eclipse you'll see a number of such launcher programs which you can copy to launch the contribution(s) of your choice. Alternatively you can add a JUnit test case to the contribution that starts Tuscany and launches the contribution. See maven-junit as an example of how to do this.
embedded-jse
This directory contains sample java launchers for the some of the Tuscany sample contributions from the learning-more directory. It shows you how to embed the Tuscany runtime in a Java program. To make you're own launchers simply copy and existing one and change the details of the contribution being loaded. You'll note that the same launcher code is used inside the contribution unit test demonstrated by maven-junit.
To use the sample JSE launchers from maven do the following:
Code Block |
---|
cd embedded-jse
mvn
|
This runs a JUnit test case that runs all the launchers in turn.
To use the sample JSE launchers with ant execute the command
Code Block |
---|
ant <contributionname>
|
where <contributionname> is one of the targets in the provided build.xml file
embedded-osgi
The Tuscany runtime jars will also work within an OSGi enviroment. If you want to load them into a vanilla OSGi environment see the osgi directory. If you want Tuscany to create an OSGi environment for you this directory contains launchers that do just that.
To use the sample JSE launchers from maven do the following:
Code Block |
---|
cd embedded-osgi
mvn
|
This runs a JUnit test case that runs all the launchers in turn.
To use the sample OSGI launchers with ant do the following:
Code Block |
---|
cd embedded-osgi
ant <contributionname>
|
where <contributionname> is one of the targets in the build.xml file
maven
Maven can be used to install contributions. Tuscany has a special plugin (maven-tuscany-plugin) that makes this happen. Look for contributions that have the following configuration in their pom.xml file:
Code Block |
---|
<plugin>
<groupId>org.apache.tuscany.maven.plugins</groupId>
<artifactId>maven-tuscany-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
</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
mvn tuscany:run
This will install the contribution in the Tuscany runtime, start the composite it contains, and then wait. At this point you can use
other clients to send messages to services that the running SCA applcation exposes, for example, try learning-more/sca-client/calculator-scaclient.
osgi
The Tuscany runtime can be run in a vanilla OSGi container such as Equinox. To do this you have to:
- launch the OSGi container itself
- load the Tuscany runtime bundles (all our jars are bundles) into the container
- install a contribution packaged as an OSGi bundle
For example, to install a contribution in Equinox do the following
On Windows, run
Code Block |
---|
java -jar ..\..\modules\osgi-3.5.0-v20090520.jar -configuration ..\..\features\configuration -clean -console
|
On *Unix, run
Code Block |
---|
java -jar ../../modules/osgi-3.5.0-v20090520.jar -configuration ../../features/configuration -clean -console
|
You should see the osgi console:
Code Block |
---|
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.
Code Block |
---|
osgi> ss
|
Then you can install and start contributions as bundles by doing the following:
Code Block |
---|
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
Running on Felix
See http://tuscany.apache.org/documentation-2x/running-tuscany-sca-2x-with-equinox-and-felix.html
shell
This directory contains a sample shell program supporting simple commands to start and stop SCA composites.
Note | ||
---|---|---|
| ||
We currently have two similar approaches available (see command-line). We need to merge the two together. |
To build the sample shell do this:
Code Block |
---|
mvn install
|
To run it:
Code Block |
---|
./sca
|
at the prompt:
Code Block |
---|
start myNode ../../applications/store/target/sample-store.jar
|
or:
Code Block |
---|
start myNode http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.jar
|
also try:
Code Block |
---|
status
stop myNode
bye
|
Starting and stopping composites is pretty fast. To see that, try the following
two scripts, which start/stop the sample store composite 10 times.
Code Block |
---|
./sca <scripts/test.txt
|
or
Code Block |
---|
./sca <scripts/test-remote.txt
|
The shell can also run as a Webapp. To try it install target/scashell.war in
a Web container, point your Web browser to http://localhost:8080/scashell
and try the links on that page.
webapp
Tuscany can be embedded inside a webapp alongside one or more SCA contributions. To execute sample webapp based contributions (contributions that have webapp at the end of their name) you can build the contribution using maven and then copy the resulting war file to your container of choice
For example, for binding-jsonrpc/contribution-calculator-webapp, do the following:
Code Block |
---|
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 webapp contributions that have the following configuration in their pom.xml file:
Code Block |
---|
<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
Code Block |
---|
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 clients to send messages to services that the running SCA applcation exposes. For this example try pointing your browser at:
Code Block |
---|
http://localhost:8080/sample-binding-jsonrpc-calculator-webapp/
|
learning-more
The samples found in the contributions below illustrate more of SCA and Tuscany's features in action. The contributions here are primarily focused on demonstrating the various SCA extensions that the Tuscany runtime supports, for example, bindings and implementations. The directories are named to let you easily find a sample of the extension you're interested in.
You can identify contributions here as the name of the directory from which they are built ends with "-contribution". There are also webapp samples here. The names of these directories end with "-webapp".
Refer to the information above in the "running tuscany" section to find the various options for installing these sample contributions. We present an single default approach for each sample as an example.
async
This sample demonstrates invocation of services offered in both synchronous and asynchronous forms. Asynchroncity is possible by either callback to or polling by the original service invoker.
sample-contribution-implementation-java-calculator-async
In the composite file src/main/resources/Calculator.composite the references "calculatorServiceRefSync" and "calculatorServiceRefAsync" make use of the alternative implementations of the Calculator service described in the CalculatorSync and CalculatorAsync components and implemented in the calculator.CalculatorServiceSyncImpl and calculator.CalculatorServiceAsyncImpljava classes.
embedded-jse-async-sample-launcher
Note that the launcher simply starts and stops a node running the contribution. Within the contribution the CalculatorClient java class, marked with the @EagerInit annotation, runs its calculate method (marked with the @Init annotation), thereby triggering the calculation service to be performed. The calculator service is actually performed by the injected instance of CalculatorServiceProxyImpl, which uses both of its references (one for the sync service, one for the async) to perform calculations. The calculations are then performed by instances of CalculatorServiceSyncImpl and CalculatorServiceAsyncImpl. Note that the Tuscany runtime views the following two interfaces as compatible.
Code Block |
---|
@Remotable
public interface CalculatorService {
String calculate(Integer n1);
}
@Remotable
@AsyncInvocation
public interface CalculatorServiceAsync {
void calculateAsync(Integer n1, ResponseDispatch<String> response);
}
|
binding-comet
Executing the command "mvn" in this sample project creates a web archive suitable for deployment to Tomcat. It makes use of the tuscany coment binding. Comet support allows a servlet to process IO asynchronously, receiving events when data is available for reading on the connection (rather than always using a blocking read), and writing data back on connections asynchronously (most likely responding to some event raised from some other source).
Warning | ||
---|---|---|
| ||
Needs expert review/update |
binding-jsonrpc
This sample demonstrates using a simple calculator service component which makes use of four services for the basic arithmetic functions. In this variant of the calculator sample you can see by looking in the src/main/resources/Calculator.composite xml file that the AddService is configured to be invoked using the json rpc protocol.
contribution-calculator
This variant of the calculator contribution configures the AddService to be accessed via the JSON RPC protocol (see the XML in the Calculator.composite file).
Warning | ||
---|---|---|
| ||
Needs review/completion |
contribution-calculator-webapp
Note | ||
---|---|---|
| ||
Understand and Document |
binding-rmi
In this example the calculator function is split over two contributions in order to demonstrate the remote method invocation binding. The CalculatorService in the CalculatorServiceComponent defined in the CalculatorRMIServer.composite file is configured to be accessible using RMI.
Warning | ||
---|---|---|
| ||
Needs review/completion |
contribution-calculator-reference (for binding-rmi)
This contribution serves the purpose of accessing the services of the calculator service contribution, in particular defining a reference that uses the add service of that contribution using the RMI protocol.
contribution-calculator-service (for binding-rmi)
This contribution defines the calcullators add service to be available via RMI invocation.
binding-sca
This sample is the simplest sample other than that shown in the getting starting section. It uses the default SCA protocol for communicating between the components.
contribution-calculator (for binding SCA)
The service and reference definitions in the Calculator.composite and CalculatorClient.composite files have no binding attributes, thereby defaulting to the SCA binding for communication between the running instances of the components.
binding-ws
This sample contains contrributions which show how the services can be offered via a web service interfaqce.
contribution-calculator (for binding-ws)
This contribution provides the four arithmetic operations in the calculator service, with the AddService being accessible as a web service via the URL http://localhost:8085/AddServiceComponent, as configured in the Calculator.composite file in the contribution project.
contribution-helloworld-ws-sdo (for binding-ws)
Note | ||
---|---|---|
| ||
Understand and Document - rework the content of the README as given below |
Code Block |
---|
Hello World Web Service References using SDO Sample
===================================================
This sample demonstrates an SCA reference that uses a web service binding which works with SDO.
The README in the samples directory (the directory above this) provides
general instructions about building and running samples. Take a look there
first.
To run this sample
------------------
This sample is dependent on helloworld-ws-service. Open a command prompt to start
the service. If you are running ant do the following:
cd helloworld-ws-service
ant run
if you don't have ant, issue one of the following commands for windows or *nix:
java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-helloworld-ws-service.jar helloworld.HelloWorldServer
and on *nix do
java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-service.jar helloworld.HelloWorldServer
You should see the following output:
Buildfile: build.xml
run-server:
[java] log4j:WARN No appenders could be found for logger (org.apache.axiom.
om.util.StAXUtils).
[java] log4j:WARN Please initialize the log4j system properly.
[java] Aug 24, 2007 11:17:33 AM org.apache.catalina.core.StandardEngine sta
rt
[java] INFO: Starting Servlet Engine: Apache Tomcat/6.0.10
[java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.ContextConfig d
efaultWebConfig
[java] INFO: No default web.xml
[java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory
register
[java] WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.
xsd
[java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory
register
[java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt
aglibrary_1_1.dtd
[java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory
register
[java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt
aglibrary_1_2.dtd
[java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory
register
[java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt
aglibrary_2_0.xsd
[java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory
register
[java] WARNING: Could not get url for /javax/servlet/resources/j2ee_web_ser
vices_1_1.xsd
[java] Aug 24, 2007 11:17:34 AM org.apache.coyote.http11.Http11Protocol ini
t
[java] INFO: Initializing Coyote HTTP/1.1 on http-8085
[java] Aug 24, 2007 11:17:34 AM org.apache.coyote.http11.Http11Protocol sta
rt
[java] INFO: Starting Coyote HTTP/1.1 on http-8085
[java] Aug 24, 2007 11:17:34 AM org.apache.tuscany.sca.http.tomcat.TomcatSe
rver addServletMapping
[java] INFO: Added Servlet mapping: http://localhost:8085/HelloWorldService
[java] HelloWorld server started (press enter to shutdown)
The server is now ready.
Now, open another command window to run the client.
cd helloworld-ws-sdo
ant run
OR if you don't have ant, on Windows do
java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-helloworld-ws-sdo.jar helloworld.HelloWorldClient
and on *nix do
java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-sdo.jar helloworl.HelloWorldClient
You should be able to see the following result:
Buildfile: build.xml
run:
[java] log4j:WARN No appenders could be found for logger (org.apache.axiom.
om.util.StAXUtils).
[java] log4j:WARN Please initialize the log4j system properly.
[java] Injected helloWorldService
[java] Called getGreetings
[java] Hello David Haney
BUILD SUCCESSFUL
Total time: 9 seconds
Sample Overview
---------------
The sample provides a single component that is wired to a reference with a
web service binding. The binding refers to WSDL that identifies the service
exposed by the helloworld-ws-service sample.
helloworld-ws-sdo/
src/
main/
java/
helloworld/
HelloWorldService.java - interface description for
HelloWorldServiceComponent
HelloWorldServiceComponent.java - component implementation
HelloWorldClient.java - starts the SCA Runtime and
deploys the helloworldwsclient
.composite. It then calls the
HelloWorldServiceComponent
resources/
wsdl
helloworld.wsdl - the service description that the
SCA reference uses to bind to service.
test/
java/
helloworld/
HelloWorldClientTestCase.java - JUnit test case
helloworld-ws-sdo.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
-----------------------------------------
You can build and run the sample with the binary distribution using Ant.
Make sure that you have started helloworld-ws-service which this sample is dependent on
in a separate command window. You can either follow the instruction at the begining of this
sample file or if you want to build and run the service, follow the README under helloworld-ws-service.
Now, let's build and run helloworld-ws-sdo sample:
cd helloworld-ws-sdo
ant
ant run
You should see the following output from the run target.
run:
[java] log4j:WARN No appenders could be found for logger (org.apache.axiom.
om.util.StAXUtils).
[java] log4j:WARN Please initialize the log4j system properly.
[java] Injected helloWorldService
[java] Called getGreetings
[java] Hello World
Building And Running The Sample Using Maven
-------------------------------------------
You can build and run the sample with either the binary or source distributions using Maven. Please note that you do not need to start helloworld-ws-service in this case since Maven does this for you.
cd helloworld-ws-sdo
mvn
You should see the following output from the test phase.
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running helloworld.HelloWorldClientTestCase
log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAX
Utils).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAX
Utils).
log4j:WARN Please initialize the log4j system properly.
Aug 23, 2007 2:27:32 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.10
Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.ContextConfig defaultWebConf
ig
INFO: No default web.xml
Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register
WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd
Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register
WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_
1.dtd
Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register
WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_
2.dtd
Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register
WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_
0.xsd
Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register
WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs
d
Aug 23, 2007 2:27:32 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8085
Aug 23, 2007 2:27:32 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8085
Aug 23, 2007 2:27:32 PM org.apache.tuscany.sca.http.tomcat.TomcatServer addServl
etMapping
INFO: Added Servlet mapping: http://localhost:8085/HelloWorldService
Injected helloWorldService
Called getGreetings
Aug 23, 2007 2:27:34 PM org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8085
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.502 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
This shows that the Junit test cases have run successfully.
|
distributed-osgi
These samples demonstrate the execution of Tuscany contributions in a distributed OSGI environment.
dosgi-dynamic-calculator
dosgi-dynamic-calculator-operations
implementation-bpel
...
title | TODO |
---|
contribution-helloworld-bpel
Note | ||
---|---|---|
| ||
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
to this sample directory, and do
Code Block |
---|
ant compile run
|
OR if you don't have ant, on Windows do
Code Block |
---|
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
Code Block |
---|
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
web service binding.
Code Block |
---|
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
follows
Code Block |
---|
cd helloworld-bpel
ant compile
ant run
|
You should see the following output from the run target.
Code Block |
---|
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
using Maven as follows. When using Maven, a simple test is present that exercise
the same logic as the client to invoke the BPEl process.
Code Block |
---|
cd helloworld-bpel
mvn
|
You should see the following output from the test phase.
Code Block |
---|
\------------------------------------------------------\-
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] \-----------------------------------------------------------------------\-
|
...
matches the distribution you have downloaded select the appropriate link below:
2.0-Beta1 samples documentation
This shows that the Junit test cases have run successfully.
helloworld-bpel-webapp
implementation-composite
Note | ||
---|---|---|
| ||
Understand and Document |
helloworld-recursive
Note | ||
---|---|---|
| ||
Understand and Document |
helloworld-recursive-ws
Note | ||
---|---|---|
| ||
Understand and Document |
implementation-extension
Note | ||
---|---|---|
| ||
Understand and Document |
implementation-java
Note | ||
---|---|---|
| ||
Understand and Document |
contribution-calculator
Note | ||
---|---|---|
| ||
Understand and Document |
implementation.osgi
dosgi-calculator
dosgi-calculator-operations
Note | ||
---|---|---|
| ||
Understand and Document |
implementation-script
Note | ||
---|---|---|
| ||
Understand and Document |
contribution-calculator
Note | ||
---|---|---|
| ||
Understand and Document |
implementation-spring
Note | ||
---|---|---|
| ||
Understand and Document |
contribution-helloworld-spring
Note | ||
---|---|---|
| ||
Understand and Document |
helloworld-spring-webapp
implementation-webapp
helloworld-jaxrs-webapp
helloworld-jms-webapp
helloworld-js-client-webapp
helloworld-jsf-webapp
helloworld-jsp-webapp
helloworld-servlet-webapp
helloworld-stripes-webapp
logging-scribe
Note | ||
---|---|---|
| ||
Understand and Document |
maven-osgi-junit
Note | ||
---|---|---|
| ||
Understand and Document |
calculator-osgi
Note | ||
---|---|---|
| ||
Understand and Document |
calculator-rest-osgi
Note | ||
---|---|---|
| ||
Understand and Document |
sca-client
Note | ||
---|---|---|
| ||
Understand and Document |
calculator-scaclient
Note | ||
---|---|---|
| ||
Understand and Document |
helloworld-scaclient
Note | ||
---|---|---|
| ||
Understand and Document |
applications
Note | ||
---|---|---|
| ||
Understand and Document |
store
Note | ||
---|---|---|
| ||
Understand and Document |
store-webapp
...
title | TODO |
---|
...