diff options
Diffstat (limited to 'tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src')
13 files changed, 0 insertions, 1321 deletions
diff --git a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/Makefile.am b/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/Makefile.am deleted file mode 100644 index 523996e74e..0000000000 --- a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/Makefile.am +++ /dev/null @@ -1,45 +0,0 @@ -# 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. - -libdir=$(prefix)/extensions/php/lib -lib_LTLIBRARIES = libtuscany_sca_php.la -includedir=$(prefix)/extensions/php/include -nobase_include_HEADERS = \ -tuscany/sca/php/*.h \ -tuscany/sca/php/model/*.h - -libtuscany_sca_php_la_SOURCES = \ -tuscany/sca/php/PHPExtension.cpp \ -tuscany/sca/php/PHPImplementationExtension.cpp \ -tuscany/sca/php/PHPServiceWrapper.cpp \ -tuscany/sca/php/model/PHPImplementation.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 - -INCLUDES = -Imodel -I$(top_builddir)/runtime/core/src \ - -I${TUSCANY_SDOCPP}/include \ - -I${PHP_INCLUDE} \ - -I${PHP_INCLUDE}/main \ - -I${PHP_INCLUDE}/Zend \ - -I${PHP_INCLUDE}/TSRM \ - -I${PHP_INCLUDE}/sapi/embed - -AM_CPPFLAGS = $(CPPFLAGS) -D_DEBUG -
\ No newline at end of file diff --git a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/osoa/sca/ServiceRuntimeException.h b/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/osoa/sca/ServiceRuntimeException.h deleted file mode 100644 index d31679b994..0000000000 --- a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/osoa/sca/ServiceRuntimeException.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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 osoa_sca_serviceruntimeexception_h -#define osoa_sca_serviceruntimeexception_h - -#include "osoa/sca/export.h" - -#include "tuscany/sca/util/Exceptions.h" -using tuscany::sca::TuscanyRuntimeException; -namespace osoa -{ - namespace sca - { - /** - * Top level exception to represent all the exceptions that may be - * thrown by an SCA runtime implementation. - */ - class SCA_PHP_API ServiceRuntimeException : public TuscanyRuntimeException - { - public: - ServiceRuntimeException( - const char *name="ServiceRuntimeException", - severity_level sev=Severe, - const char* msg_text="") - : TuscanyRuntimeException(name, sev, msg_text) - { - } - }; // End ServiceRuntimeException class definition - - - /** - * A remotable service is currently unavailable. It is possible that a retry - * may resolve this exception. - */ - class SCA_PHP_API ServiceUnavailableException: public ServiceRuntimeException - { - public: - ServiceUnavailableException(const char* serviceName) - : ServiceRuntimeException("ServiceUnavailableException", Warning, - serviceName) - { - } - private: - }; // End ServiceUnavailableException class definition - - - /** - * The target of a wire cannot be found, or the reference has not been - * configured. - */ - class SCA_PHP_API ServiceNotFoundException: public ServiceRuntimeException - { - public: - ServiceNotFoundException(const char* msg) - : ServiceRuntimeException("ServiceNotFoundException", Error, - msg) - { - } - private: - }; // End ServiceNotFoundException class definition - - - /** - * There is no current component (for example, if a non-SCA component - * tries to get the current ComponentContext). - */ - class SCA_PHP_API ComponentContextException: public ServiceRuntimeException - { - public: - ComponentContextException(const char* msg) - : ServiceRuntimeException("ComponentContextException", Error, - msg) - { - } - private: - }; // End ComponentContextException class definition - - /** - * There is an error whilst trying to invoke a component. - */ - class SCA_PHP_API ComponentInvocationException: public ServiceRuntimeException - { - public: - ComponentInvocationException(const char* msg) - : ServiceRuntimeException("ComponentInvocationException", Error, - msg) - { - } - private: - }; // End ComponentInvocationException class definition - - - } // End namespace sca -} // End namespace osoa - -#endif // osoa_sca_serviceruntimeexception_h diff --git a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/osoa/sca/export.h b/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/osoa/sca/export.h deleted file mode 100644 index 99794a3352..0000000000 --- a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/osoa/sca/export.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 osoa_sca_export_h -#define osoa_sca_export_h -#include "tuscany/sca/export.h" - -#if defined(WIN32) || defined (_WINDOWS) -#pragma warning(disable: 4786) - -#ifdef TUSCANY_SCA_PHP_EXPORTS -#define SCA_PHP_API __declspec(dllexport) -#else -#define SCA_PHP_API __declspec(dllimport) -#endif - -#else -#include <sys/time.h> -#include <inttypes.h> -#include <stdlib.h> -#define SCA_PHP_API -#endif - -#endif // osoa_sca_export_h diff --git a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp b/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp deleted file mode 100644 index f8768738e9..0000000000 --- a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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/PHPExtension.h" -#include "tuscany/sca/util/Logging.h" -#include "tuscany/sca/core/SCARuntime.h" -#include "tuscany/sca/php/PHPImplementationExtension.h" - - -extern "C" -{ - #if defined(WIN32) || defined(_WINDOWS) - __declspec(dllexport) - #endif - void tuscany_sca_extension_initialize() - { - tuscany::sca::php::PHPExtension::initialize(); - } -} - -namespace tuscany -{ - namespace sca - { - namespace php - { - // =================================================================== - // Constructor for the PHPExtension class. - // =================================================================== - PHPExtension::PHPExtension() - { - LOGENTRY(1, "PHPExtension::constructor"); - LOGEXIT(1, "PHPExtension::constructor"); - } - - // =================================================================== - // Destructor for the PHPExtension class. - // =================================================================== - PHPExtension::~PHPExtension() - { - LOGENTRY(1, "PHPExtension::destructor");; - LOGEXIT(1, "PHPExtension::destructor"); - } - - void PHPExtension::initialize() - { - LOGENTRY(1, "PHPExtension::initialize");; - SCARuntime::getInstance()->registerImplementationExtension(new PHPImplementationExtension()); - //SCARuntime::getInstance()->registerInterfaceExtension(new PHPInterfaceExtension()); - LOGEXIT(1, "PHPExtension::initialize");; - } - - } // End namespace php - } // End namespace sca -} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.h b/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.h deleted file mode 100644 index 971ed93c86..0000000000 --- a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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_phpextension_h -#define tuscany_sca_php_phpextension_h - -namespace tuscany -{ - namespace sca - { - namespace php - { - - class PHPExtension - { - public: - /** - * Default constructor - */ - PHPExtension(); - - /** - * Destructor - */ - virtual ~PHPExtension(); - - static void initialize(); - - private: - - }; - - - } // End namespace php - } // End namespace sca -} // End namespace tuscany - -#endif // tuscany_sca_php_phpextension_h - diff --git a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.cpp b/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.cpp deleted file mode 100644 index 7f204b0ce9..0000000000 --- a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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/PHPImplementationExtension.h" -#include "tuscany/sca/php/model/PHPImplementation.h" -#include "tuscany/sca/util/Logging.h" -#include "tuscany/sca/util/Utils.h" - - -namespace tuscany -{ - namespace sca - { - namespace php - { - // =================================================================== - // Constructor for the PHPImplementationExtension class. - // =================================================================== - PHPImplementationExtension::PHPImplementationExtension() - { - LOGENTRY(1, "PHPImplementationExtension::constructor"); - LOGEXIT(1, "PHPImplementationExtension::constructor"); - } - - // =================================================================== - // Destructor for the PHPImplementationExtension class. - // =================================================================== - PHPImplementationExtension::~PHPImplementationExtension() - { - LOGENTRY(1, "PHPImplementationExtension::destructor");; - LOGEXIT(1, "PHPImplementationExtension::destructor"); - } - - const string PHPImplementationExtension::extensionName("php"); - const string PHPImplementationExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#PHPImplementation"); - - // =================================================================== - // loadModelElement - load the info from implementation.php - // =================================================================== - ComponentType* PHPImplementationExtension::getImplementation(Composite *composite, DataObjectPtr scdlImplementation) - { - string implType = scdlImplementation->getType().getName(); - if (implType == "PHPImplementation") - { - string module = scdlImplementation->getCString("module"); - string className = scdlImplementation->getCString("class"); - - PHPImplementation* phpImpl = new PHPImplementation(composite, module, className); - - return phpImpl; - } - else - { - return NULL; - } - } - - } // End namespace php - } // End namespace sca -} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.h b/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.h deleted file mode 100644 index 9aa4aea969..0000000000 --- a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPImplementationExtension.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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_phpimplementationextension_h -#define tuscany_sca_php_phpimplementationextension_h - -#include "tuscany/sca/extension/ImplementationExtension.h" - -namespace tuscany -{ - namespace sca - { - namespace php - { - - class PHPImplementationExtension : public ImplementationExtension - { - public: - /** - * Default constructor - */ - PHPImplementationExtension(); - - /** - * Destructor - */ - virtual ~PHPImplementationExtension(); - - /** - * return the name of the extension - */ - virtual const string& getExtensionName() {return extensionName;} - - /** - * return the QName of schema element for this implementation extension - * (e.g. "http://www.osoa.org/xmlns/sca/1.0#implementation.phpn") - */ - virtual const string& getExtensionTypeQName() {return typeQName;} - - virtual ComponentType* getImplementation(Composite* composite, DataObjectPtr scdlImplementation); - - private: - static const string extensionName; - static const string typeQName; - - }; - - - } // End namespace php - } // End namespace sca -} // End namespace tuscany - -#endif // tuscany_sca_php_phpimplementationextension_h - diff --git a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp b/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp deleted file mode 100644 index 1b11e660c6..0000000000 --- a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp +++ /dev/null @@ -1,405 +0,0 @@ -/* - * 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$ */ - - -// some strangeness in the build that causes -// WinSock.h and WinSock2.h to be included leading to redefinitions -#define _WINSOCKAPI_ - -#include "tuscany/sca/php/PHPServiceWrapper.h" - -#include "osoa/sca/ServiceRuntimeException.h" -#include "tuscany/sca/util/Logging.h" -#include "tuscany/sca/util/Utils.h" -#include "tuscany/sca/model/Component.h" -#include "tuscany/sca/model/Composite.h" -#include "tuscany/sca/model/ServiceType.h" -#include "tuscany/sca/model/Interface.h" -#include "tuscany/sca/core/SCARuntime.h" -#include "tuscany/sca/php/model/PHPImplementation.h" - -#include <php_embed.h> - -using namespace osoa::sca; - -namespace tuscany -{ - namespace sca - { - 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; - - // Global callbacks used by the PHP engine - - // Callback for log messages - void php_log_message(char *message) - { - LOGINFO_1(5, "PHP Log (%s)", message); - } - - // Callback for unbuffered writes (echo, print etc.) - int php_ub_write(const char *str, unsigned int str_length TSRMLS_DC) - { - LOGINFO_1(5, "PHP Write (%s)", str); - scriptResponse = str; - return str_length; - } - - // Callback for errors - void php_error_cb(int type, - const char *error_filename, - const uint error_lineno, - const char *format, va_list args) - { - char buffer[2048]; - int len; - - len = snprintf(buffer, 2048, "Error on line %d: ", error_lineno); - vsnprintf(buffer + len, (2048 - len), format, args); - LOGINFO_1(5, "PHP Unformatted Error (%s)", buffer); - zend_bailout(); - } - - // Callback for flush (could be used to do something with the scriptResponse) - void php_flush(void *server_context) - { - LOGINFO(5, "Flush"); - } - - // =========== - // Constructor - // =========== - PHPServiceWrapper::PHPServiceWrapper(Service* service) - : ServiceWrapper(service) - { - LOGENTRY(1,"PHPServiceWrapper::constructor"); - - component = service->getComponent(); - interf = service->getType()->getInterface(); - remotable = interf->isRemotable(); - - // ----------------------------------------------- - // Get the implementation for the target component - // ----------------------------------------------- - PHPImplementation* impl = (PHPImplementation*)component->getType(); - if (!impl) - { - string msg = "Component " + component->getName() + " has no implementation defined"; - throw ServiceNotFoundException(msg.c_str()); - } - - LOGINFO_1(3,"PHPServiceWrapper::getServiceWrapper module %s", impl->getModule().c_str()); - LOGINFO_1(3,"PHPServiceWrapper::getServiceWrapper class %s", impl->getClass().c_str()); - - LOGEXIT(1,"PHPServiceWrapper::constructor"); - - } - - // ========== - // Destructor - // ========== - PHPServiceWrapper::~PHPServiceWrapper() - { - LOGENTRY(1,"PHPServiceWrapper::destructor"); - LOGEXIT(1,"PHPServiceWrapper::destructor"); - } - - - // ====================================================================== - // invoke: wrapper call to service with setting the component context - // ====================================================================== - void PHPServiceWrapper::invoke(Operation& operation) - { - LOGENTRY(1,"PHPServiceWrapper::invoke"); - - SCARuntime* runtime = SCARuntime::getInstance(); - runtime->setCurrentComponent(component); - - try - { - LOGINFO_1(4, "PHPServiceWrapper::invoke called with operation name: %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 - - // get the component type information - PHPImplementation* impl = (PHPImplementation*)component->getType(); - - // first create the temporay script and include the module - string script = "include '" + 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: - { - throw new ComponentInvocationException("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_1(5, "Executing PHP script \n%s", script.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_START_BLOCK(/* argc */ 0, /* argv */ NULL) - void ***tsrm_ls; - int status = php_embed_init(0, NULL PTSRMLS_CC); - LOGINFO_1(5, "Engine startup status %d", status); - - zend_first_try { - // set error handler - zend_error_cb = php_error_cb; - - // call the dynamically created script - //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 - //convert_to_string(&retval); - //LOGINFO_1(5, "Script returned %s", Z_STRVAL(retval)); - //zval_dtor(&retval); - - //PHP_EMBED_END_BLOCK() - } zend_catch { - int exit_status = EG(exit_status); - LOGINFO_1(5, "In catch %d", exit_status); - } zend_end_try(); - - //clean up - php_embed_shutdown(TSRMLS_C); - LOGINFO(5, "Engine shutdown"); - - // get the response values - LOGINFO_1(5, "Script returned %s", scriptResponse.c_str()); - - switch(operation.getReturnType()) - { - 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:; - } - } - catch (...) - { - runtime->unsetCurrentComponent(); - throw; - } - runtime->unsetCurrentComponent(); - LOGEXIT(1,"PHPServiceWrapper::invoke"); - - } - - // ====================================================================== - // getServiceWrapper: create a wrapper for the target ComponentService - // ====================================================================== - PHPServiceWrapper* PHPServiceWrapper::getServiceWrapper(Service* service) - { - LOGENTRY(1,"PHPServiceWrapper::getServiceWrapper"); - PHPServiceWrapper* serviceWrapper = 0; - - // --------------------------------- - // Create an instance of the wrapper - // --------------------------------- - serviceWrapper = new PHPServiceWrapper(service); - if (!serviceWrapper) - { - string msg = "Could not create new PHPServiceWrapper"; - LOGERROR(1, msg.c_str()); - throw ServiceNotFoundException(msg.c_str()); - } - - LOGEXIT(1,"PHPServiceWrapper::getServiceWrapper"); - return serviceWrapper; - } - - } // End namespace php - } // End namespace sca -} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.h b/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.h deleted file mode 100644 index ef83a026a6..0000000000 --- a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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_phpservicewrapper_h -#define tuscany_sca_php_phpservicewrapper_h - - -#include "osoa/sca/export.h" -#include "tuscany/sca/core/ServiceWrapper.h" -#include "tuscany/sca/core/Operation.h" -#include "tuscany/sca/model/Component.h" -#include "tuscany/sca/model/Interface.h" - -using namespace tuscany::sca::model; - - -namespace tuscany -{ - namespace sca - { - namespace php - { - class PHPInterface; - - /** - * Wraps the service on a component implementation. - * This abstract class is extended by generated code which provides - * the implementation of some of the methods. - * An instance of this class wraps the actual component implementation which - * has been written by a developer of an SCA application. - */ - class SCA_PHP_API PHPServiceWrapper : public ServiceWrapper - { - public: - /** - * Factory method to create a new PHPServiceWrapper for a given target - * service. This method will provide all the loading of dlls required to - * create the target component. - * @param target The service on the component for which this wrapper is to be - * created. - * @return A wrapper that references the given target. - */ - static PHPServiceWrapper* getServiceWrapper(Service* service); - - /** - * Constructor. - * @param target The component service to which this wrapper refers. - */ - PHPServiceWrapper(Service* service); - - /** - * Destructor. - */ - virtual ~PHPServiceWrapper(); - - /** - * All business method calls to the target component go through the invoke method. - * @param operation The details of the method, paramaters and return value for the - * business method to be called on the target component. - */ - virtual void invoke(Operation& operation); - - - protected: - - - private: - - - /** - * The component to which this wrapper refers. - */ - Component* component; - - /** - * Set to true if the service is remotable. - */ - bool remotable; - - /** - * A pointer to the interface which the service exposes. - */ - Interface* interf; - - }; - - } // End namespace php - } // End namespace sca -} // End namespace tuscany - -#endif // tuscany_sca_php_phpservicewrapper_h diff --git a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp b/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp deleted file mode 100644 index f8992ed498..0000000000 --- a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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/PHPImplementation.h" -#include "tuscany/sca/php/model/PHPServiceBinding.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" -#include "tuscany/sca/util/Utils.h" - -namespace tuscany -{ - namespace sca - { - - namespace php - { - - // Constructor - PHPImplementation::PHPImplementation(Composite* composite, const string& module, const string& className) - : ComponentType(composite, module), - module(module), className(className) - { - LOGENTRY(1,"PHPImplementation::constructor"); - LOGEXIT(1,"PHPImplementation::constructor"); - } - - PHPImplementation::~PHPImplementation() - { - LOGENTRY(1,"PHPImplementation::destructor"); - LOGEXIT(1,"PHPImplementation::destructor"); - } - - void PHPImplementation::initializeComponent(Component* component) - { - LOGENTRY(1,"PHPImplementation::initializeComponent"); - ComponentType::initializeComponent(component); - - // Create PHP bindings for all the services - const Component::SERVICE_MAP& services = component->getServices(); - Component::SERVICE_MAP::const_iterator iter = services.begin(); - for (unsigned int i=0; i< services.size(); i++) - { - Service *service = iter->second; - PHPServiceBinding* binding = new PHPServiceBinding(service); - service->setBinding(binding); - 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++; - //} - LOGEXIT(1,"PHPImplementation::initializeComponent"); - } - - } // End namespace php - } // End namespace sca -} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.h b/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.h deleted file mode 100644 index b89ba8c5c2..0000000000 --- a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPImplementation.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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_phpimplementation_h -#define tuscany_sca_php_model_phpimplementation_h -#include "tuscany/sca/model/ComponentType.h" - -#include <map> -using std::map; -#include <string> -using std::string; - -using namespace tuscany::sca::model; - -namespace tuscany -{ - namespace sca - { - namespace php - { - /** - * Holds information about an SCA implementation written in PHP - */ - class PHPImplementation : public ComponentType - { - - public: - /** - * Constructor. - * @param composite Composite containing this implementation. - * @param module Name of the module. - * @param modulePath Path to the module (could be a blank string - * if this is not specified). - * @param className Name of the class in the module (could be a blank string - * if this is not specified). - */ - PHPImplementation(Composite* composite, const string& module, const string& className); - - /** - * Destructor - */ - virtual ~PHPImplementation(); - - /** - * Initialize a component of this type. - * @param component The component to initialize. - */ - virtual void initializeComponent(Component* component); - - /** - * Returns the name of the module. - * @return The name of the module. - */ - const string& getModule() const { return module; } - - /** - * Get the name of the class. - * @return The class name if specified. - */ - const string& getClass() const { return className; } - - private: - - /** - * Name of the module. - */ - string module; - - /** - * Name of the class in the header file declaring the implementation. - * May be an empty string if not set in the SCDL file. - */ - string className; - }; - - } // End namespace php - } // End namespace sca -} // End namespace tuscany - -#endif // tuscany_sca_php_model_phpimplementation_h diff --git a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.cpp b/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.cpp deleted file mode 100644 index fa162ce8f2..0000000000 --- a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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/PHPServiceBinding.h" -#include "tuscany/sca/php/PHPServiceWrapper.h" - -namespace tuscany -{ - namespace sca - { - namespace php - { - - // Constructor - PHPServiceBinding::PHPServiceBinding(Service* service) - : ServiceBinding(service, "") - { - LOGENTRY(1,"PHPServiceBinding::constructor"); - serviceWrapper = PHPServiceWrapper::getServiceWrapper(service); - LOGEXIT(1,"PHPServiceBinding::constructor"); - } - - // Destructor - PHPServiceBinding::~PHPServiceBinding() - { - LOGENTRY(1,"PHPServiceBinding::destructor"); - LOGEXIT(1,"PHPServiceBinding::destructor"); - } - - ServiceWrapper* PHPServiceBinding::getServiceWrapper() - { - LOGENTRY(1,"PHPServiceBinding::getServiceWrapper"); - LOGEXIT(1,"PHPServiceBinding::getServiceWrapper"); - return (ServiceWrapper*)serviceWrapper; - } - - } // End namespace php - } // End namespace sca -} // End namespace tuscany diff --git a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.h b/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.h deleted file mode 100644 index 6b1e694bd6..0000000000 --- a/tags/cpp-1.0-incubating-M2-RC2/sca/runtime/extensions/php/src/tuscany/sca/php/model/PHPServiceBinding.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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_phpservicebinding_h -#define tuscany_sca_php_model_phpservicebinding_h - -#include "tuscany/sca/model/ServiceBinding.h" -using namespace tuscany::sca::model; -#include <string> -using std::string; - -namespace tuscany -{ - namespace sca - { - namespace php - { - /** - * Information about a PHP service binding for service or a reference. - */ - class PHPServiceBinding : public ServiceBinding - { - public: - - /** - * Constructor. - * @param uri The uri of the binding. - * @param port The definition of the port to which the entrypoint - * or external service is to be bound. This is of the form - * "namespace"#endpoint("service"/"port") - */ - PHPServiceBinding(Service* service); - - /** - * Destructor. - */ - virtual ~PHPServiceBinding(); - - /** - * Returns the type of binding. - */ - virtual string getType() { return "http://www.osoa.org/xmlns/sca/1.0#PHPImplementationBinding"; }; - - /** - * Create a wrapper for the service configured by this - * binding. - */ - virtual ServiceWrapper* getServiceWrapper(); - - private: - - /** - * The wrapper for the service configured by this binding. - */ - ServiceWrapper* serviceWrapper; - - }; - - } // End namespace php - } // End namespace sca -} // End namespace tuscany - -#endif // tuscany_sca_php_model_phpservicebinding_h |