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/17 01:51:09 UTC

svn commit: r508673 - in /incubator/tuscany/java/sca: core-samples/standalone/calculator/src/main/java/calculator/ core-samples/standalone/calculator/src/main/resources/META-INF/sca/ core-samples/standalone/calculator/src/test/java/calculator/ kernel/c...

Author: meerajk
Date: Fri Feb 16 16:51:08 2007
New Revision: 508673

URL: http://svn.apache.org/viewvc?view=rev&rev=508673
Log:
working version of the launcher

Modified:
    incubator/tuscany/java/sca/core-samples/standalone/calculator/src/main/java/calculator/CalculatorClient.java
    incubator/tuscany/java/sca/core-samples/standalone/calculator/src/main/resources/META-INF/sca/default.scdl
    incubator/tuscany/java/sca/core-samples/standalone/calculator/src/test/java/calculator/CalculatorClientTestCase.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaTargetInvoker.java
    incubator/tuscany/java/sca/runtime/standalone/launcher/src/main/java/org/apache/tuscany/launcher/Main.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
    incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/implementation/launched/LaunchedComponentTypeLoader.java

Modified: incubator/tuscany/java/sca/core-samples/standalone/calculator/src/main/java/calculator/CalculatorClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core-samples/standalone/calculator/src/main/java/calculator/CalculatorClient.java?view=diff&rev=508673&r1=508672&r2=508673
==============================================================================
--- incubator/tuscany/java/sca/core-samples/standalone/calculator/src/main/java/calculator/CalculatorClient.java (original)
+++ incubator/tuscany/java/sca/core-samples/standalone/calculator/src/main/java/calculator/CalculatorClient.java Fri Feb 16 16:51:08 2007
@@ -33,7 +33,7 @@
         this.calculatorService = calculatorService;
     }
     
-    public Object main(Object ... args) throws Exception {
+    public Object main(String[] args) throws Exception {
         
         if(args.length != 3) {
             throw new IllegalArgumentException("Usage <add|substract|multiply|divide> <operand1> <operand2>");

Modified: incubator/tuscany/java/sca/core-samples/standalone/calculator/src/main/resources/META-INF/sca/default.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core-samples/standalone/calculator/src/main/resources/META-INF/sca/default.scdl?view=diff&rev=508673&r1=508672&r2=508673
==============================================================================
--- incubator/tuscany/java/sca/core-samples/standalone/calculator/src/main/resources/META-INF/sca/default.scdl (original)
+++ incubator/tuscany/java/sca/core-samples/standalone/calculator/src/main/resources/META-INF/sca/default.scdl Fri Feb 16 16:51:08 2007
@@ -21,12 +21,35 @@
            xmlns:launched="http://tuscany.apache.org/xmlns/sca/1.0"
            name="CalculatorComposite">
 
-    <include name="CalculatorComposite"/>
-<!--
+    <!-- include name="CalculatorComposite"/ -->
+    
+    <component name="CalculatorServiceComponent">
+		<implementation.java class="calculator.CalculatorServiceImpl"/>
+        <reference name="addService">AddServiceComponent</reference>
+        <reference name="subtractService">SubtractServiceComponent</reference>
+        <reference name="multiplyService">MultiplyServiceComponent</reference>
+        <reference name="divideService">DivideServiceComponent</reference>
+    </component>
+
+    <component name="AddServiceComponent">
+        <implementation.java class="calculator.AddServiceImpl"/>
+    </component>
+
+    <component name="SubtractServiceComponent">
+        <implementation.java class="calculator.SubtractServiceImpl"/>
+    </component>
+
+    <component name="MultiplyServiceComponent">
+        <implementation.java class="calculator.MultiplyServiceImpl"/>
+    </component>
+
+    <component name="DivideServiceComponent">
+        <implementation.java class="calculator.DivideServiceImpl"/>
+    </component>
+
     <component name="CalculatorClient">
 		<launched:launched class="calculator.CalculatorClient"/>
         <reference name="calculatorService">CalculatorServiceComponent</reference>
     </component>
--->
 
 </composite>

Modified: incubator/tuscany/java/sca/core-samples/standalone/calculator/src/test/java/calculator/CalculatorClientTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core-samples/standalone/calculator/src/test/java/calculator/CalculatorClientTestCase.java?view=diff&rev=508673&r1=508672&r2=508673
==============================================================================
--- incubator/tuscany/java/sca/core-samples/standalone/calculator/src/test/java/calculator/CalculatorClientTestCase.java (original)
+++ incubator/tuscany/java/sca/core-samples/standalone/calculator/src/test/java/calculator/CalculatorClientTestCase.java Fri Feb 16 16:51:08 2007
@@ -14,7 +14,7 @@
         double result = 5;
         EasyMock.expect(mockService.add(2, 3)).andReturn(result);
         EasyMock.replay(mockService);
-        assertEquals(result, client.main("add", "2", "3"));
+        assertEquals(result, client.main(new String[] {"add", "2", "3"}));
         EasyMock.verify(mockService);
     }
 

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaTargetInvoker.java?view=diff&rev=508673&r1=508672&r2=508673
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaTargetInvoker.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/java/JavaTargetInvoker.java Fri Feb 16 16:51:08 2007
@@ -87,11 +87,11 @@
                 }
             }
             Object ret;
-            if (payload != null && !payload.getClass().isArray()) {
+            //if (payload != null && !payload.getClass().isArray()) {
                 ret = operation.invoke(instance, payload);
-            } else {
-                ret = operation.invoke(instance, (Object[]) payload);
-            }
+            //} else {
+            //    ret = operation.invoke(instance, (Object[]) payload);
+            //}
             if (stateless) {
                 // notify a stateless instance of a destruction event after the invoke
                 component.destroy(instance);

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=508673&r1=508672&r2=508673
==============================================================================
--- 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 Fri Feb 16 16:51:08 2007
@@ -81,7 +81,10 @@
             appArgs = new String[args.length - 1];
             System.arraycopy(args, 1, appArgs, 0, appArgs.length);
         }
-        runtime.deployAndRun(applicationScdl, applicationClassLoader, appArgs);
+        Object ret = runtime.deployAndRun(applicationScdl, applicationClassLoader, appArgs);
+        System.err.println(ret);
+        
+        System.exit(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=508673&r1=508672&r2=508673
==============================================================================
--- 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 Fri Feb 16 16:51:08 2007
@@ -40,6 +40,6 @@
      * @param args Arguments to be passed to the lauched component.
      * @deprecated This is a hack for deployment and should be removed.
      */
-    void deployAndRun(URL applicationScdl, ClassLoader applicationClassLoader, String[] args) throws Exception;
+    Object 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=508673&r1=508672&r2=508673
==============================================================================
--- 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 Fri Feb 16 16:51:08 2007
@@ -69,9 +69,9 @@
      * @param args Arguments to be passed to the lauched component.
      * @deprecated This is a hack for deployment and should be removed.
      */
-    public void deployAndRun(URL applicationScdl, ClassLoader applicationClassLoader, String[] args) throws Exception {
+    public Object deployAndRun(URL applicationScdl, ClassLoader applicationClassLoader, String[] args) throws Exception {
         
-        URI compositeUri = new URI("/test/composite");
+        URI compositeUri = new URI("/test/composite/");
         
         CompositeImplementation impl = new CompositeImplementation();
         impl.setScdlLocation(applicationScdl);
@@ -82,10 +82,10 @@
         Component component =  getDeployer().deploy(null, definition);
         component.start();
         
-        run(impl, args, compositeUri);
+        return run(impl, args, compositeUri);
     }
 
-    private void run(CompositeImplementation impl, String[] args, URI compositeUri) throws Exception {
+    private Object 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()) {
@@ -93,25 +93,21 @@
             ComponentDefinition<? extends Implementation<?>> launchedDefinition = entry.getValue();
             Implementation implementation = launchedDefinition.getImplementation();
             if(implementation.getClass().isAssignableFrom(Launched.class)) {
-                run(compositeUri.resolve(name), implementation);
+                return run(compositeUri.resolve(name), implementation, args);
             }
         }
+        return null;
     }
 
-    private void run(URI componentUri, Implementation implementation) throws TargetInvokerCreationException, InvocationTargetException {
+    private Object run(URI componentUri, Implementation implementation, String[] args) throws TargetInvokerCreationException, InvocationTargetException {
         Launched launched = (Launched) implementation;
         PojoComponentType launchedType = launched.getComponentType();
         Map services = launchedType.getServices();
         JavaMappedService testService = (JavaMappedService) services.get("main");
         Operation<?> operation = testService.getServiceContract().getOperations().get("main");
-        // TODO Find the component and invoke main on the component
         Component component = getComponentManager().getComponent(componentUri);
-        if(component == null) {
-            System.err.println("Unable to get component " + componentUri);
-        } else {
-            TargetInvoker targetInvoker = component.createTargetInvoker("main", operation, null);
-            targetInvoker.invokeTarget(null, TargetInvoker.NONE);
-        }
+        TargetInvoker targetInvoker = component.createTargetInvoker("main", operation, null);
+        return targetInvoker.invokeTarget(args, TargetInvoker.NONE);
     }
 
     protected Deployer getDeployer() {

Modified: incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/implementation/launched/LaunchedComponentTypeLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/implementation/launched/LaunchedComponentTypeLoader.java?view=diff&rev=508673&r1=508672&r2=508673
==============================================================================
--- incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/implementation/launched/LaunchedComponentTypeLoader.java (original)
+++ incubator/tuscany/java/sca/runtime/standalone/standalone-host/src/main/java/org/apache/tuscany/runtime/standalone/host/implementation/launched/LaunchedComponentTypeLoader.java Fri Feb 16 16:51:08 2007
@@ -20,6 +20,7 @@
 
 import java.lang.reflect.Type;
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -94,7 +95,8 @@
     private static final DataType<Type> OUTPUT_TYPE;
     private static final List<DataType<Type>> FAULT_TYPE;
     static {
-        List<DataType<Type>> paramDataTypes = Collections.emptyList();
+        List<DataType<Type>> paramDataTypes = new ArrayList<DataType<Type>>();
+        paramDataTypes.add(new DataType(null, String[].class, String[].class));
         INPUT_TYPE = new DataType<List<DataType<Type>>>("idl:input", Object[].class, paramDataTypes);
         OUTPUT_TYPE = new DataType<Type>(null, Object.class, Object.class);
         FAULT_TYPE = Collections.emptyList();



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