diff options
Diffstat (limited to 'sca-java-2.x/trunk/samples/getting-started/sca-scopes/src/main/java/sample/Launcher.java')
-rw-r--r-- | sca-java-2.x/trunk/samples/getting-started/sca-scopes/src/main/java/sample/Launcher.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/samples/getting-started/sca-scopes/src/main/java/sample/Launcher.java b/sca-java-2.x/trunk/samples/getting-started/sca-scopes/src/main/java/sample/Launcher.java new file mode 100644 index 0000000000..9c8614d18f --- /dev/null +++ b/sca-java-2.x/trunk/samples/getting-started/sca-scopes/src/main/java/sample/Launcher.java @@ -0,0 +1,38 @@ +package sample; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +public class Launcher { + + public static void main(String[] args) { + Node node = startRuntime(); + Client client = node.getService(Client.class, "Client"); + client.run(); + stopRuntime(node); + } + + /** + * Starts a Tuscany node with the predefined contribution. + * + * @return the running node + */ + private static Node startRuntime() { + String location = ContributionLocationHelper.getContributionLocation("scopes.composite"); + Node node = NodeFactory.newInstance().createNode("scopes.composite", new Contribution("c1", location)); + node.start(); + return node; + } + + /** + * Stops a Tuscany node. + * + * @param node the node to stop + */ + private static void stopRuntime(Node node) { + node.stop(); + } + +} |