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 2007/02/02 16:28:05 UTC
svn commit: r502623 [1/3] - in /incubator/tuscany/cpp/sca:
VSExpress/tuscany_sca/tuscany_sca_php/ runtime/core/src/tuscany/sca/core/
runtime/core/src/tuscany/sca/model/ runtime/core/src/tuscany/sca/util/
runtime/extensions/php/ runtime/extensions/php/s...
Author: ajborley
Date: Fri Feb 2 07:28:01 2007
New Revision: 502623
URL: http://svn.apache.org/viewvc?view=rev&rev=502623
Log:
Simon's initial patch for TUSCANY-1089. Currently causes build failure in PHP extension & PHP samples due to requirement of the PHP PECL SCA_SDO package
Added:
incubator/tuscany/cpp/sca/runtime/extensions/php/README (with props)
incubator/tuscany/cpp/sca/runtime/extensions/php/deploy.bat (with props)
incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.cpp (with props)
incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.h (with props)
incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.cpp (with props)
incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.h (with props)
incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/php_sca.h (with props)
incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/sca.cpp (with props)
incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/sca.h (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/Makefile.am (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/CalculatorClient.cpp (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/Makefile
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/env.sh (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_cpp.sh (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_php.bat (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.componentType (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.cpp (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.h (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Proxy.cpp (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Proxy.h (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Wrapper.cpp (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Wrapper.h (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_divideService_Proxy.cpp (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_divideService_Proxy.h (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.componentType (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.cpp (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.h (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl_DivideService_Proxy.cpp (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl_DivideService_Proxy.h (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl_DivideService_Wrapper.cpp (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl_DivideService_Wrapper.h (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Log.componentType (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Log.h (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Log.php (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Makefile.am (with props)
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/runwsserver.sh (with props)
Modified:
incubator/tuscany/cpp/sca/VSExpress/tuscany_sca/tuscany_sca_php/tuscany_sca_php.vcproj
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp
incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Library.cpp
incubator/tuscany/cpp/sca/runtime/extensions/php/src/Makefile.am
incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp
incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp
incubator/tuscany/cpp/sca/samples/Makefile.am
incubator/tuscany/cpp/sca/samples/PHPCalculator/README
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/CalculatorClient.php
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.wsclient/CalculatorWSClient.php
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Add.componentType
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Add.php
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Calculator.wsdl
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Divide.componentType
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Divide.php
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Multiply.componentType
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Multiply.php
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Subtract.componentType
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Subtract.php
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/runwsserver.bat
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/sample.calculator.composite
incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/sample.calculator.composite.back
Modified: incubator/tuscany/cpp/sca/VSExpress/tuscany_sca/tuscany_sca_php/tuscany_sca_php.vcproj
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/VSExpress/tuscany_sca/tuscany_sca_php/tuscany_sca_php.vcproj?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/VSExpress/tuscany_sca/tuscany_sca_php/tuscany_sca_php.vcproj (original)
+++ incubator/tuscany/cpp/sca/VSExpress/tuscany_sca/tuscany_sca_php/tuscany_sca_php.vcproj Fri Feb 2 07:28:01 2007
@@ -40,7 +40,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="../../../runtime/extensions/php/src;../../../deploy/include;"$(TUSCANY_SDOCPP)/include";"$(PHP_HOME)/sapi/embed";"$(PHP_HOME)";"$(PHP_HOME)/zend";"$(PHP_HOME)/TSRM""
+ AdditionalIncludeDirectories="../../../runtime/extensions/php/src;../../../deploy/include;$(TUSCANY_SDOCPP)/include;$(PHP_HOME)/main;$(PHP_HOME)/sapi/embed;$(PHP_HOME);$(PHP_HOME)/zend;$(PHP_HOME)/TSRM"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TUSCANY_SCA_PHP_EXPORTS;ZEND_WIN32;PHP_WIN32;ZTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -187,6 +187,14 @@
>
</File>
<File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\model\PHPReferenceBinding.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\model\PHPReferenceBinding.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\model\PHPServiceBinding.cpp"
>
</File>
@@ -200,6 +208,10 @@
>
</File>
<File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\php_sca.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPExtension.cpp"
>
</File>
@@ -216,11 +228,27 @@
>
</File>
<File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPServiceProxy.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPServiceProxy.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPServiceWrapper.cpp"
>
</File>
<File
RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\PHPServiceWrapper.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\sca.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\runtime\extensions\php\src\tuscany\sca\php\sca.h"
>
</File>
</Files>
Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp Fri Feb 2 07:28:01 2007
@@ -430,6 +430,7 @@
logentry();
if (extension)
{
+ loginfo("Registering interface: %s", extension->getExtensionTypeQName().c_str());
interfaceExtensions[extension->getExtensionTypeQName()] = extension;
}
}
@@ -450,6 +451,7 @@
logentry();
if (extension)
{
+ loginfo("Registering implementation: %s", extension->getExtensionTypeQName().c_str());
implementationExtensions[extension->getExtensionTypeQName()] = extension;
}
}
@@ -470,6 +472,7 @@
logentry();
if (extension)
{
+ loginfo("Registering reference binding: %s", extension->getExtensionTypeQName().c_str());
referenceBindingExtensions[extension->getExtensionTypeQName()] = extension;
}
}
@@ -490,6 +493,7 @@
logentry();
if (extension)
{
+ loginfo("Registering service binding: %s", extension->getExtensionTypeQName().c_str());
serviceBindingExtensions[extension->getExtensionTypeQName()] = extension;
}
}
Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp Fri Feb 2 07:28:01 2007
@@ -806,12 +806,12 @@
void ModelLoader::loadXMLSchema(Composite* composite, const char *fileName)
{
logentry();
-
+ loginfo("Loading XML schema %s", fileName);
// Load a xsd file -> set the types in the data factory associated with
// the composite
try {
composite->getXSDHelper()->defineFile(fileName);
- //Utils::printTypes((*compositeIter)->getXSDHelper()->getDataFactory());
+ //Utils::printTypes(composite->getXSDHelper()->getDataFactory());
} catch (SDORuntimeException& ex)
{
Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Library.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Library.cpp?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Library.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Library.cpp Fri Feb 2 07:28:01 2007
@@ -98,7 +98,7 @@
{
dllName = name+".dll";
}
- SetErrorMode(SEM_FAILCRITICALERRORS);
+// SetErrorMode(SEM_FAILCRITICALERRORS);
hDLL = LoadLibrary(dllName.c_str());
if (hDLL == NULL)
{
Added: incubator/tuscany/cpp/sca/runtime/extensions/php/README
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/README?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/README (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/README Fri Feb 2 07:28:01 2007
@@ -0,0 +1,239 @@
+PHP Extension for C++ SCA README
+================================
+
+Overview
+--------
+
+The PHP extension for C++ SCA allows PHP scripts to be used to implement SCA components.
+This is achieved by using the C++ SCA extension API to drive script execution through the
+PHP embedding SAPI. In its current incarnation the PHP Extension requires that a full SCDL
+description is provided for each PHP component, i.e. we are not yet making use of the meta data
+provided by the annotations that can appear in PHP SCA components.
+
+There are various styles of PHP script that are supported. The examples here are taken from
+the PHPCalculator sample and if you look at the SCDL files provided with the sample you can
+see the component type and composite files that tie these components into the working system
+
+SCA Service
+-----------
+
+/**
+ * @service
+ * @binding.ws
+ */
+class Divide {
+
+ /**
+ * @reference
+ * @binding.tuscany cppDivideService
+ */
+ public $another_divide;
+
+ /**
+ * Division
+ *
+ * @param float $num1 (the first number)
+ * @param float $num2 (the second number)
+ * @return float The result
+ */
+ function div($num1, $num2) {
+ return $this->another_divide->div($num1, $num2);
+ }
+
+}
+
+PHP Class
+---------
+
+class Multiply {
+ function mul($num1, $num2) {
+ $result = $num1 * $num2;
+
+ $log_proxy = SCA::getService("log_service");
+ $log_proxy->log_message($result);
+
+ return $result;
+ }
+}
+
+PHP Function
+------------
+
+function sub($num1, $num2){
+ $result = $num1 - $num2;
+
+ $log_proxy = SCA::getService("log_service");
+ $log_proxy->log_message($result);
+
+ return $result;
+}
+
+PHP Script
+----------
+
+$num1 = $_REQUEST[0];
+$num2 = $_REQUEST[1];
+
+$result = $num1 + $num2;
+
+$log_proxy = SCA::getService("log_service");
+$log_proxy->log_message($result);
+
+echo $result;
+
+TODO
+----
+1 I could not get this extension to work on Windows (memory corruption) but I suspect
+ my configuration so I need to work with someone who is prepared to test it for me
+2 scagen does not run on my linux box (NPE) so I have constructed the PHPCalculator
+ sample from the parts of the CPPCalculator that had alread been generated. Need
+ to get a working scagen and try it from scratch
+3 I struggled for a long time with a missing symbol problem loading sdo.so at runtime on linux.
+ I got round this by creating a standalone Makefile for the CalculatorClient exe. All the
+ shared objects that are loaded are compiled with the normal automake toolchain still but this
+ solves the problem. I need to investigate in detail what's going on here. Having someone
+ else try building with the full automake configuration would be insteresting
+4 The problem from 3 appears when running SCA behind axis hence I am unable to test with
+ remote clients
+5 The SCA_SDO build generates sdo.so and the Tuscany PHP Extension tries to load libsdo.so.
+ One side needs fixing. For now I just copy the library
+6 SDO passing in and out of components is coded but not tested
+7 Returning values from plain PHP scripts (scripts without classes and functions) is not
+ operating correctly
+8 Error handling needs looking at. Many situations are not trapped and those
+ that are may not be reported correctly
+9 Reorganize the extension code so that Tuscany SCA can be loaded by PHP running in Apache
+ and accessed through SCA references. This will play the same role as SCA running hosted
+ in Axis2C and will open up the service bindings implemented in PHP SCA_SDO.
+10Implement meta data exchange between the PHP SCA implementation and the Tuscany C++ SCA
+ implementations so that selected parts of the SCDL definition can be omitted
+
+Dependencies
+------------
+PHP5.2.0 - (http://php.net/)
+ To compile this extension you require a working installation of PHP5.2
+PHP5.2.0 source code - - (http://php.net/)
+ The binary release of PHP doesn't ship with the header files required to build
+ against the PHP embedding SAPI and runtime libraries. You don't necessarily need
+ to build PHP though just have the PHP source available
+SCA_SDO PECL extension V1.1.2 - (http://pecl.php.net/package/SCA_SDO)
+ Provides the SCA framework for PHP and the necessary mediation code to translate
+ between Tuscany SCA and PHP SCA. You will need to copy the library sdo.so to
+ libsdo.so so that the Tuscany PHPExtension can load it given the makefile
+ configuration as it stands.
+SCA_SDO PECL extension V1.1.2 source code - (http://pecl.php.net/package/SCA_SDO)
+ On linux you can install this SCA_SDO extension automaitcally with PEAR but you
+ need access to the source to build the extension so it's best to go get the
+ extension and install it somewhere you can point PHP_SCA_SDO_INCLUDE to
+
+Building on windows
+-------------------
+
+The Visual C++ Express solution provided with C++ SCA includes a project
+to build the PHP extension. This project relies on being able to access the
+PHP include files from the source code directory and the PHP lib files from the
+binary install. Make sure your environment is set as follows before you start
+Visual C++ Express (if you do this after you start Visual C++ Express it will
+not pick up the changes)
+
+PHP_HOME = the root directory of the PHP 5.2.0 source code install
+PATH = ensure that the root directory of the PHP 5.2.0 binary install appears
+
+These changes come over and above the enviroment changes you need to make
+to build the core C++ SCA software (where are these described?)
+
+Now compile the PHP extension. Compiling with VC++ Express requires some care
+
+1/ Ensure that the PHP include files are configured correctly for
+ compiling against C++ SCA in Visual C++ express
+
+ See - http://bugs.php.net/bug.php?id=39130
+
+ Comment out two lines in $(PHP_HOME)/main/config.w32.h:
+ #define _USE_32BIT_TIME_T 1
+ #define HAVE_STDLIB_H 1
+
+
+Building on Linux
+-----------------
+
+The PHP extension comes with a set of automake files so that the PHP extension is built
+at the same time as all of the other extensions assuming that appropriate environment
+variables are set. The build.sh script that can be found under the top level sca directory
+checks whether the PHP_LIB and PHP_INCLUDE variables are set and if so enables compilation
+of the PHP extension automatically by adding --enable-php to the configure line.
+
+There are a number of environment variables that the build depends on. I find setting the
+following variables useful.
+
+# the location of libxm2
+export LIBXML2_LIB=/usr/lib
+export LIBXML2_INCLUDE=/usr/include/libxml2
+
+# the location of PHP
+export PHP_LIB=/usr/local/lib
+export PHP_INCLUDE=/usr/local/include/php
+
+# the location of the PHP SCA_SDO extension source
+# the lib location depends oh the configuration options used
+# when building PHP so beware
+export PHP_SCA_SDO_INCLUDE=where ever you install the SCA_SDO package source
+export PHP_SCA_SDO_LIB=$PHP_LIB/php/extensions/no-debug-zts-20060613/
+
+# the location of axis2
+export AXIS2C_HOME=/usr/local/axis2c-bin-0.96-linux
+
+# the install directories for the tuscany sca and sdo projects
+export TUSCANY_SDOCPP=/usr/local/tuscany/cpp/sdo/deploy
+export TUSCANY_SCACPP=/usr/local/tuscany/cpp/sca/deploy
+
+Once these are set running sca/build.sh should compile and install the PHP extension.
+
+Testing the PHP Extension
+-------------------------
+
+In order to run the PHP extension successfully as an embedded component of the
+C++ SCA runtime the PHP environment must be configured correctly. This configuration
+is provided by the php.ini file. The location of this file depends on your installation
+of PHP but by default is as follows.
+
+/usr/local/bin - PHP executables
+/usr/local/lib/php.ini - the ini file that tell PHP where to look for scripts and
+ extension libraries
+/usr/local/lib/php - PHP runtime installation, extension files and tests
+
+As is usually the case your milage may vary but wherever PHP is installed you will find
+a similar set of directories. To force PHP to look in the correct place use the following
+setting
+
+# tell PHP specifically where to find php.ini rather than relying on the default
+set PHPRC=/usr/local/lib
+
+The php.ini file must be configured to load the SCA_SDO extension so you would expect to
+see the following modifications to the file.
+
+; around line 528 you need to set the variable that tells PHP where to
+; load extension libraries from. This varies depending on how PHP has been
+; compiled and installed, for example,
+extension_dir = "/usr/local/lib/php/extensions/no-debug-zts-20060613/"
+
+; around line 512 you need to set the variable that tells PHP where to
+; load included scripts from. There are windows and unix versions. Here
+; is a Unix example
+include_path=".:/usr/local/lib/php:/usr/local/lib/php/PEAR:/usr/local/tuscany/cppsca/samples/PHPCalculator/deploy/sample.calculator"
+
+; around line 673 you will find the end of the list of enabled extensions. We need to turn
+; on SDO so add the following line. sdo.so should be found in "extension_dir".
+extension=sdo.so
+
+
+
+Compiling with VC++ Express requires some care
+
+- http://bugs.php.net/bug.php?id=39130
+
+ Comment out two lines in config.w32.h:
+ #define _USE_32BIT_TIME_T 1
+ #define HAVE_STDLIB_H 1
+
+-
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/README
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/README
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/php/deploy.bat
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/deploy.bat?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/deploy.bat (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/deploy.bat Fri Feb 2 07:28:01 2007
@@ -0,0 +1,64 @@
+@echo off
+
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements. See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership. The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License. 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,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied. See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+
+
+setlocal
+
+if . == .%1 (
+echo sca root not specified
+goto usage
+)
+set rootdir=%1
+set deploydir=%rootdir%\deploy
+set extdir=%deploydir%\extensions
+set phpextdir=%extdir%\php
+set srcdir=%rootdir%\runtime\extensions\php\src
+
+if . == .%2 (
+echo input directory not specified
+goto usage
+)
+set inpath=%2
+echo %inpath%
+
+
+if not exist %deploydir% mkdir %deploydir%
+if not exist %extdir% mkdir %extdir%
+if not exist %phpextdir% mkdir %phpextdir%
+if not exist %phpextdir%\bin mkdir %phpextdir%\bin
+if not exist %phpextdir%\lib mkdir %phpextdir%\lib
+if not exist %phpextdir%\xsd mkdir %phpextdir%\xsd
+
+del %phpextdir%\bin\tuscany_sca_php.*
+del %phpextdir%\lib\*.lib
+
+@ copy %srcdir%\deploy.bat %phpextdir%
+copy %srcdir%\..\xsd\*.* %phpextdir%\xsd
+
+copy %inpath%\tuscany_sca_php.lib %phpextdir%\lib
+copy %inpath%\tuscany_sca_php.dll %phpextdir%\bin\tuscany_sca_php.dll
+
+if exist %inpath%\tuscany_sca_php.pdb copy %inpath%\tuscany_sca_php.pdb %phpextdir%\bin
+
+goto end
+:usage
+echo "Usage: deploy <sca-root> <build-output>"
+:end
+
+endlocal
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/deploy.bat
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/deploy.bat
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/cpp/sca/runtime/extensions/php/src/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/src/Makefile.am?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/src/Makefile.am (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/src/Makefile.am Fri Feb 2 07:28:01 2007
@@ -26,12 +26,16 @@
tuscany/sca/php/PHPExtension.cpp \
tuscany/sca/php/PHPImplementationExtension.cpp \
tuscany/sca/php/PHPServiceWrapper.cpp \
+tuscany/sca/php/PHPServiceProxy.cpp \
+tuscany/sca/php/sca.cpp \
tuscany/sca/php/model/PHPImplementation.cpp \
+tuscany/sca/php/model/PHPReferenceBinding.cpp \
tuscany/sca/php/model/PHPServiceBinding.cpp
libtuscany_sca_php_la_LIBADD = -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo \
-L$(top_builddir)/runtime/core/src -ltuscany_sca \
- -L${PHP_LIB} -lphp5 -lresolv
+ -L${PHP_LIB} -lphp5 \
+ -L${PHP_SCA_SDO_LIB} -lsdo
INCLUDES = -Imodel -I$(top_builddir)/runtime/core/src \
-I${TUSCANY_SDOCPP}/include \
@@ -39,7 +43,8 @@
-I${PHP_INCLUDE}/main \
-I${PHP_INCLUDE}/Zend \
-I${PHP_INCLUDE}/TSRM \
- -I${PHP_INCLUDE}/sapi/embed
+ -I${PHP_INCLUDE}/sapi/embed \
+ -I${PHP_SCA_SDO_INCLUDE}
+
+AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
-AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG
-
\ No newline at end of file
Added: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.cpp?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.cpp Fri Feb 2 07:28:01 2007
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/php/PHPServiceProxy.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/php/model/PHPReferenceBinding.h"
+
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+
+ // ============================================
+ // Constructor: Create a proxy from a reference
+ // ============================================
+ PHPServiceProxy::PHPServiceProxy(Reference* reference)
+ : ServiceProxy(reference)
+ {
+ logentry();
+
+ // Get the service wrapper
+ PHPReferenceBinding* referenceBinding = (PHPReferenceBinding*)reference->getBinding();
+ serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper();
+ }
+
+ // ==========================================
+ // Constructor: Create a proxy from a service
+ // ==========================================
+ PHPServiceProxy::PHPServiceProxy(Service* service)
+ : ServiceProxy(NULL)
+ {
+ logentry();
+
+ // Get the service wrapper
+ serviceWrapper = service->getBinding()->getServiceWrapper();
+ }
+
+ // ==========
+ // Destructor
+ // ==========
+ PHPServiceProxy::~PHPServiceProxy()
+ {
+ logentry();
+ }
+
+ // =====================================================
+ // invokeService: invoke the service wired to this proxy
+ // =====================================================
+ void PHPServiceProxy::invokeService(Operation& operation)
+ {
+ logentry();
+
+ // Invoke the service
+ serviceWrapper->invoke(operation);
+ }
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.h?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.h (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.h Fri Feb 2 07:28:01 2007
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_php_phpserviceproxy_h
+#define tuscany_sca_php_phpserviceproxy_h
+
+#include "export.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Service.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+
+ /**
+ * Holds a proxy for a given reference from a component implemented in PHP.
+ */
+ class PHPServiceProxy : public ServiceProxy
+ {
+ public:
+ /**
+ * Create a new service proxy for a reference. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param reference The reference on the source component.
+ */
+ PHPServiceProxy(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Create a new service proxy for a service. The proxy will contain a pointer to
+ * the target ServiceWrapper.
+ * @param service The service on the target component.
+ */
+ PHPServiceProxy(tuscany::sca::model::Service* service);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PHPServiceProxy();
+
+ /**
+ * Invoke the wired service.
+ */
+ virtual void invokeService(Operation& operation);
+
+ private:
+
+ /**
+ * The target service wrapper
+ */
+ ServiceWrapper* serviceWrapper;
+ };
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_php_phpserviceproxy_h
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceProxy.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp Fri Feb 2 07:28:01 2007
@@ -22,13 +22,15 @@
// some strangeness in the build that causes
// WinSock.h and WinSock2.h to be included leading to redefinitions
-#define _WINSOCKAPI_
-
-#include <iostream>
+//#define _WINSOCKAPI_
#include <php_embed.h>
+#include <iostream>
+#include <sstream>
+
#include "tuscany/sca/php/PHPServiceWrapper.h"
+#include "tuscany/sca/php/PHPServiceProxy.h"
#include "tuscany/sca/util/Logging.h"
#include "tuscany/sca/core/Exceptions.h"
#include "tuscany/sca/util/Utils.h"
@@ -39,6 +41,9 @@
#include "tuscany/sca/core/SCARuntime.h"
#include "tuscany/sca/php/model/PHPImplementation.h"
+
+#include "sca.h"
+
using namespace std;
using namespace tuscany::sca::model;
@@ -48,29 +53,32 @@
{
namespace php
{
- // a global!! place to put the response
- // as I can't get the PHP return value
- // processing to work. Need to be
- // removed when the proper PHP SAPI is used
- // The variable is only valid between the PHP engine call and
- // the results processing. It stores the last thing that
- // the script echoed
- string scriptResponse;
-
+
+ int embedSAPIInitializeCount = 0;
+
// Global callbacks used by the PHP engine
+ // Callback for SAPI error
+ void php_sapi_error(int type, const char *error_msg, ...)
+ {
+ logwarning("PHP sapi error: %s", error_msg);
+ //TODO - do something sensible with this output
+ zend_bailout();
+ }
+
// Callback for log messages
void php_log_message(char *message)
{
loginfo("PHP log: %s", message);
+ //TODO - do something sensible with this output
}
// Callback for unbuffered writes (echo, print etc.)
int php_ub_write(const char *str, unsigned int str_length TSRMLS_DC)
{
logentry();
- loginfo("Write: %s", str);
- scriptResponse = str;
+ loginfo("PHP Output: %s", str);
+ //TODO - do something sensible with this output
return str_length;
}
@@ -85,17 +93,13 @@
char buffer[2048];
int len;
- len = snprintf(buffer, 2048, "Error on line %d: ", error_lineno);
+ len = snprintf(buffer, 2048, "Error in file %s on line %d: ", error_filename, error_lineno);
vsnprintf(buffer + len, (2048 - len), format, args);
- logwarning("PHP unformatted error: %s", buffer);
+ logwarning("PHP error: %s", buffer);
+ //TODO - do something sensible with this output
zend_bailout();
}
- // Callback for flush (could be used to do something with the scriptResponse)
- void php_flush(void *server_context)
- {
- logentry();
- }
// ===========
// Constructor
@@ -138,252 +142,139 @@
void PHPServiceWrapper::invoke(Operation& operation)
{
logentry();
-
+
+ // set the current component in the SCA runtime
+ // so that other things can get at it thorugh this
+ // static class
SCARuntime* runtime = SCARuntime::getCurrentRuntime();
runtime->setCurrentComponent(component);
-
- try
- {
- loginfo("Operation: %s", operation.getName().c_str());
- // create a temporary script which
- // - includes the named script
- // - creates a class instance if required
- // - calls the named method with the provided arguments
-
+ try
+ {
// get the component type information
PHPImplementation* impl = (PHPImplementation*)component->getType();
// get the directory containing the component type
const string &compositeDir = impl->getComposite()->getRoot();
-
- // first create the temporay script and include the module
- string script = "include '" + compositeDir + "/" + impl->getModule() + ".php';";
-
- // if we have a class create an instance
- string className = impl->getClass();
- if( &className != NULL && className.size() > 0)
- {
- script += "$anobject = new " + className + "();";
- }
-
- // construct the call to the function
- script += "$response = ";
-
- if( &className != NULL && className.size() > 0)
- {
- script += " $anobject->";
- }
-
- script += operation.getName().c_str();
- script += "(";
-
- char tempString [32];
-
- // add the parameters to the call
- for(unsigned int i = 0; i < operation.getNParms(); i++)
- {
- const Operation::Parameter& parm = operation.getParameter(i);
- switch(parm.getType())
- {
- case Operation::BOOL:
- {
- if( *(bool*)parm.getValue())
- {
- //boolean true
- script += "true";
- }
- else
- {
- script += "false";
- }
- break;
- }
- case Operation::SHORT:
- {
- sprintf ( tempString, "%d", *(short*)parm.getValue() );
- script += tempString;
- break;
- }
- case Operation::USHORT:
- {
- sprintf ( tempString, "%d", *(unsigned short*)parm.getValue() );
- script += tempString;
- break;
- }
- case Operation::LONG:
- {
- sprintf ( tempString, "%d", *(long*)parm.getValue() );
- script += tempString;
- break;
- }
- case Operation::ULONG:
- {
- sprintf ( tempString, "%d", *(unsigned long*)parm.getValue() );
- script += tempString;
- break;
- }
- case Operation::FLOAT:
- {
- sprintf ( tempString, "%g", *(float*)parm.getValue() );
- script += tempString;
- break;
- }
- case Operation::DOUBLE:
- {
- sprintf ( tempString, "%g", *(double*)parm.getValue() );
- script += tempString;
- break;
- }
- case Operation::LONGDOUBLE:
- {
- sprintf ( tempString, "%g", *(long double*)parm.getValue() );
- script += tempString;
- break;
- }
- case Operation::CHARS:
- {
- script += *(char**)parm.getValue();
- break;
- }
- case Operation::STRING:
- {
- script += (*(string*)parm.getValue()).c_str();
- break;
- }
- default:
- {
- throwException(ServiceDataException, "Operation parameter type not supported");
- }
- }
-
- if ( ( i + 1 ) < operation.getNParms() )
- {
- script += ", ";
- }
- }
-
-
- // the closing bracket of the call
- script += ");echo $response;return $response;";
-
- // we now have the temporary script to make the call
- loginfo("Script: %s", script.c_str());
+ // get some useful information that will be used later
+ // when we construct the wrapper script
+ string componentName = component->getName();
+ string className = impl->getClass();
+ string operationName = operation.getName();
+ loginfo("Component %s class %s operation: %s",
+ componentName.c_str(),
+ className.c_str(),
+ operationName.c_str());
+
// load the PHP logging and error callback methods
php_embed_module.log_message = php_log_message;
php_embed_module.ub_write = php_ub_write;
- php_embed_module.flush = php_flush;
+ php_embed_module.sapi_error = php_sapi_error;
- //PHP_EMBED_START_BLOCK(/* argc */ 0, /* argv */ NULL)
- void ***tsrm_ls;
- int status = php_embed_init(0, NULL PTSRMLS_CC);
- loginfo("Engine startup status: %d", status);
-
- zend_first_try {
+// would normally use the following macro before the embeded call
+// but we need to take account of multiple nested calls
+// and ZTS threading safety is not behaving itself
+// PHP_EMBED_START_BLOCK(/* argc */ 0, /* argv */ NULL)
+// =====================================================================
+ {
+#ifdef ZTS
+ static void ***tsrm_ls;
+ loginfo("ZTS enabled");
+#endif
+ if ( embedSAPIInitializeCount == 0 )
+ {
+ embedSAPIInitializeCount = 1;
+
+ php_embed_init(0, NULL PTSRMLS_CC);
+
+ // load up the sca module that provides the interface between
+ // C++ and user space PHP
+ zend_startup_module(&sca_module_entry);
+ }
+ else
+ {
+ embedSAPIInitializeCount++;
+ }
+// should really be doing a first try but don't want to
+// do it more than once
+// zend_first_try {
+ zend_try {
+// =====================================================================
// set error handler
zend_error_cb = php_error_cb;
-
+
+ // create an SCA_Tuscany object and give it the operation
+ // object so that the script in user space PHP can get
+ // at the arguments and return a response.
+ long object_id = createSCATuscanyObject(operation TSRMLS_CC);
+ std::stringstream string_stream;
+ string object_id_str;
+ string_stream << object_id;
+ string_stream >> object_id_str;
+
+ // create the wrapper script that gets everything up and
+ // going in userspace PHP
+ string script;
+ script += "include 'SCA/SCA.php';";
+ script += "include 'SCA/SCA_TuscanyWrapper.php';";
+ script += "$wrapper = new SCA_TuscanyWrapper(";
+ script += object_id_str;
+ script += ", '" + componentName + "', ";
+
+ if( &className != NULL && className.size() > 0)
+ {
+ script += " '" + className + "'";
+ }
+ else
+ {
+ script += "null";
+ }
+
+ script += ", '" + operationName + "');";
+ script += "include '" + compositeDir + "/" + impl->getModule() + ".php';";
+ script += "$response = $wrapper->invoke();";
+ script += "echo $response;";
+ loginfo("Script: %s", script.c_str());
+
// call the dynamically created script
+ // I'm not trapping the return value here
+ // as it seems to prevent any kind of output
+ // being produced. Needs investigation.
//zval retval;
zend_eval_string((char *) script.c_str(),
NULL,//&retval,
"PHP Component" TSRMLS_CC);
- // get the response
- // This doesn't want to work for some reason
- // so have chaced the last echo that the script
- // returns in the global scriptResponse variable
- // This is a bit of a rubbish way of doing things so
- // needs replacing when proper SAPI is used
+ // As retval is not behaving post processing is commented out for now
//convert_to_string(&retval);
- //loginfo("Script returned: %s", Z_STRVAL(retval));
+ //loginfo("Script returned1: %s", Z_STRVAL(retval));
//zval_dtor(&retval);
-
- //PHP_EMBED_END_BLOCK()
- } zend_catch {
- int exit_status = EG(exit_status);
- loginfo("In catch: %d", exit_status);
- } zend_end_try();
-
- //clean up
-// TODO
-// Shutdown is crashing now I have moved from PHP5.1.4 to PHP5.2.0
-// This SAPI needs rewiriting properly anyhow so I'm not spending the
-// time to fix at the moment
-// php_embed_shutdown(TSRMLS_C);
- loginfo("Engine shutdown");
-
- // get the response values
- loginfo("Script returned: %s", scriptResponse.c_str());
-
-// TODO
-// how do we determine the return type of the component method
-// something has changed in the infrastructure so that this no longer works
-// I'm cheating for now and assuming it is always a string.
-// Needs fixing when we revist the SAPI
-// the following has the effect of setting the return value type
-// to CHARS
- static const char *tempChars = "";
- operation.setReturnValue(&tempChars);
-
- switch(operation.getReturnType())
+
+// would normally use the following macro after the embeded call
+// but we need to take account of multiple nested calls
+// PHP_EMBED_END_BLOCK()
+// =====================================================================
+ } zend_catch {
+ /* int exit_status = EG(exit_status); */
+ }
+ zend_end_try();
+
+ if ( embedSAPIInitializeCount == 1 )
+ {
+ php_embed_shutdown(TSRMLS_C);
+ loginfo("Engine shutdown");
+ }
+ else
{
- case Operation::BOOL:
- {
- if(scriptResponse == "true")
- {
- *(bool*)operation.getReturnValue() = true;
- }
- break;
- }
- case Operation::SHORT:
- {
- *(short*)operation.getReturnValue() = (short) strtol(scriptResponse.c_str(), NULL,10);
- break;
- }
- case Operation::LONG:
- {
- *(long*)operation.getReturnValue() = (long) strtol(scriptResponse.c_str(), NULL,10);
- break;
- }
- case Operation::USHORT:
- {
- *(unsigned short*)operation.getReturnValue() = (unsigned short) strtoul(scriptResponse.c_str(), NULL,10);
- break;
- }
- case Operation::ULONG:
- {
- *(unsigned long*)operation.getReturnValue() = (unsigned long) strtoul(scriptResponse.c_str(), NULL,10);
- break;
- }
- case Operation::FLOAT:
- {
- *(float*)operation.getReturnValue() = (float) strtod(scriptResponse.c_str(), NULL);
- break;
- }
- case Operation::DOUBLE:
- {
- *(double*)operation.getReturnValue() = (double) strtod(scriptResponse.c_str(), NULL);
- break;
- }
- case Operation::LONGDOUBLE:
- {
- *(long double*)operation.getReturnValue() = (long double) strtod(scriptResponse.c_str(), NULL);
- break;
- }
- case Operation::CHARS:
- {
- *(char**)operation.getReturnValue() = (char *)scriptResponse.c_str();
- break;
- }
- case Operation::STRING:
- {
- *(string*)operation.getReturnValue() = scriptResponse;
- break;
- }
- default:;
+ embedSAPIInitializeCount--;
+ }
}
+// =====================================================================
+
+ // The response is set back into 'operation' by the
+ // PECL extension code when the PHP user sapce wrapper
+ // calls setResponse()
}
catch (...)
{
@@ -391,6 +282,7 @@
throw;
}
runtime->unsetCurrentComponent();
+
}
// ======================================================================
Modified: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp Fri Feb 2 07:28:01 2007
@@ -22,7 +22,7 @@
#include "tuscany/sca/util/Logging.h"
#include "tuscany/sca/php/model/PHPImplementation.h"
#include "tuscany/sca/php/model/PHPServiceBinding.h"
-//#include "tuscany/sca/php/model/PHPReferenceBinding.h"
+#include "tuscany/sca/php/model/PHPReferenceBinding.h"
#include "tuscany/sca/model/Component.h"
#include "tuscany/sca/model/Service.h"
#include "tuscany/sca/model/Reference.h"
@@ -68,18 +68,16 @@
iter++;
}
- // References not yet supported..
-
- //// Create PHP bindings for all the references
- //const Component::REFERENCE_MAP& references = component->getReferences();
- //Component::REFERENCE_MAP::const_iterator refiter = references.begin();
- //for (int ri=0; ri< references.size(); ri++)
- //{
- // Reference *reference = refiter->second;
- // PHPReferenceBinding* binding = new PHPReferenceBinding(reference);
- // reference->setBinding(binding);
- // refiter++;
- //}
+ // Create PHP bindings for all the references
+ const Component::REFERENCE_MAP& references = component->getReferences();
+ Component::REFERENCE_MAP::const_iterator refiter = references.begin();
+ for (int ri=0; ri< references.size(); ri++)
+ {
+ Reference *reference = refiter->second;
+ PHPReferenceBinding* binding = new PHPReferenceBinding(reference);
+ reference->setBinding(binding);
+ refiter++;
+ }
}
} // End namespace php
Added: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.cpp?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.cpp Fri Feb 2 07:28:01 2007
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/php/model/PHPReferenceBinding.h"
+#include "tuscany/sca/php/PHPServiceProxy.h"
+
+using namespace std;
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+
+ // Constructor
+ PHPReferenceBinding::PHPReferenceBinding(Reference* reference)
+ : ReferenceBinding(reference, ""), serviceProxy(NULL)
+ {
+ }
+
+ // Destructor
+ PHPReferenceBinding::~PHPReferenceBinding()
+ {
+ }
+
+ ServiceProxy* PHPReferenceBinding::getServiceProxy()
+ {
+ return serviceProxy;
+ }
+
+ void PHPReferenceBinding::configure(ServiceBinding* binding)
+ {
+ targetServiceBinding = binding;
+
+ serviceProxy = new PHPServiceProxy(getReference());
+ }
+
+ } // End namespace
+ } // End namespace sca
+} // End namespace tuscany
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.h?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.h (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.h Fri Feb 2 07:28:01 2007
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_php_model_phpreferencebinding_h
+#define tuscany_sca_php_model_phpreferencebinding_h
+
+#include <string>
+
+#include "tuscany/sca/model/ReferenceBinding.h"
+
+
+namespace tuscany
+{
+ namespace sca
+ {
+ namespace php
+ {
+ /**
+ * Information about a PHP service binding for service or a reference.
+ */
+ class PHPReferenceBinding : public tuscany::sca::model::ReferenceBinding
+ {
+ public:
+
+ /**
+ * Constructor.
+ */
+ PHPReferenceBinding(tuscany::sca::model::Reference* reference);
+
+ /**
+ * Destructor.
+ */
+ virtual ~PHPReferenceBinding();
+
+ /**
+ * Returns the type of binding.
+ */
+ virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#PHPImplementationBinding"; };
+
+ /**
+ * Create a proxy representing the reference to the
+ * client component.
+ */
+ virtual ServiceProxy* getServiceProxy();
+
+ /**
+ * Configure this binding from a service binding.
+ */
+ virtual void configure(tuscany::sca::model::ServiceBinding* serviceBinding);
+
+ /**
+ * Returns the target service binding.
+ */
+ tuscany::sca::model::ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; };
+
+ private:
+
+ /**
+ * The proxy representing the reference to the client
+ * component.
+ */
+ ServiceProxy* serviceProxy;
+
+ /**
+ * The service binding of the target
+ */
+ tuscany::sca::model::ServiceBinding* targetServiceBinding;
+ };
+
+ } // End namespace php
+ } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_php_model_phpreferencebinding_h
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPReferenceBinding.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/php_sca.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/php_sca.h?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/php_sca.h (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/php_sca.h Fri Feb 2 07:28:01 2007
@@ -0,0 +1,153 @@
+/*
+ * 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.
+ */
+
+/* $ Id: $ */
+
+#ifndef PHP_SCA_H
+#define PHP_SCA_H
+
+#include "tuscany/sca/core/Operation.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef HAVE_CONFIG_H
+//#include "config.h"
+#endif
+
+#include <php.h>
+
+#ifdef HAVE_SCA
+
+#include <php_ini.h>
+#include <SAPI.h>
+#include <ext/standard/info.h>
+#include <Zend/zend_extensions.h>
+#ifdef __cplusplus
+} // extern "C"
+#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+//extern zend_module_entry sca_module_entry;
+#define phpext_sca_ptr &sca_module_entry
+
+#ifdef PHP_WIN32
+#define PHP_SCA_API __declspec(dllexport)
+#else
+#define PHP_SCA_API
+#endif
+
+PHP_MINIT_FUNCTION(sca);
+PHP_MSHUTDOWN_FUNCTION(sca);
+PHP_RINIT_FUNCTION(sca);
+PHP_RSHUTDOWN_FUNCTION(sca);
+PHP_MINFO_FUNCTION(sca);
+
+#ifdef ZTS
+#include "TSRM.h"
+#endif
+
+#define FREE_RESOURCE(resource) zend_list_delete(Z_LVAL_P(resource))
+
+#define PROP_GET_LONG(name) Z_LVAL_P(zend_read_property(_this_ce, _this_zval, #name, strlen(#name), 1 TSRMLS_CC))
+#define PROP_SET_LONG(name, l) zend_update_property_long(_this_ce, _this_zval, #name, strlen(#name), l TSRMLS_CC)
+
+#define PROP_GET_DOUBLE(name) Z_DVAL_P(zend_read_property(_this_ce, _this_zval, #name, strlen(#name), 1 TSRMLS_CC))
+#define PROP_SET_DOUBLE(name, d) zend_update_property_double(_this_ce, _this_zval, #name, strlen(#name), d TSRMLS_CC)
+
+#define PROP_GET_STRING(name) Z_STRVAL_P(zend_read_property(_this_ce, _this_zval, #name, strlen(#name), 1 TSRMLS_CC))
+#define PROP_GET_STRLEN(name) Z_STRLEN_P(zend_read_property(_this_ce, _this_zval, #name, strlen(#name), 1 TSRMLS_CC))
+#define PROP_SET_STRING(name, s) zend_update_property_string(_this_ce, _this_zval, #name, strlen(#name), s TSRMLS_CC)
+#define PROP_SET_STRINGL(name, s, l) zend_update_property_string(_this_ce, _this_zval, #name, strlen(#name), s, l TSRMLS_CC)
+
+
+PHP_METHOD(SCA_Tuscany, getSCATuscanyObject);
+#if (PHP_MAJOR_VERSION >= 5)
+ZEND_BEGIN_ARG_INFO_EX(SCA_Tuscany_getSCATuscanyObject_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, object_id)
+ZEND_END_ARG_INFO()
+#else /* PHP 4.x */
+#define SCA_Tuscany_getSCATuscanyObject_args NULL
+#endif
+
+PHP_METHOD(SCA_Tuscany, __construct);
+#if (PHP_MAJOR_VERSION >= 5)
+ZEND_BEGIN_ARG_INFO_EX(SCA_Tuscany____construct_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+#else /* PHP 4.x */
+#define SCA_Tuscany____construct_args NULL
+#endif
+
+PHP_METHOD(SCA_Tuscany, invoke);
+#if (PHP_MAJOR_VERSION >= 5)
+ZEND_BEGIN_ARG_INFO_EX(SCA_Tuscany__invoke_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 4)
+ ZEND_ARG_INFO(0, component_name)
+ ZEND_ARG_INFO(0, reference_name)
+ ZEND_ARG_INFO(0, method_name)
+#if (PHP_MINOR_VERSION > 0)
+ ZEND_ARG_ARRAY_INFO(0, arguments, 1)
+#else
+ ZEND_ARG_INFO(0, arguments)
+#endif
+ZEND_END_ARG_INFO()
+#else /* PHP 4.x */
+#define SCA_Tuscany__invoke_args NULL
+#endif
+
+PHP_METHOD(SCA_Tuscany, getArgArray);
+#if (PHP_MAJOR_VERSION >= 5)
+ZEND_BEGIN_ARG_INFO_EX(SCA_Tuscany__getArgArray_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+#else /* PHP 4.x */
+#define SCA_Tuscany__getArgArray_args NULL
+#endif
+
+PHP_METHOD(SCA_Tuscany, setResponse);
+#if (PHP_MAJOR_VERSION >= 5)
+ZEND_BEGIN_ARG_INFO_EX(SCA_Tuscany__setResponse_args, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_INFO(0, response)
+ZEND_END_ARG_INFO()
+#else /* PHP 4.x */
+#define SCA_Tuscany__setResponse_args NULL
+#endif
+
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+
+
+#endif /* PHP_HAVE_SCA */
+
+#endif /* PHP_SCA_H */
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/php_sca.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/php_sca.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org