Getting Started with Apache Tuscany SCA Java M2

Downloading the Release Files

The following files are available for download:

These archives all unpack into the current directory.

Building the Source Distribution

To build the Tuscany SCA Java implementation from source:

  1. Download the implementation source distribution tuscany-sca-1.0-incubator-M2-src.tar.gz or tuscany-sca-1.0-incubator-M2-src.zip.
  2. Create an empty directory and unpack the source distribution into that directory.
  3. Follow the instructions in the BUILDING.txt file that was unpacked.

As part of the above build process, the SCA and commonj specification files will be downloaded as pre-built binaries from the remote maven repositories into your local maven repository.

If you prefer, you can build these specification binaries from source and install them in your local maven repository, as follows:

  1. Download the SCA specification source distribution tuscany-spec-sca-r0.95-incubator-M2-src.tar.gz or tuscany-spec-sca-r0.95-incubator-M2-src.zip.
  2. Create a new empty directory and unpack the source distribution into that directory.
  3. Change directory to the newly created directory and run "mvn install". The SCA specification binary jar will be installed in your local maven repository.
  4. Download the commonj specification source distribution tuscany-spec-commonj-1.1-incubator-M2-src.tar.gz or tuscany-spec-commonj-1.1-incubator-M2-src.zip.
  5. Create a new empty directory and unpack the source distribution into that directory.
  6. Change directory to the newly created directory and run "mvn install". The commonj specification binary jar will be installed in your local maven repository.

Installing the Binary Distribution

If you prefer to run from a pre-built binary, proceed as follows:

  1. Download the binary distribution tuscany-sca-1.0-incubator-M2-bin.tar.gz or tuscany-sca-1.0-incubator-M2-bin.zip.
  2. Create an empty directory and unpack the binary distribution into that directory.
  3. In later sections of this document, we will refer to the directory that was created in step 2 (or built from source following the alternative instructions above) as <sca-home>.

Building and Running the Samples

  1. Download the samples distribution tuscany-spec-sca-r0.95-incubator-M2-samples.tar.gz or tuscany-spec-sca-r0.95-incubator-M2-samples.zip.
  2. Create a new empty directory and unpack the samples distribution into that directory.
  3. Change directory to the newly created directory and run "mvn -N install". This will install the samples parent pom.xml file into your local maven repository.
  4. Follow the instructions in the readme.html files for the various samples.

Tuscany SCA Java M2 files available from maven

The following Tuscany SCA Java M2 files have been published to the public maven respository

and will be downloaded automatically by maven as needed.

The Tuscany runtime is able to download dependent jars of Tuscany extensions from the maven repositories as needed.

Packaging a Standalone Tuscany Application

To package a Tuscany application for running in the standalone environment (i.e., not within a web application), the application must be packaged as a jar file with the following contents:

In the following instructions, we will refer to this application jar file as <executable-jar>.

The MANIFEST.MF file must contain the following line:

This is the name of the main class to be run by the Tuscany standalone launcher.

The default.scdl file defines the SCA components whose implementations are in the jar file. See the SCA documentation and the Tuscany samples for details of how to write an SCDL file.

Running a Standalone Tuscany Application

To run a Tuscany application in the standalone environment, issue the following command:

The standalone launcher initializes the Tuscany runtime, deploys any installed extensions (see below), creates components defined by the default.scdl file, and calls the main class of the application jar file <executable-jar>.

Adding Extensions to the Standalone Environment

To add extensions to the standalone environment, you need to copy the required extension jars into the directory

The launcher for the standalone environment looks for this directory and deploys all the extension jars that it finds there.

Applications may need a combination of extensions, and some extensions may depend on other extensions. For example, the helloworldwsclient sample needs the following extensions to be present in the extensions directory:

These extensions will load their required dependencies from the maven repository. The required dependencies are:

Building a Tuscany Web Application

To package a Tuscany application for running in a web application container such as Apache Tomcat, the application must be packaged as a war file with some Tuscany-specific contents.

If you are buildng a Tuscany war file using maven, Tuscany provides a maven plugin

that performs this packaging. It is downloaded automatically from the maven repository when invoked by a pom.xml. For an example of how to create a pom.xml file that uses this plugin, see the pom.xml file for the webapp/calculatorws sample. Within this pom.xml file, you will see the line

This instructs the Tuscany maven war plugin to create a war file that does not include dependent jar files of Tuscany extensions. Instead, these jar files will be loaded on demand by the Tuscany runtime. If the value of this element is set to true, then the Tuscany maven war plugin will bundle all required dependent jar files within the war file.

If you are not using maven to build a Tuscany war file, then you will need to ensure that the following files are included in the war file:

  WEB-INF/default.scdl                             see description above
  WEB-INF/web.xml                                  see below
  WEB-INF/classes                                  application executable code and resources
  WEB-INF/lib                                      Tuscany runtime jars from <sca-home>/lib,
                                                    plus webapp-1.0-incubator-M2.jar (available from maven repository)
  WEB-INF/tuscany/boot                             Tuscany runtime jars from <sca-home>/boot,
                                                    plus webapp-host-1.0-incubator-M2.jar (available from maven repository)
  WEB-INF/tuscany/extensions                       required Tuscany extensions
  WEB-INF/tuscany/repository/dependency.metadata   see below

The <web-app>...</webapp> section of the WEB-INF/web.xml file must contain the following code:

  <listener>
     <listener-class>org.apache.tuscany.runtime.webapp.TuscanyContextListener</listener-class>
  </listener>
  <servlet>
     <servlet-name>TuscanyServlet</servlet-name>
     <display-name>Tuscany Servlet</display-name>
     <servlet-class>org.apache.tuscany.runtime.webapp.TuscanyServlet</servlet-class>
  </servlet>
  <servlet-mapping>
     <servlet-name>TuscanyServlet</servlet-name>
     <url-pattern>/services/*</url-pattern>
  </servlet-mapping>

For runtime loading of dependent jars (see the description of the <loadExtensionDependencies> element above), the WEB-INF/tuscany/repository/dependency.metadata file must contain the following code:

  <?xml version="1.0" encoding="UTF-8"?> 
  <java version="1.5.0_06" class="java.beans.XMLDecoder"> 
   <object class="java.util.HashMap"/> 
  </java> 

If these dependent jars are packaged within the web application's WEB-INF/tuscany/repository/ directory, please refer to the output of the Tuscany war plugin (with <loadExtensionDependencies> set to true) to see what code needs to be included within the WEB-INF/tuscany/repository/dependency.metadata file.

For Further Information

If you have any questions about installing, building, or running Tuscany SCA Java M2 that are not answered here, please post them to either the tuscany-user@ws.apache.org list (for end-user questions) or the tuscany-dev@ws.apache.org list (for developer questions).

The Apache Tuscany team

Tuscany/TuscanyJava/SCA_Java/GettingStarted (last edited 2009-09-20 22:47:53 by localhost)