summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/samples/running-tuscany
diff options
context:
space:
mode:
authorkelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68>2010-09-14 13:37:53 +0000
committerkelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68>2010-09-14 13:37:53 +0000
commita799bd1b828dcf0077832ec0f9a306a59031856f (patch)
treeb4c66ccd42e36a6e07cd8aa1f85a9c47dbe70f74 /sca-java-2.x/trunk/samples/running-tuscany
parent42ee19f055d31f63e4f073cd273a95c6b06123b5 (diff)
TUSCANY-3677 move launchers into running-tuscany folder
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@996894 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/samples/running-tuscany')
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-command-line/README13
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/README20
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/build.xml110
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/pom.xml94
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java38
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingJSONRPCCalculator.java59
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingRMICalculator.java61
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingSCACalculator.java59
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingWSCalculator.java59
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationJavaCalculator.java46
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationScriptCalculator.java59
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/RuntimeIntegration.java43
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/SampleLauncherException.java42
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java48
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/README24
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/build.xml94
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/pom.xml71
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/calculator/CalculatorService.java38
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/RuntimeIntegration.java61
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/SampleJSELauncher.java89
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/SampleLauncherException.java42
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/test/java/launcher/LauncherTestCase.java39
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/README20
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/build.xml94
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/pom.xml76
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/calculator/CalculatorService.java38
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/RuntimeIntegration.java61
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/SampleJSELauncher.java89
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/SampleLauncherException.java42
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/test/java/launcher/LauncherTestCase.java39
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-maven/README18
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/README34
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/pom.xml79
-rwxr-xr-xsca-java-2.x/trunk/samples/running-tuscany/launcher-shell/sca19
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/sca.bat30
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-remote.txt36
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-start.txt18
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-status.txt17
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-stop.txt17
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test.txt36
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/java/sample/Shell.java197
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/java/sample/ShellServlet.java48
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/webapp/WEB-INF/web.xml48
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/webapp/index.html40
-rw-r--r--sca-java-2.x/trunk/samples/running-tuscany/launcher-webapp/README29
45 files changed, 2334 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-command-line/README b/sca-java-2.x/trunk/samples/running-tuscany/launcher-command-line/README
new file mode 100644
index 0000000000..bf963ea98e
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-command-line/README
@@ -0,0 +1,13 @@
+To execute a sample contribution from the command line
+
+on Windows, from a command prompt in the samples directory, run the command ...
+
+..\bin\tuscany.bat "contribution-name"
+
+for example
+
+..\bin\tuscany.bat contribution-binding-sca-calculator
+
+or on *nix platforms, from a shell prompt in the samples directory, run the command ...
+
+../bin/tuscany.sh contribution-binding-sca-calculator
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/README b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/README
new file mode 100644
index 0000000000..7108333efa
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/README
@@ -0,0 +1,20 @@
+JSE Sample Launcher
+===================
+
+This directory contains a sample java launcher for the
+tuscany sample contributions.
+
+The README file in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running sample contributions using the
+tuscany sample launchers ( where distribution-unpack-dir is the directory in which you
+unpacked the tuscany binary distribution archive)
+
+To use this sample JSE launcher with ant excute the command
+
+ant run-<contributionname>
+
+where run-<contributionname> is one of the targets in the build.xml file
+
+To use this sample launcher to run all of the contributions as junit test cases,
+execute the command "mvn" in the launcher directory.
+
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/build.xml b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/build.xml
new file mode 100644
index 0000000000..05c7ab3c49
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/build.xml
@@ -0,0 +1,110 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project name="launcher-embedded-jse" default="run">
+ <property name="tuscany.home" value="../.."/>
+ <property name="jar.name" value="sample-launcher-embedded-jse.jar" />
+ <property name="wait.before.stopping" value="dontWaitBeforeStopping" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-base-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ </jar>
+ </target>
+
+ <target name="run" depends="compile">
+ <echo>Please use 'ant run-name-of-sample-contribution-to-run' for example, try one of</echo>
+ <echo> 'ant run-contribution-binding-sca-calculator' </echo>
+ <echo> 'ant run-contribution-binding-ws-calculator' </echo>
+ <echo> 'ant run-contribution-binding-rmi-calculator' </echo>
+ <echo> 'ant run-contribution-implementation-java-calculator' </echo>
+ </target>
+
+ <target name="run-contribution-binding-sca-calculator" depends="compile">
+ <java classname="launcher.JSELauncherBindingSCACalculator"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="run-contribution-binding-ws-calculator" depends="compile">
+ <java classname="launcher.JSELauncherBindingWSCalculator"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="run-contribution-binding-rmi-calculator" depends="compile">
+ <java classname="launcher.JSELauncherBindingRMICalculator"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="run-contribution-implementation-java-calculator" depends="compile">
+ <java classname="launcher.JSELauncherImplementationJavaCalculator"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/features">
+ <include name="tuscany-sca-manifest.jar" />
+ </fileset>
+ </classpath>
+ </java>
+ </target>
+
+</project>
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/pom.xml b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/pom.xml
new file mode 100644
index 0000000000..a30d55d2e9
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/pom.xml
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-launcher-embedded-jse</artifactId>
+ <name>Apache Tuscany SCA Sample Launcher Embedded JSE</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-script-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-json</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..12d80ffd1c
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingJSONRPCCalculator.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingJSONRPCCalculator.java
new file mode 100644
index 0000000000..3d6af9f561
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingJSONRPCCalculator.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and locate and invoke an SCA component
+ */
+public class JSELauncherBindingJSONRPCCalculator {
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherBindingJSONRPCCalculator launcher = new JSELauncherBindingJSONRPCCalculator();
+ launcher.launchBindingSCACalculator();
+ }
+
+ /*
+ * Using the Tuscany Node API to load a contribution.
+ * Using the Tuscany Node API to get a local service proxy
+ */
+ public void launchBindingSCACalculator(){
+ Node node = NodeFactory.newInstance().createNode(new Contribution("c1", "../binding-jsonrpc/contribution-calculator/target/sample-contribution-binding-jsonrpc-calculator.jar"));
+ node.start();
+
+ CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ // TODO - could use JUnit assertions but don't want to have to handle JUnit dependency from Ant script
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+ node.stop();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingRMICalculator.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingRMICalculator.java
new file mode 100644
index 0000000000..18fb2f4fb7
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingRMICalculator.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and locate and invoke an SCA component
+ */
+public class JSELauncherBindingRMICalculator {
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherBindingRMICalculator launcher = new JSELauncherBindingRMICalculator();
+ launcher.launchBindingRMICalculator();
+ }
+
+
+ public void launchBindingRMICalculator(){
+
+ Node node1 = NodeFactory.newInstance().createNode(new Contribution("c1", "../binding-rmi/contribution-calculator-service/target/classes"));
+ Node node2 = NodeFactory.newInstance().createNode(new Contribution("c1", "../binding-rmi/contribution-calculator-reference/target/classes"));
+
+ node1.start();
+ node2.start();
+
+ CalculatorService calculator = node2.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+
+ node1.stop();
+ node2.stop();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingSCACalculator.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingSCACalculator.java
new file mode 100644
index 0000000000..4355bcfbd8
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingSCACalculator.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and locate and invoke an SCA component
+ */
+public class JSELauncherBindingSCACalculator {
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherBindingSCACalculator launcher = new JSELauncherBindingSCACalculator();
+ launcher.launchBindingSCACalculator();
+ }
+
+ /*
+ * Using the Tuscany Node API to load a contribution.
+ * Using the Tuscany Node API to get a local service proxy
+ */
+ public void launchBindingSCACalculator(){
+ Node node = NodeFactory.newInstance().createNode(new Contribution("c1", "../binding-sca/contribution-calculator/target/sample-contribution-binding-sca-calculator.jar"));
+ node.start();
+
+ CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ // TODO - could use JUnit assertions but don't want to have to handle JUnit dependency from Ant script
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+ node.stop();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingWSCalculator.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingWSCalculator.java
new file mode 100644
index 0000000000..f23257769e
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingWSCalculator.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and locate and invoke an SCA component
+ */
+public class JSELauncherBindingWSCalculator {
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherBindingWSCalculator launcher = new JSELauncherBindingWSCalculator();
+ launcher.launchBindingWSCalculator();
+ }
+
+ /*
+ * Using the Tuscany Node API to load a contribution.
+ * Using the Tuscany Node API to get a local service proxy
+ */
+ public void launchBindingWSCalculator(){
+ Node node = NodeFactory.newInstance().createNode(new Contribution("c1", "../binding-ws/contribution-calculator/target/sample-contribution-binding-ws-calculator.jar"));
+ node.start();
+
+ CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ // TODO - could use JUnit assertions but don't want to have to handle JUnit dependency from Ant script
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+ node.stop();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationJavaCalculator.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationJavaCalculator.java
new file mode 100644
index 0000000000..4aebda1bcf
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationJavaCalculator.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and locate and invoke an SCA component
+ */
+public class JSELauncherImplementationJavaCalculator {
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherImplementationJavaCalculator launcher = new JSELauncherImplementationJavaCalculator();
+ launcher.launchImplementationJavaCalculator();
+ }
+
+ public void launchImplementationJavaCalculator(){
+ Node node = NodeFactory.newInstance().createNode(new Contribution("c1", "../implementation-java/contribution-calculator/target/classes"));
+ node.start();
+
+ node.stop();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationScriptCalculator.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationScriptCalculator.java
new file mode 100644
index 0000000000..ca652718d7
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationScriptCalculator.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import calculator.CalculatorService;
+
+/**
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and locate and invoke an SCA component
+ */
+public class JSELauncherImplementationScriptCalculator {
+
+ public static void main(String[] args) throws Exception {
+ JSELauncherImplementationScriptCalculator launcher = new JSELauncherImplementationScriptCalculator();
+ launcher.launchImplementationScriptCalculator();
+ }
+
+ /*
+ * Using the Tuscany Node API to load a contribution.
+ * Using the Tuscany Node API to get a local service proxy
+ */
+ public void launchImplementationScriptCalculator(){
+ Node node = NodeFactory.newInstance().createNode(new Contribution("c1", "../implementation-script/contribution-calculator/target/sample-contribution-implementation-script-calculator.jar"));
+ node.start();
+
+ CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ // TODO - could use JUnit assertions but don't want to have to handle JUnit dependency from Ant script
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+ node.stop();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/RuntimeIntegration.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/RuntimeIntegration.java
new file mode 100644
index 0000000000..fdff16c12c
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/RuntimeIntegration.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+
+/**
+ * Base JSE launcher function
+ */
+public class RuntimeIntegration {
+
+
+ public Node startNode(Contribution... contributions){
+ Node node = NodeFactory.newInstance().createNode(contributions);
+ node.start();
+ return node;
+ }
+
+ public void stopNode(Node node){
+ node.stop();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/SampleLauncherException.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/SampleLauncherException.java
new file mode 100644
index 0000000000..f2ed3d421d
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/SampleLauncherException.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package launcher;
+
+/**
+ * This exception signals problems in the management of SCA component execution.
+ */
+public class SampleLauncherException extends RuntimeException {
+ /**
+ * Constructs a SampleLauncherException with no detail message.
+ */
+ public SampleLauncherException() {
+ super();
+ }
+
+ /**
+ * Constructs a SampleLauncherException with the specified detail
+ * message.
+ *
+ * @param message the detail message
+ */
+ public SampleLauncherException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java
new file mode 100644
index 0000000000..6bbbe32a7f
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package launcher;
+
+import org.junit.Test;
+
+/**
+ * Test sample contributions.
+ */
+public class LauncherTestCase {
+
+ @Test
+ public void testContributionBindingSCACalculator() throws Exception {
+ JSELauncherBindingSCACalculator.main(null);
+ }
+
+
+ @Test
+ public void testContributionBindingWSCalculator() throws Exception {
+ JSELauncherBindingWSCalculator.main(null);
+ }
+
+ @Test
+ public void testContributionBindingRMICalculator() throws Exception {
+ JSELauncherBindingRMICalculator.main(null);
+ }
+
+ @Test
+ public void testContributionImplementationJavaCalculator() throws Exception {
+ JSELauncherImplementationJavaCalculator.main(null);
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/README b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/README
new file mode 100644
index 0000000000..362d6032d2
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/README
@@ -0,0 +1,24 @@
+OSGI Sample Launcher
+===================
+
+This directory contains a sample launcher for the running the
+tuscany sample contributions in an OSGI environment.
+
+The difference between this sample and the sample with the name without the
+-base suffix is that this one uses the Tuscany aggregated jar to minimize the
+jars a user needs to use.
+
+The README file in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running sample contributions using the
+tuscany sample launchers. ( where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive)
+
+To use this sample OSGI launcher with ant excute the command
+
+ant run-<contributionname>
+
+where run-<contributionname> is one of the targets in the build.xml file
+
+To use this sample launcher to run all of the contributions as junit test cases,
+execute the command "mvn" in the launcher directory.
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/build.xml b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/build.xml
new file mode 100644
index 0000000000..139ff054f7
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/build.xml
@@ -0,0 +1,94 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project name="launcher-embedded-osgi" default="run">
+ <property name="tuscany.home" value="../.."/>
+ <property name="jar.name" value="sample-launcher-embedded-osgi.jar" />
+ <property name="main.class" value="launcher.SampleJSELauncher" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-base-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run" depends="compile">
+ <echo>Please use 'ant run-name-of-sample-contribution-to-run' for example, try one of</echo>
+ <echo> 'ant run-contribution-binding-sca-calculator' </echo>
+ </target>
+
+ <target name="run-contribution-binding-sca-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/modules">
+ <include name="tuscany-node-api-*.jar" />
+ <include name="tuscany-sca-api-*.jar" />
+ <include name="tuscany-node-launcher-equinox-*.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-binding-sca-calculator"/>
+ </java>
+ <echo> and ant run </echo>
+ </target>
+
+ <!-- TODO - this runs from mvn but not from ant so there is some issue with the
+ way the environment gets set up
+ <target name="run-contribution-binding-ws-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/modules">
+ <include name="tuscany-node-api-*.jar" />
+ <include name="tuscany-sca-api-*.jar" />
+ <include name="tuscany-node-launcher-equinox-*.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-binding-ws-calculator"/>
+ </java>
+ </target>
+ -->
+
+</project>
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/pom.xml b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/pom.xml
new file mode 100644
index 0000000000..aa0876b338
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/pom.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-launcher-embedded-osgi-base</artifactId>
+ <name>Apache Tuscany SCA Sample Launcher Embedded OSGi using base jar</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.shades</groupId>
+ <artifactId>tuscany-base-nodep</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse</groupId>
+ <artifactId>osgi</artifactId>
+ <version>3.5.0-v20090520</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>services</artifactId>
+ <version>3.2.0-v20090520-1800</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/calculator/CalculatorService.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..a59a7c3b16
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/calculator/CalculatorService.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/RuntimeIntegration.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/RuntimeIntegration.java
new file mode 100644
index 0000000000..2c1cdf187a
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/RuntimeIntegration.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.equinox.launcher.LauncherException;
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+
+
+/**
+ * OSGi launcher function
+ */
+public class RuntimeIntegration {
+
+ public Node startNode(Contribution... contributions){
+ NodeLauncher launcher = NodeLauncher.newInstance();
+
+ // TODO - why do we have 3 different versions of the Contribution class?
+ org.apache.tuscany.sca.node.equinox.launcher.Contribution equinoxContributions[] =
+ new org.apache.tuscany.sca.node.equinox.launcher.Contribution[contributions.length];
+ int i = 0;
+ for (Contribution inContrib : contributions) {
+ org.apache.tuscany.sca.node.equinox.launcher.Contribution outContrib =
+ new org.apache.tuscany.sca.node.equinox.launcher.Contribution(inContrib.getURI(), inContrib.getLocation());
+ equinoxContributions[i] = outContrib;
+ i++;
+ }
+ Node node = null;
+
+ try {
+ node = launcher.createNode(null, equinoxContributions);
+ } catch (LauncherException ex) {
+ throw new SampleLauncherException(ex.getMessage());
+ }
+ node.start();
+ return node;
+ }
+
+ public void stopNode(Node node){
+ node.stop();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/SampleJSELauncher.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/SampleJSELauncher.java
new file mode 100644
index 0000000000..b3a0b1ce7e
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/SampleJSELauncher.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launcher;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+import calculator.CalculatorService;
+
+
+/**
+ * This client program shows how to create an embedded SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class SampleJSELauncher extends RuntimeIntegration {
+
+ public static void main(String[] args) throws Exception {
+ SampleJSELauncher launcher = new SampleJSELauncher();
+
+ String contribution = null;
+
+ if (args == null || args.length != 1){
+ System.out.println("Please provide the name of the sample contribution to run as a parameter");
+ System.out.println("Running binding-sca-calculator by default");
+ contribution = "contribution-binding-sca-calculator";
+ } else {
+ contribution = args[0];
+ }
+
+ if (contribution.equals("contribution-binding-sca-calculator")){
+ launcher.launchBindingSCACalculator();
+ } else if (contribution.equals("contribution-binding-ws-calculator")){
+ launcher.launchBindingWSCalculator();
+ } else {
+ System.out.println("Sample contribution " + contribution + "not found");
+ }
+
+ }
+
+ /**
+ * The contribution-binding-sca-calculator contribution includes a client component
+ * that calls the CalculatorServiceComponent from an operation marked by @Init.
+ */
+ public void launchBindingSCACalculator(){
+ Node node = startNode(new Contribution("c1", "../binding-sca/contribution-calculator/target/sample-contribution-binding-sca-calculator.jar"));
+
+ stopNode(node);
+ }
+
+ /*
+ * Using a Tuscany specific mechanism for getting at local service proxies
+ */
+ public void launchBindingWSCalculator() throws NoSuchDomainException, NoSuchServiceException{
+ Node node = startNode(new Contribution("c1", "../binding-ws/contribution-calculator/target/sample-contribution-binding-ws-calculator.jar"));
+
+ CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+ stopNode(node);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/SampleLauncherException.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/SampleLauncherException.java
new file mode 100644
index 0000000000..1eacb94b19
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/SampleLauncherException.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package launcher;
+
+/**
+ * This exception signals problems in the management of SCA component execution.
+ */
+public class SampleLauncherException extends RuntimeException {
+ /**
+ * Constructs a SampleLauncherException with no detail message.
+ */
+ public SampleLauncherException() {
+ super();
+ }
+
+ /**
+ * Constructs a SampleLauncherException with the specified detail
+ * message.
+ *
+ * @param message the detail message
+ */
+ public SampleLauncherException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/test/java/launcher/LauncherTestCase.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/test/java/launcher/LauncherTestCase.java
new file mode 100644
index 0000000000..9228d33018
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi-base/src/test/java/launcher/LauncherTestCase.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package launcher;
+
+import org.junit.Test;
+
+
+
+/**
+ * Test the Calculator composition.
+ */
+public class LauncherTestCase {
+
+ @Test
+ public void testContributionBindingSCACalculator() throws Exception {
+ SampleJSELauncher.main(new String[] {"contribution-binding-sca-calculator"});
+ }
+
+ @Test
+ public void testContributionBindingWSCalculator() throws Exception {
+ SampleJSELauncher.main(new String[] {"contribution-binding-ws-calculator"});
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/README b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/README
new file mode 100644
index 0000000000..01d277ae09
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/README
@@ -0,0 +1,20 @@
+OSGI Sample Launcher
+===================
+
+This directory contains a sample launcher for the running the
+tuscany sample contributions in an OSGI environment.
+
+The README file in the <distribution-unpack-dir>/samples directory provides
+general instructions about building and running sample contributions using the
+tuscany sample launchers. ( where
+distribution-unpack-dir is the directory in which you unpacked the tuscany
+binary distribution archive)
+
+To use this sample OSGI launcher with ant excute the command
+
+ant run-<contributionname>
+
+where run-<contributionname> is one of the targets in the build.xml file
+
+To use this sample launcher to run all of the contributions as junit test cases,
+execute the command "mvn" in the launcher directory.
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/build.xml b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/build.xml
new file mode 100644
index 0000000000..f08d19e472
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/build.xml
@@ -0,0 +1,94 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project name="launcher-embedded-osgi" default="run">
+ <property name="tuscany.home" value="../.."/>
+ <property name="jar.name" value="sample-launcher-embedded-osgi.jar" />
+ <property name="main.class" value="launcher.SampleJSELauncher" />
+
+ <echo>${tuscany.home}</echo>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java"
+ destdir="target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5"
+ failonerror="true">
+ <classpath>
+ <fileset dir="${tuscany.home}/lib">
+ <include name="tuscany-base-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ <manifest>
+ <attribute name="Main-Class" value="${main.class}" />
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="run" depends="compile">
+ <echo>Please use 'ant run-name-of-sample-contribution-to-run' for example, try one of</echo>
+ <echo> 'ant run-contribution-binding-sca-calculator' </echo>
+ </target>
+
+ <target name="run-contribution-binding-sca-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/modules">
+ <include name="tuscany-node-api-*.jar" />
+ <include name="tuscany-sca-api-*.jar" />
+ <include name="tuscany-node-launcher-equinox-*.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-binding-sca-calculator"/>
+ </java>
+ <echo> and ant run </echo>
+ </target>
+
+ <!-- TODO - this runs from mvn but not from ant so there is some issue with the
+ way the environment gets set up
+ <target name="run-contribution-binding-ws-calculator" depends="compile">
+ <java classname="${main.class}"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="target/${jar.name}"/>
+ <fileset dir="${tuscany.home}/modules">
+ <include name="tuscany-node-api-*.jar" />
+ <include name="tuscany-sca-api-*.jar" />
+ <include name="tuscany-node-launcher-equinox-*.jar" />
+ </fileset>
+ </classpath>
+ <arg value="contribution-binding-ws-calculator"/>
+ </java>
+ </target>
+ -->
+
+</project>
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/pom.xml b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/pom.xml
new file mode 100644
index 0000000000..c3cf7e6577
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/pom.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-launcher-embedded-osgi</artifactId>
+ <name>Apache Tuscany SCA Sample Launcher Embedded OSGi</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+
+ <plugins>
+
+ </plugins>
+ </build>
+</project>
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/calculator/CalculatorService.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..12d80ffd1c
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/calculator/CalculatorService.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package calculator;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+/**
+ * The Calculator service interface.
+ */
+@Remotable
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/RuntimeIntegration.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/RuntimeIntegration.java
new file mode 100644
index 0000000000..f4a2f0780c
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/RuntimeIntegration.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launcher;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.equinox.launcher.LauncherException;
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+
+
+/**
+ * OSGi launcher function
+ */
+public class RuntimeIntegration {
+
+ public Node startNode(Contribution... contributions){
+ NodeLauncher launcher = NodeLauncher.newInstance();
+
+ // TODO - why do we have 3 different versions of the Contribution class?
+ org.apache.tuscany.sca.node.equinox.launcher.Contribution equinoxContributions[] =
+ new org.apache.tuscany.sca.node.equinox.launcher.Contribution[contributions.length];
+ int i = 0;
+ for (Contribution inContrib : contributions) {
+ org.apache.tuscany.sca.node.equinox.launcher.Contribution outContrib =
+ new org.apache.tuscany.sca.node.equinox.launcher.Contribution(inContrib.getURI(), inContrib.getLocation());
+ equinoxContributions[i] = outContrib;
+ i++;
+ }
+ Node node = null;
+
+ try {
+ node = launcher.createNode(null, equinoxContributions);
+ } catch (LauncherException ex) {
+ throw new SampleLauncherException(ex.getMessage());
+ }
+ node.start();
+ return node;
+ }
+
+ public void stopNode(Node node){
+ node.stop();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/SampleJSELauncher.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/SampleJSELauncher.java
new file mode 100644
index 0000000000..bfc4681836
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/SampleJSELauncher.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package launcher;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+import calculator.CalculatorService;
+
+
+/**
+ * This client program shows how to create an embedded SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+public class SampleJSELauncher extends RuntimeIntegration {
+
+ public static void main(String[] args) throws Exception {
+ SampleJSELauncher launcher = new SampleJSELauncher();
+
+ String contribution = null;
+
+ if (args == null || args.length != 1){
+ System.out.println("Please provide the name of the sample contribution to run as a parameter");
+ System.out.println("Running binding-sca-calculator by default");
+ contribution = "contribution-binding-sca-calculator";
+ } else {
+ contribution = args[0];
+ }
+
+ if (contribution.equals("contribution-binding-sca-calculator")){
+ launcher.launchBindingSCACalculator();
+ } else if (contribution.equals("contribution-binding-ws-calculator")){
+ launcher.launchBindingWSCalculator();
+ } else {
+ System.out.println("Sample contribution " + contribution + "not found");
+ }
+
+ }
+
+ /**
+ * The contribution-binding-sca-calculator contribution includes a client component
+ * that calls the CalculatorServiceComponent from an operation marked by @Init.
+ */
+ public void launchBindingSCACalculator(){
+ Node node = startNode(new Contribution("c1", "../binding-sca/contribution-calculator/target/sample-contribution-binding-sca-calculator.jar"));
+
+ stopNode(node);
+ }
+
+ /*
+ * Using a Tuscany specific mechanism for getting at local service proxies
+ */
+ public void launchBindingWSCalculator() throws NoSuchDomainException, NoSuchServiceException{
+ Node node = startNode(new Contribution("c1", "../binding-ws/contribution-calculator/target/sample-contribution-binding-ws-calculator.jar"));
+
+ CalculatorService calculator = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ double result = calculator.add(3, 2);
+ System.out.println("3 + 2 = " + result);
+ if (result != 5.0){
+ throw new SampleLauncherException();
+ }
+
+ stopNode(node);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/SampleLauncherException.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/SampleLauncherException.java
new file mode 100644
index 0000000000..f2ed3d421d
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/SampleLauncherException.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package launcher;
+
+/**
+ * This exception signals problems in the management of SCA component execution.
+ */
+public class SampleLauncherException extends RuntimeException {
+ /**
+ * Constructs a SampleLauncherException with no detail message.
+ */
+ public SampleLauncherException() {
+ super();
+ }
+
+ /**
+ * Constructs a SampleLauncherException with the specified detail
+ * message.
+ *
+ * @param message the detail message
+ */
+ public SampleLauncherException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/test/java/launcher/LauncherTestCase.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/test/java/launcher/LauncherTestCase.java
new file mode 100644
index 0000000000..7b72ec7aee
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-embedded-osgi/src/test/java/launcher/LauncherTestCase.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package launcher;
+
+import org.junit.Test;
+
+
+
+/**
+ * Test the Calculator composition.
+ */
+public class LauncherTestCase {
+
+ @Test
+ public void testContributionBindingSCACalculator() throws Exception {
+ SampleJSELauncher.main(new String[] {"contribution-binding-sca-calculator"});
+ }
+
+ @Test
+ public void testContributionBindingWSCalculator() throws Exception {
+ SampleJSELauncher.main(new String[] {"contribution-binding-ws-calculator"});
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-maven/README b/sca-java-2.x/trunk/samples/running-tuscany/launcher-maven/README
new file mode 100644
index 0000000000..ff976c3515
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-maven/README
@@ -0,0 +1,18 @@
+To execute a sample contribution from Maven
+
+look for contributions that have the following configuration in their pom.xml file:
+
+<plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-tuscany-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+</plugin>
+
+For contributions that have this, for example, binding-sca/contribution-calculator, do the following
+
+cd samples/binding-sca/contribution-calculator
+mvn tuscany:run
+
+This will launch the contribution in the Tuscany runtime 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 calculator-scaclient.
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/README b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/README
new file mode 100644
index 0000000000..abdf824621
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/README
@@ -0,0 +1,34 @@
+Sample Tuscany Shell
+====================
+
+This directory contains a sample shell program supporting simple commands to
+start and stop SCA composites.
+
+To build the sample shell do this:
+mvn install
+
+To run it:
+./sca
+
+at the prompt:
+start myNode mySampleContrib ../contribution-implementation-java-calculator/target/classes
+
+or:
+start myNode mySampleContrib http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+
+also try:
+status
+stop myNode
+bye
+
+Starting and stopping composites is pretty fast. To see that, try the following
+two scripts, which start/stop a sample composite 10 times.
+
+./sca <scripts/test.txt
+or
+./sca <scripts/test-remote.txt
+
+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.
+
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/pom.xml b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/pom.xml
new file mode 100644
index 0000000000..cde0e15f62
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/pom.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-samples</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-launcher-shell</artifactId>
+ <name>Apache Tuscany SCA Sample Launcher Shell</name>
+ <packaging>war</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-web20</artifactId>
+ <type>pom</type>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>scashell</finalName>
+ </build>
+</project>
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/sca b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/sca
new file mode 100755
index 0000000000..8f6cf268b3
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/sca
@@ -0,0 +1,19 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+
+java -classpath target/classes:`ls target/scashell/WEB-INF/lib/*.jar | awk '{ printf "%s:", $1}'` sample.Shell
+
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/sca.bat b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/sca.bat
new file mode 100644
index 0000000000..5110effc25
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/sca.bat
@@ -0,0 +1,30 @@
+@echo off
+rem Licensed to the Apache Software Foundation (ASF) under one
+rem or more contributor license agreements. See the NOTICE file
+rem distributed with this work for additional information
+rem regarding copyright ownership. The ASF licenses this file
+rem to you under the Apache License, Version 2.0 (the
+rem "License"); you may not use this file except in compliance
+rem with the License. You may obtain a copy of the License at
+rem
+rem http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing,
+rem software distributed under the License is distributed on an
+rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+rem KIND, either express or implied. See the License for the
+rem specific language governing permissions and limitations
+
+rem cd to target to reduce the length of the classpath. It blows up cmd.exe without this
+cd target
+set _CLASSPATH=.\classes
+for %%i in (.\scashell\WEB-INF\lib\*.jar) do call:setClasspath %%i
+set CLASSPATH=%_CLASSPATH%
+@echo on
+java sample.Shell
+cd ..
+goto:eof
+
+:setClasspath
+set _CLASSPATH=%_CLASSPATH%;%1
+goto:eof \ No newline at end of file
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-remote.txt b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-remote.txt
new file mode 100644
index 0000000000..fd7bd5766a
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-remote.txt
@@ -0,0 +1,36 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+stop foo
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-start.txt b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-start.txt
new file mode 100644
index 0000000000..71f7f3f4aa
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-start.txt
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+
+start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar
+status
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-status.txt b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-status.txt
new file mode 100644
index 0000000000..4df56e85e8
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-status.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+
+status
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-stop.txt b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-stop.txt
new file mode 100644
index 0000000000..c942a3087b
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test-stop.txt
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+
+stop foo
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test.txt b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test.txt
new file mode 100644
index 0000000000..66c760b937
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/scripts/test.txt
@@ -0,0 +1,36 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
+start foo c1 ../contribution-implementation-java-calculator/target/classes
+stop foo
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/java/sample/Shell.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/java/sample/Shell.java
new file mode 100644
index 0000000000..f2790409e9
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/java/sample/Shell.java
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package sample;
+
+import static java.lang.System.in;
+import static java.lang.System.out;
+import static java.util.Collections.emptyList;
+import static java.util.Collections.singletonList;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ * A little SCA command shell.
+ */
+public class Shell {
+ final NodeFactory nodeFactory;
+
+ public static class NodeInfo {
+ final String name;
+ final String curi;
+ final String cloc;
+ final Node node;
+
+ NodeInfo(final String name, final String curi, final String cloc, final Node node) {
+ this.name = name;
+ this.curi = curi;
+ this.cloc = cloc;
+ this.node = node;
+ }
+
+ public String toString() {
+ return name + " " + curi + " " + cloc;
+ }
+ }
+
+ final Map<String, NodeInfo> nodes = new HashMap<String, NodeInfo>();
+ final List<String> history = new ArrayList<String>();
+
+ public Shell(NodeFactory nf) {
+ this.nodeFactory = nf;
+ }
+
+ List<?> start(final String name, final String curi, final String cloc) {
+ if(nodes.containsKey(name))
+ return emptyList();
+ final Node node = nodeFactory.createNode(new Contribution(curi, cloc));
+ nodes.put(name, new NodeInfo(name, curi, cloc, node));
+ node.start();
+ return emptyList();
+ }
+
+ List<?> stop(final String name) {
+ final NodeInfo ninfo = nodes.get(name);
+ if(ninfo == null)
+ return emptyList();
+ ninfo.node.stop();
+ nodes.remove(name);
+ return emptyList();
+ }
+
+ List<?> stop() {
+ for(NodeInfo ninfo: nodes.values())
+ ninfo.node.stop();
+ nodes.clear();
+ return emptyList();
+ }
+
+ List<?> restart(final String name, final String curi, final String cloc) {
+ stop(name);
+ return start(name, curi, cloc);
+ }
+
+ List<?> status() {
+ return new ArrayList<Object>(nodes.values());
+ }
+
+ List<?> history() {
+ return history;
+ }
+
+ List<?> bye() {
+ return null;
+ }
+
+ List<String> read(final BufferedReader r) throws IOException {
+ final String l = r.readLine();
+ history.add(l);
+ return l != null ? Arrays.asList(l.split(" ")) : singletonList("bye");
+ }
+
+ Callable<List<?>> eval(final List<String> toks) {
+ final String op = toks.get(0);
+ if(op.equals("start"))
+ return new Callable<List<?>>() {
+ public List<?> call() {
+ return start(toks.get(1), toks.get(2), toks.get(3));
+ }
+ };
+ if(op.equals("stop"))
+ return new Callable<List<?>>() {
+ public List<?> call() {
+ if(toks.size() == 1)
+ return stop();
+ return stop(toks.get(1));
+ }
+ };
+ if(op.equals("restart"))
+ return new Callable<List<?>>() {
+ public List<?> call() {
+ return restart(toks.get(1), toks.get(2), toks.get(3));
+ }
+ };
+ if(op.equals("status"))
+ return new Callable<List<?>>() {
+ public List<?> call() {
+ return status();
+ }
+ };
+ if(op.equals("history"))
+ return new Callable<List<?>>() {
+ public List<?> call() {
+ return history();
+ }
+ };
+ if(op.equals("bye"))
+ return new Callable<List<?>>() {
+ public List<?> call() {
+ return bye();
+ }
+ };
+ return new Callable<List<?>>() {
+ public List<?> call() {
+ return emptyList();
+ }
+ };
+ }
+
+ List<?> apply(final Callable<List<?>> func) {
+ try {
+ return func.call();
+ } catch(Exception e) {
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ return singletonList(sw);
+ }
+ }
+
+ boolean print(final List<?> l, PrintWriter w) {
+ if(l == null)
+ return false;
+ for(Object o: l)
+ w.println(o);
+ return true;
+ }
+
+ public Map<String, NodeInfo> run(final BufferedReader r, final PrintWriter w) throws IOException {
+ while(print(apply(eval(read(r))), w))
+ ;
+ r.close();
+ return nodes;
+ }
+
+ public static void main(final String[] args) throws Exception {
+ new Shell(NodeFactory.newInstance()).run(new BufferedReader(new InputStreamReader(in)), new PrintWriter(out, true));
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/java/sample/ShellServlet.java b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/java/sample/ShellServlet.java
new file mode 100644
index 0000000000..55aadbd09b
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/java/sample/ShellServlet.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package sample;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.host.webapp.WebAppHelper;
+
+public class ShellServlet extends HttpServlet {
+ static final long serialVersionUID = 1L;
+
+ Shell shell;
+
+ public void init() {
+ shell = new Shell(WebAppHelper.getNodeFactory());
+ }
+
+ public void destroy() {
+ shell.stop();
+ }
+
+ protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws IOException {
+ shell.run(new BufferedReader(new InputStreamReader(new URL(req.getParameter("conf")).openStream())), resp.getWriter());
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/webapp/WEB-INF/web.xml b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..ac1ad1cc8e
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
+ <display-name>scashell</display-name>
+
+ <listener><listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class></listener>
+
+ <filter>
+ <filter-name>tuscany</filter-name>
+ <filter-class>org.apache.tuscany.sca.host.webapp.TuscanyServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>tuscany</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <servlet>
+ <servlet-name>ShellServlet</servlet-name>
+ <servlet-class>sample.ShellServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>ShellServlet</servlet-name>
+ <url-pattern>/run</url-pattern>
+ </servlet-mapping>
+
+ <welcome-file-list id="WelcomeFileList">
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+</web-app>
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/webapp/index.html b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/webapp/index.html
new file mode 100644
index 0000000000..d2ae91e0e9
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-shell/src/main/webapp/index.html
@@ -0,0 +1,40 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+<head>
+<title>Sample Runtime Shell</title>
+</head>
+<body>
+<h1>It works</h1>
+
+<p>This Web app runs a sample Tuscany runtime shell similar to samples/launcher-shell.<br/>
+To see how it works and what configuration commands are supported, just read the Shell program's <a href="http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/launcher-shell/src/main/java/sample/Shell.java">source code</a>.</p>
+
+<p>Configuration commands can be provided through a text document served from a Web location, for example:<br/>
+<a href="http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/launcher-shell/scripts/test-start.txt">http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/launcher-shell/scripts/test-start.txt</a></p>
+
+<p>To run that particular configuration script just point your Web browser to:<br/>
+<a href="http://localhost:8080/scashell/run?conf=http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/launcher-shell/scripts/test-start.txt">http://localhost:8080/scashell/run?conf=http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/launcher-shell/scripts/test-start.txt</a><br/>
+To run the script again and refresh the runtime shell, just refresh that page in your Web browser.
+</p>
+
+<p>Sample configuration script samples are available in the Tuscany Subversion repository <a href="http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/launcher-shell/scripts/">there</a>.
+
+</body>
+</html>
diff --git a/sca-java-2.x/trunk/samples/running-tuscany/launcher-webapp/README b/sca-java-2.x/trunk/samples/running-tuscany/launcher-webapp/README
new file mode 100644
index 0000000000..4031b9c0bd
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/running-tuscany/launcher-webapp/README
@@ -0,0 +1,29 @@
+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
+
+cd samples/binding-jsonrpc/contribution-calculator-webapp
+mvn
+cp target/sample-contribution-binding-jsonrpc-calculator-webapp.war your_container_deployment-dir
+
+
+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:
+
+<plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+</plugin>
+
+For contributions that have this, for example, binding-jsonrpc/contribution-calculator-webapp, do the following
+
+cd samples/binding-sca/contribution-calculator
+mvn jetty:run
+
+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:
+
+http://localhost:8080/sample-contribution-binding-jsonrpc-calculator-webapp/