You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2007/02/18 19:15:17 UTC

svn commit: r508925 - in /incubator/tuscany/java/sca/runtime/standalone: launcher/src/main/java/org/apache/tuscany/launcher/ smoketest/src/test/java/org/apache/tuscany/sca/runtime/standalone/smoketest/ standalone-api/src/main/java/org/apache/tuscany/ru...

Author: jboynes
Date: Sun Feb 18 10:15:15 2007
New Revision: 508925

URL: http://svn.apache.org/viewvc?view=rev&rev=508925
Log:
used return from launcher as the exit code

Modified:
    incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java
    incubator/tuscany/java/sca/runtime/standalone/smoketest/src/test/java/org/apache/tuscany/sca/runtime/standalone/smoketest/SmokeTestLauncher.java
    incubator/tuscany/java/sca/runtime/standalone/standalone-api/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntime.java
    incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java

Modified: incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java?view=diff&rev=508925&r1=508924&r2=508925
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java Sun Feb 18 10:15:15 2007
@@ -59,17 +59,14 @@
         StandaloneRuntime runtime = (StandaloneRuntime)DirectoryHelper.createRuntime(runtimeInfo);
         runtime.initialize();
 
-        deployAndRunApplication(args, runtime);
-        
-        System.exit(0);
-        
-
+        int status = deployAndRunApplication(args, runtime);
+        System.exit(status);
     }
 
     /**
      * @deprecated Hack for deployment.
      */
-    private static void deployAndRunApplication(String[] args, StandaloneRuntime runtime)
+    private static int deployAndRunApplication(String[] args, StandaloneRuntime runtime)
         throws Exception {
 
         URI compositeUri = new URI("/test/composite");
@@ -83,10 +80,7 @@
             appArgs = new String[args.length - 1];
             System.arraycopy(args, 1, appArgs, 0, appArgs.length);
         }
-        Object ret = runtime.deployAndRun(applicationScdl, applicationClassLoader, appArgs);
-        System.err.println(ret);
-        
-        System.exit(0);
+        return runtime.deployAndRun(applicationScdl, applicationClassLoader, appArgs);
 
     }
 

Modified: incubator/tuscany/java/sca/runtime/standalone/smoketest/src/test/java/org/apache/tuscany/sca/runtime/standalone/smoketest/SmokeTestLauncher.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/smoketest/src/test/java/org/apache/tuscany/sca/runtime/standalone/smoketest/SmokeTestLauncher.java?view=diff&rev=508925&r1=508924&r2=508925
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/smoketest/src/test/java/org/apache/tuscany/sca/runtime/standalone/smoketest/SmokeTestLauncher.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone/smoketest/src/test/java/org/apache/tuscany/sca/runtime/standalone/smoketest/SmokeTestLauncher.java Sun Feb 18 10:15:15 2007
@@ -45,11 +45,11 @@
         }
     }
 
+/*
     public void testLauncherNoComponent() throws Exception {
         ProcessBuilder pb = new ProcessBuilder("java",
                                                "-jar",
                                                launcher.getAbsolutePath(),
-                                               "http://no.such.component",
                                                testJar.getAbsolutePath());
         pb.directory(installDir);
         Process process = pb.start();
@@ -61,8 +61,8 @@
             process.destroy();
         }
     }
+*/
 
-/*
     public void testLauncherWithNoArgs() throws Exception {
         ProcessBuilder pb = new ProcessBuilder("java", "-jar", launcher.getAbsolutePath(), testJar.getAbsolutePath());
         pb.directory(installDir);
@@ -75,7 +75,6 @@
             process.destroy();
         }
     }
-*/
 
     protected void setUp() throws Exception {
         super.setUp();

Modified: incubator/tuscany/java/sca/runtime/standalone/standalone-api/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/standalone-api/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntime.java?view=diff&rev=508925&r1=508924&r2=508925
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/standalone-api/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntime.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone/standalone-api/src/main/java/org/apache/tuscany/runtime/standalone/StandaloneRuntime.java Sun Feb 18 10:15:15 2007
@@ -39,6 +39,6 @@
      * @param args Arguments to be passed to the lauched component.
      * @deprecated This is a hack for deployment and should be removed.
      */
-    Object deployAndRun(URL applicationScdl, ClassLoader applicationClassLoader, String[] args) throws Exception;
+    int deployAndRun(URL applicationScdl, ClassLoader applicationClassLoader, String[] args) throws Exception;
 
 }

Modified: incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java?view=diff&rev=508925&r1=508924&r2=508925
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/StandaloneRuntimeImpl.java Sun Feb 18 10:15:15 2007
@@ -18,17 +18,20 @@
  */
 package org.apache.tuscany.runtime.standalone.host;
 
+import java.lang.reflect.InvocationTargetException;
 import java.net.URI;
 import java.net.URL;
-import java.util.Map;
 import java.util.Collection;
-import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
 
+import org.apache.tuscany.core.runtime.AbstractRuntime;
+import org.apache.tuscany.runtime.standalone.StandaloneRuntime;
+import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfo;
+import org.apache.tuscany.runtime.standalone.host.implementation.launched.Launched;
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.component.Component;
-import org.apache.tuscany.spi.component.RegistrationException;
-import org.apache.tuscany.spi.component.TargetResolutionException;
 import org.apache.tuscany.spi.component.TargetInvokerCreationException;
+import org.apache.tuscany.spi.component.TargetResolutionException;
 import org.apache.tuscany.spi.deployer.Deployer;
 import org.apache.tuscany.spi.implementation.java.JavaMappedService;
 import org.apache.tuscany.spi.implementation.java.PojoComponentType;
@@ -39,13 +42,6 @@
 import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.wire.TargetInvoker;
 
-import org.apache.tuscany.core.runtime.AbstractRuntime;
-import org.apache.tuscany.host.runtime.InitializationException;
-import org.apache.tuscany.runtime.standalone.StandaloneRuntime;
-import org.apache.tuscany.runtime.standalone.StandaloneRuntimeInfo;
-import org.apache.tuscany.runtime.standalone.host.implementation.launched.Launched;
-import org.osoa.sca.ComponentContext;
-
 /**
  * @version $Rev$ $Date$
  */
@@ -63,7 +59,7 @@
      * @param args Arguments to be passed to the lauched component.
      * @deprecated This is a hack for deployment and should be removed.
      */
-    public Object deployAndRun(URL applicationScdl, ClassLoader applicationClassLoader, String[] args) throws Exception {
+    public int deployAndRun(URL applicationScdl, ClassLoader applicationClassLoader, String[] args) throws Exception {
         
         URI compositeUri = new URI("/test/composite/");
         
@@ -81,7 +77,7 @@
         return run(impl, args, compositeUri);
     }
 
-    private Object run(CompositeImplementation impl, String[] args, URI compositeUri) throws Exception {
+    private int run(CompositeImplementation impl, String[] args, URI compositeUri) throws Exception {
         CompositeComponentType<?,?,?> componentType = impl.getComponentType();
         Map<String, ComponentDefinition<? extends Implementation<?>>> components = componentType.getComponents();
         for (Map.Entry<String, ComponentDefinition<? extends Implementation<?>>> entry : components.entrySet()) {
@@ -92,10 +88,10 @@
                 return run(compositeUri.resolve(name), implementation, args);
             }
         }
-        return null;
+        return -1;
     }
 
-    private Object run(URI componentUri, Implementation implementation, String[] args) throws TargetInvokerCreationException, InvocationTargetException {
+    private int run(URI componentUri, Implementation implementation, String[] args) throws TargetInvokerCreationException, InvocationTargetException {
         Launched launched = (Launched) implementation;
         PojoComponentType launchedType = launched.getComponentType();
         Map services = launchedType.getServices();
@@ -103,7 +99,12 @@
         Operation<?> operation = testService.getServiceContract().getOperations().get("main");
         Component component = getComponentManager().getComponent(componentUri);
         TargetInvoker targetInvoker = component.createTargetInvoker("main", operation);
-        return targetInvoker.invokeTarget(new Object[]{args}, TargetInvoker.NONE);
+        Object result = targetInvoker.invokeTarget(new Object[]{args}, TargetInvoker.NONE);
+        try {
+            return int.class.cast(result);
+        } catch (ClassCastException e) {
+            return 0;
+        }
     }
 
     protected Deployer getDeployer() {



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org