Space: Apache Tuscany Docs 2.x
(https://cwiki.apache.org/confluence/display/TUSCANYxDOCx2x)
Page: Samples
(https://cwiki.apache.org/confluence/display/TUSCANYxDOCx2x/Samples)
Edited by Simon Laws:
---------------------------------------------------------------------
h1. {color:#003366}{*}Tuscany Samples{*}{color}
{color:#000000}The 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.{color}
[2.0-beta samples documentation|TUSCANYxDOCx2x: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 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.
If you're new to Tuscany SCA start with the getting-started. Samples are
generally presented in the form on an SCA contribution (look for directories
ending in "-contribution") or as a webapp (look for directories ending in
"-webapp"). The directories getting-started, learning-more and applications all
contain sample SCA contributions of increasing complexity. The running-tuscany
directory describes the various ways you can start the Tuscany runtime and
install contributions. For each sample contribution described in this document
we do suggest an example way to install it and start the composites it contains
however the other approaches in running-tuscany should also work for most
sample contributions. The extending-tuscany directory contains some examples of
how to build new binding and implementation extensions for using in Tuscany.
In the following text we us <some_text> to mean 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.
Instructions are colour coded as follows:
{panel:bgColor=pink}
Instructions in pink boxes are for the Ant user
{panel}
{panel:bgColor=silver}
Instructions in silver boxes are for the Maven user
{panel}
{toc:outline=true|minLevel=2}
h2. 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.
h3. 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.
{panel:bgColor=pink}
To build this contribution using Ant do the following:
TODO
{panel}
{panel:bgColor=silver}
To build this contribution using Maven do the following:
{code}
cd helloworld-contribution
mvn
{code}
This will produce the contribution as follows:
{code}
helloworld-contribution/target/helloworld-contribution.jar
{code}
You can run the contribution using Maven by doing the following:
{code}
cd helloworld-contribution
mvn tuscany:run
{code}
{panel}
{note:title=TODO}
And then what? (!)
{note}
{note:title=TODO}
need description of structure and operation this application once we've decided
what that should be
{note}
For more information on getting started with the Apache Tuscany SCA Java
runtime see the [getting started] page.
h3. 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.
{panel:bgColor=silver}
To build this contribution using Maven do the following:
{code}
cd helloworld-webapp
mvn
{code}
This will produce a webapp as follows:
{code}
helloworld-webapp/target/helloworld.war
{code}
{panel}
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}
cp helloworld-webapp/target/helloworld.war my_tomcat_install/webapps
my_tomcat_install/bin/catalina run
{code}
{note:title=TODO}
This sample webapp doesn't provide any web pages so how to make it do something?
{note}
{note:title=TODO}
need description of structure and operation this application once we've decided
what that should be
{note}
{note:title=TODO}
For more information on creating webapps to run SCA contributions with Tuscany
see - ?
{note}
h3. callback-api
{note:title=TODO}
{color:#000000}This feels like a learning-more sample. I wouldn't focus on
callbacks with the first time user{color}
{note}
h3. sca-scopes
{note:title=TODO}
{color:#000000}This feels like a learning-more sample. I wouldn't focus on
scopes with the first time user{color}
{note}
h3. sca-include-contribution
{note:title=TODO}
{color:#000000}This feels like a learning-more sample. I wouldn't focus on
inclusion with the first time user{color}
{note}
h2. 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.
h3. command-line
You can execute a sample contribution from the command line on Windows or Linux.
{note:title=TODO}
Waiting for tuscany.bat to be reworked before correcting
{note}
To execute a sample contribution from the command line
on Windows, from a command prompt in the samples directory, run the command ...
{code}
<tuscany_din_distro>\bin\tuscany.bat "contribution-name"
{code}
for example
{code}
cd
<tuscany_din_distro>\samples\learning-more\binding-sca\calculator-contribution
<tuscany_din_distro>\bin\tuscany.bat
sample-binding-sca-calculator-contribution.jar
{code}
or on \*nix platforms, from a shell prompt in the samples directory, run the
command ...
{code}
cd
<tuscany_din_distro>/samples/learning-more/binding-sca/calculator-contribution
<tuscany_din_distro>/bin/tuscany.sh
sample-binding-sca-calculator-contribution.jar
{code}
h3. 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.
h3. 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.
{panel:bgColor=pink}
To use the sample JSE launchers with ant execute the command
{code}
ant <contributionname>
{code}
where <contributionname> is one of the targets in the provided build.xml file
{panel}
{panel:bgColor=silver}
To use the sample JSE launchers from Maven do the following:
{code}
cd embedded-jse
mvn
{code}
This runs a JUnit test case that runs all the launchers in turn.
{panel}
h3. 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.
{panel:bgColor=pink}
To use the sample OSGI launchers with ant do the following:
{code}
cd embedded-osgi
ant <contributionname>
{code}
where <contributionname> is one of the targets in the build.xml file
{panel}
{panel:bgColor=silver}
To use the sample JSE launchers from Maven do the following:
{code}
cd embedded-osgi
mvn
{code}
This runs a JUnit test case that runs all the launchers in turn.
{panel}
h3. 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}
<plugin>
<groupId>org.apache.tuscany.maven.plugins</groupId>
<artifactId>maven-tuscany-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
</plugin>
{code}
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.
h3. maven-junit
Maven will run JUnit tests found in a module's src/test/java directory
automatically. If you use embedded-jse style code in the JUnit test to install
a contribution and start any composites it contains they you can unit test your
contributions. This directory contains a contribution and a unit test which
installs the contribution using very similar code to that found in embedded-jse.
To run the contributions unit test do the following:
{code}
cd maven-junit/calculator-contribution
mvn
{code}
h3. maven-junit-osgi
You can use a special Tuscany Maven plugin (maven-osgi-junit-plugin) to unit
test contributions in a JUnit environment. This relies on adding some
configuration to the Maven pom.xml. For example, if you look in
maven-junit-osgi/calculator-osgi you'll see:
{code}
<plugin>
<groupId>org.apache.tuscany.maven.plugins</groupId>
<artifactId>maven-osgi-junit-plugin</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-node-launcher-equinox</artifactId>
<version>${pom.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>osgi-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemProperties>
<property>
<name>osgi.configuration.area</name>
<value>${project.build.directory}/equinox</value>
</property>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
{code}
This configures the maven-osgi-junit-plugin to use the
tuscany-node-launcher-equinox to install the contribution represented by the
calculator-osgi directory. As an alternative to this configuration you could
use the contents of tuscany-node-launcher-equinox directly in your JUnit test
to launch the Tuscany runtime using OSGi.
To run the contributions unit test do the following:
{code}
cd maven-junit/calculator-contribution
mvn
{code}
h3. 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}
java -jar ..\..\modules\osgi-3.5.0-v20090520.jar -configuration
..\..\features\configuration -clean -console
{code}
On \*Unix, run
{code}
java -jar ../../modules/osgi-3.5.0-v20090520.jar -configuration
../../features/configuration -clean -console
{code}
You should see the osgi console:
{code}
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.
{code}
You can run "ss" command under the osgi> to see the status of the bundles.
{code}
osgi> ss
{code}
Then you can install and start contributions as bundles by doing the following:
{code}
osgi> install file:./path/to/<contribution_bundle.jar>
{code}
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]
h3. shell
This directory contains a sample shell program supporting simple commands to
start and stop SCA composites.
{note:title=TODO}
We currently have two similar approaches available (see command-line). We need
to merge the two together.
{note}
To build the sample shell do this:
{code}
mvn install
{code}
To run it:
{code}
./sca
{code}
at the prompt:
{code}
start myNode ../../applications/store/target/sample-store.jar
{code}
or:
{code}
start myNode
http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.jar
{code}
also try:
{code}
status
stop myNode
bye
{code}
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}
./sca <scripts/test.txt
{code}
or
{code}
./sca <scripts/test-remote.txt
{code}
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.
h3. 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}
cd samples/binding-jsonrpc/contribution-calculator-webapp
mvn
cp target/sample-contribution-binding-jsonrpc-calculator-webapp.war
<your_container_deployment-dir>
{code}
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}
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.18</version>
</plugin>
{code}
For contributions that have this, for example,
binding-jsonrpc/contribution-calculator-webapp, do the following
{code}
cd samples/binding-sca/contribution-calculator
mvn jetty:run
{code}
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}
http://localhost:8080/sample-binding-jsonrpc-calculator-webapp/
{code}
h2. 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.
h3. async
This sample demonstrates the SCA asynchronous progamming model in action as
typified by services that are configured with the asyncInvocation intent. For
example, from calculator-contribution
{code}
@Remotable
@AsyncInvocation
public interface CalculatorServiceAsync {
void calculateAsync(Integer n1, ResponseDispatch<String> response);
}
{code}
A client component can access an asynchronous service either synchronously or
asynchronously. Asynchronous reference interfaces also have a special form,
again from calculator-contribution:
{code}
@Remotable
public interface CalculateReferenceAsync {
// Sync
public String calculate(Integer i1);
// Aysnc Poll
public Response<String> calculateAsync(Integer i1);
// Async Callback
public Future<String> calculateAsync(Integer i1, AsyncHandler<String>
handler);
}
{code}
h4. calculator-contribution
This contribution defines synchronous and asynchronous component services and a
client component which references both. During the test the client component
exercise all three styles of reference interface operation against both the
synchronous and asynchronous service.
{panel:bgColor=pink}
The contribution can be built using Ant as follows:
{code}
cd learning-more/async/calculator-contribution
ant
{code}
The contribution can be installed and the composite it contains run using Ant
as follows
{code}
cd running-tuscany/embedded-jse
ant sample-implementation-java-calculator-async-contribution
{code}
{panel}
{panel:bgColor=silver}
The contribution can be built using Maven as follows:
{code}
cd learning-more/async/calculator-contribution
mvn
{code}
The contribution can be installed and the composite it contains run using Maven
as follows
{code}
cd running-tuscany/embedded-jse
mvn
{code}
This will run several contributions including the
sample-implementation-java-calculator-async-contribution.
{panel}
h3. binding-comet
The Comet protocol 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).
h4. weather-webapp
Executing the command "mvn" in this sample project creates a web archive
suitable for deployment to Tomcat. It makes use of the tuscany comet binding.
{panel:bgColor=silver}
The webapp can be built using Maven as follows:
{code}
cd learning-more/binding-commet/weather-webapp
mvn
{code}
{panel}
The webapp can be installed and run as follows:
{code}
cd learning-more/binding-commet/weather-webapp
cp target/sample-binding-comet-1.0.war <your_container_deployment-dir>
start the container as appropriate
{code}
h3. binding-jms
This binding supports message orient communication via the JMS API.
h4. helloworld-webapp
This contribution packages an SCA application inside a webapp. The application
has two components which exchange helloworld style messages over the JMS
binding.
{panel:bgColor=silver}
The webapp can be built using Maven as follows:
{code}
cd learning-more/binding-jms/helloworld-webapp
mvn
{code}
{panel}
The webapp can be installed and run as follows:
{code}
cd learning-more/binding-jms/helloworld-webapp
cp target/helloworld-jms.war <your_container_deployment-dir>
start the container as appropriate
{code}
{warning:title=TODO}
By rights the webapp should be called sample-binding-jms-helloworld-webapp.war
{warning}
Once the webapp is deployed point your browser at:
{code}
http://localhost:8080/helloworld-jms/
{code}
h3. binding-jsonrpc
This binding supports communication over the JSON-RPC protocol.
h4. calculator-contribution
This sample demonstrates using the simple calculator service component which
makes use of four other services for add, subtract, multiply and divide
functions. In this variant of the calculator sample the AddService is
configured to be invoked using the JSON-RPC protocol. You can see the
configuration by looking in the src/main/resources/Calculator.composite xml
file.
{panel:bgColor=pink}
The contribution Jar can be built using Ant as follows:
{code}
cd learning-more/binding-jsonrpc/calculator-contribution
ant
{code}
The contribution can be installed and the composite it contains run using Ant
as follows:
{code}
cd running-tuscany/embedded-jse
ant sample-implementation-java-calculator-async-contribution
{code}
{panel}
{panel:bgColor=silver}
The contribution Jar can be built using Maven as follows:
{code}
cd learning-more/binding-jsonrpc/calculator-contribution
mvn
{code}
The contribution can be installed and the composite it contains run using Maven
as follows
{code}
cd running-tuscany/embedded-jse
mvn
{code}
This will run several contributions including the
sample-implementation-java-calculator-async-contribution.
{panel}
h4. calculator-webapp
This contribution packages the same calculator-contribution inside a webapp.
{panel:bgColor=silver}
The webapp can be built using Maven as follows:
{code}
cd learning-more/binding-jsonrpc/calculator-webapp
mvn
{code}
{panel}
The webapp can be installed and run as follows:
{code}
cd learning-more/binding-jsonrpc/calculator-webapp
cp target/sample-binding-jsonrpc-calculator-webapp.war
<your_container_deployment-dir>
start the container as appropriate
{code}
Once the webapp is deployed point your browser at:
{code}
http://localhost:8080/sample-binding-jsonrpc-calculator-webapp/
{code}
h3. binding-rmi
In this example the calculator function is split over two contributions in
order to demonstrate the remote method invocation binding (binding.rmi). The
calculator-service-contribution contains a composite which defines a
CalculatorServiceComponent which exposes a CalculatorService using binding.rmi.
The calculator-reference-contribution contains a composite which also defines a
CalculatorServiceComponent but which in this case calls the add, subtract,
multiple and divide operations offered by the component in the
calculator-service-contribution. The two contributions are run using separate
Tuscany nodes and the resulting components communicate over RMI. Both
contributions must be deployed and started for the sample to work;
{panel:bgColor=pink}
The contributions can be installed and the composite they contain run using Ant
as follows:
{code}
cd running-tuscany/embedded-jse
ant sample-binding-rmi-calculator-contribution
{code}
{panel}
{panel:bgColor=silver}
The contributions can be installed and the composite they contain run using Ant
as follows:
{code}
cd running-tuscany/embedded-jse
mvn
{code}
This will run several contributions including the binding-rmi sample
contributions
{panel}
h4. calculator-service-contribution
This contribution defines a CalculatorServiceComponent whose add, subtract,
multiply and divide operations are available over RMI.
{panel:bgColor=pink}
The contribution Jar can be built using Ant as follows:
{code}
cd learning-more/binding-rmi/calculator-service-contribution
ant
{code}
{panel}
{panel:bgColor=silver}
The contribution Jar can be built using Maven as follows:
{code}
cd learning-more/binding-rmi/calculator-service-contribution
mvn
{code}
{panel}
h4. calculator-reference-contribution
This contribution defines a CalculatorServiceComponent which accesses the
service version of the component using binding.rmi.
{panel:bgColor=pink}
The contribution Jar can be built using Ant as follows:
{code}
cd learning-more/binding-rmi/calculator-reference-contribution
ant
{code}
{panel}
{panel:bgColor=silver}
The contribution Jar can be built using Maven as follows:
{code}
cd learning-more/binding-rmi/calculator-reference-contribution
mvn
{code}
{panel}
h3. 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 various components of the caluclator application.
h4. calculator-contribution
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.
{panel:bgColor=pink}
The contribution Jar can be built using Ant as follows:
{code}
cd learning-more/binding-sca/calculator-contribution
ant
{code}
The contribution can be installed and the composite it contains run using Ant
as follows:
{code}
cd running-tuscany/embedded-jse
ant sample-binding-sca-calculator-contribution
{code}
{panel}
{panel:bgColor=silver}
The contribution Jar can be built using Maven as follows:
{code}
cd learning-more/binding-sca/calculator-contribution
mvn
{code}
The contribution can be installed and the composite it contains run using Maven
as follows
{code}
cd running-tuscany/embedded-jse
mvn
{code}
This will run several contributions including the
sample-binding-sca-calculator-contribution.
{panel}
h3. binding-ws
The web service binding allows components to expose and call services using
SOAP formatted messages primarily over HTTP.
h4. calculator-contribution
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.
{panel:bgColor=pink}
The contribution Jar can be built using Ant as follows:
{code}
cd learning-more/binding-ws/calculator-contribution
ant
{code}
The contribution can be installed and the composite it contains run using Ant
as follows:
{code}
cd running-tuscany/embedded-jse
ant sample-binding-ws-calculator-contribution
{code}
{panel}
{panel:bgColor=silver}
The contribution Jar can be built using Maven as follows:
{code}
cd learning-more/binding-ws/calculator-contribution
mvn
{code}
The contribution can be installed and the composite it contains run using Maven
as follows
{code}
cd running-tuscany/embedded-jse
mvn
{code}
This will run several contributions including the
sample-binding-sca-calculator-contribution.
{panel}
h4. contribution-helloworld-ws-sdo
This sample demonstrates an SCA reference that uses a web service binding which
works with SDO. Instead if using JAXB style Java beans in the service interface
they are replaced with SDO object.
{note:title=TODO}
{color:#000000}Sample not currently enabled - awaiting SDO support{color}
{note}
h3. distributed-osgi
These samples demonstrate the execution of Tuscany contributions in a OSGI
environment. In particular the two projects in this directory define calculator
objects that communicate with one another using the mechanisms defined in the
OSGi remote services specifications. Here the Tuscany SCA runtime provides
dynamic service discovery functionality. The calculator objects are registered
as services directly with the OSGi bundle context by the bundle activator.
Under the covers SCA provides the remote service disovery features that allow
OSGi registered service to discover and communicate with one anothe across two
JVMs.
h4. dosgi-dynamic-calculator
h4. dosgi-dynamic-calculator-operations
h3. implementation-bpel
{note:title=TODO}{note}
h4. contribution-helloworld-bpel
{note:title=TODO}check instructions work and fix up{note}
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}
ant compile run
{code}
OR if you don't have ant, on Windows do
{code}
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
{code}
and on \*nix do
{code}
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
{code}
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}
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
{code}
*Building And Running The Sample Using Ant*
With the binary distribution the sample can be built and run using Ant as
follows
{code}
cd helloworld-bpel
ant compile
ant run
{code}
You should see the following output from the run target.
{code}
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
{code}
*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}
cd helloworld-bpel
mvn
{code}
You should see the following output from the test phase.
{code}
\------------------------------------------------------\-
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]
\-----------------------------------------------------------------------\-
{code}
{code}
{code}
This shows that the Junit test cases have run successfully.
h4. helloworld-bpel-webapp
h3. implementation-composite
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h4. helloworld-recursive
{note:title=TODO}Understand and Document{note}
h4. helloworld-recursive-ws
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h3. implementation-extension
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h3. implementation-java
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h4. contribution-calculator
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h3. implementation.osgi
h4. dosgi-calculator
h4. dosgi-calculator-operations
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h3. implementation-script
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h4. contribution-calculator
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h3. implementation-spring
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h4. contribution-helloworld-spring
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h4. helloworld-spring-webapp
h3. implementation-webapp
h4. helloworld-jaxrs-webapp
h4. helloworld-jms-webapp
h4. helloworld-js-client-webapp
h4. helloworld-jsf-webapp
h4. helloworld-jsp-webapp
h4. helloworld-servlet-webapp
h4. helloworld-stripes-webapp
h3. logging-scribe
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h3. maven-osgi-junit
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h4. calculator-osgi
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h4. calculator-rest-osgi
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h3. sca-client
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h4. calculator-scaclient
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h4. helloworld-scaclient
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h2. applications
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h3. store
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
h3. store-webapp
{note:title=TODO}
{color:#000000}Understand and Document{color}
{note}
Change your notification preferences:
https://cwiki.apache.org/confluence/users/viewnotifications.action