You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2010/05/20 15:39:39 UTC

svn commit: r946630 - in /tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse: build.xml src/main/java/launcher/SampleJSELauncher.java

Author: slaws
Date: Thu May 20 13:39:39 2010
New Revision: 946630

URL: http://svn.apache.org/viewvc?rev=946630&view=rev
Log:
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.

Modified:
    tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml
    tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java

Modified: tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml?rev=946630&r1=946629&r2=946630&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml (original)
+++ tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/build.xml Thu May 20 13:39:39 2010
@@ -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>
 	

Modified: tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java?rev=946630&r1=946629&r2=946630&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java (original)
+++ tuscany/sca-java-2.x/trunk/samples/launcher-embedded-jse/src/main/java/launcher/SampleJSELauncher.java Thu May 20 13:39:39 2010
@@ -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 R
             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 R
         } 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 R
      */
     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 R
             throw new SampleLauncherException();
         }
         
+        waitBeforeStopping();
         stopNode(node);
     }
     
@@ -99,6 +132,7 @@ public class SampleJSELauncher extends R
             throw new SampleLauncherException();
         }
         
+        waitBeforeStopping();
         stopNode(node2);
         stopNode(node1);
     }   
@@ -109,7 +143,7 @@ public class SampleJSELauncher extends R
      */
     public void launchImplementationJavaCalculator(){
         Node node = startNode(new Contribution("c1", "../contribution-implementation-java-calculator/target/classes"));
-               
+        waitBeforeStopping();
         stopNode(node);
     }