You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by aj...@apache.org on 2006/09/13 15:07:33 UTC

svn commit: r442977 - in /incubator/tuscany/cpp/sca/samples/PythonCalculator: ./ sample.calculator.client/ sample.calculator/

Author: ajborley
Date: Wed Sep 13 06:07:32 2006
New Revision: 442977

URL: http://svn.apache.org/viewvc?view=rev&rev=442977
Log:
Converted to a Python-only sample that demonstrates using new support for references and clients using locateService

Added:
    incubator/tuscany/cpp/sca/samples/PythonCalculator/deploy.cmd
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/calculator_client.py
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/CalculatorImpl.py
Removed:
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/Calculator.h
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/CalculatorClient.cpp
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/Calculator.h
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/CalculatorImpl.cpp
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/CalculatorImpl.h
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/Divide.h
Modified:
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/Makefile.am
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/runclient.bat
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/runclient.sh
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/CalculatorImpl.componentType
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/DivideImpl.componentType
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/Makefile.am
    incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/sample.calculator.composite

Added: incubator/tuscany/cpp/sca/samples/PythonCalculator/deploy.cmd
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PythonCalculator/deploy.cmd?view=auto&rev=442977
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PythonCalculator/deploy.cmd (added)
+++ incubator/tuscany/cpp/sca/samples/PythonCalculator/deploy.cmd Wed Sep 13 06:07:32 2006
@@ -0,0 +1,47 @@
+@echo off
+
+@REM  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+@REM
+@REM  Licensed under the Apache License, Version 2.0 (the "License");
+@REM  you may not use this file except in compliance with the License.
+@REM  You may obtain a copy of the License at
+@REM
+@REM     http://www.apache.org/licenses/LICENSE-2.0
+@REM
+@REM  Unless required by applicable law or agreed to in writing, software
+@REM  distributed under the License is distributed on an "AS IS" BASIS,
+@REM  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@REM  See the License for the specific language governing permissions and
+@REM  limitations under the License.
+
+rem Will copy the correct files from the source tree for packaging and deployment of the 
+rem SCA sample.
+setlocal
+set currentPath=%~d0%~p0
+set sourcePath=%currentPath%
+
+if . == %2. (
+set destinationPath=%sourcePath%\deploy
+) ELSE (
+set destinationPath=%2
+)
+
+if not exist %destinationPath%\packages mkdir %destinationPath%\packages 
+if not exist %destinationPath%\packages\sample.calculator mkdir %destinationPath%\packages\sample.calculator
+
+copy %sourcePath%\sample.calculator\*.componentType %destinationPath%\packages\sample.calculator
+copy %sourcePath%\sample.calculator\*.composite %destinationPath%\packages\sample.calculator
+copy %sourcePath%\sample.calculator\*.py %destinationPath%\packages\sample.calculator
+copy %sourcePath%\sample.calculator\Calculator.wsdl %destinationPath%\packages\sample.calculator
+
+if not exist %destinationPath%\bin mkdir %destinationPath%\bin
+copy %sourcePath%\sample.calculator.client\calculator_client.py   %destinationPath%\bin
+copy %sourcePath%\sample.calculator.client\runclient.bat   %destinationPath%\bin
+
+
+if not exist %destinationPath%\configuration mkdir %destinationPath%\configuration
+if not exist %destinationPath%\configuration\sample.calculator.solution mkdir %destinationPath%\configuration\sample.calculator.solution
+
+copy %sourcePath%\sample.calculator.solution\*.composite %destinationPath%\configuration\sample.calculator.solution
+
+endlocal

Modified: incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/Makefile.am?view=diff&rev=442977&r1=442976&r2=442977
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/Makefile.am (original)
+++ incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/Makefile.am Wed Sep 13 06:07:32 2006
@@ -1,34 +1,5 @@
 deploydir=$(prefix)/samples/PythonCalculator/deploy
 prgbindir=$(deploydir)/bin
 
-prgbin_PROGRAMS = calculator_client
-prgbin_SCRIPTS = runclient.sh
-EXTRA_DIST = runclient.sh
-
-AM_CPPFLAGS = $(CPPFLAGS)
-calculator_client_SOURCES = \
-CalculatorClient.cpp
-
-calculator_client_LDADD = \
--L${TUSCANY_SCACPP}/lib \
-  -ltuscany_sca \
--L${TUSCANY_SCACPP}/extensions/cpp/lib \
-  -ltuscany_sca_cpp \
--L${TUSCANY_SDOCPP}/lib \
-  -ltuscany_sdo \
-  -ltuscany_sdo_axiom \
--L$(AXIS2C_HOME)/lib \
-  -laxis2_util \
-  -laxis2_axiom \
-  -laxis2_wsdl \
-  -laxis2_engine \
-  -laxis2_parser \
-  -laxis2_minizip \
-  -lpthread \
-  -laxis2_http_sender \
-  -laxis2_http_receiver
-	
-INCLUDES = \
--I$(TUSCANY_SCACPP)/extensions/cpp/include \
--I${TUSCANY_SCACPP}/include \
--I${TUSCANY_SDOCPP}/include
+prgbin_SCRIPTS = runclient.sh *.py
+EXTRA_DIST = runclient.sh *.py

Added: incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/calculator_client.py
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/calculator_client.py?view=auto&rev=442977
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/calculator_client.py (added)
+++ incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/calculator_client.py Wed Sep 13 06:07:32 2006
@@ -0,0 +1,50 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+# 
+# 
+# This Python code is a simple sample that provides a Python 
+# client for the Calculator sample
+ 
+
+import sys
+import TuscanySCA
+
+op = sys.argv[1]
+val1 = sys.argv[2]
+val2 = sys.argv[3]
+
+# Locate the calculator service
+calc = TuscanySCA.locateService("CalculatorComponent/CalculatorService")
+
+# Invoke the calculator operations
+if op == 'add':
+    result = calc.add(val1, val2)
+
+elif op == 'sub':
+    result = calc.sub(val1, val2)
+
+elif op == 'mul':
+    result = calc.mul(val1, val2)
+
+elif op == 'div':
+    result = calc.div(val1, val2)
+
+
+print "calculator_client: ",op,"(",val1,",",val2,") = ",result
+

Modified: incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/runclient.bat
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/runclient.bat?view=diff&rev=442977&r1=442976&r2=442977
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/runclient.bat (original)
+++ incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/runclient.bat Wed Sep 13 06:07:32 2006
@@ -37,11 +37,12 @@
 set TUSCANY_SCACPP_SYSTEM_ROOT=%~d0%~p0\..\
 set TUSCANY_SCACPP_DEFAULT_COMPONENT=sample.calculator.CalculatorComponent
 
-set PATH=%TUSCANY_SCACPP%\bin;%TUSCANY_SCACPP%\extensions\cpp\bin;%TUSCANY_SDOCPP%\bin;%AXIS2C_HOME%\lib;%PATH%
+set PATH=%TUSCANY_SCACPP%\bin;%TUSCANY_SCACPP%\extensions\python\bin;%TUSCANY_SDOCPP%\bin;%AXIS2C_HOME%\lib;%PATH%
 
-.\calculator_client.exe add 4.7 9
-.\calculator_client.exe div 7.2 3.6
-.\calculator_client.exe mul 7 6
 
+python calculator_client.py add 4.7 9   
+python calculator_client.py div 7.2 3.6 
+python calculator_client.py mul 7 6 
+    
 :end
 endlocal

Modified: incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/runclient.sh
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/runclient.sh?view=diff&rev=442977&r1=442976&r2=442977
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/runclient.sh (original)
+++ incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator.client/runclient.sh Wed Sep 13 06:07:32 2006
@@ -36,12 +36,13 @@
 
 TEST_SYSTEM=$APFULLDIR/../
 
-export LD_LIBRARY_PATH=$TUSCANY_SCACPP/lib:$TUSCANY_SCACPP/extensions/cpp/lib:$TUSCANY_SDOCPP/lib:$AXIS2C_HOME/lib:$LD_LIBRARY_PATH
+export LD_LIBRARY_PATH=$TUSCANY_SCACPP/lib:$TUSCANY_SCACPP/extensions/python/lib:$TUSCANY_SDOCPP/lib:$AXIS2C_HOME/lib:$LD_LIBRARY_PATH
 
 export TUSCANY_SCACPP_SYSTEM_ROOT=$TEST_SYSTEM
 export TUSCANY_SCACPP_DEFAULT_COMPONENT=sample.calculator.CalculatorComponent
 
-./calculator_client add 4.7 9
-./calculator_client div 7.2 3.6
-./calculator_client mul 7 6
+python calculator_client.py add 4.7 9   
+python calculator_client.py div 7.2 3.6 
+python calculator_client.py mul 7 6 
+    
 

Modified: incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/CalculatorImpl.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/CalculatorImpl.componentType?view=diff&rev=442977&r1=442976&r2=442977
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/CalculatorImpl.componentType (original)
+++ incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/CalculatorImpl.componentType Wed Sep 13 06:07:32 2006
@@ -18,11 +18,11 @@
 <componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
 
 	<service name="CalculatorService">
-		<interface.cpp header="Calculator.h"/>
+		<interface.python/>
 	</service>
 
     <reference name="divideService">
-		<interface.cpp header="Divide.h"/>
+		<interface.python/>
 	</reference>
 
 </componentType>

Added: incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/CalculatorImpl.py
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/CalculatorImpl.py?view=auto&rev=442977
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/CalculatorImpl.py (added)
+++ incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/CalculatorImpl.py Wed Sep 13 06:07:32 2006
@@ -0,0 +1,56 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#
+# 
+# 
+# This Python code is a simple sample that provides a Python implementation of 
+# the Calculator sample
+# 
+ 
+
+# The module-level add function
+def add(val1, val2):
+    result = float(val1) + float(val2)
+    print "Python - CalculatorImpl.add " + str(val1) + " + " + str(val2) + " = " + str(result)
+    return result
+
+# The module-level sub function
+def sub(val1, val2):
+    result = float(val1) - float(val2)
+    print "Python - CalculatorImpl.sub " + str(val1) + " - " + str(val2) + " = " + str(result)
+    return result
+
+# The module-level mul function
+def mul(val1, val2):
+    result = float(val1) * float(val2)
+    print "Python - CalculatorImpl.mul " + str(val1) + " * " + str(val2) + " = " + str(result)
+    return result
+
+# The module-level div function
+def div(val1, val2):
+    
+
+    print "Python - CalculatorImpl.div calling divideService to determine " + str(val1) + " / " + str(val2)
+
+    # Use the divideService reference
+    result = divideService.divide(val1, val2)
+
+    print "Python - CalculatorImpl.div divideService returned " + str(result)
+
+    return result
+

Modified: incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/DivideImpl.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/DivideImpl.componentType?view=diff&rev=442977&r1=442976&r2=442977
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/DivideImpl.componentType (original)
+++ incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/DivideImpl.componentType Wed Sep 13 06:07:32 2006
@@ -18,7 +18,7 @@
 <componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
 
 	<service name="DivideService">
-		<interface.cpp header="Divide.h"/>
+		<interface.python/>
 	</service>
 
 </componentType>

Modified: incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/Makefile.am?view=diff&rev=442977&r1=442976&r2=442977
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/Makefile.am (original)
+++ incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/Makefile.am Wed Sep 13 06:07:32 2006
@@ -1,32 +1,6 @@
 deploydir=$(prefix)/samples/PythonCalculator/deploy
 compositedir=$(deploydir)/packages/sample.calculator
 
-BUILT_SOURCES = CalculatorImpl_CalculatorService_Proxy.cpp \
-CalculatorImpl_CalculatorService_Wrapper.cpp \
-CalculatorImpl_divideService_Proxy.cpp
-
-noinst_HEADERS = *.h
-
-${BUILT_SOURCES}: sample.calculator.composite
-	java -jar $(TUSCANY_SCACPP)/bin/scagen.jar -dir . -output .
-
-composite_LTLIBRARIES = libCalculator.la
 composite_DATA = *.composite *.componentType *.wsdl *.py
 EXTRA_DIST = *.composite *.componentType *.wsdl *.py
 
-libCalculator_la_SOURCES = \
-CalculatorImpl.cpp \
-CalculatorImpl_CalculatorService_Proxy.cpp \
-CalculatorImpl_CalculatorService_Wrapper.cpp \
-CalculatorImpl_divideService_Proxy.cpp
-
-libCalculator_la_LIBADD = \
--L${TUSCANY_SCACPP}/lib \
-  -ltuscany_sca \
--L${TUSCANY_SCACPP}/extensions/cpp/lib \
-  -ltuscany_sca_cpp
-
-INCLUDES = \
--I$(TUSCANY_SCACPP)/extensions/cpp/include \
--I$(TUSCANY_SCACPP)/include \
--I${TUSCANY_SDOCPP}/include

Modified: incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/sample.calculator.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/sample.calculator.composite?view=diff&rev=442977&r1=442976&r2=442977
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/sample.calculator.composite (original)
+++ incubator/tuscany/cpp/sca/samples/PythonCalculator/sample.calculator/sample.calculator.composite Wed Sep 13 06:07:32 2006
@@ -19,18 +19,18 @@
 	name="sample.calculator">
 
 	<service name="CalculatorService">
-		<interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/>
-		<binding.ws/>
+		<interface.wsdl interface="http://sample/calculator#wsdl.interface(CalculatorPortType)"/>
+		<binding.ws port="http://sample/calculator#wsdl.endpoint(CalculatorService/CalculatorPort)"/>
 		<reference>CalculatorComponent/CalculatorService</reference>
 	</service>
 
 	<component name="CalculatorComponent">
-		<implementation.cpp library="Calculator" header="CalculatorImpl.h"/>
+        <implementation.python module="CalculatorImpl" scope="composite"/>
 	    <reference name="divideService">DivideComponent/DivideService</reference>
 	</component>
-        
-	<component name="DivideComponent">
-		<implementation.python module="DivideImpl" class="DivideClass"/>
-	</component>
+
+    <component name="DivideComponent">
+        <implementation.python module="DivideImpl" scope="composite"/>
+    </component>
 
 </composite>



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