summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-05-20 13:39:39 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-05-20 13:39:39 +0000
commit4f6f917357572b1db1b9a5202c009c6afd4f3933 (patch)
tree464d43a1a72c2935994037df5a97a4bd4cce436f
parent699ac8beb54479aca905932502c4c7025fafc801 (diff)
Add some simple code to allow the embedded launcher to keep the SCA app running so that it can be called by the stand-alone launcher. Not enabled yet.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@946630 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml2
-rw-r--r--sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java44
2 files changed, 41 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml b/sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml
index a37d7f0d09..1ac9c6f23e 100644
--- a/sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml
+++ b/sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml
@@ -20,6 +20,7 @@
<property name="tuscany.home" value="../.."/>
<property name="jar.name" value="sample-launcher-embedded-jse.jar" />
<property name="main.class" value="launcher.SampleJSELauncher" />
+ <property name="wait.before.stopping" value="dontWaitBeforeStopping" />
<echo>${tuscany.home}</echo>
@@ -65,6 +66,7 @@
</fileset>
</classpath>
<arg value="contribution-binding-sca-calculator"/>
+ <arg value="${wait.before.stopping}"/>
</java>
</target>
diff --git a/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java b/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java
index 21564ce692..9a4a73c556 100644
--- a/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java
+++ b/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java
@@ -26,14 +26,16 @@ import calculator.CalculatorService;
/**
- * This client program shows how to create an embedded SCA runtime, start it,
- * and locate and invoke a SCA component
+ * This client program shows how to create an embedded SCA runtime, load a contribution,
+ * start it and, in some cases, locate and invoke an SCA component
*/
public class SampleJSELauncher extends RuntimeIntegration {
+ protected boolean waitBeforeStopping = false;
+
public static void main(String[] args) throws Exception {
- SampleJSELauncher launcher = new SampleJSELauncher();
+ // get the contribution name from the 1st argument it there is one
String contribution = null;
if (args == null || args.length != 1){
@@ -44,6 +46,16 @@ public class SampleJSELauncher extends RuntimeIntegration {
contribution = args[0];
}
+ // assume that more than one argument means that the caller wants to
+ // keep the SCA application running while other clients use the services
+ boolean waitBeforeStopping = false;
+
+ if (args != null && args.length > 1 && args[1].equals("waitBeforeStopping")){
+ waitBeforeStopping = true;
+ }
+
+ SampleJSELauncher launcher = new SampleJSELauncher(waitBeforeStopping);
+
if (contribution.equals("contribution-binding-sca-calculator")){
launcher.launchBindingSCACalculator();
} else if (contribution.equals("contribution-binding-ws-calculator")){
@@ -55,6 +67,26 @@ public class SampleJSELauncher extends RuntimeIntegration {
} else {
System.out.println("Sample contribution " + contribution + "not found");
}
+
+ }
+
+ public SampleJSELauncher(boolean waitBeforeStopping){
+ this.waitBeforeStopping = waitBeforeStopping;
+ }
+
+ /**
+ * Wait for user input. Allows us to keep the Tuscany runtime and the SCA application
+ * running while other clients access the services provided
+ */
+ public void waitBeforeStopping(){
+ if (waitBeforeStopping){
+ try {
+ System.out.println("Press key to continue");
+ int input = System.in.read();
+ } catch (Exception ex) {
+ // do nothing
+ }
+ }
}
/**
@@ -63,7 +95,7 @@ public class SampleJSELauncher extends RuntimeIntegration {
*/
public void launchBindingSCACalculator(){
Node node = startNode(new Contribution("c1", "../binding-sca/contribution-calculator/target/sample-contribution-binding-sca-calculator.jar"));
-
+ waitBeforeStopping();
stopNode(node);
}
@@ -81,6 +113,7 @@ public class SampleJSELauncher extends RuntimeIntegration {
throw new SampleLauncherException();
}
+ waitBeforeStopping();
stopNode(node);
}
@@ -99,6 +132,7 @@ public class SampleJSELauncher extends RuntimeIntegration {
throw new SampleLauncherException();
}
+ waitBeforeStopping();
stopNode(node2);
stopNode(node1);
}
@@ -109,7 +143,7 @@ public class SampleJSELauncher extends RuntimeIntegration {
*/
public void launchImplementationJavaCalculator(){
Node node = startNode(new Contribution("c1", "../contribution-implementation-java-calculator/target/classes"));
-
+ waitBeforeStopping();
stopNode(node);
}