Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Software Organization

Source Code Locations

If you take a Tuscany SCA Java source distribution or look in the Tuscany subversion repository ( Removed) you'll see the code layed out as follows:

Code Block
distribution    - Maven archetypes for creating Tuscany project templates
distribution  - the code that defines and build Tuscany distributions
features               - Maven projects that collect together Tuscany featuresmodules 
itestmaven         -
 project integrationarchetypes tests
modules       - the source code- forMaven thearchetypes runtimefor andcreating theTuscany SCAproject extensionstemplates
pom.xml  maven-tuscany-plugin - ???
modules                - the source code for the runtime and the SCA extensions
samples                - project samples
  itest                - TBD
project integration tests
  compliance-tests     - OASIS compliance tests

There is some There is some related source code that's worth mentioning up front. Firstly the project Maven build relies on a set of Maven plugins that have been written specifically for Tuscany. They can also be found in the Tuscany subversion repository ( Removed) and are as follows:


Secondly there are a set of tests that the OASIS SCA specifications define called otests. These test the Tuscany SCA runtime for compliance with the specifications. The tests themselves are stored in the OASIS subversion system ( Removed). Tuscany has a set of modules that retrieve these tests automatically and configure the Tuscany environment to run them ( Removed) as follows:

Code Block
build.xml                    - Ant utility script
sca-assembly                 - Generated automatically by svn externals when you check this directory out
sca-java-caa                 - Generated automatically by svn externals when you check this directory out
sca-java-ci                  - Generated automatically by svn externals when you check this directory out
sca-policy                   - Generated automatically by svn externals when you check this directory out
tuscany-java-caa-test-runner - Java Common Annotations and APIs test runner
tuscany-java-ci-test-runner  - Java Component Implementation test runner
tuscany-policy-test-runner   - Policy test runner
tuscany-test-runner          - Assembly test runner

SCA Java Modules

All of the functional code in Tuscany Java SCA can be found under the modules directory. There are a lot of sub-directories here but they basically fall into one of two categories, core function or extensions. We are using the term extension here in the sense that the SCA Assembly specification talks about and extension model You always have to have the core functions but most of the extensions are optional (we say most here because without some of the basic extensions the runtime won't do anything) Finding extension modules is easy. Modules that start with the following words are extensions.


As you can see SCA extensions relate to the extensible parts of the SCA composite file. For example, if you want to use <binding.jms/> in you SCA composite files then you need to include the Tuscany modules for this extension in you installation. In this case that would mean the modules binding-jms and binding-jms-runtime.

All of the other modules in the modules directory are core modules and are generally required to be present in you Tuscany runtime installation. The use of the word "generally" here sounds a bit vague. This is because the Tuscany runtime itself is based on an extensibility mechanism which means that many parts of the runtime (as well as the SCA extensions) are pluggable. In this way, for example, different hosting environments can be supported. Well talk about runtime extensibility further down this article but for the time being consider all core modules to be mandatory.

Runtime Building Blocks

As you may have realized the Tuscany SCA Java runtime is just a Java program that, once started listens for incoming messages (via SCA component services) and, sometimes responds with outgoing messages (via SCA component references).

Image Modified

The runtime then provides the context within which SCA composite applications run. If we crack open the Tuscany Runtime box we see the following structure.

Image Modified

We'll take a high level look at these different blocks in turn starting with Core.

Tuscany Core


The Tuscany core is made up of several modules that provide basic runtime and extensibility support to the extensions that provide the real SCA functions. If you look in the modules directory of a Tuscany distribtuion (2.0-M4 at the time of writing - this list may change in subsequent releases) the modules that make up the Tuscany core are as follows:

Code Block

assembly                - The in-memory model of an OASIS SCA composite application (sometimes called an assembly)
assembly-xml            - The Tuscany processors that translate to and from XML and the in-memory model
assembly-xsd            - The schema used to validate the contents of various SCA files, e.g. the composite file
builder                 - Process the in-memory model to build a complete SCA application representation
common-java             - General Java utilities
common-xml              - General XML utilities
contribution            - Read and process SCA contributions
core                    - The core Tuscany SCA Java runtime functions
core-databinding        - The core databinding functions
core-spi                - The Java interfaces that extension developers use to create and register extensions
databinding             - Builds on the core databinding functions to provide features common to all databindings???
deployment              - Loads the runtime and orchestrates the loading of SCA contributions 
extensibility           - Reads META-INF/services files and manages Tuscany extensibility
extensibility-equinox   - Manages Tuscany extensibility in an OSGi environment
host-http               - Base interfaces for providing integration with a servlet container
interface-java          - Java interface model and instrospection
interface-java-jaxws    - Process JAX-WS annotations from a Java interface
interface-wsdl          - WSDL interface model 
launcher                - Command line Tuscany runtime launcher
monitor                 - Collects errors as they occur in the Tuscany runtime
node-api                - API for accessing an embedded Tuscany node (A node loads/runs contributions)
node-impl               - The JSE implementation for the node API
node-impl-osgi          - The OSGi implementation for the node API ????
node-launcher           - The JSE based command line launcher for a Tuscany node
node-launcher-equinox   - The OSGi based command line launcher for a Tuscany node
sca-api                 - The OASIS defined SCA API
sca-client-impl         - The Tuscany implementation of the OASIS defined SCA client
xsd                     - The in-memory model of an XSD file, along with the processors to read it

We have already said that there are a set of extensions that, while in theory they are are optional, are in practice required to do anything useful. These are are follows:

Code Block

binding-sca-runtime          - The implementation for the local version of
binding-sca-axis2-runtime    - The implementation for the remote version of based on web services
binding-ws                   - The in-memory model for 
binding-ws-axis2             - TBD - should be called runtime
binding-ws-axis2-policy      - TBD
binding-ws-wsdlgen           - TBD
databinding-axiom            - The databinding for Axiom 
databinding-jaxb             - The databinding for JAXB
databinding-jaxb-axiom       - TBD
endpoint-tribes              - The distributed endpoint registry based on tribes
host-jetty                   - Allows Jetty to be started automatically to support HTTP based bindings
host-webapp                  - Allows Tuscany to be embedded in a WAR
implementation-java          - The in-memory model for
implementation-java-runtime  - The runtime artifacts for

The rest of the modules are optional and can be omitted. In practice the easiest way to get started is to keep all of the modules. By default this is what you get when you install the binding distribution. In the future you're free to remove the extensions you don't use to reduce the size of the installation. The Tuscany project may even make releases in the future that package sets of extensions targeted at particular types of application.

Tuscany SCA API

The Tuscany SCA API is used by SCA applications to access various information from the runtime. It's not mandatory to use the API but it can be useful in some circumstances.

Code Block

  Tuscany API                          
  Tuscany API             
  Tuscany API
  Tuscany API 
  OASIS API             

Tuscany SPI

The Tuscany SPI is generally used for building extensions. Extensions come in two flavours SCA extensions, like implementation and binding types, and Tuscany runtime extensions, like builders and binders. Both of these types of extension are discussed a little later in this article. The modules and module packages that describe the Tuscany SPI are as follows:

Code Block

core-spi (why not extension SPI?)

More detail on extension points and SPIs can be found here

Tuscany Runtime Extensibility and Extensions

As we've already mentioned the Tuscany core doesn't do much on it's own apart from providing basic features and support the plugging in of extensions which do the real work. Extensions come in two forms. Extension types defined by the OASIS SCA specifications and those that are particular to Tuscany. In the first category are the extension types defined by the OASIS Assembly specification:

  • interface
  • implementation
  • binding
  • import
  • export

The Tuscany runtime defines it's own extension types which exploit the core runtimes extensibility features

  • policy
  • databinding
  • contribution
  • host

The Tuscany extensibility framework is based on two simple ideas. Firstly that the Tuscany runtime provides extension points into which extension functions can be plugged. Secondly that the the Java META-INF/services mechanism provides a way for extension developers to register new extension functions with these extension points.

The Tuscany extensibility framework exposes quite a few extension points, for example,(o.a.t.s = org.apache.tuscany)

Code Block

Extension points are usually used in groups. You have to populate the right extension points when implementing say an implementation or a binding extensions. The best way to get a grip on how this works is to look at existing extensions and see what they do. As an example, if you look at how the extension registers an extension to read the <> element from a composite file and turn it into an in-memory Java model you will see the following file:


Which contains a single line as follows:;qname=,

This tells the Tuscany runtime to register and extension in the StAXArtifactProcessorExtensionPoint with the follwing properties:

    • The name of the process that turns the XML <> element into a Java model
  • qname=
    • The QName of the <> element to look for in incoming composite files
    • The name of the Java model interface that will be used to represent the XML element in-memory.

The full set of extension points required to represent the extension is spread across the implemenation-java and implementation-java-runtime modules as follows:


  • resources/META-INF/services/
    • o.a.t.s.contribution.processor.StAXArtifactProcessor - Converts <> to/from JavaImplementation model
    • - Creates JavaImplementation model objects
    • - Registers visitors used to introspect Java classes


  • resources/META-INF/services/
    • o.a.t.s.context.PropertyValueFactory - ???
    • o.a.t.s.definitions.xml.Definitions - Registers a definitions.xml file for
    • o.a.t.s.provider.ImplementationProviderFactory - Creates a runtime provider for
    • o.a.t.s.runtime.RuntimeWireProcessor - Registers a processor for endpoint and endpoint reference interceptor chains

All of these extension point entries come together at runtime to allow Tuscany to process elements that appear in composite files.

Most extension are packaged in a least two modules. For example the extension is provided in the following modules:

Code Block

modules/implementation-java            - the model classes and XML processor
modules/implementation-java-runtime    - the runtime artifacts such as the runtime providers 

You will currently see extension that don't match this pattern. Often this is because the extension has been moved into 2.x from 1.x but has not been tidied up yet.

More detail on extension points and SPIs can be found here

Runtime hosting and containers, OSGi, JSE, Webapps etc.

The Tuscany runtime will work in the JSE environment and when deployed to an OSGi runtime like Felix or Equinox. Since 1.x we have been through an exercise of refactoring all of the runtime modules into OSGi bundles and providing consistent OSGi manifest files. See ( for more details on how we OSGi-igfied the Tuscany runtime.

A launcher is provided to each environment. For JSE use the following class from modules/node-launcher:

Code Block

For in OSGi in the Equinoz framework use the following class from modules/node-launcher-equinox:

Code Block

In both cases you use the launcher to create a node instance as follows:

Code Block

Node node = launcher.createNode(new Contribution("contrib1", "./contrib1.jar"),                    
                                new Contribution("contrib2", "./contrib2.jar"));

When you use the JSE launcher the runtime starts and creates a classpath to load the Tuscany runtime. It uses the following algorithm (coded in the NodeLauncherUtil.runtimeClassloader method) to create the classpath:

  • Check to see if the runtime has been added to the current classpath already. If it has don't do anything more
  • Determine where the launcher class was loaded from and load all the Tuscany classes from that location
  • Look for an environment variable called TUSCANY_HOME which should point to a distribution. Load jars from there and from lib and modules sub directories
  • Look for an environment variable called TUSCANY_PATCH which contains a list of Jars to load?

When you use the OSGI launcher the algorithm is similar but of course this time the Tuscany bundles are loaded into the OSGi framework. The node launcher starts up the Equinox framework and then goes looking for bundles to load using the following algorithm:

  • TBD

There is no single classpath that gives access to the Tuscany runtime.

TODO what features of the OSGi integration do we need to cover in this overview?
(In the OSGi runtime special processing is applied to collect together all the META-INF/services information so that it is all accessible without having to delve inside each bundle. See the runtime enviroments section for more information)

You can of course use the launchers from the command line in various guises.

Code Block


TODO - what other ways are we actually going to support for starting the runtime?

SCA Domain and Nodes

The design for the 2.x SCA domain is based on a registry that is accessible from all nodes that are running composites in the domain. There is also the intention to add a management mechanism to allow for central control of the nodes. This is not in place yet.

Image Added

It is out intention to bring the Domain Manager function over from the 1.x code base to provide a central place for adding contributions and assigning them to nodes. This time though it won't be mandatory to run a Domain Manager to have nodes run a distributed SCA application. If you are happy to configure nodes directly and start them individually you are able to do that. The domain manager will just be one of a number of applications that can sit on top of and exploit the distributed registry.

The registry holds information that is common across the domain including:

  • available endpoints (the result of specifying a binding on a component services)
  • policy model
  • extension type model

The following diagram shows an example of domain data populating the registry and two nodes, in separate JVMs, running separate composites from the SCA application

Image Added

With no domain manager each node is started with a set of contributions. A node reads the contributions and processes deployed composites ready to run. As part of this processing domain level information, such as deployed endpoints and available policies, is published to the registry for other nodes to find. When domain level information is required by a node, for example, when a component reference targets a service running on a different node in the domain, the information can be obtained by looking in the registry.

If a domain manager is present it can pre-process all available contributions and pre-populate the registry as required. This is however not mandatory.

Runtime Lifecycle


Runtime creation is contrilled by the environment in which the runtime is being started. For example, if you are running Tuscany from the runtime then using the node launcher will start the runtime. Alternatively if you are deploying Tuscany embedded in a web app then the runtime will not be started until the WAR file is deployed. See the previous hosting section for more details.


When a node is started and configured with the location of a contribution, for example,

Code Block

Node node = launcher.createNode(new Contribution("contrib1", "./contrib1.jar"),                    
                                new Contribution("contrib2", "./contrib2.jar"));

the node will look at each contribution and identify all of the aritifacts that it holds. Artifacts can be anything from XML, XSD, WSDL and Java .class files to the SCA .composite files. Once the node knows what artifacts are available in all of its input contributions it will read the composite files. It does this using the extension processors that are provided with each extension. The output of reading the composite file is an in-memory model of the SCA application. This model is used to configured the runtime in later phases.


The in-memory model that results from the read phase will contain a lot of unresolved references. For example, for a component that uses

Code Block

< class="my.package.MyClassImpl"/>

The model knows the name of the class file that will be used to implement the component but it doesn't actually have a reference to that real Java class. These references are resolved in the resolve phase. Again the extension processors are used and this time their resolve method looks through the available contributions, using the import/export relationships, to locate referenced artifacts.


Once we get to this stage we have an in-memory model that faithfully matches what was present in the .composite files that are deployed to the node. We now need to build the model to prepare it read for creating the runtime artifacts. There are a number of things that we need to do an primarily the process involves applying the SCA rules to calculate a complete model of the application based on the input composite files. The input composite files don't necessarily contain all of the right details in the right places, for example, imagine a Java component implementation as follows:

Code Block

class MyClassImpl implements MyClass {
  protected MyOtherClass myOtherClassReference;

  public String doSomething(String input){
     return myOtherClassReference.doSomething(input);

We can define an SCA component as follows:

Code Block

<component name="MyComponent">
    < class="my.package.MyClassImpl"/>

We haven't said that this component defines any services or references but based on the component type implied by the MyClassImpl class we know that it really as a service called "MyClass" and a reference called "myOtherClassReference".

The build process

The build process applies these kinds of rules and enhances the in-memory model with all of the implied information.

The following diagram shows the basic process and the steps that form the process.

Image Added

The steps are as follows:

  1. Flatten includes - this copies all information from an included composite into the including composite.
  2. Attach policies - policies that specify external attachment are applied to the model here
  3. Calculate composite component types - the use of implementation.composite implies a hierarchical organization of composite and the components that use them as implementations. This step calculates the component type for a composite recursively so that the configuration of the component that the composite implements can be configured correctly
  4. Binding specific building - Sometimes bindings have specific processing to do, for example, the web services binding created WSDL at this stage.
  5. Construct endpoints - endpoints represent the service endpoints that components expose. They are the runtime representation of the service binding configuration.
  6. Construct endpoint references - endpoint references represent the references that components expose. They are the runtime representation of the reference binding configuration.
  7. Compute policy - all of the intents and policy sets should be applied in their correct locations by this stage. This processing computes the policy sets that actually applies and performs policy specific processing

The endpoints and endpoint references provide the runtime connection between the component implementations and the bindings protocols used when communicating with other components. The hold all of the message handling chains in the runtime.

Endpoints and Endpoint References

The following diagram shows how enpoints and enpoint references relate to the model of the more recognizable component references and services.

Image Added

And endpoint maps to a service binding and an endpoint reference maps to a reference target (or a configured reference binding if one is present instead of a target).You will note that endpoints and endpoint references are used to represent callbacks too. An service that specifies a callback gives rise to one or more callback endpoint references. These sit behind the callback proxy at runtime. An endpoint reference that specifies a callback gives rise to a callback endpoint. This endpoint receives callback messages.

Looking in more detail you can see that both endpoints and endpoint references hold the interceptor chains that proces references side (endpoint reference) and service side (endpoint) messages. At the end of the interceptor chain endpoint information is placed into the protocol message. The following diagram shows how the web service binding uses endpoint information in forward and callback messages.

Image Added

The twist here is that while a forward Tuscany message has a from field that points to the source endpoint reference when this gets turned into a SOAP envelope the from field represents the callback endpoint if there is one.

Building endpoints and endpoint references

The following diagram shows how endpoints and endpoint references are created and used at a very high level.

Image Added

  1. First endoints and endpoint references are created during the build phase. An endpoint is created for every service binding. Endpoint references are created for every reference target or configured binding. Reference targets are either explicit specified through the reference or the binding uri or are implicitly specified through the use of autowire. If the endpoint to which an endpoint reference is available locally at this point the the two are linked (or bound) together at this point. If the node is running in a distributed domain, endpoint references can be created at this point where the target endpoint is not bound because it's not running in the same node. These endpoint references will be boundat runtime when the first messages passes through the endpoint reference
  2. Second, during the activation phase, all endpoints are added to the endpoint registry. In this way any node that has access to the endpoint registry can see the details of these endpoints
  3. Lastly, on first use, endpoint references that remain unbound are bound using a pluggable binding algorithm which will usually involve looking up and endpoint in the registry.


At the activate stage the various extension providers are created as required.


During start the "start" operation is called on all active providers in order to perform any extension specific start processing.

Message Processing

Reference side operation and binding chains

Image Added

Service side operation and binding chains

Image Added


During stop the "stop" operation is called on all started providers in order to perform any extension specific stop processing.


During the deactivate stage the various parts of the runtime model are picked apart to allow for successful garbage collection.


Mapping interfaces to the runtime model

Image Added

Reference side runtime interface driven databinding processing

Image Added

Service side runtime interface driven databinding processing

Image Added

OSGi Support

Runtime Extensibility

Runtime Modularity

Tuscany SPI

SCA Extensions

Tuscany API

Tuscany Hosting

Runtime Features

Domain and Nodes

Runtime Lifecycle