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 [2/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...
Added: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/sca.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/sca.cpp?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/sca.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/sca.cpp Fri Feb 2 07:28:01 2007
@@ -0,0 +1,750 @@
+/*
+ * 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: $ */
+
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/php/PHPServiceProxy.h"
+#include "commonj/sdo/RefCountingPointer.h"
+
+using namespace std;
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+using namespace tuscany::sca::php;
+using namespace commonj::sdo;
+
+#define HAVE_SCA 1
+
+
+#include "php_sca.h"
+#include "sca.h"
+
+#if HAVE_SCA
+
+#include "php_sdo.h"
+#include "php_sdo_int.h"
+/* {{{ Class definitions */
+
+/* {{{ Class SCA_Tuscany */
+
+static zend_class_entry * SCA_Tuscany_ce_ptr = NULL;
+static zend_object_handlers SCA_Tuscany_object_handlers;
+
+/* {{{ Methods */
+
+/* {{{ proto object getSCATuscanyObject(long object_id)
+ return an SCA_Tuscany object based on the object_id
+ the object_id
+ */
+PHP_METHOD(SCA_Tuscany, getSCATuscanyObject)
+{
+ long object_id = 0;
+
+ printf("IN getSCATuscanyObject\n");
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "l", &object_id) == FAILURE)
+ {
+ return;
+ }
+
+ Z_TYPE_P(return_value) = IS_OBJECT;
+
+ // poke the object id that has been passed in into the zval
+ // to fake the creation of the object
+ return_value->value.obj.handle = (zend_object_handle) object_id;
+ return_value->value.obj.handlers = &SCA_Tuscany_object_handlers;
+ return_value->value.obj.handlers->add_ref(return_value TSRMLS_CC);
+}
+/* }}} getSCATuscanyObject */
+
+/* {{{ proto void __construct(int operation_handle)
+ */
+PHP_METHOD(SCA_Tuscany, __construct)
+{
+ zend_class_entry * _this_ce;
+ zval * _this_zval;
+ long operation_handle = 0;
+
+ printf("IN constructor\n");
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &operation_handle) == FAILURE) {
+ return;
+ }
+
+ _this_zval = getThis();
+ _this_ce = Z_OBJCE_P(_this_zval);
+
+ PROP_SET_LONG("operation", operation_handle);
+}
+/* }}} __construct */
+
+/* {{{ proto int invoke(string component_name, string reference_name, string method_name, array arguments)
+ Invoke a Tuscany component */
+PHP_METHOD(SCA_Tuscany, invoke)
+{
+ zend_class_entry * _this_ce;
+ zval * _this_zval = NULL;
+ const char * component_name = NULL;
+ int component_name_len = 0;
+ const char * reference_name = NULL;
+ int reference_name_len = 0;
+ const char * method_name = NULL;
+ int method_name_len = 0;
+ zval * arguments = NULL;
+ HashTable * arguments_hash = NULL;
+
+ printf("IN invoke\n");
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osssa/", &_this_zval, SCA_Tuscany_ce_ptr, &component_name, &component_name_len, &reference_name, &reference_name_len, &method_name, &method_name_len, &arguments) == FAILURE) {
+ return;
+ }
+
+ arguments_hash = HASH_OF(arguments);
+
+ // find the correct service proxy
+ SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+ Component* component = runtime->getCurrentComponent();
+ Reference* ref = component->findReference(reference_name);
+ if(!ref)
+ {
+ char *class_name;
+ char *space;
+ class_name = get_active_class_name(&space TSRMLS_CC);
+ php_error(E_ERROR,
+ "%s%s%s(): Can't find reference %s",
+ class_name,
+ space,
+ get_active_function_name(TSRMLS_C),
+ reference_name);
+ return;
+ }
+
+ ReferenceBinding* refBinding = ref->getBinding();
+ PHPServiceProxy *serviceProxy = (PHPServiceProxy*) refBinding->getServiceProxy();
+
+ // construct an operation structure
+ Operation operation(method_name);
+
+ // add the parameters to the operation
+ for ( zend_hash_internal_pointer_reset(arguments_hash);
+ zend_hash_has_more_elements(arguments_hash) == SUCCESS;
+ zend_hash_move_forward(arguments_hash) )
+ {
+ zval **data;
+
+ if ( zend_hash_get_current_data(arguments_hash,
+ (void**)&data ) == FAILURE )
+ {
+ continue;
+ }
+
+ char *hashKey;
+ uint hashKeyLength;
+ ulong hashIndex;
+ int type;
+
+ type = zend_hash_get_current_key_ex(arguments_hash,
+ &hashKey,
+ &hashKeyLength,
+ &hashIndex,
+ 0,
+ NULL);
+
+ switch(Z_TYPE_PP(data))
+ {
+ case IS_NULL:
+ {
+ printf("NULL agument");
+ }
+ case IS_BOOL:
+ {
+ convert_to_boolean(*data);
+ bool *newBool = new bool;
+ *newBool = Z_BVAL_PP(data);
+ operation.addParameter(newBool);
+ break;
+ }
+ case IS_LONG:
+ {
+ convert_to_long(*data);
+ long *newLong = new long;
+ *newLong = Z_LVAL_PP(data);
+ operation.addParameter(newLong);
+ break;
+ }
+ case IS_DOUBLE:
+ {
+ //convert_to_double(*data);
+ //double *newDouble = new double;
+ convert_to_double(*data);
+ float *newDouble = new float;
+ *newDouble = (float)Z_DVAL_PP(data);
+ operation.addParameter(newDouble);
+ break;
+ }
+ case IS_STRING:
+ {
+ convert_to_string(*data);
+ string newString (Z_STRVAL_PP(data));
+ operation.addParameter(&newString);
+ break;
+ }
+ case IS_OBJECT:
+ {
+ // convert the PHP SDO into a Tuscany SDO
+ DataObjectPtr sdo = sdo_do_get(*data TSRMLS_CC);
+ operation.addParameter(&sdo);
+ break;
+ }
+ default:
+ {
+ char *class_name;
+ char *space;
+ class_name = get_active_class_name(&space TSRMLS_CC);
+ php_error(E_ERROR,
+ "%s%s%s(): Input argument type %d not supported on invoke",
+ class_name,
+ space,
+ get_active_function_name(TSRMLS_C),
+ Z_TYPE_PP(data));
+ }
+ }
+ }
+
+ // call the proxy
+ serviceProxy->invokeService(operation);
+
+ switch(operation.getReturnType())
+ {
+ case Operation::BOOL:
+ {
+ ZVAL_BOOL(return_value, *(bool*)operation.getReturnValue());
+ break;
+ }
+ case Operation::SHORT:
+ case Operation::USHORT:
+ case Operation::LONG:
+ case Operation::ULONG:
+ {
+ ZVAL_LONG(return_value, *(long*)operation.getReturnValue());
+ break;
+ }
+ case Operation::FLOAT:
+ case Operation::DOUBLE:
+ case Operation::LONGDOUBLE:
+ {
+ ZVAL_DOUBLE(return_value, (double)*(float*)operation.getReturnValue());
+ break;
+ }
+ case Operation::CHARS:
+ {
+ ZVAL_STRING(return_value, (char*)operation.getReturnValue(), 1);
+ break;
+ }
+ case Operation::STRING:
+ {
+ ZVAL_STRING(return_value, (char*)((string*)operation.getReturnValue())->c_str(), 1);
+ break;
+ }
+ case Operation::VOID_TYPE:
+ {
+ // do nothing
+ }
+ case Operation::DATAOBJECT:
+ {
+ // convert the tuscany SDO into a PHP SDO
+ sdo_do_new(return_value, *(DataObjectPtr*)operation.getReturnValue() TSRMLS_CC);
+ break;
+ }
+ default:
+ {
+ char *class_name;
+ char *space;
+ class_name = get_active_class_name(&space TSRMLS_CC);
+ php_error(E_ERROR,
+ "%s%s%s(): Response type %d not supported on invoke",
+ class_name,
+ space,
+ get_active_function_name(TSRMLS_C),
+ operation.getReturnType());
+ }
+ }
+
+}
+/* }}} invoke */
+
+
+
+/* {{{ proto array getArgArray()
+ return the arguments for the operation as an array */
+PHP_METHOD(SCA_Tuscany, getArgArray)
+{
+ zend_class_entry * _this_ce;
+ zval * _this_zval = NULL;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &_this_zval, SCA_Tuscany_ce_ptr) == FAILURE) {
+ return;
+ }
+
+ _this_zval = getThis();
+ _this_ce = Z_OBJCE_P(_this_zval);
+
+ array_init(return_value);
+
+ printf("IN getArgArray\n");
+
+ array_init(return_value);
+
+ // get the operaton object from the object properties
+
+ Operation *operation = (Operation *)(long)PROP_GET_LONG("operation");
+
+ // get the parameters from the operation structure
+ for(unsigned int i = 0; i < operation->getNParms(); i++)
+ {
+ const Operation::Parameter& parm = operation->getParameter(i);
+ printf("Arg %d type %d\n", i, parm.getType());
+ switch(parm.getType())
+ {
+ case Operation::BOOL:
+ {
+ add_next_index_bool(return_value,(int)*(bool*)parm.getValue() );
+ break;
+ }
+ case Operation::SHORT:
+ case Operation::USHORT:
+ case Operation::LONG:
+ case Operation::ULONG:
+ {
+ add_next_index_long(return_value,*(long*)parm.getValue() );
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ add_next_index_double(return_value,(double)*(float*)parm.getValue() );
+ break;
+ }
+ case Operation::DOUBLE:
+ case Operation::LONGDOUBLE:
+ {
+ add_next_index_double(return_value,*(double*)parm.getValue() );
+ break;
+ }
+ case Operation::CHARS:
+ {
+ add_next_index_string(return_value,*(char**)parm.getValue(), 1 );
+ break;
+ }
+ case Operation::STRING:
+ {
+ add_next_index_string(return_value,(char*)(*(string*)parm.getValue()).c_str(), 1 );
+ break;
+ }
+ case Operation::DATAOBJECT:
+ {
+ // convert the tuscany SDO into a PHP SDO
+
+ // create the object
+ zval * sdo;
+ sdo_do_new(sdo, *(DataObjectPtr*)parm.getValue() TSRMLS_CC);
+
+ // add it to the arg array
+ add_next_index_zval(return_value, sdo);
+ break;
+ }
+ default:
+ {
+ char *class_name;
+ char *space;
+ class_name = get_active_class_name(&space TSRMLS_CC);
+ php_error(E_ERROR,
+ "%s%s%s(): Argument type %d not supported",
+ class_name,
+ space,
+ get_active_function_name(TSRMLS_C),
+ parm.getType());
+ }
+ }
+ }
+}
+/* }}} getArgArray */
+
+
+/* {{{ proto void setResponse(mixed response)
+ set the results from the operation */
+PHP_METHOD(SCA_Tuscany, setResponse)
+{
+ zend_class_entry * _this_ce;
+ zval * _this_zval = NULL;
+ zval * response = NULL;
+
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oz/", &_this_zval, SCA_Tuscany_ce_ptr, &response) == FAILURE) {
+ return;
+ }
+
+ _this_zval = getThis();
+ _this_ce = Z_OBJCE_P(_this_zval);
+
+ printf("IN setResponse\n");
+
+ // get the operaton object from the object properties
+ Operation *operation = (Operation *)(long)PROP_GET_LONG("operation");
+
+ switch(Z_TYPE_P(response))
+ {
+ case IS_NULL:
+ {
+ printf("NULL response");
+ }
+ case IS_BOOL:
+ {
+ bool *newBool = new bool;
+ *newBool = Z_BVAL_P(response);
+ operation->setReturnValue(newBool);
+ break;
+ }
+ case IS_LONG:
+ {
+ long *newLong = new long;
+ *newLong = Z_LVAL_P(response);
+ operation->setReturnValue(newLong);
+ break;
+ }
+ case IS_DOUBLE:
+ {
+ //double *newDouble = new double;
+ float *newDouble = new float;
+ *newDouble = (float)Z_DVAL_P(response);
+ operation->setReturnValue(newDouble);
+ break;
+ }
+ case IS_STRING:
+ {
+ string newString (Z_STRVAL_P(response));
+ operation->setReturnValue(&newString);
+ break;
+ }
+ case IS_OBJECT:
+ {
+ // convert the PHP SDO into a Tuscany SDO
+ DataObjectPtr sdo = sdo_do_get(response TSRMLS_CC);
+ operation->setReturnValue(&sdo);
+ break;
+ }
+ default:
+ {
+ char *class_name;
+ char *space;
+ class_name = get_active_class_name(&space TSRMLS_CC);
+ php_error(E_ERROR,
+ "%s%s%s(): Input argument type %d not supported on invoke",
+ class_name,
+ space,
+ get_active_function_name(TSRMLS_C),
+ Z_TYPE_P(response));
+ }
+
+ }
+
+/*
+The following code interprets the return based on what the operation
+structure is expecting. In the case of a call from another dynamic script
+component this will be not be set correct so I have changed the code above
+to rely on the type returned from the script instead. Hanging on to the
+following switch just in case
+ switch(operation->getReturnType())
+ {
+ case Operation::BOOL:
+ {
+ convert_to_boolean(response);
+ *(bool*)operation->getReturnValue() = Z_BVAL_P(response);
+ break;
+ }
+ case Operation::SHORT:
+ {
+ convert_to_long(response);
+ *(short*)operation->getReturnValue() = (short) Z_LVAL_P(response);
+ break;
+ }
+ case Operation::LONG:
+ {
+ convert_to_long(response);
+ *(long*)operation->getReturnValue() = (long) Z_LVAL_P(response);
+ break;
+ }
+ case Operation::USHORT:
+ {
+ convert_to_long(response);
+ *(unsigned short*)operation->getReturnValue() = (unsigned short) Z_LVAL_P(response);
+ break;
+ }
+ case Operation::ULONG:
+ {
+ convert_to_long(response);
+ *(unsigned long*)operation->getReturnValue() = (unsigned long) Z_LVAL_P(response);
+ break;
+ }
+ case Operation::FLOAT:
+ {
+ convert_to_double(response);
+ *(float*)operation->getReturnValue() = (float) Z_DVAL_P(response);
+ break;
+ }
+ case Operation::DOUBLE:
+ {
+ convert_to_double(response);
+ *(double*)operation->getReturnValue() = (double) Z_DVAL_P(response);
+ break;
+ }
+ case Operation::LONGDOUBLE:
+ {
+ convert_to_double(response);
+ *(long double*)operation->getReturnValue() = (long double) Z_DVAL_P(response);
+ break;
+ }
+ case Operation::CHARS:
+ {
+ convert_to_string(response);
+ // need to copy the string out of PHP memory into SCA memory
+ char * strCopy = strdup((char *)Z_STRVAL_P(response));
+ *(char**)operation->getReturnValue() = strCopy;
+ break;
+ }
+ case Operation::STRING:
+ {
+ convert_to_string(response);
+ string reponseString ( Z_STRVAL_P(response) );
+ *(string*)operation->getReturnValue() = reponseString;
+ break;
+ }
+ case Operation::VOID_TYPE:
+ {
+ // do nothing
+ }
+ case Operation::DATAOBJECT:
+ {
+ // need to convert the PHP SDO into a Tuscanu SDO?
+ printf("SDOs are not supported yet");
+ break;
+ }
+ default:
+ {
+ char *class_name;
+ char *space;
+ class_name = get_active_class_name(&space TSRMLS_CC);
+ php_error(E_ERROR,
+ "%s%s%s(): Response type %d not supported",
+ class_name,
+ space,
+ get_active_function_name(TSRMLS_C),
+ operation->getReturnType());
+ }
+ }
+*/
+}
+/* }}} setResponse */
+
+
+static zend_function_entry SCA_Tuscany_methods[] = {
+ PHP_ME(SCA_Tuscany, getSCATuscanyObject, SCA_Tuscany_getSCATuscanyObject_args, /**/ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+ PHP_ME(SCA_Tuscany, __construct, NULL, /**/ZEND_ACC_PUBLIC)
+ PHP_ME(SCA_Tuscany, invoke, SCA_Tuscany__invoke_args, /**/ZEND_ACC_PUBLIC)
+ PHP_ME(SCA_Tuscany, getArgArray, NULL, /**/ZEND_ACC_PUBLIC)
+ PHP_ME(SCA_Tuscany, setResponse, SCA_Tuscany__setResponse_args, /**/ZEND_ACC_PUBLIC)
+ { NULL, NULL, NULL }
+};
+
+/* }}} Methods */
+
+static void class_init_SCA_Tuscany(TSRMLS_D)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "SCA_Tuscany", SCA_Tuscany_methods);
+ SCA_Tuscany_ce_ptr = zend_register_internal_class(&ce TSRMLS_CC);
+
+ /* {{{ Property registration */
+
+ zend_declare_property_long(SCA_Tuscany_ce_ptr,
+ "operation", 9, -1,
+ ZEND_ACC_PRIVATE TSRMLS_CC);
+
+ /* }}} Property registration */
+
+}
+
+/* }}} Class SCA_Tuscany */
+
+/* }}} Class definitions*/
+
+/* {{{ sca_functions[] */
+function_entry sca_functions[] = {
+ { NULL, NULL, NULL }
+};
+/* }}} */
+
+/* {{{ cross-extension dependencies */
+
+#if ZEND_EXTENSION_API_NO >= 220050617
+static zend_module_dep sca_deps[] = {
+ ZEND_MOD_REQUIRED("sdo")
+ {NULL, NULL, NULL, 0}
+};
+#endif
+/* }}} */
+
+/* {{{ sca_module_entry */
+zend_module_entry sca_module_entry = {
+#if ZEND_EXTENSION_API_NO >= 220050617
+ STANDARD_MODULE_HEADER_EX, NULL,
+ sca_deps,
+#else
+ STANDARD_MODULE_HEADER,
+#endif
+
+ "sca",
+ sca_functions,
+ PHP_MINIT(sca), /* Replace with NULL if there is nothing to do at php startup */
+ PHP_MSHUTDOWN(sca), /* Replace with NULL if there is nothing to do at php shutdown */
+ PHP_RINIT(sca), /* Replace with NULL if there is nothing to do at request start */
+ PHP_RSHUTDOWN(sca), /* Replace with NULL if there is nothing to do at request end */
+ PHP_MINFO(sca),
+ "0.0.1",
+ STANDARD_MODULE_PROPERTIES
+};
+/* }}} */
+
+#ifdef COMPILE_DL_SCA
+extern "C" {
+ZEND_GET_MODULE(sca)
+} // extern "C"
+#endif
+
+
+/* {{{ PHP_MINIT_FUNCTION */
+PHP_MINIT_FUNCTION(sca)
+{
+ class_init_SCA_Tuscany(TSRMLS_C);
+
+ memcpy(&SCA_Tuscany_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+/* {{{ PHP_MSHUTDOWN_FUNCTION */
+PHP_MSHUTDOWN_FUNCTION(sca)
+{
+
+ /* add your stuff here */
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+/* {{{ PHP_RINIT_FUNCTION */
+PHP_RINIT_FUNCTION(sca)
+{
+ /* add your stuff here */
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+/* {{{ PHP_RSHUTDOWN_FUNCTION */
+PHP_RSHUTDOWN_FUNCTION(sca)
+{
+ /* add your stuff here */
+
+ return SUCCESS;
+}
+/* }}} */
+
+
+/* {{{ PHP_MINFO_FUNCTION */
+PHP_MINFO_FUNCTION(sca)
+{
+ php_info_print_box_start(0);
+ php_printf("<p>SCA Extension</p>\n");
+ php_printf("<p>Version 0.0.1alpha (2007-01-15)</p>\n");
+ php_printf("<p><b>Authors:</b></p>\n");
+ php_printf("<p>Simon Laws <slaws@php.net> (lead)</p>\n");
+ php_printf("<p>Caroline Maynard <cem@php.net> (lead)</p>\n");
+ php_info_print_box_end();
+ php_info_print_table_start();
+ php_info_print_table_header(2, "SCA", "enabled");
+ php_info_print_table_row(2, "SCA Version", "0.0.1");
+ php_info_print_table_end();
+
+}
+/* }}} */
+
+/* Other functions not directly related to implementing the
+ SCA_Tuscany extension */
+
+long createSCATuscanyObject(Operation& operation TSRMLS_DC)
+{
+ printf("IN createSCATuscanyObject\n");
+
+ // create an object of type SCA_Tuscany
+ zval *_this_zval;
+ Z_TYPE_P(_this_zval) = IS_OBJECT;
+ if ( object_init_ex(_this_zval, SCA_Tuscany_ce_ptr) == FAILURE) {
+ char *class_name;
+ char *space;
+ class_name = get_active_class_name(&space TSRMLS_CC);
+ php_error(E_ERROR,
+ "%s%s%s(): internal error (%i) - failed to instantiate SCA_Tuscany object",
+ class_name,
+ space,
+ get_active_function_name(TSRMLS_C),
+ __LINE__);
+ return 0;
+ }
+
+ zend_class_entry * _this_ce;
+ _this_ce = Z_OBJCE_P(_this_zval);
+
+ // Set the address of the C++ operation object as a four byte value
+ // in the operation property
+ PROP_SET_LONG("operation", (long) &operation);
+
+ // get the four byte value of the address of the object
+ // we have just created and return it
+ long object_id = (long) Z_OBJ_HANDLE_P(_this_zval);
+
+ printf("IN object_id = %d\n", object_id);
+
+ return object_id;
+}
+
+#endif /* HAVE_SCA */
+
+
+/*
+ * 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/sca.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/sca.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/sca.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/sca.h?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/sca.h (added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/sca.h Fri Feb 2 07:28:01 2007
@@ -0,0 +1,55 @@
+/*
+ * 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 SCA_H
+#define SCA_H
+
+#include "tuscany/sca/core/Operation.h"
+
+#include <php.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// creates an instance of SCA_Tuscany and popoulates
+// the operation property. It returns the four byte
+// representation of the object id from the objects
+// zval.
+long createSCATuscanyObject(tuscany::sca::Operation& operation TSRMLS_DC);
+
+extern zend_module_entry sca_module_entry;
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif /* 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/sca.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/sca.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/cpp/sca/samples/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/Makefile.am?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/Makefile.am (original)
+++ incubator/tuscany/cpp/sca/samples/Makefile.am Fri Feb 2 07:28:01 2007
@@ -40,6 +40,7 @@
RUBY_SAMPLES = RubyCalculator RubyBigBank HttpdBigBank RestCalculator
endif
if WANT_PHP_SAMPLES
+ PHP_SAMPLES = PHPCalculator
endif
endif
SUBDIRS = ${CPP_SAMPLES} ${CPP_AXIS2C_SAMPLES} ${PYTHON_SAMPLES} ${RUBY_SAMPLES} ${PYTHON_RUBY_SAMPLES} ${PHP_SAMPLES}
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/Makefile.am?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/Makefile.am (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/Makefile.am Fri Feb 2 07:28:01 2007
@@ -0,0 +1,26 @@
+# 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.
+
+if WITH_AXIS2C
+ WSBINDING_SAMPLE = sample.calculator.wsclient
+endif
+
+deploydir=$(prefix)/samples/PHPCalculator/deploy
+# SUBDIRS = sample.calculator sample.calculator.client ${WSBINDING_SAMPLE}
+SUBDIRS = sample.calculator
+EXTRA_DIST = *.php *.composite README.html
+deploy_DATA = *.composite
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/Makefile.am
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/Makefile.am
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/cpp/sca/samples/PHPCalculator/README
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/README?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/README (original)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/README Fri Feb 2 07:28:01 2007
@@ -1,18 +1,18 @@
Tuscany SCA for C++ Samples - PHP Calculator Sample
===================================================
-This is a very simple sample to show how an SCA composite can wire together
-two components to implement a Calculator service and expose that service as
-a Web Service. The sample components are implemented in various ways to demonstrate
-the different features of the PHP SCA extension.
+This is a simple sample to show how an SCA composite can wire together
+a number of components to implement a Calculator service and expose that service as
+to a number of different tpyes of client. The sample components are implemented in various
+ways to demonstrate the different features of the PHP SCA extension.
There are three sub projects in this workspace:
- sample.calculator
- This contains the source code and SCDL artifacts for the SCA Calculator.
- composite implementing the sample Calculator.
+ This contains the source code and SCDL artifacts for the SCA Calculator
+ composite implementing the sample Calculator
- sample.calculator.client
- A sample client which does a local call to the Calculator service.
+ A sample client which does a local call to the Calculator service
- sample.calculator.wsclient
A sample PHP SCA Web Service client which calls the Calculator Web service.
@@ -23,32 +23,32 @@
(See the README.html file for instructions to build and run this sample - TODO)
-This is a work in progress. The ultimate intention is to demonstrate integration
-of PHP SCA with C++ SCA and this sample is being used as a motivator for that
-work. As it stands the PHP extension for C++ SCA only supports PHP functions or classes
-as service implementations and the work to include PHP SCA is in progress. To this end
-this sample exposes the "add" service and method. This is only callable from the
-CalculatorWSClient.php.
-
-
-Client (PHP/SCA) -> Calculator (PHP/SCA Service in PHP extension )
- add() ------------------------> Add (PHP function)
- sub() ------------------------> Subtract (PHP class/function)
- mul() ------------------------> PHP/SCA local service
- div() ------------------------> PHP/SCA remote service
-
-In the first instance of course we don't have this all working. The following is the
-current configuration
-
-Client (PHP/SCA) -> Calculator (PHP/SCA Service in PHP extension )
- add() ------------------------> Add (PHP function)
-
-To run the sample configure the axis runtime to reference the PHPCalculator
-application.
+The file phpcalculator.png is a picture of the sample. Given the restrictions on the
+current PHP extension (see TODOs in the PHP Extension README) some parts of this
+have not been tested yet.
+
+The path that has been tested is as follows:
+
+Local CPP client -> CPP Calculator -> PHP Divide -> PHP Add ------> PHP Log
+ |-------> PHP Subtract -> PHP Log
+ |-------> PHP Multiple -> PHP Log
+ |-------> PHP Divide ---> PHP Log
+
+The local CPP client is used because
+ - the work to enable PHP to host SCA is not done yet
+ - running with the axis service causes missing symbols errors on my box
+
+The CPP Calculator component is used because
+ - The local CPP client can only talk directly to a CPP component
+
+To run the sample in this configuration use the CalculatorClient.cpp found in the
+sample.calculator.client directory
Windows
=======
+Hasn't yet been tests on windows in this configuration so ignore the following
+
I use the following bat file to start the stand alone axis server and include
appropriate references to PHP dependencies. This needs turning into a proper
run script but I haven't got to this yet
@@ -70,14 +70,53 @@
to generate a web service request to the C++ SCA runtime hosting the calculator
application.
-Currently this doesn't runt all the way through due to a WSDL bug in PHP SCA
+Currently this doesn't run all the way through due to a WSDL bug in PHP SCA
(http://pecl.php.net/bugs/bug.php?id=9572). But it gets 99% of the way there.
You will see the server doing all of its stuff and returning the correct result.
Linux
=====
-TBD
-
+I find the following environment variables useful when running PHP embedded inside of
+Tuscany SCA.
+
+# the library path use to locate shared libraries
+export LD_LIBRARY_PATH=$LIBXML2_LIB:\
+$AXIS2C_HOME/lib:\
+$PHP_LIB:\
+$TUSCANY_SDOCPP/lib:\
+$TUSCANY_SCACPP/lib:\
+$TUSCANY_SCACPP/extensions/cpp/lib:\
+$TUSCANY_SCACPP/extensions/php/lib:\
+$TUSCANY_SCACPP/extensions/ws/lib:\
+$TUSCANY_SCACPP/samples/PHPCalculator/deploy/sample.calculator:\
+$PHP_SCA_SDO_LIB
+
+# tell PHP specifically where to find php.ini rather than relying on the default
+set PHPRC=/usr/local/lib
+
+# tell Tuscany SCA which composite appplication to run
+export TUSCANY_SCACPP_ROOT=/usr/local/tuscany/cpp/sca/deploy/samples/PHPCalculator
+
+# tell Tuscany SCA which is the default component in this composite
+export TUSCANY_SCACPP_COMPONENT=sample.calculator.CalculatorComponent
+
+# turn on logging so you can see what's going on
+export TUSCANY_SCACPP_LOGGING=9
+
+There is an env.sh file that can be edited and used to set your environment. One edited
+to reflect your environment do:
+
+source env.sh
+
+The CPP client currently has an independent Makefile due to build problems with the automake
+build on my box. If you have your environment configured as above you should be able to do:
+
+make
+
+This will produce a.out which can be run using the provided script.
+
+runclient_cpp.sh
+
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/CalculatorClient.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/CalculatorClient.cpp?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/CalculatorClient.cpp (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/CalculatorClient.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$ */
+
+// some strangeness in the build that causes
+// WinSock.h and WinSock2.h to be included leading to redefinitions
+//#define _WINSOCKAPI_
+
+
+#include <iostream>
+
+#include <php_embed.h>
+
+#include <string>
+
+#include "commonj/sdo/SDO.h"
+
+#include "osoa/sca/sca.h"
+
+#include "Calculator.h"
+
+
+using namespace std;
+using namespace commonj::sdo;
+using namespace osoa::sca;
+
+
+int main (int argc, char** argv)
+{
+
+ try
+ {
+ CompositeContext myContext = CompositeContext::getCurrent();
+ Calculator *calcService = (Calculator*) myContext.locateService("CalculatorCPPComponent/CalculatorService");
+ float result = calcService->div(10, 2);
+ cout << "calculator_client: div(10,2) = " << result << endl;
+ }
+ catch (...)
+ {
+ printf("Got and exception");
+ }
+
+ return 0;
+}
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/CalculatorClient.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/CalculatorClient.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/CalculatorClient.php
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/CalculatorClient.php?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/CalculatorClient.php (original)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/CalculatorClient.php Fri Feb 2 07:28:01 2007
@@ -17,6 +17,7 @@
# under the License.
#
#
+
include 'SCA/SCA.php';
// Get a proxy to the local Calculator.php
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/Makefile
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/Makefile?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/Makefile (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/Makefile Fri Feb 2 07:28:01 2007
@@ -0,0 +1,53 @@
+# 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.
+
+INCLUDES = \
+-I/usr/local/include/php \
+-I/usr/local/include/php/sapi/embed \
+-I/usr/local/include/php/Zend \
+-I/usr/local/include/php/main \
+-I/usr/local/include/php/TSRM \
+-I${TUSCANY_SDOCPP}/include \
+-I${TUSCANY_SCACPP}/include \
+-I${TUSCANY_SCACPP}/extensions/cpp/include \
+-I${TUSCANY_SCACPP}/samples/CppCalculator/sample.calculator
+
+FLAGS = \
+-g \
+-O2 \
+-MD \
+-MP \
+-fPIC \
+-DPIC
+
+LIBS = \
+-L${LIBXML2_LIB} \
+-L${$AXIS2C_HOME}/lib \
+-L${PHP_LIB} \
+-L${TUSCANY_SDOCPP}/lib \
+-L${TUSCANY_SCACPP}/lib \
+-L${TUSCANY_SCACPP}/extensions/cpp/lib \
+-L${TUSCANY_SCACPP}/extensions/php/lib \
+-L${TUSCANY_SCACPP}/extensions/ws/lib \
+-lphp5 \
+-ltuscany_sdo \
+-ltuscany_sca \
+-ltuscany_sca_cpp
+
+phpembedtest:
+ g++ $(INCLUDES) $(FLAGS) $(LIBS) CalculatorClient.cpp
+
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/env.sh
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/env.sh?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/env.sh (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/env.sh Fri Feb 2 07:28:01 2007
@@ -0,0 +1,29 @@
+export AXIS2C_HOME=/home/slaws/apps/axis2c-bin-0.96-linux
+
+export LIBXML2_LIB=/usr/lib
+export LIBXML2_INCLUDE=/usr/include/libxml2
+
+export PHP_LIB=/usr/local/lib
+export PHP_INCLUDE=/usr/local/include/php
+
+export PHP_SCA_SDO_INCLUDE=/home/slaws/phpbuild-5-2/pecl/SDO
+export PHP_SCA_SDO_LIB=$PHP_LIB/php/extensions/no-debug-zts-20060613/
+
+export TUSCANY_SDOCPP=/sdo/deploy
+export TUSCANY_SCACPP=/usr/local/tuscany/cpp/sca/deploy
+
+export LD_LIBRARY_PATH=$LIBXML2_LIB:\
+$AXIS2C_HOME/lib:\
+$PHP_LIB:\
+$TUSCANY_SDOCPP/lib:\
+$TUSCANY_SCACPP/lib:\
+$TUSCANY_SCACPP/extensions/cpp/lib:\
+$TUSCANY_SCACPP/extensions/php/lib:\
+$TUSCANY_SCACPP/extensions/ws/lib:\
+$TUSCANY_SCACPP/samples/PHPCalculator/deploy/sample.calculator:\
+$PHP_SCA_SDO_LIB
+
+export TUSCANY_SCACPP_LOGGING=9
+export TUSCANY_SCACPP_ROOT=/usr/local/tuscany/cpp/sca/deploy/samples/PHPCalculator
+
+export PATH=.:$PATH
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/env.sh
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/env.sh
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/env.sh
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_cpp.sh
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_cpp.sh?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_cpp.sh (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_cpp.sh Fri Feb 2 07:28:01 2007
@@ -0,0 +1,7 @@
+export TUSCANY_SCACPP_ROOT=/usr/local/tuscany/cpp/sca/deploy/samples/PHPCalculator
+export TUSCANY_SCACPP_COMPONENT=sample.calculator.CalculatorComponent
+
+a.out
+# gdb a.out
+# strace a.out &> strace.txt
+# valgrind a.out
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_cpp.sh
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_cpp.sh
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_cpp.sh
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_php.bat
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_php.bat?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_php.bat (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_php.bat Fri Feb 2 07:28:01 2007
@@ -0,0 +1,25 @@
+@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
+
+php TuscanyTest.php
+
+:end
+endlocal
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_php.bat
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.client/runclient_php.bat
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.wsclient/CalculatorWSClient.php
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.wsclient/CalculatorWSClient.php?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.wsclient/CalculatorWSClient.php (original)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator.wsclient/CalculatorWSClient.php Fri Feb 2 07:28:01 2007
@@ -23,9 +23,9 @@
$service = SCA::getService('Calculator.wsdl');
// Call the local service and write out the response
-echo "add(1.23, 4.56) = " . $service->add(1.23, 4.56) . "\n";
+//echo "add(1.23, 4.56) = " . $service->add(1.23, 4.56) . "\n";
//echo "sub(1.23, 4.56) = " . $service->sub(1.23, 4.56) . "\n";
//echo "mul(1.23, 4.56) = " . $service->mul(1.23, 4.56) . "\n";
-//echo "div(1.23, 4.56) = " . $service->div(1.23, 4.56) . "\n";
+echo "div(1.23, 4.56) = " . $service->div(1.23, 4.56) . "\n";
?>
Modified: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Add.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Add.componentType?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Add.componentType (original)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Add.componentType Fri Feb 2 07:28:01 2007
@@ -22,4 +22,8 @@
<service name="AddService">
<interface.cpp header="Add.h"/>
</service>
+
+ <reference name="log_service">
+ <interface.cpp header="Log.h"/>
+ </reference>
</componentType>
Modified: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Add.php
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Add.php?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Add.php (original)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Add.php Fri Feb 2 07:28:01 2007
@@ -18,8 +18,15 @@
#
#
-function add($num1, $num2)
-{
- return $num1 + $num2;
-}
+require 'SCA/SCA.php';
+
+$num1 = $_REQUEST[0];
+$num2 = $_REQUEST[1];
+
+$result = $num1 + $num2;
+
+$log_proxy = SCA::getService("log_service");
+$log_proxy->log_message($result);
+
+echo $result;
?>
Modified: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Calculator.wsdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Calculator.wsdl?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Calculator.wsdl (original)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Calculator.wsdl Fri Feb 2 07:28:01 2007
@@ -1,173 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-
-<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://sample/calculator"
- targetNamespace="http://sample/calculator">
- <types>
- <xs:schema targetNamespace="http://sample/calculator"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://sample/calculator" elementFormDefault="qualified">
-
- <xs:element name="add">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="param1" type="xs:float"/>
- <xs:element name="param2" type="xs:float"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="sub">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="param1" type="xs:float"/>
- <xs:element name="param2" type="xs:float"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="mul">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="param1" type="xs:float"/>
- <xs:element name="param2" type="xs:float"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="div">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="param1" type="xs:float"/>
- <xs:element name="param2" type="xs:float"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="addResponse">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="addReturn" type="xs:float"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="result">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="data" type="xs:float"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- </xs:schema>
- </types>
-
- <message name="addRequestMsg">
- <part name="body" element="tns:add" />
- </message>
- <message name="addResponseMsg">
- <part name="body" element="tns:addResponse" />
- </message>
- <message name="subRequestMsg">
- <part name="body" element="tns:sub" />
- </message>
- <message name="mulRequestMsg">
- <part name="body" element="tns:mul" />
- </message>
- <message name="divRequestMsg">
- <part name="body" element="tns:div" />
- </message>
-
- <message name="calculatorResponseMsg">
- <part name="body" element="tns:result" />
- </message>
-
- <portType name="Calculator">
- <operation name="add">
- <input message="tns:addRequestMsg" />
- <output message="tns:addResponseMsg" />
- </operation>
- <operation name="sub">
- <input message="tns:subRequestMsg" />
- <output message="tns:calculatorResponseMsg" />
- </operation>
- <operation name="mul">
- <input message="tns:mulRequestMsg" />
- <output message="tns:calculatorResponseMsg" />
- </operation>
- <operation name="div">
- <input message="tns:divRequestMsg" />
- <output message="tns:calculatorResponseMsg" />
- </operation>
- </portType>
-
- <binding name="CalculatorBinding"
- type="tns:Calculator">
- <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <operation name="add">
- <soap:operation soapAction="CalculatorService#add" />
- <input>
- <soap:body use="literal" />
- </input>
- <output>
- <soap:body use="literal" />
- </output>
- </operation>
- <operation name="sub">
- <soap:operation soapAction="CalculatorService#sub" />
- <input>
- <soap:body use="literal" />
- </input>
- <output>
- <soap:body use="literal" />
- </output>
- </operation>
- <operation name="mul">
- <soap:operation soapAction="CalculatorService#mul" />
- <input>
- <soap:body use="literal" />
- </input>
- <output>
- <soap:body use="literal" />
- </output>
- </operation>
- <operation name="div">
- <soap:operation soapAction="CalculatorService#div" />
- <input>
- <soap:body use="literal" />
- </input>
- <output>
- <soap:body use="literal" />
- </output>
- </operation>
- </binding>
-
- <service name="CalculatorService">
- <port name="CalculatorPort"
- binding="tns:CalculatorBinding">
- <soap:address location="http://localhost:9090/axis2/services/sample.calculator.CalculatorComponent/CalculatorService" />
- </port>
- </service>
-</definitions>
-<!-- this line identifies this file as WSDL generated by SCA for PHP. Do not remove -->
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.componentType?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.componentType (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.componentType Fri Feb 2 07:28:01 2007
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
+
+ <service name="CalculatorService">
+ <interface.cpp header="Calculator.h"/>
+ </service>
+
+ <reference name="divideService">
+ <interface.cpp header="Divide.h"/>
+ </reference>
+
+</componentType>
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.componentType
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.componentType
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.cpp?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.cpp (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.cpp Fri Feb 2 07:28:01 2007
@@ -0,0 +1,90 @@
+/*
+ * 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 <stdio.h>
+
+#include "osoa/sca/ComponentContext.h"
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#include "CalculatorImpl.h"
+#include "Divide.h"
+
+CalculatorImpl::CalculatorImpl()
+{
+}
+
+CalculatorImpl::~CalculatorImpl()
+{
+}
+
+// Calculator interface
+float CalculatorImpl::add(float arg1, float arg2)
+{
+ float result = arg1 + arg2;
+
+ printf("CalculatorImpl::add %f + %f = %f\n", arg1, arg2, result);
+ return result;
+}
+
+float CalculatorImpl::sub(float arg1, float arg2)
+{
+ float result = arg1 - arg2;
+ printf("CalculatorImpl::sub %f - %f = %f\n", arg1, arg2, result);
+ return result;
+}
+
+float CalculatorImpl::mul(float arg1, float arg2)
+{
+ float result = arg1 * arg2;
+ printf("CalculatorImpl::mul %f * %f = %f\n", arg1, arg2, result);
+ return result;
+}
+
+float CalculatorImpl::div(float arg1, float arg2)
+{
+ float result = 0;
+
+ // This method shows how to invoke a service on a different component from within a component
+
+ // First, get the current ComponentContext
+ osoa::sca::ComponentContext myContext = osoa::sca::ComponentContext::getCurrent();
+
+ try
+ {
+ // Find the required service, as referenced in CalculatorImpl.componentType
+ Divide* divideService = (Divide*)myContext.getService("divideService");
+
+ // Finally, invoke the service
+ result = divideService->div(arg1, arg2);
+
+ printf("CalculatorImpl::div Divide returned result: %f\n", result);
+
+ }
+ catch (osoa::sca::ServiceRuntimeException& e)
+ {
+ // Print out error message and carry on
+ printf("CalculatorImpl::div Error whilst invoking Divide: %s", e.getMessageText());
+ }
+
+ return result;
+}
+
+
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.h?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.h (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.h Fri Feb 2 07:28:01 2007
@@ -0,0 +1,41 @@
+/*
+ * 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 sample_calculatorimpl_h
+#define sample_calculatorimpl_h
+
+#include "Calculator.h"
+
+class CalculatorImpl : public Calculator
+{
+public:
+ CalculatorImpl();
+ virtual ~CalculatorImpl();
+
+ // Calculator interface
+ virtual float add(float arg1, float arg2);
+ virtual float sub(float arg1, float arg2);
+ virtual float mul(float arg1, float arg2);
+ virtual float div(float arg1, float arg2);
+};
+
+#endif // sample_calculatorimpl_h
+
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Proxy.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Proxy.cpp?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Proxy.cpp (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Proxy.cpp Fri Feb 2 07:28:01 2007
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+
+#include "CalculatorImpl_CalculatorService_Proxy.h"
+
+#include "osoa/sca/sca.h"
+
+extern "C"
+{
+
+ #if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+ #endif
+ CalculatorImpl_CalculatorService_Proxy* CalculatorImpl_CalculatorService_Proxy_Factory(tuscany::sca::ServiceWrapper* target)
+ {
+ return new CalculatorImpl_CalculatorService_Proxy(target);
+ }
+
+ #if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+ #endif
+ void CalculatorImpl_CalculatorService_Proxy_Destructor(void* proxy)
+ {
+ delete (CalculatorImpl_CalculatorService_Proxy*)proxy;
+ }
+}
+
+CalculatorImpl_CalculatorService_Proxy::CalculatorImpl_CalculatorService_Proxy(tuscany::sca::ServiceWrapper* targ) : target(targ)
+{
+}
+
+CalculatorImpl_CalculatorService_Proxy::~CalculatorImpl_CalculatorService_Proxy()
+{
+ if (target)
+ delete target;
+}
+
+float CalculatorImpl_CalculatorService_Proxy::add( float arg0, float arg1)
+{
+ tuscany::sca::Operation operation("add");
+ operation.addParameter("arg1", &arg0);
+ operation.addParameter("arg2", &arg1);
+ float ret;
+ operation.setReturnValue(&ret);
+ target->invoke(operation);
+ return *(float*)operation.getReturnValue();
+}
+
+float CalculatorImpl_CalculatorService_Proxy::sub( float arg0, float arg1)
+{
+ tuscany::sca::Operation operation("sub");
+ operation.addParameter("arg1", &arg0);
+ operation.addParameter("arg2", &arg1);
+ float ret;
+ operation.setReturnValue(&ret);
+ target->invoke(operation);
+ return *(float*)operation.getReturnValue();
+}
+
+float CalculatorImpl_CalculatorService_Proxy::mul( float arg0, float arg1)
+{
+ tuscany::sca::Operation operation("mul");
+ operation.addParameter("arg1", &arg0);
+ operation.addParameter("arg2", &arg1);
+ float ret;
+ operation.setReturnValue(&ret);
+ target->invoke(operation);
+ return *(float*)operation.getReturnValue();
+}
+
+float CalculatorImpl_CalculatorService_Proxy::div( float arg0, float arg1)
+{
+ tuscany::sca::Operation operation("div");
+ operation.addParameter("arg1", &arg0);
+ operation.addParameter("arg2", &arg1);
+ float ret;
+ operation.setReturnValue(&ret);
+ target->invoke(operation);
+ return *(float*)operation.getReturnValue();
+}
+
+
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Proxy.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Proxy.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Proxy.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Proxy.h?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Proxy.h (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Proxy.h Fri Feb 2 07:28:01 2007
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+#ifndef CalculatorImpl_CalculatorService_Proxy_h
+#define CalculatorImpl_CalculatorService_Proxy_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#endif
+
+#include "Calculator.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+
+class CalculatorImpl_CalculatorService_Proxy : public Calculator
+{
+public:
+ CalculatorImpl_CalculatorService_Proxy(tuscany::sca::ServiceWrapper*);
+ virtual ~CalculatorImpl_CalculatorService_Proxy();
+ virtual float add( float arg1, float arg2);
+ virtual float sub( float arg1, float arg2);
+ virtual float mul( float arg1, float arg2);
+ virtual float div( float arg1, float arg2);
+private:
+ tuscany::sca::ServiceWrapper* target;
+};
+
+#endif // CalculatorImpl_CalculatorService_Proxy_h
+
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Proxy.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Proxy.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Wrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Wrapper.cpp?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Wrapper.cpp (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Wrapper.cpp Fri Feb 2 07:28:01 2007
@@ -0,0 +1,135 @@
+/*
+ * 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.
+ */
+
+#include "CalculatorImpl_CalculatorService_Wrapper.h"
+
+#include "osoa/sca/sca.h"
+
+
+
+extern "C"
+{
+
+ #if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+ #endif
+ CalculatorImpl_CalculatorService_Wrapper* CalculatorImpl_CalculatorService_Wrapper_Factory(tuscany::sca::model::Service* target)
+ {
+ return new CalculatorImpl_CalculatorService_Wrapper(target);
+ }
+}
+
+CalculatorImpl_CalculatorService_Wrapper::CalculatorImpl_CalculatorService_Wrapper(tuscany::sca::model::Service* target) : tuscany::sca::cpp::CPPServiceWrapper(target)
+{
+ impl = (CalculatorImpl*)getImplementation();
+}
+
+CalculatorImpl_CalculatorService_Wrapper::~CalculatorImpl_CalculatorService_Wrapper()
+{
+ releaseImplementation();
+}
+
+void* CalculatorImpl_CalculatorService_Wrapper::newImplementation()
+{
+ return new CalculatorImpl;
+}
+
+void CalculatorImpl_CalculatorService_Wrapper::deleteImplementation()
+{
+ delete impl;
+}
+
+void CalculatorImpl_CalculatorService_Wrapper::invokeService(tuscany::sca::Operation& operation)
+{
+ const std::string& operationName = operation.getName();
+
+ if (operationName == "add")
+ {
+ float& p0 = *( float*)operation.getParameterValue(0);
+ float& p1 = *( float*)operation.getParameterValue(1);
+
+ if(operation.getReturnValue() != NULL)
+ {
+ *(float*)operation.getReturnValue() = impl->add(p0, p1);
+ }
+ else
+ {
+ float* ret = new float;
+ *ret = impl->add(p0, p1);
+ operation.setReturnValue((const float*)ret);
+ }
+ return;
+ }
+ if (operationName == "sub")
+ {
+ float& p0 = *( float*)operation.getParameterValue(0);
+ float& p1 = *( float*)operation.getParameterValue(1);
+
+ if(operation.getReturnValue() != NULL)
+ {
+ *(float*)operation.getReturnValue() = impl->sub(p0, p1);
+ }
+ else
+ {
+ float* ret = new float;
+ *ret = impl->sub(p0, p1);
+ operation.setReturnValue((const float*)ret);
+ }
+ return;
+ }
+ if (operationName == "mul")
+ {
+ float& p0 = *( float*)operation.getParameterValue(0);
+ float& p1 = *( float*)operation.getParameterValue(1);
+
+ if(operation.getReturnValue() != NULL)
+ {
+ *(float*)operation.getReturnValue() = impl->mul(p0, p1);
+ }
+ else
+ {
+ float* ret = new float;
+ *ret = impl->mul(p0, p1);
+ operation.setReturnValue((const float*)ret);
+ }
+ return;
+ }
+ if (operationName == "div")
+ {
+ float& p0 = *( float*)operation.getParameterValue(0);
+ float& p1 = *( float*)operation.getParameterValue(1);
+
+ if(operation.getReturnValue() != NULL)
+ {
+ *(float*)operation.getReturnValue() = impl->div(p0, p1);
+ }
+ else
+ {
+ float* ret = new float;
+ *ret = impl->div(p0, p1);
+ operation.setReturnValue((const float*)ret);
+ }
+ return;
+ }
+
+
+ throw osoa::sca::ServiceRuntimeException("Invalid operation");
+
+}
+
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Wrapper.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Wrapper.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Wrapper.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Wrapper.h?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Wrapper.h (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Wrapper.h Fri Feb 2 07:28:01 2007
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+
+#ifndef CalculatorImpl_CalculatorService_Wrapper_h
+#define CalculatorImpl_CalculatorService_Wrapper_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#endif
+
+#include "CalculatorImpl.h"
+#include "tuscany/sca/cpp/CPPServiceWrapper.h"
+
+class CalculatorImpl_CalculatorService_Wrapper : public tuscany::sca::cpp::CPPServiceWrapper
+{
+public:
+ CalculatorImpl_CalculatorService_Wrapper(tuscany::sca::model::Service* target);
+ virtual ~CalculatorImpl_CalculatorService_Wrapper();
+ virtual void invokeService(tuscany::sca::Operation& operation);
+ virtual void* newImplementation();
+ virtual void deleteImplementation();
+private:
+ CalculatorImpl* impl;
+};
+
+#endif // CalculatorImpl_CalculatorService_Wrapper_h
+
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Wrapper.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_CalculatorService_Wrapper.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_divideService_Proxy.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_divideService_Proxy.cpp?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_divideService_Proxy.cpp (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_divideService_Proxy.cpp Fri Feb 2 07:28:01 2007
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+#include "CalculatorImpl_divideService_Proxy.h"
+
+#include "osoa/sca/sca.h"
+
+extern "C"
+{
+
+ #if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+ #endif
+ CalculatorImpl_divideService_Proxy* CalculatorImpl_divideService_Proxy_Factory(tuscany::sca::ServiceWrapper* target)
+ {
+ return new CalculatorImpl_divideService_Proxy(target);
+ }
+
+ #if defined(WIN32) || defined(_WINDOWS)
+ __declspec(dllexport)
+ #endif
+ void CalculatorImpl_divideService_Proxy_Destructor(void* proxy)
+ {
+ delete (CalculatorImpl_divideService_Proxy*)proxy;
+ }
+}
+
+CalculatorImpl_divideService_Proxy::CalculatorImpl_divideService_Proxy(tuscany::sca::ServiceWrapper* targ) : target(targ)
+{
+}
+
+CalculatorImpl_divideService_Proxy::~CalculatorImpl_divideService_Proxy()
+{
+ if (target)
+ delete target;
+}
+
+float CalculatorImpl_divideService_Proxy::div( float arg0, float arg1)
+{
+ tuscany::sca::Operation operation("div");
+ operation.addParameter("num1", &arg0);
+ operation.addParameter("num2", &arg1);
+ float ret;
+ operation.setReturnValue(&ret);
+ target->invoke(operation);
+ return *(float*)operation.getReturnValue();
+}
+
+
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_divideService_Proxy.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_divideService_Proxy.cpp
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_divideService_Proxy.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_divideService_Proxy.h?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_divideService_Proxy.h (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_divideService_Proxy.h Fri Feb 2 07:28:01 2007
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+#ifndef CalculatorImpl_divideService_Proxy_h
+#define CalculatorImpl_divideService_Proxy_h
+
+#if defined(WIN32) || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#endif
+
+#include "Divide.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+
+class CalculatorImpl_divideService_Proxy : public Divide
+{
+public:
+ CalculatorImpl_divideService_Proxy(tuscany::sca::ServiceWrapper*);
+ virtual ~CalculatorImpl_divideService_Proxy();
+ virtual float div( float num1, float num2);
+private:
+ tuscany::sca::ServiceWrapper* target;
+};
+
+#endif // CalculatorImpl_divideService_Proxy_h
+
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_divideService_Proxy.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/CalculatorImpl_divideService_Proxy.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Divide.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Divide.componentType?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Divide.componentType (original)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Divide.componentType Fri Feb 2 07:28:01 2007
@@ -22,4 +22,20 @@
<service name="DivideService">
<interface.cpp header="Divide.h"/>
</service>
+
+ <reference name="cppDivideService">
+ <interface.cpp header="Divide.h"/>
+ </reference>
+
+ <reference name="add_service">
+ <interface.cpp header="Add.h"/>
+ </reference>
+
+ <reference name="subtract_service">
+ <interface.cpp header="Subtract.h"/>
+ </reference>
+
+ <reference name="multiply_service">
+ <interface.cpp header="Multiply.h"/>
+ </reference>
</componentType>
Modified: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Divide.php
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Divide.php?view=diff&rev=502623&r1=502622&r2=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Divide.php (original)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/Divide.php Fri Feb 2 07:28:01 2007
@@ -1,39 +0,0 @@
-<?php
-# 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.
-#
-#
-
-/**
- * @service
- * @binding.ws
- */
-class Divide {
-
- /**
- * Division
- *
- * @param float $num1 (the first number)
- * @param float $num2 (the second number)
- * @return float The result
- */
- function div($num1, $num2) {
- return $num1 / $num2;
- }
-}
-
-?>
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.componentType?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.componentType (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.componentType Fri Feb 2 07:28:01 2007
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
+
+ <service name="DivideService">
+ <interface.cpp header="Divide.h"/>
+ </service>
+
+</componentType>
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.componentType
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.componentType
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.cpp?view=auto&rev=502623
==============================================================================
--- incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.cpp (added)
+++ incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.cpp Fri Feb 2 07:28:01 2007
@@ -0,0 +1,48 @@
+/*
+ * 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 <stdio.h>
+
+#include "DivideImpl.h"
+
+DivideImpl::DivideImpl()
+{
+}
+
+DivideImpl::~DivideImpl()
+{
+}
+
+// Divide interface
+float DivideImpl::div(float arg1, float arg2)
+{
+ if(arg2 == 0.0)
+ {
+ printf("DivideImpl::div %f / %f !! Cannot divide by zero, so returning 0\n", arg1, arg2);
+ return 0;
+ }
+
+ float result = arg1 / arg2;
+ printf("DivideImpl::div %f / %f = %f\n", arg1, arg2, result);
+ return result;
+}
+
+
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sca/samples/PHPCalculator/sample.calculator/DivideImpl.cpp
------------------------------------------------------------------------------
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