You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by me...@apache.org on 2007/02/16 07:46:54 UTC

svn commit: r508324 - in /incubator/tuscany/java/sca/runtime/standalone: launcher/src/main/java/org/apache/tuscany/launcher/ launcher/src/main/resources/org/apache/tuscany/launcher/ standalone-api/src/main/java/org/apache/tuscany/runtime/standalone/ st...

Author: meerajk
Date: Thu Feb 15 22:46:54 2007
New Revision: 508324

URL: http://svn.apache.org/viewvc?view=rev&rev=508324
Log:
Added support for application arguments for laucher

Modified:
    incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.java
    incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/resources/org/apache/tuscany/launcher/Main.properties
    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=508324&r1=508323&r2=508324
==============================================================================
--- 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 Thu Feb 15 22:46:54 2007
@@ -50,7 +50,7 @@
      */
     public static void main(String[] args) throws Throwable {
 
-        if (args.length != 1) {
+        if (args.length < 1) {
             usage();
             throw new AssertionError();
         }
@@ -75,7 +75,13 @@
         ClassLoader applicationClassLoader =
             new URLClassLoader(new URL[] {applicationJar}, runtime.getHostClassLoader());
         URL applicationScdl = applicationClassLoader.getResource("META-INF/sca/default.scdl");
-        runtime.deployAndRun(compositeUri, applicationScdl, applicationClassLoader);
+        
+        String[] appArgs = new String[0];
+        if(args.length > 1) {
+            appArgs = new String[args.length - 1];
+            System.arraycopy(args, 1, appArgs, 0, appArgs.length);
+        }
+        runtime.deployAndRun(applicationScdl, applicationClassLoader, appArgs);
 
     }
 

Modified: incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/resources/org/apache/tuscany/launcher/Main.properties
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/resources/org/apache/tuscany/launcher/Main.properties?view=diff&rev=508324&r1=508323&r2=508324
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/resources/org/apache/tuscany/launcher/Main.properties (original)
+++ incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/resources/org/apache/tuscany/launcher/Main.properties Thu Feb 15 22:46:54 2007
@@ -17,5 +17,5 @@
 #
 #  $Rev$ $Date$
 #
-org.apache.tuscany.launcher.Usage=usage: java [jvm-options] -jar launcher.jar <componentJar>
+org.apache.tuscany.launcher.Usage=usage: java [jvm-options] -jar launcher.jar <componentJar> [apparg1, apparg2, ...]
 org.apache.tuscany.launcher.NoComponent=No component found with id "{0}"

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=508324&r1=508323&r2=508324
==============================================================================
--- 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 Thu Feb 15 22:46:54 2007
@@ -35,11 +35,11 @@
     /**
      * Deploys the specified application SCDL and runs the lauched component within the deployed composite.
      * 
-     * @param compositeUri URI by which the composite is deployed.
      * @param applicationScdl Application SCDL that implements the composite.
      * @param applicationClassLoader Classloader used to deploy the composite.
+     * @param args Arguments to be passed to the lauched component.
      * @deprecated This is a hack for deployment and should be removed.
      */
-    void deployAndRun(URI compositeUri, URL applicationScdl, ClassLoader applicationClassLoader) throws Exception;
+    void 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=508324&r1=508323&r2=508324
==============================================================================
--- 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 Thu Feb 15 22:46:54 2007
@@ -57,12 +57,14 @@
     /**
      * Deploys the specified application SCDL and runs the lauched component within the deployed composite.
      * 
-     * @param compositeUri URI by which the composite is deployed.
      * @param applicationScdl Application SCDL that implements the composite.
      * @param applicationClassLoader Classloader used to deploy the composite.
+     * @param args Arguments to be passed to the lauched component.
      * @deprecated This is a hack for deployment and should be removed.
      */
-    public void deployAndRun(URI compositeUri, URL applicationScdl, ClassLoader applicationClassLoader) throws Exception {
+    public void deployAndRun(URL applicationScdl, ClassLoader applicationClassLoader, String[] args) throws Exception {
+        
+        URI compositeUri = new URI("/test/composite");
         
         CompositeImplementation impl = new CompositeImplementation();
         impl.setScdlLocation(applicationScdl);
@@ -71,13 +73,18 @@
         ComponentDefinition<CompositeImplementation> definition =
             new ComponentDefinition<CompositeImplementation>(compositeUri, impl);
         Component component =  getDeployer().deploy(null, definition);
+        component.start();
         
+        run(impl, args);
+    }
+
+    private void run(CompositeImplementation impl, String[] args) {
         CompositeComponentType<?,?,?> componentType = impl.getComponentType();
         Map<String, ComponentDefinition<? extends Implementation<?>>> components = componentType.getComponents();
         for (Map.Entry<String, ComponentDefinition<? extends Implementation<?>>> entry : components.entrySet()) {
             String name = entry.getKey();
-            ComponentDefinition<? extends Implementation<?>> junitDefinition = entry.getValue();
-            Implementation<?> implementation = junitDefinition.getImplementation();
+            ComponentDefinition<? extends Implementation<?>> launchedDefinition = entry.getValue();
+            Implementation<?> implementation = launchedDefinition.getImplementation();
             System.err.println(implementation.getClass());
         }
     }



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