You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2006/08/29 04:13:01 UTC

svn commit: r437914 - in /incubator/tuscany/cpp/sca/runtime: core/src/ core/src/tuscany/sca/core/ core/src/tuscany/sca/ws/ extensions/cpp/src/ ws_service/axis2c/src/

Author: jsdelfino
Date: Mon Aug 28 19:13:00 2006
New Revision: 437914

URL: http://svn.apache.org/viewvc?rev=437914&view=rev
Log:
Port of the WS service runtime (server side) to the new assembly model

Removed:
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/CompositeServiceHelper.cpp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/CompositeServiceHelper.h
Modified:
    incubator/tuscany/cpp/sca/runtime/core/src/Makefile.am
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSReferenceBinding.cpp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSReferenceBinding.h
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceProxy.cpp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceProxy.h
    incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/CPPServiceProxy.h
    incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/CPPServiceWrapper.h
    incubator/tuscany/cpp/sca/runtime/ws_service/axis2c/src/Axis2Service_skeleton.cpp

Modified: incubator/tuscany/cpp/sca/runtime/core/src/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/Makefile.am?rev=437914&r1=437913&r2=437914&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/Makefile.am (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/Makefile.am Mon Aug 28 19:13:00 2006
@@ -21,7 +21,6 @@
 tuscany/sca/core/DefaultServiceProxy.cpp \
 tuscany/sca/core/ComponentContextImpl.cpp \
 tuscany/sca/core/CompositeContextImpl.cpp \
-tuscany/sca/core/CompositeServiceHelper.cpp \
 tuscany/sca/core/Operation.cpp \
 tuscany/sca/core/SCARuntime.cpp \
 tuscany/sca/core/ServiceProxy.cpp \

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSReferenceBinding.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSReferenceBinding.cpp?rev=437914&r1=437913&r2=437914&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSReferenceBinding.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSReferenceBinding.cpp Mon Aug 28 19:13:00 2006
@@ -20,6 +20,7 @@
 #include "tuscany/sca/util/Logging.h"
 #include "tuscany/sca/ws/WSReferenceBinding.h"
 #include "tuscany/sca/core/ServiceProxy.h"
+#include "tuscany/sca/ws/WSServiceProxy.h"
 
 namespace tuscany
 {
@@ -121,14 +122,14 @@
             
             void WSReferenceBinding::configure(ServiceBinding *binding)
             {
-                //TODO configure this reference binding from the info in the
-                // given service binding
+                targetServiceBinding = binding;
+                
+                serviceProxy = new WSServiceProxy(getReference());
             }
             
             ServiceProxy* WSReferenceBinding::getServiceProxy()
             {
-                //TODO create the service proxy
-                return (ServiceProxy*)0;
+                return serviceProxy;
             }
                 
         } // End namespace ws

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSReferenceBinding.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSReferenceBinding.h?rev=437914&r1=437913&r2=437914&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSReferenceBinding.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSReferenceBinding.h Mon Aug 28 19:13:00 2006
@@ -89,6 +89,11 @@
                  */
                 string getPortName() const { return portName; };
                 
+                 /**
+                  * Returns the target service binding.
+                  */
+                  ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; };
+                                
             private:
             
                 /**
@@ -115,6 +120,17 @@
                  * Port name from the port.
                  */
                 string portName;
+
+                /**
+                 * The proxy representing the reference to the client
+                 * component.
+                 */
+                ServiceProxy* serviceProxy;
+                
+                /**
+                 * The service binding of the target
+                 */
+                ServiceBinding* targetServiceBinding; 
             };
             
         } // End namespace model

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceProxy.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceProxy.cpp?rev=437914&r1=437913&r2=437914&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceProxy.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceProxy.cpp Mon Aug 28 19:13:00 2006
@@ -1,36 +1,45 @@
 /*
- * Copyright 2006 The Apache Software Foundation.
  *
- * Licensed 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
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *  Licensed 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
  *
- * 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.
+ *     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 "tuscany/sca/ws/WSServiceProxy.h"
 
-using namespace tuscany::sca;
+/* $Rev: 437637 $ $Date: 2006-08-28 03:42:10 -0700 (Mon, 28 Aug 2006) $ */
 
-#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/ws/WSServiceProxy.h"
 #include "tuscany/sca/util/Logging.h"
-#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Exceptions.h"
 #include "tuscany/sca/core/SCARuntime.h"
-#include "tuscany/sca/core/TuscanyRuntime.h"
-#include "tuscany/sca/core/Operation.h"
-#include "tuscany/sca/core/CompositeServiceHelper.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/ServiceType.h"
 #include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/ComponentType.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
 #include "tuscany/sca/model/Composite.h"
-#include "tuscany/sca/model/CompositeService.h"
+#include "tuscany/sca/model/ServiceBinding.h"
+#include "tuscany/sca/model/WSDLDefinition.h"
+#include "tuscany/sca/model/WSDLOperation.h"
+#include "tuscany/sca/ws/WSReferenceBinding.h"
 
 #include "commonj/sdo/SDO.h"
 using namespace commonj::sdo;
 
+using namespace osoa::sca;
+using namespace tuscany::sca::model;
+
 namespace tuscany
 {
     namespace sca
@@ -38,498 +47,406 @@
         namespace ws
         {
             
-            // Singleton pattern
-            WSServiceProxy* WSServiceProxy::compositeServiceProxyInstance = new WSServiceProxy();
-            
-            WSServiceProxy* WSServiceProxy::getInstance()
-            {
-                return compositeServiceProxyInstance;
-            }
-            
-            WSServiceProxy::WSServiceProxy()
+            // ============================
+            // Constructor: Create a proxy
+            // ============================
+            WSServiceProxy::WSServiceProxy(Reference* reference)
+                : ServiceProxy(reference)
             {
                 LOGENTRY(1,"WSServiceProxy::constructor");
-                tuscanyRuntime = NULL;
-                compositeServiceName = "";
-                systemRoot = "";
-                defaultComponentName = "";
+    
+                // Get the target service wrapper
+                WSReferenceBinding* referenceBinding = (WSReferenceBinding*)reference->getBinding();
+                serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper();
+                
+                // getProxy and getProxies will return "this"
+                proxies.push_back(this);
+    
                 LOGEXIT(1,"WSServiceProxy::constructor");
             }
             
+            // ==========
+            // Destructor
+            // ==========
             WSServiceProxy::~WSServiceProxy()
             {
                 LOGENTRY(1,"WSServiceProxy::destructor");
-            
-                if(tuscanyRuntime != NULL)
-                {
-                    tuscanyRuntime->stop();
-                    delete tuscanyRuntime;
-                    tuscanyRuntime = NULL;
-                }
                 LOGEXIT(1,"WSServiceProxy::destructor");
             }
             
-            void WSServiceProxy::init(const char* systemRootPath, const char* fullCompositeServiceName)
+            ServiceProxy::PROXIES WSServiceProxy::getProxies()
+            {
+                return proxies;
+            }
+            
+            void* WSServiceProxy::getProxy()
+            {
+                return this;
+            }
+            
+            ///
+            /// This method will be called to process an operation invocation.
+            ///
+            DataObjectPtr WSServiceProxy::invoke(const char* operationName, DataObjectPtr inputDataObject)
             {
-                LOGENTRY(1,"WSServiceProxy::init");
+                LOGENTRY(1,"WSServiceProxy::invoke");
             
+                Reference* reference = getReference();
+                Component* component = reference->getComponent();
+                Composite* composite = component ->getComposite();
+            
+                WSReferenceBinding* referenceBinding = (WSReferenceBinding*)reference->getBinding();
+                DataFactoryPtr dataFactoryPtr = reference->getComponent()->getComposite()->getDataFactory();
+                                    
+                DataObjectPtr outputDataObject = NULL;
+                
+                string wsdlNamespace = referenceBinding->getWSDLNamespaceURL();
+                string wsdlPort  = referenceBinding->getPortName();
+                string wsdlService = referenceBinding->getServiceName();
+        
+                WSDLDefinition* wsdl = composite->findWSDLDefinition(wsdlNamespace);
+                if (wsdl == 0)
+                {
+                    LOGINFO_1(0, "WSDL description %s not found\n", wsdlNamespace.c_str());
+                    return NULL;
+                }
+        
+                WSDLOperation wsdlOperation;
                 try
-            	{
+                {
+                    wsdlOperation = wsdl->findOperation(wsdlService, wsdlPort, operationName);
+                }
+              catch(SystemConfigurationException &ex)
+              {   
+                  LOGERROR_1(0, "SystemConfigurationException has been caught: %s\n", ex.getMessageText());
+                    return NULL;
+                }
+        
+                LOGINFO_2(4, "WSServiceSkeleton has got WSDLOperation with inputType: %s#%s",
+                    wsdlOperation.getInputTypeUri().c_str(), 
+                    wsdlOperation.getInputTypeName().c_str());
+                LOGINFO_2(4, "WSServiceSkeleton has got WSDLOperation with outputType: %s#%s",
+                    wsdlOperation.getOutputTypeUri().c_str(), 
+                    wsdlOperation.getOutputTypeName().c_str());
+                LOGINFO_2(4, "WSServiceSkeleton has got WSDLOperation with documentStyle=%d and encoded=%d",        
+                    wsdlOperation.isDocumentStyle(),
+                    wsdlOperation.isEncoded());
+                
+                if(wsdlOperation.isDocumentStyle())
+                {
+                    // Document style
+                    outputDataObject = dataFactoryPtr->create(wsdlOperation.getOutputTypeUri().c_str(), wsdlOperation.getOutputTypeName().c_str());
+        
+                    //printf("outputDataObject %s#%s\n", outputDataObject->getType().getURI(), outputDataObject->getType().getName());
+                    //Utils::printDO(outputDataObject);
+                }
+                else
+                {
+                    // RPC style
+                    LOGERROR(0, "CompositeServices with RPC style WSDL Operations are not yet supported");
+                    return NULL;
+                }
             
-            		// fullCompositeServiceName is of the form "subsystem name"/"composite component name"/"entry point name"
-            		// Get the "subsystem name"/"composite component name" part for setDefaultCompositeComponent
-                    // Keep the "entry point name" part for use in invoke
-            		string subsystemAndComponentName, epName;
-            		Utils::rTokeniseString("/", fullCompositeServiceName, subsystemAndComponentName, epName);
+                // Create new Operation object and set parameters and return value
+                Operation operation(operationName);
             
-                    bool newInitParams = false;
+                // Go through input data object to set the operation parameters
+                PropertyList pl = inputDataObject->getInstanceProperties();
             
-                    if(systemRoot.length() != 0 && systemRoot != systemRootPath)
-                    {
-                        systemRoot = systemRootPath;
-                        newInitParams = true;
-                    }
+                for(int i=0; i<pl.size(); i++)
+                {
+                    const char* name = pl[i].getName();
             
-                    if(defaultComponentName.length() != 0 && defaultComponentName != subsystemAndComponentName)
+                    switch (pl[i].getTypeEnum()) 
                     {
-                        defaultComponentName = subsystemAndComponentName;
-                        newInitParams = true;
-                    }
+                    case Type::BooleanType:
+                        {
+                            bool* boolData = new bool;
+                            *boolData = inputDataObject->getBoolean(pl[i]);
+                            //printf("inputDataObject has BooleanType named %s with value %d\n", name, boolData);
+                            operation.addParameter(boolData);
+                        }
+                        break;
+                    case Type::ByteType:
+                        {
+                            char* byteData = new char;
+                            //printf("inputDataObject has ByteType named %s\n", name);
+                            *byteData = inputDataObject->getByte(pl[i]);
+                            operation.addParameter(byteData);
+                        }
+                        break;
+                    case Type::BytesType:
+                        {
+                            int len = inputDataObject->getLength(pl[i]);
+                            char* bytesData = new char[len+1];
+                            int bytesWritten = inputDataObject->getBytes(pl[i], bytesData, len);
+                            // Ensure the bytes end with the null char. Not sure if this is neccessary
+                            if(bytesWritten <= len)
+                            {
+                                bytesData[bytesWritten] = 0;
+                            }
+                            else
+                            {
+                                bytesData[len] = 0;
+                            }
+                            //printf("inputDataObject has BytesType named %s with length %d\n", name, bytesWritten);
+                            operation.addParameter(&bytesData);
+                        }
+                        break;
+                    case Type::CharacterType:
+                        {
+                            // This code should work but won't be used as there is no mapping from an XSD type to the SDO CharacterType
+                            wchar_t* charData = new wchar_t;
+                            //printf("inputDataObject has CharacterType named %s\n", name);
+                            *charData = inputDataObject->getCharacter(pl[i]);
+                            operation.addParameter(charData);
+                        }
+                        break;
+                    case Type::DoubleType:
+                        {
+                            long double* doubleData = new long double;
+                            *doubleData = inputDataObject->getDouble(pl[i]);
+                            //printf("inputDataObject has DoubleType named %s\n", name);            
+                            operation.addParameter(doubleData);
+                        }
+                        break;
+                    case Type::FloatType:
+                        {
+                            float* floatData = new float;
+                            *floatData = inputDataObject->getFloat(pl[i]);
+                            //printf("inputDataObject has FloatType named %s with value %f\n", name, *floatData);
+                            operation.addParameter(floatData); 
+                        }
+                        break;
+                    case Type::IntegerType:
+                        {
+                            long* intData = new long;
+                            //printf("inputDataObject has IntegerType named %s\n", name);
+                            *intData = inputDataObject->getInteger(pl[i]);
+                            operation.addParameter(intData);
+                        }
+                        break;
+                    case Type::ShortType:
+                        {
+                            short* shortData = new short;
+                            //printf("inputDataObject has ShortType named %s\n", name);
+                            *shortData = inputDataObject->getShort(pl[i]);
+                            operation.addParameter(shortData);
+                        }
+                        break;
+                    case Type::StringType:
+                        {
+                            const char** stringData = new const char*; 
+                            *stringData = inputDataObject->getCString(pl[i]);
+                            //printf("inputDataObject has StringType named %s with value %s\n", name, stringData);
+                            operation.addParameter(stringData);
+                        }
+                        break;
+                    case Type::DataObjectType:
+                        {
+                            DataObjectPtr dataObjectData = inputDataObject->getDataObject(pl[i]);
+                            //printf("inputDataObject has DataObjectType named %s (#%d)\n", name, dataObjectData);
             
-                    if(compositeServiceName.length() != 0 && compositeServiceName != epName)
-                    {
-                        compositeServiceName = epName;
-                        newInitParams = true;
-                    }
+                            if(!dataObjectData)
+                            {
+                                LOGINFO_1(4, "SDO DataObject parameter named %s was null", name);
+                            }
+                            operation.addParameter(&dataObjectData);
+                        }
+                        break;
+                    case Type::OpenDataObjectType:
+                        {         
+                            /*
+                             * This code deals with xsd:any element parameters
+                             * Get each element as a DataObject and add in to the parameter list
+                             */
+            
+                            //printf("inputDataObject has OpenDataObjectType named %s\n", name);
+                            DataObjectList& dataObjectList = inputDataObject->getList(pl[i]);
+                            
+                            for(int j=0; j<dataObjectList.size(); j++)
+                            {
+                                DataObjectPtr dataObjectData = dataObjectList[j];
+                                if(!dataObjectData)
+                                {
+                                    LOGINFO_2(4, "SDO OpenDataObject parameter named %s[%d] was null", name, j);
+                                }
+                                operation.addParameter(&dataObjectData);
+                                //Utils::printDO(dataObjectData);
+                            }
+                        }
+                        break;
+                    case Type::DateType:
+                        LOGERROR_1(0, "SDO DateType parameters are not yet supported (%s)", name);
+                        return NULL;
+                    case Type::LongType:
+                        LOGERROR_1(0, "SDO LongType (int64_t) parameters are not yet supported (%s)", name);
+                        return NULL;
+                        break;
+                    case Type::UriType:
+                        LOGERROR_1(0, "SDO UriType parameters are not yet supported (%s)", name);
+                        return NULL;
+                        break;
+                    case Type::BigDecimalType:
+                        LOGERROR_1(0, "SDO BigDecimalType parameters are not yet supported (%s)", name);
+                        return NULL;
+                        break;
+                    case Type::BigIntegerType:
+                        LOGERROR_1(0, "SDO BigIntegerType parameters are not yet supported (%s)", name);
+                        return NULL;
+                        break;
+                    default:
+                        LOGERROR_1(0, "Unknown SDO type parameter named %s has been found. Unknown types are not yet supported", name);
+                        return NULL;
+                    }         
+                }
+                        
+                // Now go through outputDataObject to set the return value
+                pl = outputDataObject->getInstanceProperties();
             
+                // Set up the possible return value pointers
+                bool boolData = 0;
+                char byteData = 0;
+                wchar_t charData = 0;
+                long double doubleData = 0;
+                float floatData = 0;
+                long intData = 0;
+                short shortData = 0;
+                const char* stringData;
+                DataObjectPtr dataObjectData;
             
-                    if(tuscanyRuntime == NULL)
-                    {
-                        LOGINFO(4, "Creating new TuscanyRuntime");
-                        defaultComponentName = subsystemAndComponentName;
-                        systemRoot = systemRootPath;
-                        compositeServiceName = epName;
-                        tuscanyRuntime = new TuscanyRuntime(defaultComponentName, systemRoot);
-                        tuscanyRuntime->start();
-                    }
-                    else if(tuscanyRuntime != NULL && newInitParams)
-                    {
-                        LOGINFO(4, "Restarting TuscanyRuntime with new SystemRoot or DefaultComponent");
-                        tuscanyRuntime->stop();
-                        tuscanyRuntime->setDefaultComponentName(defaultComponentName);
-                        tuscanyRuntime->setSystemRoot(systemRoot);
-                        tuscanyRuntime->start();
-                    }
             
-                    if(compositeServiceHelper == NULL)
+                // There should only be one return value, but go through any list anyway?
+                if(pl.size() > 1)
+                {
+                    LOGINFO(4, "More than one return value is defined in the WSDL, just defining the first");
+                }
+                else if(pl.size() == 0)
+                {
+                    if(outputDataObject->getType().isOpenType() && outputDataObject->getType().isDataObjectType())
                     {
-                        compositeServiceHelper = new CompositeServiceHelper(fullCompositeServiceName);
+                        /*
+                         * This code deals with returning xsd:any elements
+                         * Return as a DataObject set within the outputDataObject
+                         */
+                       
+                        // An OpenDataObject for the data to return in
+                        operation.setReturnValue(&dataObjectData);            
                     }
                     else
                     {
-                        if(newInitParams)
-                        {
-                            delete compositeServiceHelper;
-                            compositeServiceHelper = NULL;
-                            compositeServiceHelper = new CompositeServiceHelper(fullCompositeServiceName);
-                        }
+                        LOGINFO(4, "No return values are defined in the WSDL");
                     }
-            	}
-            	catch(SystemConfigurationException &ex)
-            	{	
-            		LOGERROR_1(0, "SystemConfigurationException has been caught: %s\n", ex.getMessageText());
-                    compositeServiceHelper = 0;
-            	}
-            	catch(ServiceRuntimeException &ex)
-            	{	
-                    LOGERROR_2(0, "%s has been caught: %s\n", ex.getEClassName(), ex.getMessageText());
-                    compositeServiceHelper = 0;
-            	}  
-                LOGEXIT(1,"WSServiceProxy::init");
-            }
             
-            DataFactoryPtr WSServiceProxy::getDataFactory()
-            {
-                if (compositeServiceHelper == 0) return 0;
-                return compositeServiceHelper->getDataFactory();
-            }
+                }
             
-            ///
-            /// This method will be called when an CompositeService needs to be invoked.
-            ///
-            DataObjectPtr WSServiceProxy::invoke(const char* operationName, DataObjectPtr inputDataObject)
-            {
-                LOGENTRY(1,"WSServiceProxy::invoke");
+                if(pl.size() > 0)
+                {
+                    const char* name = pl[0].getName();
+                    
+                    switch (pl[0].getTypeEnum()) 
+                    {
+                    case Type::BooleanType:
+                        {
+                            //printf("outputDataObject has BooleanType named %s\n", name);
+                            operation.setReturnValue(&boolData);
+                        }
+                        break;
+                    case Type::ByteType:
+                        {
+                            //printf("outputDataObject has ByteType named %s\n", name);
+                            operation.setReturnValue(&byteData);
+                        }
+                        break;
+                    case Type::CharacterType:
+                        {
+                            //printf("outputDataObject has CharacterType named %s\n", name);
+                            operation.setReturnValue(&charData);
+                        }
+                        break;
+                    case Type::DoubleType:
+                        {
+                            //printf("outputDataObject has DoubleType named %s\n", name);
+                            operation.setReturnValue((long double*) &doubleData);
+                        }
+                        break;
+                    case Type::FloatType:
+                        {
+                            //printf("outputDataObject has FloatType named %s\n", name);
+                            operation.setReturnValue(&floatData);
+                        }
+                        break;
+                    case Type::IntegerType:
+                        {
+                            //printf("outputDataObject has IntegerType named %s\n", name);
+                            operation.setReturnValue(&intData);
+                        }
+                        break;
+                    case Type::ShortType:
+                        {
+                            //printf("outputDataObject has ShortType named %s\n", name);
+                            operation.setReturnValue(&shortData);
+                        }
+                        break;
+                    case Type::StringType:
+                    case Type::BytesType:
+                         {
+                            //printf("outputDataObject has StringType or BytesType named %s\n", name);
+                            operation.setReturnValue((const char**) &stringData);
+                        }
+                        break;
+                    case Type::DataObjectType:
+                        {
+                            // printf("outputDataObject has DataObjectType named %s with type %s # %s\n", name, pl[0].getType().getURI(), pl[0].getType().getName());
+                            operation.setReturnValue(&dataObjectData);
+                        }
+                        break;
+                    case Type::DateType:
+                        LOGERROR_1(0, "SDO DateType return values are not yet supported (%s)", name);
+                        return NULL;
+                    case Type::LongType:
+                        LOGERROR_1(0, "SDO LongType (int64_t) return values are not yet supported (%s)", name);
+                        return NULL;
+                    case Type::UriType:
+                        LOGERROR_1(0, "SDO UriType return values are not yet supported (%s)", name);
+                        return NULL;
+                    case Type::BigDecimalType:
+                        LOGERROR_1(0, "SDO BigDecimalType return values are not yet supported (%s)", name);
+                        return NULL;
+                    case Type::BigIntegerType:
+                        LOGERROR_1(0, "SDO BigIntegerType return values are not yet supported (%s)", name);
+                        return NULL;
+                    default:
+                        LOGERROR_1(0, "Unknown SDO type return value named %s has been found. Unknown types are not yet supported", name);
+                        return NULL;
+                    }         
+                }
             
-                if (compositeServiceHelper == 0)
+                try
                 {
-                    LOGINFO(4, "WSServiceProxy has not got an sca CompositeService\n");
-                    return NULL;
+                    // Call into the target service wrapper
+                    serviceWrapper->invoke(operation);
+            
+                    // Set the data in the outputDataObject to be returned
+                    setOutputData(operation, outputDataObject);                            
                 }
+              catch(SDORuntimeException &ex)
+              {   
+                    // TODO: Return more error information than just a null DataObject
+                    LOGERROR_2(0, "%s has been caught: %s\n", ex.getEClassName(), ex.getMessageText());
+                    return NULL;
+              }  
+              catch(ServiceRuntimeException &ex)
+              {   
+                    // TODO: Return more error information than just a null DataObject
+                    LOGERROR_2(0, "%s has been caught: %s\n", ex.getEClassName(), ex.getMessageText());
+                    return NULL;
+              }  
             
-                DataFactoryPtr dataFactoryPtr = compositeServiceHelper->getDataFactory();
-            						
-                DataObjectPtr outputDataObject = NULL;
-                SCARuntime* runtime = SCARuntime::getInstance();
-                
-            	Component* defaultComponent = runtime->getDefaultComponent();
-                Composite* composite  = (Composite*)defaultComponent->getType();
-
-//TODO Fix this                
+                LOGEXIT(1,"WSServiceSkeleton::invoke");
             
-//            	CompositeService* compositeService = (CompositeService)composite->findComponent(compositeServiceName);
-//            
-//                Binding* binding = compositeService->getBinding();
-//                WSBinding* wsBinding = (WSBinding*) binding;
-//        
-//                string wsdlNamespace = wsBinding->getWSDLNamespaceURL();
-//                string wsdlPort  = wsBinding->getPortName();
-//                string wsdlService = wsBinding->getServiceName();
-//        
-//                WSDL* wsdl = composite->findWSDLDefinition(wsdlNamespace);
-//                if (wsdl == 0)
-//                {
-//                    LOGINFO_1(0, "WSDL description %s not found\n", wsdlNamespace.c_str());
-//                    return NULL;
-//                }
-//        
-//                WSDLOperation operation;
-//                try
-//                {
-//                    operation = wsdl->findOperation(wsdlService, wsdlPort, operationName);
-//                }
-//        	    catch(SystemConfigurationException &ex)
-//        	    {	
-//        		    LOGERROR_1(0, "SystemConfigurationException has been caught: %s\n", ex.getMessageText());
-//                    return NULL;
-//                }
-//        
-//                LOGINFO_2(4, "WSServiceProxy has got WSDLOperation with inputType: %s#%s",
-//                    operation.getInputTypeUri().c_str(), 
-//                    operation.getInputTypeName().c_str());
-//                LOGINFO_2(4, "WSServiceProxy has got WSDLOperation with outputType: %s#%s",
-//                    operation.getOutputTypeUri().c_str(), 
-//                    operation.getOutputTypeName().c_str());
-//                LOGINFO_2(4, "WSServiceProxy has got WSDLOperation with documentStyle=%d and encoded=%d",        
-//                    operation.isDocumentStyle(),
-//                    operation.isEncoded());
-//                
-//                if(operation.isDocumentStyle())
-//                {
-//                    // Document style
-//                    outputDataObject = dataFactoryPtr->create(operation.getOutputTypeUri().c_str(), operation.getOutputTypeName().c_str());
-//        
-//                    //printf("outputDataObject %s#%s\n", outputDataObject->getType().getURI(), outputDataObject->getType().getName());
-//                    //Utils::printDO(outputDataObject);
-//                }
-//                else
-//                {
-//                    // RPC style
-//                    LOGERROR(0, "CompositeServices with RPC style WSDL Operations are not yet supported");
-//                    return NULL;
-//                }
-//            
-//                // Create new Operation object and set parameters and return value
-//                Operation operation(operationName);
-//            
-//                // Go through input data object to set the operation parameters
-//                PropertyList pl = inputDataObject->getInstanceProperties();
-//            
-//                for(int i=0; i<pl.size(); i++)
-//                {
-//                    const char* name = pl[i].getName();
-//            
-//                    switch (pl[i].getTypeEnum()) 
-//                    {
-//                    case Type::BooleanType:
-//                        {
-//                            bool* boolData = new bool;
-//                            *boolData = inputDataObject->getBoolean(pl[i]);
-//                            //printf("inputDataObject has BooleanType named %s with value %d\n", name, boolData);
-//                            operation.addParameter(boolData);
-//                        }
-//                        break;
-//                    case Type::ByteType:
-//                        {
-//                            char* byteData = new char;
-//                            //printf("inputDataObject has ByteType named %s\n", name);
-//                            *byteData = inputDataObject->getByte(pl[i]);
-//                            operation.addParameter(byteData);
-//                        }
-//                        break;
-//                    case Type::BytesType:
-//                        {
-//                            int len = inputDataObject->getLength(pl[i]);
-//                            char* bytesData = new char[len+1];
-//                            int bytesWritten = inputDataObject->getBytes(pl[i], bytesData, len);
-//                            // Ensure the bytes end with the null char. Not sure if this is neccessary
-//                            if(bytesWritten <= len)
-//                            {
-//                                bytesData[bytesWritten] = 0;
-//                            }
-//                            else
-//                            {
-//                                bytesData[len] = 0;
-//                            }
-//                            //printf("inputDataObject has BytesType named %s with length %d\n", name, bytesWritten);
-//                            operation.addParameter(&bytesData);
-//                        }
-//                        break;
-//                    case Type::CharacterType:
-//                        {
-//                            // This code should work but won't be used as there is no mapping from an XSD type to the SDO CharacterType
-//                            wchar_t* charData = new wchar_t;
-//                            //printf("inputDataObject has CharacterType named %s\n", name);
-//                            *charData = inputDataObject->getCharacter(pl[i]);
-//                            operation.addParameter(charData);
-//                        }
-//                        break;
-//                    case Type::DoubleType:
-//                        {
-//                            long double* doubleData = new long double;
-//                            *doubleData = inputDataObject->getDouble(pl[i]);
-//                            //printf("inputDataObject has DoubleType named %s\n", name);            
-//                            operation.addParameter(doubleData);
-//                        }
-//                        break;
-//                    case Type::FloatType:
-//                        {
-//                            float* floatData = new float;
-//                            *floatData = inputDataObject->getFloat(pl[i]);
-//                            //printf("inputDataObject has FloatType named %s with value %f\n", name, *floatData);
-//                            operation.addParameter(floatData); 
-//                        }
-//                        break;
-//                    case Type::IntegerType:
-//                        {
-//                            long* intData = new long;
-//                            //printf("inputDataObject has IntegerType named %s\n", name);
-//                            *intData = inputDataObject->getInteger(pl[i]);
-//                            operation.addParameter(intData);
-//                        }
-//                        break;
-//                    case Type::ShortType:
-//                        {
-//                            short* shortData = new short;
-//                            //printf("inputDataObject has ShortType named %s\n", name);
-//                            *shortData = inputDataObject->getShort(pl[i]);
-//                            operation.addParameter(shortData);
-//                        }
-//                        break;
-//                    case Type::StringType:
-//                        {
-//                            const char** stringData = new const char*; 
-//                            *stringData = inputDataObject->getCString(pl[i]);
-//                            //printf("inputDataObject has StringType named %s with value %s\n", name, stringData);
-//                            operation.addParameter(stringData);
-//                        }
-//                        break;
-//                    case Type::DataObjectType:
-//                        {
-//                            DataObjectPtr dataObjectData = inputDataObject->getDataObject(pl[i]);
-//                            //printf("inputDataObject has DataObjectType named %s (#%d)\n", name, dataObjectData);
-//            
-//                            if(!dataObjectData)
-//                            {
-//                                LOGINFO_1(4, "SDO DataObject parameter named %s was null", name);
-//                            }
-//                            operation.addParameter(&dataObjectData);
-//                        }
-//                        break;
-//                    case Type::OpenDataObjectType:
-//                        {         
-//                            /*
-//                             * This code deals with xsd:any element parameters
-//                             * Get each element as a DataObject and add in to the parameter list
-//                             */
-//            
-//                            //printf("inputDataObject has OpenDataObjectType named %s\n", name);
-//                            DataObjectList& dataObjectList = inputDataObject->getList(pl[i]);
-//                            
-//                            for(int j=0; j<dataObjectList.size(); j++)
-//                            {
-//                                DataObjectPtr dataObjectData = dataObjectList[j];
-//                                if(!dataObjectData)
-//                                {
-//                                    LOGINFO_2(4, "SDO OpenDataObject parameter named %s[%d] was null", name, j);
-//                                }
-//                                operation.addParameter(&dataObjectData);
-//                                //Utils::printDO(dataObjectData);
-//                            }
-//                        }
-//                        break;
-//                    case Type::DateType:
-//                        LOGERROR_1(0, "SDO DateType parameters are not yet supported (%s)", name);
-//                        return NULL;
-//                    case Type::LongType:
-//                        LOGERROR_1(0, "SDO LongType (int64_t) parameters are not yet supported (%s)", name);
-//                        return NULL;
-//                        break;
-//                    case Type::UriType:
-//                        LOGERROR_1(0, "SDO UriType parameters are not yet supported (%s)", name);
-//                        return NULL;
-//                        break;
-//                    case Type::BigDecimalType:
-//                        LOGERROR_1(0, "SDO BigDecimalType parameters are not yet supported (%s)", name);
-//                        return NULL;
-//                        break;
-//                    case Type::BigIntegerType:
-//                        LOGERROR_1(0, "SDO BigIntegerType parameters are not yet supported (%s)", name);
-//                        return NULL;
-//                        break;
-//                    default:
-//                        LOGERROR_1(0, "Unknown SDO type parameter named %s has been found. Unknown types are not yet supported", name);
-//                        return NULL;
-//                    }         
-//                }
-//                        
-//                // Now go through outputDataObject to set the return value
-//                pl = outputDataObject->getInstanceProperties();
-//            
-//                // Set up the possible return value pointers
-//                bool boolData = 0;
-//                char byteData = 0;
-//                wchar_t charData = 0;
-//                long double doubleData = 0;
-//                float floatData = 0;
-//                long intData = 0;
-//                short shortData = 0;
-//                const char* stringData;
-//                DataObjectPtr dataObjectData;
-//            
-//            
-//                // There should only be one return value, but go through any list anyway?
-//                if(pl.size() > 1)
-//                {
-//                    LOGINFO(4, "More than one return value is defined in the WSDL, just defining the first");
-//                }
-//                else if(pl.size() == 0)
-//                {
-//                    if(outputDataObject->getType().isOpenType() && outputDataObject->getType().isDataObjectType())
-//                    {
-//                        /*
-//                         * This code deals with returning xsd:any elements
-//                         * Return as a DataObject set within the outputDataObject
-//                         */
-//                       
-//                        // An OpenDataObject for the data to return in
-//                        operation.setReturnValue(&dataObjectData);            
-//                    }
-//                    else
-//                    {
-//                        LOGINFO(4, "No return values are defined in the WSDL");
-//                    }
-//            
-//                }
-//            
-//                if(pl.size() > 0)
-//                {
-//                    const char* name = pl[0].getName();
-//                    
-//                    switch (pl[0].getTypeEnum()) 
-//                    {
-//                    case Type::BooleanType:
-//                        {
-//                            //printf("outputDataObject has BooleanType named %s\n", name);
-//                            operation.setReturnValue(&boolData);
-//                        }
-//                        break;
-//                    case Type::ByteType:
-//                        {
-//                            //printf("outputDataObject has ByteType named %s\n", name);
-//                            operation.setReturnValue(&byteData);
-//                        }
-//                        break;
-//                    case Type::CharacterType:
-//                        {
-//                            //printf("outputDataObject has CharacterType named %s\n", name);
-//                            operation.setReturnValue(&charData);
-//                        }
-//                        break;
-//                    case Type::DoubleType:
-//                        {
-//                            //printf("outputDataObject has DoubleType named %s\n", name);
-//                            operation.setReturnValue((long double*) &doubleData);
-//                        }
-//                        break;
-//                    case Type::FloatType:
-//                        {
-//                            //printf("outputDataObject has FloatType named %s\n", name);
-//                            operation.setReturnValue(&floatData);
-//                        }
-//                        break;
-//                    case Type::IntegerType:
-//                        {
-//                            //printf("outputDataObject has IntegerType named %s\n", name);
-//                            operation.setReturnValue(&intData);
-//                        }
-//                        break;
-//                    case Type::ShortType:
-//                        {
-//                            //printf("outputDataObject has ShortType named %s\n", name);
-//                            operation.setReturnValue(&shortData);
-//                        }
-//                        break;
-//                    case Type::StringType:
-//                    case Type::BytesType:
-//                         {
-//                            //printf("outputDataObject has StringType or BytesType named %s\n", name);
-//                            operation.setReturnValue((const char**) &stringData);
-//                        }
-//                        break;
-//                    case Type::DataObjectType:
-//                        {
-//                            // printf("outputDataObject has DataObjectType named %s with type %s # %s\n", name, pl[0].getType().getURI(), pl[0].getType().getName());
-//                            operation.setReturnValue(&dataObjectData);
-//                        }
-//                        break;
-//                    case Type::DateType:
-//                        LOGERROR_1(0, "SDO DateType return values are not yet supported (%s)", name);
-//                        return NULL;
-//                    case Type::LongType:
-//                        LOGERROR_1(0, "SDO LongType (int64_t) return values are not yet supported (%s)", name);
-//                        return NULL;
-//                    case Type::UriType:
-//                        LOGERROR_1(0, "SDO UriType return values are not yet supported (%s)", name);
-//                        return NULL;
-//                    case Type::BigDecimalType:
-//                        LOGERROR_1(0, "SDO BigDecimalType return values are not yet supported (%s)", name);
-//                        return NULL;
-//                    case Type::BigIntegerType:
-//                        LOGERROR_1(0, "SDO BigIntegerType return values are not yet supported (%s)", name);
-//                        return NULL;
-//                    default:
-//                        LOGERROR_1(0, "Unknown SDO type return value named %s has been found. Unknown types are not yet supported", name);
-//                        return NULL;
-//                    }         
-//                }
-//            
-//                try
-//                {
-//                    // Call into the wired composite
-//                    compositeServiceHelper->invoke(operation);
-//            
-//                    // Set the data in the outputDataObject to be returned
-//                    setOutputData(operation, outputDataObject);                            
-//                }
-//            	catch(SDORuntimeException &ex)
-//            	{	
-//                    // TODO: Return more error information than just a null DataObject
-//                    LOGERROR_2(0, "%s has been caught: %s\n", ex.getEClassName(), ex.getMessageText());
-//                    return NULL;
-//            	}  
-//            	catch(ServiceRuntimeException &ex)
-//            	{	
-//                    // TODO: Return more error information than just a null DataObject
-//                    LOGERROR_2(0, "%s has been caught: %s\n", ex.getEClassName(), ex.getMessageText());
-//                    return NULL;
-//            	}  
-//            
-//                LOGEXIT(1,"WSServiceProxy::invoke");
-//            
-//                return outputDataObject;
+                return outputDataObject;
 
-                    return NULL;
             }
             
             
@@ -674,7 +591,7 @@
                     }   
                 }
             }
-
-        } // End namespace ws
+    
+        } // End namespace ws        
     } // End namespace sca
 } // End namespace tuscany

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceProxy.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceProxy.h?rev=437914&r1=437913&r2=437914&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceProxy.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/ws/WSServiceProxy.h Mon Aug 28 19:13:00 2006
@@ -1,6 +1,6 @@
 /*
  *
- *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -15,48 +15,96 @@
  *  limitations under the License.
  */
 
-#ifndef tuscany_sca_ws_wsserviceproxy_h
-#define tuscany_sca_ws_wsserviceproxy_h
+/* $Rev: 437730 $ $Date: 2006-08-28 08:57:52 -0700 (Mon, 28 Aug 2006) $ */
+
+#ifndef tuscany_sca_extension_ws_wsserviceproxy_h
+#define tuscany_sca_extension_ws_wsserviceproxy_h
 
 #include "osoa/sca/export.h"
-#include "tuscany/sca/core/TuscanyRuntime.h"
-#include "tuscany/sca/core/Operation.h"
-#include "tuscany/sca/core/CompositeServiceHelper.h"
+#include "tuscany/sca/core/ServiceProxy.h" 
+#include "tuscany/sca/core/ServiceWrapper.h" 
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/ws/WSReferenceBinding.h"
 #include "commonj/sdo/SDO.h"
-using commonj::sdo::DataFactoryPtr;
-using commonj::sdo::DataObjectPtr;
-
-#include <string>
-using std::string;
 
+using namespace tuscany::sca::model;
 
+using commonj::sdo::DataObjectPtr;
 
 namespace tuscany
 {
     namespace sca
     {
         namespace ws
-        {        
-            class SCA_API WSServiceProxy
+        {
+            
+            /**
+             * Holds a proxy for a given component and reference.
+             * The proxy which is held inside a ServiceProxy will be specific to the programming
+             * interface expected by the client. In this particular case the client is an Axis2 
+             * Web service skeleton.
+             */
+            class WSServiceProxy : public ServiceProxy
             {
             public:
-                static WSServiceProxy* getInstance();
+                /**
+                 * Create a new service proxy for a reference. The proxy will contain a pointer to
+                 * the target ServiceWrapper.
+                 * @param reference The reference on the source component.
+                 * @param target The wrapper of the service which is wired to this reference.
+                 */
+                WSServiceProxy(Reference* reference);
+    
+                /**
+                 * Create a new service proxy for a service. The proxy will contain a pointer to
+                 * the target ServiceWrapper.
+                 * @param reference The service on the target component.
+                 * @param target The wrapper of the target service.
+                 */
+                WSServiceProxy(Service* service);
+    
+                /**
+                 * Destructor.
+                 */
                 virtual ~WSServiceProxy();
-                virtual void init(const char* systemRoot, const char* compositeServiceName);
-                virtual DataFactoryPtr getDataFactory(void);
-                virtual DataObjectPtr invoke(const char* operationName, DataObjectPtr inputDataObject);    
+    
+                /**
+                 * Return an instance of the proxy created for this particular component and reference.
+                 * @return The proxy.
+                 */
+                virtual void* getProxy();
+                
+                /**
+                 * Return the proxies created for this particular component and reference.
+                 * @return The proxies.
+                 */
+                virtual PROXIES getProxies();
+
+                /**
+                 * Invoke the specified operation
+                 */
+                DataObjectPtr invoke(const char* operationName, DataObjectPtr inputDataObject);    
+    
             private:
-                WSServiceProxy();
-                static WSServiceProxy* compositeServiceProxyInstance;
-                virtual void setOutputData(Operation operation, DataObjectPtr outputDataObject);
-                string compositeServiceName;
-                string systemRoot;
-                string defaultComponentName;
-                TuscanyRuntime* tuscanyRuntime;
-                CompositeServiceHelper* compositeServiceHelper;
+
+                void setOutputData(Operation operation, DataObjectPtr outputDataObject);
+                
+                /**
+                 * The target service wrapper
+                 */
+                 ServiceWrapper* serviceWrapper;
+            
+                /**
+                 * Holds the instances of the WS proxies.
+                 */ 
+                PROXIES proxies;
+    
             };
+            
         } // End namespace ws
     } // End namespace sca
 } // End namespace tuscany
 
-#endif // tuscany_sca_ws_wsserviceproxy_h
+#endif // tuscany_sca_extension_ws_wsserviceproxy_h

Modified: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/CPPServiceProxy.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/CPPServiceProxy.h?rev=437914&r1=437913&r2=437914&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/CPPServiceProxy.h (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/CPPServiceProxy.h Mon Aug 28 19:13:00 2006
@@ -17,8 +17,8 @@
 
 /* $Rev$ $Date$ */
 
-#ifndef tuscany_sca_extension_cpp_model_cppserviceproxy_h
-#define tuscany_sca_extension_cpp_model_cppserviceproxy_h
+#ifndef tuscany_sca_extension_cpp_cppserviceproxy_h
+#define tuscany_sca_extension_cpp_cppserviceproxy_h
 
 #include "osoa/sca/export.h"
 #include "tuscany/sca/core/ServiceProxy.h" 
@@ -109,4 +109,4 @@
     } // End namespace sca
 } // End namespace tuscany
 
-#endif // tuscany_sca_extension_cpp_model_cppserviceproxy_h
+#endif // tuscany_sca_extension_cpp_cppserviceproxy_h

Modified: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/CPPServiceWrapper.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/CPPServiceWrapper.h?rev=437914&r1=437913&r2=437914&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/CPPServiceWrapper.h (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/CPPServiceWrapper.h Mon Aug 28 19:13:00 2006
@@ -17,8 +17,8 @@
 
 /* $Rev$ $Date$ */
 
-#ifndef tuscany_sca_extension_cpp_model_cppservicewrapper_h
-#define tuscany_sca_extension_cpp_model_cppservicewrapper_h
+#ifndef tuscany_sca_extension_cpp_cppservicewrapper_h
+#define tuscany_sca_extension_cpp_cppservicewrapper_h
 
 #include "osoa/sca/export.h"
 #include "tuscany/sca/core/ServiceWrapper.h"
@@ -156,4 +156,4 @@
     } // End namespace sca
 } // End namespace tuscany
 
-#endif // tuscany_sca_extension_cpp_model_cppservicewrapper_h
+#endif // tuscany_sca_extension_cpp_cppservicewrapper_h

Modified: incubator/tuscany/cpp/sca/runtime/ws_service/axis2c/src/Axis2Service_skeleton.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/ws_service/axis2c/src/Axis2Service_skeleton.cpp?rev=437914&r1=437913&r2=437914&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/ws_service/axis2c/src/Axis2Service_skeleton.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/ws_service/axis2c/src/Axis2Service_skeleton.cpp Mon Aug 28 19:13:00 2006
@@ -29,12 +29,23 @@
 using namespace commonj::sdo;
 using namespace commonj::sdo_axiom;
 
-#include "tuscany/sca/util/Utils.h"
-using namespace tuscany::sca;
+#include "osoa/sca/sca.h"
+using namespace osoa::sca;
 
+#include "tuscany/sca/util/Exceptions.h"
 #include "tuscany/sca/ws/WSServiceProxy.h"
+#include "tuscany/sca/ws/WSReferenceBinding.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/CompositeService.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/core/TuscanyRuntime.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/util/Utils.h"
 #include "Axis2Utils.h"
+
+using namespace tuscany::sca;
 using namespace tuscany::sca::ws;
+using namespace tuscany::sca::model;
 
 
 int AXIS2_CALL
@@ -53,8 +64,6 @@
 int AXIS2_CALL Axis2Service_init(axis2_svc_skeleton_t *svc_skeleton,
                         const axis2_env_t *env);
 
-WSServiceProxy* compositeServiceProxy = NULL;
-
 axis2_svc_skeleton_t *
 axis2_Axis2Service_create(axis2_env_t *env)
 {
@@ -73,11 +82,6 @@
     svc_skeleton->ops->invoke = Axis2Service_invoke;
     /*svc_skeleton->ops->on_fault = Axis2Service_on_fault;*/
 
-    if(compositeServiceProxy == NULL)
-    {
-        compositeServiceProxy = WSServiceProxy::getInstance();
-    }
-
     return svc_skeleton;
 }
 
@@ -115,6 +119,79 @@
     return AXIS2_SUCCESS; 
 }
 
+/**
+ * Initialize the Tuscany runtime
+ */
+ 
+static string systemRoot = "";
+static string serviceName = "";
+static TuscanyRuntime* tuscanyRuntime = NULL;
+static CompositeService* compositeService = NULL;
+
+void initTuscanyRuntime(const axis2_env_t *env, const char* root, const char* service)
+{
+    AXIS2_LOG_INFO((env)->log, "Axis2Service init : %s $s\n", root, service);
+    try
+    {
+
+        bool newInitParams = false;
+
+        if(systemRoot.length() != 0 && systemRoot != root)
+        {
+            systemRoot = root;
+            newInitParams = true;
+        }
+
+        if(serviceName.length() != 0 && serviceName != service)
+        {
+            serviceName = service;
+            newInitParams = true;
+        }
+        
+        // service is of the form "component name"/"composite service name"
+        string defaultComponentName, compositeServiceName;
+        Utils::rTokeniseString("/", service, defaultComponentName, compositeServiceName);
+
+        if(tuscanyRuntime == NULL)
+        {
+            AXIS2_LOG_INFO((env)->log, "Creating new Tuscany runtime\n");
+            tuscanyRuntime = new TuscanyRuntime(defaultComponentName, systemRoot);
+            tuscanyRuntime->start();
+        }
+        else if(tuscanyRuntime != NULL && newInitParams)
+        {
+            AXIS2_LOG_INFO((env)->log, "Restarting Tuscany runtime\n");
+            tuscanyRuntime->stop();
+            tuscanyRuntime->setDefaultComponentName(defaultComponentName);
+            tuscanyRuntime->setSystemRoot(systemRoot);
+            tuscanyRuntime->start();
+        }
+
+        if(compositeService == NULL)
+        {
+            Composite* composite = SCARuntime::getInstance()->getDefaultComponent()->getComposite();
+            compositeService = (CompositeService*)composite->findComponent(compositeServiceName);
+        }
+        else
+        {
+            if(newInitParams)
+            {
+                Composite* composite = SCARuntime::getInstance()->getDefaultComponent()->getComposite();
+                compositeService = (CompositeService*)composite->findComponent(compositeServiceName);
+            }
+        }
+    }
+    catch(SystemConfigurationException &ex)
+    {   
+        AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI,  "SystemConfigurationException has been caught: %s\n", ex.getMessageText());
+    }
+    catch(ServiceRuntimeException &ex)
+    {   
+        AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI,  "%s has been caught: %s\n", ex.getEClassName(), ex.getMessageText());
+    }  
+}
+
+
 /*
  * This method invokes the right service method 
  */
@@ -141,24 +218,25 @@
                 axis2_char_t *op_name = AXIOM_ELEMENT_GET_LOCALNAME(element, env);
                 if (op_name)
 				{
-                    char* systemRoot = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanySystemRoot");
-                    char* fullCompositeServiceName = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyService");
-
-                    AXIS2_LOG_INFO((env)->log, "Axis2Service invoke called with system root: %s entrypoint name: %s operation name: %s", systemRoot, fullCompositeServiceName, op_name);
+                    char* root = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanySystemRoot");
+                    char* service = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyService");
+                    
+                    AXIS2_LOG_INFO((env)->log, "Axis2Service invoke called with system root: %s entrypoint name: %s operation name: %s", root, service, op_name);
 
                     //LOGINFO_2(4, "Axis2Service invoke called with system root: %s and entrypoint name: %s", systemRoot, fullCompositeServiceName);
                     //LOGINFO_1(4, "Axis2Service invoke called with operation", op_name);
-                    compositeServiceProxy->init(systemRoot, fullCompositeServiceName);
+                    initTuscanyRuntime(env, root, service);
 
                     //Utils::printTypes(compositeServiceProxy->getDataFactory());
 
-                    AxiomHelper* axiomHelper = AxiomHelper::getHelper();
-                    if (compositeServiceProxy->getDataFactory() == 0)
+                    DataFactoryPtr dataFactory = compositeService->getComposite()->getDataFactory();
+                    if (dataFactory == 0)
                     {
                 		AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: CompositeService has no SCA implementation");
                         return 0;
                     }
 
+                    AxiomHelper* axiomHelper = AxiomHelper::getHelper();
                     char* om_str = NULL;
                     om_str = AXIOM_NODE_TO_STRING(node, env);
                     if (om_str)
@@ -166,7 +244,7 @@
                         AXIS2_LOG_INFO((env)->log, "Axis2Service invoke has request OM: %s\n", om_str);
                     }
 
-                    DataObjectPtr inputDataObject = axiomHelper->toSdo(node, compositeServiceProxy->getDataFactory());
+                    DataObjectPtr inputDataObject = axiomHelper->toSdo(node, dataFactory);
 
                     //printf("Axis2ServiceType inputDataObject: (%d)\n", inputDataObject);
 
@@ -181,7 +259,13 @@
                     //Utils::printDO(inputDataObject);			
                     //std::cout << "Axis2ServiceType inputDataObject printed\n";
                     
-                    DataObjectPtr outputDataObject = compositeServiceProxy->invoke(op_name, inputDataObject);
+                    //
+                    //  Dispatch to the WS proxy
+                    //
+                    
+                    WSReferenceBinding* referenceBinding = (WSReferenceBinding*)compositeService->getReference()->getBinding();
+                    WSServiceProxy* proxy = (WSServiceProxy*)referenceBinding->getServiceProxy();
+                    DataObjectPtr outputDataObject = proxy->invoke(op_name, inputDataObject);
 
                     //std::cout << "Axis2ServiceType outputDataObject:" << outputDataObject;
                     //Utils::printDO(outputDataObject);			



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