# Running the Tuscany runtime from a Java program

The Tuscany SCA Runtime provides a Node API that allows the runtime to be started from within a Java program. A Node in Tuscany represents a set of activated composites and a Node is configured with all of the contributions required for those composites to run. The idea is to allow you to partition the domain up into it's constituent deployable composites and run each one in its own node on an appropriate machine. In that way the domain can easily be distributed while SCA takes care of making sure that wired services can communicate regardless of where they are.

The basic pattern is as follows:

1/ Use the org.apache.tuscany.sca.node.NodeFactory API to create a org.apache.tuscany.sca.node.Node instance configured with enough contributions to run the required composite

2/ Start the Node instance. This starts deployable composites contained in the provided contributions

3/ Interact with the services that the Node instance has made available

4/ Stop the Node instance

The pattern is demonstrated in this sample in the launcher.LaunchCalculatorContribution class. It loads the calculator-contribution.jar contribution found in the parent directory, makes a simple call to add two numbers together using the Calculator service and then shuts down.

To run the sample on Windows do:

cd jse

run-sample.bat

To run the sample on *nix do:

cd jse

run-sample.sh

To re-build the sample classes do

cd jse

mvn

Note. The mvn build will automatically run a unit test that also runs the sample.