summaryrefslogtreecommitdiffstats
path: root/sandbox/samples/running-tuscany
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-09-20 12:32:50 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-09-20 12:32:50 +0000
commit4f6a51d428d96dbb476d8412143748e841993372 (patch)
treec2a264458c31dae29adb516fe7978373e7b49e77 /sandbox/samples/running-tuscany
parent67096b069e946edd0421284519010b3e6e5e49f6 (diff)
Copy trunk samples to sanbox to experiment with renames and moves
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@998905 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/samples/running-tuscany')
-rw-r--r--sandbox/samples/running-tuscany/launcher-command-line/README13
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-jse/README20
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-jse/build.xml110
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-jse/pom.xml94
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java38
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingJSONRPCCalculator.java59
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingRMICalculator.java61
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingSCACalculator.java59
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingWSCalculator.java59
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationJavaCalculator.java46
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationScriptCalculator.java59
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/RuntimeIntegration.java43
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/SampleLauncherException.java42
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java48
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi-base/README24
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi-base/build.xml94
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi-base/pom.xml71
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/calculator/CalculatorService.java38
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/RuntimeIntegration.java61
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/SampleJSELauncher.java89
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/SampleLauncherException.java42
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/test/java/launcher/LauncherTestCase.java39
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi/README20
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi/build.xml94
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi/pom.xml76
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi/src/main/java/calculator/CalculatorService.java38
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/RuntimeIntegration.java61
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/SampleJSELauncher.java89
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/SampleLauncherException.java42
-rw-r--r--sandbox/samples/running-tuscany/launcher-embedded-osgi/src/test/java/launcher/LauncherTestCase.java39
-rw-r--r--sandbox/samples/running-tuscany/launcher-maven/README18
-rw-r--r--sandbox/samples/running-tuscany/launcher-osgi/README33
-rw-r--r--sandbox/samples/running-tuscany/launcher-shell/README34
-rw-r--r--sandbox/samples/running-tuscany/launcher-shell/pom.xml79
-rwxr-xr-xsandbox/samples/running-tuscany/launcher-shell/sca19
-rw-r--r--sandbox/samples/running-tuscany/launcher-shell/sca.bat30
-rw-r--r--sandbox/samples/running-tuscany/launcher-shell/scripts/test-remote.txt36
-rw-r--r--sandbox/samples/running-tuscany/launcher-shell/scripts/test-start.txt18
-rw-r--r--sandbox/samples/running-tuscany/launcher-shell/scripts/test-status.txt17
-rw-r--r--sandbox/samples/running-tuscany/launcher-shell/scripts/test-stop.txt17
-rw-r--r--sandbox/samples/running-tuscany/launcher-shell/scripts/test.txt36
-rw-r--r--sandbox/samples/running-tuscany/launcher-shell/src/main/java/sample/Shell.java203
-rw-r--r--sandbox/samples/running-tuscany/launcher-shell/src/main/java/sample/ShellServlet.java48
-rw-r--r--sandbox/samples/running-tuscany/launcher-shell/src/main/webapp/WEB-INF/web.xml48
-rw-r--r--sandbox/samples/running-tuscany/launcher-shell/src/main/webapp/index.html42
-rw-r--r--sandbox/samples/running-tuscany/launcher-webapp/README29
-rw-r--r--sandbox/samples/running-tuscany/pom.xml53
47 files changed, 2428 insertions, 0 deletions
diff --git a/sandbox/samples/running-tuscany/launcher-command-line/README b/sandbox/samples/running-tuscany/launcher-command-line/README
new file mode 100644
index 0000000000..bf963ea98e
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-jse/README b/sandbox/samples/running-tuscany/launcher-embedded-jse/README
new file mode 100644
index 0000000000..7108333efa
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-jse/build.xml b/sandbox/samples/running-tuscany/launcher-embedded-jse/build.xml
new file mode 100644
index 0000000000..05c7ab3c49
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-jse/pom.xml b/sandbox/samples/running-tuscany/launcher-embedded-jse/pom.xml
new file mode 100644
index 0000000000..a30d55d2e9
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java b/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..12d80ffd1c
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingJSONRPCCalculator.java b/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingJSONRPCCalculator.java
new file mode 100644
index 0000000000..3d6af9f561
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingRMICalculator.java b/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingRMICalculator.java
new file mode 100644
index 0000000000..0c9c820ccb
--- /dev/null
+++ b/sandbox/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", "../../sca-features//binding-rmi/contribution-calculator-service/target/classes"));
+ Node node2 = NodeFactory.newInstance().createNode(new Contribution("c1", "../../sca-features//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/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingSCACalculator.java b/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingSCACalculator.java
new file mode 100644
index 0000000000..49960a7506
--- /dev/null
+++ b/sandbox/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", "../../sca-features/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/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingWSCalculator.java b/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherBindingWSCalculator.java
new file mode 100644
index 0000000000..71ff526589
--- /dev/null
+++ b/sandbox/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", "../../sca-features/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/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationJavaCalculator.java b/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationJavaCalculator.java
new file mode 100644
index 0000000000..74202d5b86
--- /dev/null
+++ b/sandbox/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", "../../sca-features/implementation-java/contribution-calculator/target/classes"));
+ node.start();
+
+ node.stop();
+ }
+
+}
diff --git a/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationScriptCalculator.java b/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/JSELauncherImplementationScriptCalculator.java
new file mode 100644
index 0000000000..ca652718d7
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/RuntimeIntegration.java b/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/RuntimeIntegration.java
new file mode 100644
index 0000000000..fdff16c12c
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/SampleLauncherException.java b/sandbox/samples/running-tuscany/launcher-embedded-jse/src/main/java/launcher/SampleLauncherException.java
new file mode 100644
index 0000000000..f2ed3d421d
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java b/sandbox/samples/running-tuscany/launcher-embedded-jse/src/test/java/launcher/LauncherTestCase.java
new file mode 100644
index 0000000000..6bbbe32a7f
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/README b/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/README
new file mode 100644
index 0000000000..362d6032d2
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/build.xml b/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/build.xml
new file mode 100644
index 0000000000..139ff054f7
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/pom.xml b/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/pom.xml
new file mode 100644
index 0000000000..aa0876b338
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/calculator/CalculatorService.java b/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..a59a7c3b16
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/RuntimeIntegration.java b/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/RuntimeIntegration.java
new file mode 100644
index 0000000000..2c1cdf187a
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/SampleJSELauncher.java b/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/SampleJSELauncher.java
new file mode 100644
index 0000000000..34ee729921
--- /dev/null
+++ b/sandbox/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", "../../sca-features/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", "../../sca-features/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/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/SampleLauncherException.java b/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/main/java/launcher/SampleLauncherException.java
new file mode 100644
index 0000000000..1eacb94b19
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/test/java/launcher/LauncherTestCase.java b/sandbox/samples/running-tuscany/launcher-embedded-osgi-base/src/test/java/launcher/LauncherTestCase.java
new file mode 100644
index 0000000000..9228d33018
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-osgi/README b/sandbox/samples/running-tuscany/launcher-embedded-osgi/README
new file mode 100644
index 0000000000..01d277ae09
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-osgi/build.xml b/sandbox/samples/running-tuscany/launcher-embedded-osgi/build.xml
new file mode 100644
index 0000000000..f08d19e472
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-osgi/pom.xml b/sandbox/samples/running-tuscany/launcher-embedded-osgi/pom.xml
new file mode 100644
index 0000000000..c3cf7e6577
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-osgi/src/main/java/calculator/CalculatorService.java b/sandbox/samples/running-tuscany/launcher-embedded-osgi/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..12d80ffd1c
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/RuntimeIntegration.java b/sandbox/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/RuntimeIntegration.java
new file mode 100644
index 0000000000..f4a2f0780c
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/SampleJSELauncher.java b/sandbox/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/SampleJSELauncher.java
new file mode 100644
index 0000000000..06b646f0d2
--- /dev/null
+++ b/sandbox/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", "../../sca-features/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", "../../sca-features/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/sandbox/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/SampleLauncherException.java b/sandbox/samples/running-tuscany/launcher-embedded-osgi/src/main/java/launcher/SampleLauncherException.java
new file mode 100644
index 0000000000..f2ed3d421d
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-embedded-osgi/src/test/java/launcher/LauncherTestCase.java b/sandbox/samples/running-tuscany/launcher-embedded-osgi/src/test/java/launcher/LauncherTestCase.java
new file mode 100644
index 0000000000..7b72ec7aee
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-maven/README b/sandbox/samples/running-tuscany/launcher-maven/README
new file mode 100644
index 0000000000..ff976c3515
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-osgi/README b/sandbox/samples/running-tuscany/launcher-osgi/README
new file mode 100644
index 0000000000..6df2c1d2f2
--- /dev/null
+++ b/sandbox/samples/running-tuscany/launcher-osgi/README
@@ -0,0 +1,33 @@
+The Tuscany runtime can be run in and OSGi container.
+
+Running in Equinox
+------------------
+
+On Windows, run
+java -jar ..\..\modules\osgi-3.5.0-v20090520.jar -configuration ..\..\features\configuration -clean -console
+
+On *Unix, run
+java -jar ../../modules/osgi-3.5.0-v20090520.jar -configuration ../../features/configuration -clean -console
+
+You should see the osgi console:
+
+osgi>
+
+osgi> Jun 22, 2009 1:32:27 PM org.apache.tuscany.sca.extensibility.equinox.EquinoxServiceDiscoveryActivator start
+INFO: Equinox-based service discoverer is now configured.
+
+You can run "ss" command under the osgi> to see the status of the bundles.
+osgi> ss
+
+Then you can install and start contributions as bundles by doing the following:
+
+osgi> install file:./path/to/contribution_bundle.jar
+
+Note that contribution_bundle.jar will need an activator in order to register the bundle as a SCA contribution
+see samples/????
+TODO is this still true
+
+Running on Felix
+----------------
+
+See http://tuscany.apache.org/documentation-2x/running-tuscany-sca-2x-with-equinox-and-felix.html
diff --git a/sandbox/samples/running-tuscany/launcher-shell/README b/sandbox/samples/running-tuscany/launcher-shell/README
new file mode 100644
index 0000000000..9745f57ad9
--- /dev/null
+++ b/sandbox/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 ../../applications/store/target/sample-store.jar
+
+or:
+start myNode http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.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 the sample store 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/sandbox/samples/running-tuscany/launcher-shell/pom.xml b/sandbox/samples/running-tuscany/launcher-shell/pom.xml
new file mode 100644
index 0000000000..cde0e15f62
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-shell/sca b/sandbox/samples/running-tuscany/launcher-shell/sca
new file mode 100755
index 0000000000..8f6cf268b3
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-shell/sca.bat b/sandbox/samples/running-tuscany/launcher-shell/sca.bat
new file mode 100644
index 0000000000..5110effc25
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-shell/scripts/test-remote.txt b/sandbox/samples/running-tuscany/launcher-shell/scripts/test-remote.txt
new file mode 100644
index 0000000000..dc13e5c401
--- /dev/null
+++ b/sandbox/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 testNode http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.jar
+stop testNode
+start testNode http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.jar
+stop testNode
+start testNode http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.jar
+stop testNode
+start testNode http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.jar
+stop testNode
+start testNode http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.jar
+stop testNode
+start testNode http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.jar
+stop testNode
+start testNode http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.jar
+stop testNode
+start testNode http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.jar
+stop testNode
+start testNode http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.jar
+stop testNode
+start testNode http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.jar
+stop testNode
diff --git a/sandbox/samples/running-tuscany/launcher-shell/scripts/test-start.txt b/sandbox/samples/running-tuscany/launcher-shell/scripts/test-start.txt
new file mode 100644
index 0000000000..2514a9058d
--- /dev/null
+++ b/sandbox/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
+
+restart testNode http://people.apache.org/~jsdelfino/tuscany/java/test/sample-store.jar
+status
diff --git a/sandbox/samples/running-tuscany/launcher-shell/scripts/test-status.txt b/sandbox/samples/running-tuscany/launcher-shell/scripts/test-status.txt
new file mode 100644
index 0000000000..4df56e85e8
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-shell/scripts/test-stop.txt b/sandbox/samples/running-tuscany/launcher-shell/scripts/test-stop.txt
new file mode 100644
index 0000000000..39eb36aa77
--- /dev/null
+++ b/sandbox/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 testNode
diff --git a/sandbox/samples/running-tuscany/launcher-shell/scripts/test.txt b/sandbox/samples/running-tuscany/launcher-shell/scripts/test.txt
new file mode 100644
index 0000000000..bf489a46a5
--- /dev/null
+++ b/sandbox/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 testNode ../../applications/store/target/sample-store.jar
+stop testNode
+start testNode ../../applications/store/target/sample-store.jar
+stop testNode
+start testNode ../../applications/store/target/sample-store.jar
+stop testNode
+start testNode ../../applications/store/target/sample-store.jar
+stop testNode
+start testNode ../../applications/store/target/sample-store.jar
+stop testNode
+start testNode ../../applications/store/target/sample-store.jar
+stop testNode
+start testNode ../../applications/store/target/sample-store.jar
+stop testNode
+start testNode ../../applications/store/target/sample-store.jar
+stop testNode
+start testNode ../../applications/store/target/sample-store.jar
+stop testNode
+start testNode ../../applications/store/target/sample-store.jar
+stop testNode
diff --git a/sandbox/samples/running-tuscany/launcher-shell/src/main/java/sample/Shell.java b/sandbox/samples/running-tuscany/launcher-shell/src/main/java/sample/Shell.java
new file mode 100644
index 0000000000..d0d8fb5dfe
--- /dev/null
+++ b/sandbox/samples/running-tuscany/launcher-shell/src/main/java/sample/Shell.java
@@ -0,0 +1,203 @@
+/*
+ * 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 nf;
+
+ public static class Nodeconf {
+ final String name;
+ final String cloc;
+ final String dcuri;
+ final Node node;
+
+ Nodeconf(final String name, final String cloc, final String dcuri, final Node node) {
+ this.name = name;
+ this.cloc = cloc;
+ this.dcuri = dcuri;
+ this.node = node;
+ }
+
+ public String toString() {
+ return name + " " + cloc + (dcuri != null? " " + dcuri : "");
+ }
+ }
+
+ final Map<String, Nodeconf> nodes = new HashMap<String, Nodeconf>();
+ final List<String> history = new ArrayList<String>();
+
+ public Shell(NodeFactory nf) {
+ this.nf = nf;
+ }
+
+ List<?> start(final String name, final String cloc, final String dcuri) {
+ if(nodes.containsKey(name))
+ return emptyList();
+ final Node node = dcuri != null? nf.createNode(dcuri, new Contribution(cloc, cloc)) : nf.createNode(new Contribution(cloc, cloc));
+ nodes.put(name, new Nodeconf(name, cloc, dcuri, node));
+ node.start();
+ return emptyList();
+ }
+
+ List<?> stop(final String name) {
+ final Nodeconf ninfo = nodes.get(name);
+ if(ninfo == null)
+ return emptyList();
+ ninfo.node.stop();
+ nodes.remove(name);
+ return emptyList();
+ }
+
+ List<?> stop() {
+ for(Nodeconf ninfo: nodes.values())
+ ninfo.node.stop();
+ nodes.clear();
+ return emptyList();
+ }
+
+ List<?> restart(final String name, final String cloc, final String dcuri) {
+ final Nodeconf ninfo = nodes.get(name);
+ if(ninfo == null)
+ return start(name, cloc, dcuri);
+ ninfo.node.stop();
+ nodes.remove(name);
+ if (cloc == null)
+ return start(ninfo.name, ninfo.cloc, ninfo.dcuri);
+ return start(name, cloc, dcuri);
+ }
+
+ 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.size() >= 4? toks.get(3) : null);
+ }
+ };
+ 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.size() >= 3? toks.get(2) : null, toks.size() >= 4? toks.get(3) : null);
+ }
+ };
+ 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, Nodeconf> 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/sandbox/samples/running-tuscany/launcher-shell/src/main/java/sample/ShellServlet.java b/sandbox/samples/running-tuscany/launcher-shell/src/main/java/sample/ShellServlet.java
new file mode 100644
index 0000000000..55aadbd09b
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-shell/src/main/webapp/WEB-INF/web.xml b/sandbox/samples/running-tuscany/launcher-shell/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..ac1ad1cc8e
--- /dev/null
+++ b/sandbox/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/sandbox/samples/running-tuscany/launcher-shell/src/main/webapp/index.html b/sandbox/samples/running-tuscany/launcher-shell/src/main/webapp/index.html
new file mode 100644
index 0000000000..3d41472a46
--- /dev/null
+++ b/sandbox/samples/running-tuscany/launcher-shell/src/main/webapp/index.html
@@ -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.
+-->
+<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/running-tuscany/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/running-tuscany/launcher-shell/scripts/test-start.txt">http://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/samples/running-tuscany/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/running-tuscany/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/running-tuscany/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>This script starts the Tuscany sample store application. Click <a href="http://localhost:8080/scashell/store/">here</a> to use that application after you've started it.</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/running-tuscany/launcher-shell/scripts/">there</a>.
+
+</body>
+</html>
diff --git a/sandbox/samples/running-tuscany/launcher-webapp/README b/sandbox/samples/running-tuscany/launcher-webapp/README
new file mode 100644
index 0000000000..4031b9c0bd
--- /dev/null
+++ b/sandbox/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/
diff --git a/sandbox/samples/running-tuscany/pom.xml b/sandbox/samples/running-tuscany/pom.xml
new file mode 100644
index 0000000000..67b6a29eb3
--- /dev/null
+++ b/sandbox/samples/running-tuscany/pom.xml
@@ -0,0 +1,53 @@
+<?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>tuscany-samples-running-tuscany</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Running Tuscany Samples</name>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+
+ <!-- don't need to process these as they just contain README files
+ <module>launcher-command-line</module>
+ <module>launcher-maven</module>
+ <module>launcher-webapp</module>
+ -->
+ <module>launcher-embedded-jse</module>
+ <module>launcher-embedded-osgi</module>
+ <module>launcher-embedded-osgi-base</module>
+ <module>launcher-shell</module>
+
+ </modules>
+ </profile>
+ </profiles>
+</project>