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/12/05 07:10:44 UTC

svn commit: r482513 - in /incubator/tuscany/cpp/sca/runtime: core/src/ core/src/tuscany/sca/core/ core/src/tuscany/sca/model/ extensions/rest/reference/curl/src/tuscany/sca/rest/ extensions/ws/reference/axis2c/src/tuscany/sca/ws/

Author: jsdelfino
Date: Mon Dec  4 22:10:42 2006
New Revision: 482513

URL: http://svn.apache.org/viewvc?view=rev&rev=482513
Log:
Fixed the instantiation of services and references as well as reference bindings on Composite components. Added an option to SCARuntime to allow the construction of URIs to be configured using an env variable, and code to use that in the reference bindings.

Added:
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.cpp   (with props)
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.h   (with props)
Modified:
    incubator/tuscany/cpp/sca/runtime/core/src/Makefile.am
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Binding.h
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Composite.cpp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Composite.h
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReference.h
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.h
    incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.h
    incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.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?view=diff&rev=482513&r1=482512&r2=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/Makefile.am (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/Makefile.am Mon Dec  4 22:10:42 2006
@@ -41,6 +41,7 @@
 tuscany/sca/model/ComponentType.cpp \
 tuscany/sca/model/Composite.cpp \
 tuscany/sca/model/CompositeReference.cpp \
+tuscany/sca/model/CompositeReferenceBinding.cpp \
 tuscany/sca/model/CompositeService.cpp \
 tuscany/sca/model/Contract.cpp \
 tuscany/sca/model/Interface.cpp \

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp?view=diff&rev=482513&r1=482512&r2=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp Mon Dec  4 22:10:42 2006
@@ -48,6 +48,7 @@
         static const char* TUSCANY_SCACPP_ROOT = "TUSCANY_SCACPP_ROOT";
         static const char* TUSCANY_SCACPP_COMPONENT = "TUSCANY_SCACPP_COMPONENT";
         static const char* TUSCANY_SCACPP_PATH = "TUSCANY_SCACPP_PATH";
+        static const char* TUSCANY_SCACPP_BASE_URI = "TUSCANY_SCACPP_BASE_URI";
  
         // ==========================================================
         // Initialize static class member to not pointing at anything
@@ -57,6 +58,7 @@
         string SCARuntime::systemRoot = "";
         string SCARuntime::systemPath = "";
         string SCARuntime::defaultComponentName = "";
+        string SCARuntime::defaultBaseURI = "";
         
 
         // ==========================================================
@@ -114,6 +116,24 @@
         }
 
         // ==========================================================
+        // Set the default base URI
+        // ==========================================================
+        void SCARuntime::setDefaultBaseURI(const string& baseURI)
+        {
+            logentry();
+            defaultBaseURI = baseURI;
+            loginfo("Default base URI: %s", baseURI.c_str());
+        }
+
+        // ==========================================================
+        // Returns the default base URI
+        // ==========================================================
+        const string& SCARuntime::getDefaultBaseURI()
+        {
+            return defaultBaseURI;
+        }
+
+        // ==========================================================
         // Set the install root
         // ==========================================================
         void SCARuntime::setInstallRoot(const string& root)
@@ -211,6 +231,17 @@
                         systemPath = systemPathEnv;
                     }
                 }
+                if (defaultBaseURI == "")
+                {
+                    
+                    // Get default base URI from environment variable TUSCANY_SCACPP_BASE_URI
+                    char* baseURI = getenv(TUSCANY_SCACPP_BASE_URI);
+                    if (baseURI != 0)
+                    {
+                        loginfo("Default base URI: %s", baseURI);
+                        defaultBaseURI = baseURI;
+                    }
+                }
 
                 // Create new instance of the runtime
                 instance = new SCARuntime();
@@ -481,7 +512,7 @@
         }
         
         // ===========================================
-        // getCurrentCompositeComponent: return the current composite component
+        // getDefaultComponent: return the default composite component
         // ===========================================
         Component* SCARuntime::getDefaultComponent()
         {

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h?view=diff&rev=482513&r1=482512&r2=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h Mon Dec  4 22:10:42 2006
@@ -121,6 +121,17 @@
             SCA_API static const string& getDefaultComponentName();
 
             /**
+             * Set the default base URI for the system
+             * @param baseURI The default base URI.
+             */
+            SCA_API static void setDefaultBaseURI(const string& baseURI);
+
+            /**
+             * Returns the default base URI for the system
+             */
+            SCA_API static const string& getDefaultBaseURI();
+
+            /**
              * Set the current component for the current thread.
              * @param component The current component.
              */
@@ -235,6 +246,11 @@
              * The default CompositeComponent.
              */
             static string defaultComponentName;
+
+            /**
+             * The default base URI.
+             */
+            static string defaultBaseURI;
 
             /**
              * The default component set for this runtime.

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Binding.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Binding.h?view=diff&rev=482513&r1=482512&r2=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Binding.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Binding.h Mon Dec  4 22:10:42 2006
@@ -66,7 +66,7 @@
                  * Returns the binding URI.
                  * @return The binding URI.
                  */
-                SCA_API const string& getURI() const { return uri; };
+                SCA_API virtual const string& getURI() const { return uri; };
                 
             private:
             

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Composite.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Composite.cpp?view=diff&rev=482513&r1=482512&r2=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Composite.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Composite.cpp Mon Dec  4 22:10:42 2006
@@ -23,6 +23,12 @@
 #include "tuscany/sca/util/Utils.h"
 #include "tuscany/sca/model/Composite.h"
 #include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/CompositeReference.h"
+#include "tuscany/sca/model/CompositeReferenceBinding.h"
+#include "tuscany/sca/model/CompositeService.h"
+//#include "tuscany/sca/model/CompositeServiceBinding.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/ReferenceType.h"
 #include "tuscany/sca/model/Wire.h"
 #include "tuscany/sca/model/WSDLDefinition.h"
 #include "tuscany/sca/model/Service.h"
@@ -57,6 +63,62 @@
                 components[component->getName()] = component;
             }
             
+            void Composite::addCompositeReference(CompositeReference* compositeReference)
+            {
+                logentry(); 
+                components[compositeReference->getName()] = compositeReference;
+
+                // Create a reference type describing the composite reference                
+                ServiceType* serviceType = compositeReference->getType()->findServiceType("");
+                ReferenceType* referenceType = new ReferenceType(
+                    this, compositeReference->getName(),
+                    serviceType->getInterface(),
+                    serviceType->getCallbackInterface(),
+                    compositeReference->getMultiplicity());
+                addReferenceType(referenceType);
+            }
+            
+            void Composite::addCompositeService(CompositeService* compositeService)
+            {
+                logentry(); 
+                components[compositeService->getName()] = compositeService;
+                
+                // Create a service type describing the composite service
+                ReferenceType* referenceType = compositeService->getType()->findReferenceType("");
+                ServiceType* serviceType = new ServiceType(
+                    this, compositeService->getName(),
+                    referenceType->getInterface(),
+                    referenceType->getCallbackInterface());
+                addServiceType(serviceType);
+            }
+            
+            void Composite::initializeComponent(Component* component)
+            {
+                ComponentType::initializeComponent(component);
+                
+                // Create bindings for all the services
+                const Component::SERVICE_MAP& services = component->getServices();
+                Component::SERVICE_MAP::const_iterator iter = services.begin();
+                for (int i=0; i< services.size(); i++)
+                {
+                    Service *service = iter->second;
+                    //CompositeServiceBinding* binding = new CompositeServiceBinding(service);
+                    //service->setBinding(binding);
+                    iter++;
+                }
+                
+                // Create bindings for all the references
+                const Component::REFERENCE_MAP& references = component->getReferences();
+                Component::REFERENCE_MAP::const_iterator refiter = references.begin();
+                for (int ri=0; ri< references.size(); ri++)
+                {
+                    Reference *reference = refiter->second;
+                    CompositeReferenceBinding* binding = new CompositeReferenceBinding(reference);
+                    reference->setBinding(binding);
+                    refiter++;
+                }
+            }
+            
             Component* Composite::findComponent(const std::string& name)
             {
                 logentry(); 
@@ -113,35 +175,28 @@
                 iter++)
                 {
                     Wire* wire = *iter;
-                    
-                    // Locate the target
-                    Service* service = findComponentService(wire->getTarget());
-                    if (!service)
+
+                    // Find the source component and reference
+                    Component* component = findComponent(wire->getSourceComponent());
+                    Reference* reference;                    
+                    if (component)
                     {
-                        logerror("Wire target %s not found", wire->getTarget().c_str());
+                        reference = component->findReference(wire->getSourceReference());
+                        if (!reference)
+                        {
+                            logerror("Wire source reference %s not found", wire->getSourceReference().c_str());
+                        }
                     }
                     else
                     {
-                        Component* component = findComponent(wire->getSourceComponent());
-                        if (component)
-                        {
-                            Reference* reference = component->findReference(wire->getSourceReference());
-                            if (reference)
-                            {
-                                
-                                // Configure the binding on the reference from the binding on the target
-                                // service
-                                reference->getBinding()->configure(service->getBinding());
-                            }
-                            else
-                            {
-                                logerror("Wire source reference %s not found", wire->getSourceReference().c_str());
-                            }
-                        }
-                        else
-                        {
-                            logerror("Wire source %s not found", wire->getSourceComponent().c_str());
-                        }
+                        reference = NULL;
+                        logerror("Wire source %s not found", wire->getSourceComponent().c_str());
+                    }
+                    
+                    // Configure the reference binding with the wire target URI 
+                    if (reference)
+                    {
+                        reference->getBinding()->configure(wire->getTarget());
                     }
                 }
             }

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Composite.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Composite.h?view=diff&rev=482513&r1=482512&r2=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Composite.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Composite.h Mon Dec  4 22:10:42 2006
@@ -45,6 +45,8 @@
         {
             class Component;
             class ComponentType;
+            class CompositeReference;
+            class CompositeService;
             class Service;
             class WSDLDefinition;
             class Wire;
@@ -85,6 +87,18 @@
                 SCA_API void addComponent(Component* component);
 
                 /**
+                 * Add a new composite reference to the composite.
+                 * @param compositeReference The composite reference to add.
+                 */
+                SCA_API void addCompositeReference(CompositeReference* compositeReference);
+
+                /**
+                 * Add a new composite service to the composite.
+                 * @param compositeService The composite service to add.
+                 */
+                SCA_API void addCompositeService(CompositeService* compositeService);
+
+                /**
                  * Add/include a composite in this composite.
                  * @param composite The composite included in this composite.
                  */
@@ -127,6 +141,12 @@
                  * @param wsdlNamespace The namespace of the WSDL definitions to find.
                  */
                 SCA_API WSDLDefinition* findWSDLDefinition(const string& wsdlNamespace);
+
+                 /**
+                 * Initialize a component of this type.
+                 * @param component The component to initialize.
+                 */
+                virtual void initializeComponent(Component* component);
 
                 /**
                  * Return a cached SDO XSDHelper.

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReference.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReference.h?view=diff&rev=482513&r1=482512&r2=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReference.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReference.h Mon Dec  4 22:10:42 2006
@@ -65,6 +65,12 @@
                  * @return The service exposed by this composite reference.
                  */
                 SCA_API Service* getService() const { return service; };
+                
+                /**
+                 * Returns the multiplicity of this composite reference
+                 * @return The multiplicity of the composite reference
+                 */
+                 SCA_API ReferenceType::Multiplicity getMultiplicity() { return multiplicity; }
 
             private:
             
@@ -72,6 +78,11 @@
                  * The service exposed by this composite reference.
                  */
                 Service* service;
+                
+                /**
+                 * The multiplicity of this reference
+                 */
+                 ReferenceType::Multiplicity multiplicity;
 
             };
         } // End namespace model

Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.cpp?view=auto&rev=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.cpp Mon Dec  4 22:10:42 2006
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *   
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/model/CompositeReferenceBinding.h"
+
+namespace tuscany
+{
+    namespace sca
+    {
+        namespace model
+        {
+
+            // Constructor
+            CompositeReferenceBinding::CompositeReferenceBinding(Reference* reference)
+                : ReferenceBinding(reference, ""), uri("")
+            {
+            }
+            
+            // Destructor
+            CompositeReferenceBinding::~CompositeReferenceBinding()
+            {
+            }
+            
+            void CompositeReferenceBinding::configure(ServiceBinding *binding)
+            {
+                targetServiceBinding = binding;
+            }
+            
+            ServiceProxy* CompositeReferenceBinding::getServiceProxy()
+            {
+                return serviceProxy;
+            }
+                
+            void CompositeReferenceBinding::configure(const string& uri)
+            {
+                this->uri = uri;
+            }
+                                
+        } // End namespace model
+    } // End namespace sca
+} // End namespace tuscany

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.h?view=auto&rev=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.h Mon Dec  4 22:10:42 2006
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *   
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_sca_model_compositereferencebinding_h
+#define tuscany_sca_model_compositereferencebinding_h
+
+#include "tuscany/sca/model/ReferenceBinding.h"
+
+#include <string>
+
+namespace tuscany
+{
+    namespace sca
+    {
+        namespace model
+        {
+            /**
+             * A default composite reference binding
+             */
+            class CompositeReferenceBinding : public ReferenceBinding
+            {    
+            public:
+
+                /**
+                 * Constructor.
+                 * @param uri The uri of the binding.
+                 */
+                SCA_API CompositeReferenceBinding(Reference* reference);  
+
+                /**
+                 * Destructor.
+                 */
+                SCA_API virtual ~CompositeReferenceBinding();
+                            
+                /**
+                 * Returns the type of binding.
+                 */                
+                virtual string getType() { return "http://www.osoa.org/xmlns/sca/1.0#CompositeServiceBinding"; };
+                            
+                 /**
+                  * Configure this binding from a service binding.
+                  */
+                SCA_API virtual void configure(ServiceBinding* serviceBinding);
+                                
+                 /**
+                  * Configure this binding from a URI.
+                  */
+                  SCA_API virtual void configure(const string& uri);
+                                
+                /**
+                 * Create a proxy representing the reference to the
+                 * client component.
+                 */
+                SCA_API virtual ServiceProxy* getServiceProxy();
+                                
+                 /**
+                  * Returns the target service binding.
+                  */
+                  ServiceBinding* getTargetServiceBinding() const { return targetServiceBinding; };
+                                
+                /**
+                 * Returns the binding URI.
+                 * @return The binding URI.
+                 */
+                SCA_API virtual const string& getURI() const { return uri; };
+                
+            private:
+            
+                /**
+                 * The proxy representing the reference to the client
+                 * component.
+                 */
+                ServiceProxy* serviceProxy;
+                
+                /**
+                 * The service binding of the target
+                 */
+                ServiceBinding* targetServiceBinding;
+                
+                /**
+                 * The binding URI
+                 */
+                 string uri; 
+            };
+            
+        } // End namespace model
+    } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_compositereferencebinding_h

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/CompositeReferenceBinding.h
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp?view=diff&rev=482513&r1=482512&r2=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp Mon Dec  4 22:10:42 2006
@@ -605,7 +605,7 @@
                 CompositeService* compositeService = new CompositeService(
                         composite, compositeServiceName, iface, NULL, false, multiplicity); 
                 
-                composite->addComponent(compositeService);    
+                composite->addCompositeService(compositeService);    
 
                 DataObjectList& refs = compositeServiceDO->getList("reference");
                 for (unsigned int i=0; i<refs.size(); i++)
@@ -674,7 +674,7 @@
                 CompositeReference* compositeReference = new CompositeReference(
                         composite, compositeReferenceName, iface, NULL, false, ReferenceType::ONE_ONE); 
                     
-                composite->addComponent(compositeReference);
+                composite->addCompositeReference(compositeReference);
                 
                 // Get binding, it will be the first and only binding
                 DataObjectList& bindings = compositeReferenceDO->getList("binding");

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp?view=diff&rev=482513&r1=482512&r2=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.cpp Mon Dec  4 22:10:42 2006
@@ -21,6 +21,10 @@
 
 #include "tuscany/sca/util/Logging.h"
 #include "tuscany/sca/model/ReferenceBinding.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Service.h"
 
 
 namespace tuscany
@@ -44,6 +48,24 @@
                 logentry(); 
             }
 
+            void ReferenceBinding::configure(const string& uri)
+            {
+                // Find the target service
+                Component* component = reference->getComponent();
+                Composite* composite = component->getComposite();
+                Service* service;
+                service = composite->findComponentService(uri);
+                if (!service)
+                {
+                    logerror("Wire target %s not found", uri.c_str());
+                }
+                else
+                {
+                    // Configure this binding from the target service binding
+                    configure(service->getBinding());
+                }
+            }
+                                
         } // End namespace model
     } // End namespace sca
 } // End namespace tuscany

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.h?view=diff&rev=482513&r1=482512&r2=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ReferenceBinding.h Mon Dec  4 22:10:42 2006
@@ -73,6 +73,11 @@
                   */
                   SCA_API virtual void configure(ServiceBinding* serviceBinding) = 0;
                                 
+                 /**
+                  * Configure this binding from a URI.
+                  */
+                  SCA_API virtual void configure(const string& uri);
+                                
                   /**
                    * Returns the reference.
                    * @return The reference.

Modified: incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp?view=diff&rev=482513&r1=482512&r2=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp Mon Dec  4 22:10:42 2006
@@ -25,6 +25,7 @@
 #include "tuscany/sca/util/Utils.h"
 #include "RESTServiceWrapper.h"
 #include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/core/SCARuntime.h"
 #include "tuscany/sca/model/Service.h"
 #include "tuscany/sca/model/Component.h"
 #include "tuscany/sca/model/Composite.h"
@@ -253,12 +254,12 @@
                             }
                             else
                             {
-                                uri = binding->getURI();
+                                uri = getBindingURI();
                             }
                         }
                         else
                         {
-                            uri = binding->getURI();
+                            uri = getBindingURI();
                         }
                         // Add the parameters to the end of the URI
                         ostringstream os;
@@ -357,7 +358,7 @@
                         // HTTP POST
                         
                         // Set the target URL
-                        string url = binding->getURI();  
+                        string url = getBindingURI();  
                         curl_easy_setopt(curl_handle, CURLOPT_URL, url.c_str());
     
                         // Create the input payload     
@@ -452,12 +453,12 @@
                             }
                             else
                             {
-                                uri = binding->getURI();
+                                uri = getBindingURI();
                             }
                         }
                         else
                         {
-                            uri = binding->getURI();
+                            uri = getBindingURI();
                         }
                         // Add the parameters to the end of the URI
                         ostringstream os;
@@ -577,12 +578,12 @@
                             }
                             else
                             {
-                                uri = binding->getURI();
+                                uri = getBindingURI();
                             }
                         }
                         else
                         {
-                            uri = binding->getURI();
+                            uri = getBindingURI();
                         }
                         // Add the parameters to the end of the URI
                         ostringstream os;
@@ -684,7 +685,7 @@
                     if (complexContent)
                     {
                        // Set the target URL
-                        string uri = binding->getURI();
+                        string uri = getBindingURI();
                         ostringstream os;
                         os << uri << "/" << opName;
                         url = os.str();                                        
@@ -756,7 +757,7 @@
                     {
 
                         // Build the request URL, uri / opName ? params
-                        string uri = binding->getURI();
+                        string uri = getBindingURI();
                         ostringstream os;
                         os << uri << "/" << opName;
     
@@ -830,6 +831,44 @@
                 // Cleanup curl session
                 curl_easy_cleanup(curl_handle);
             }
+            
+
+            const string RESTServiceWrapper::getBindingURI()
+            {
+                string bindingURI = "";
+                
+                // Get the binding URI configured on the top level component 
+                Service* service = getService();
+                CompositeReference* compositeReference = (CompositeReference*)service->getComponent();
+                SCARuntime* runtime = SCARuntime::getInstance();
+                Component* component = runtime->getDefaultComponent();
+                Reference* reference = component->findReference(compositeReference->getName());
+                if (reference != NULL)
+                {
+                    ReferenceBinding* binding = reference->getBinding();
+                    if (binding != NULL && binding->getURI() != "")
+                    {
+                        bindingURI = binding->getURI();
+                    } 
+                }
+                if (bindingURI == "")
+                {
+                    // Get the binding URI configured on the binding 
+                    RESTServiceBinding* binding = (RESTServiceBinding *)service->getBinding();
+                    bindingURI = binding->getURI();
+                }
+                if (bindingURI != "")
+                {
+                    
+                    // Prepend the default base URI if the URI is not absolute
+                    if (bindingURI.find("://") == string::npos)
+                    {
+                        bindingURI = runtime->getDefaultBaseURI() + bindingURI;
+                    }
+                }
+                return bindingURI;
+            }
+            
             
             void RESTServiceWrapper::writeParameter(XMLHelper* xmlHelper, ostringstream& os, const Operation::Parameter& parm)
             {

Modified: incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.h?view=diff&rev=482513&r1=482512&r2=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.h (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.h Mon Dec  4 22:10:42 2006
@@ -69,6 +69,11 @@
                 static bool initialized;
                 
                 /**
+                 * Get the configured binding URI
+                 */
+                 const string getBindingURI();
+                
+                /**
                  * Write a parameter into a URL
                  */
                 void writeParameter(commonj::sdo::XMLHelper* xmlHelper, std::ostringstream& os, const Operation::Parameter& parm);

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp?view=diff&rev=482513&r1=482512&r2=482513
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp Mon Dec  4 22:10:42 2006
@@ -173,26 +173,39 @@
                         "Only wrapped document style WSDL operations are currentlysupported");
                 }
                     
-                // Get the target endpoint address
                 // The URI specified in the binding overrides the address specified in
                 // the WSDL
                 axis2_char_t* address;
-                if (binding->getURI() != "")
+
+                // Get the URI configured on the top level component                
+                string bindingURI = "";
+                SCARuntime* runtime = SCARuntime::getInstance();
+                Component* component = runtime->getDefaultComponent();
+                Reference* reference = component->findReference(compositeReference->getName());
+                if (reference != NULL)
                 {
-                    if (binding->getURI().find("http://")==0)
+                    ReferenceBinding* referenceBinding = reference->getBinding();
+                    if (referenceBinding != NULL && referenceBinding->getURI() != "")
                     {
-                        address = (axis2_char_t*)binding->getURI().c_str();
+                        bindingURI = referenceBinding->getURI();
+                    } 
+                }
+                if (bindingURI == "")
+                {
+                    // Get the URI configured on the binding
+                    if (binding->getURI() != "")
+                    {
+                        bindingURI = binding->getURI();
                     }
-                    else
+                }
+                if (bindingURI != "")
+                {
+                    // Prepend the default base URI if the URI is not absolute
+                    if (bindingURI.find("://") == string::npos)
                     {
-                        //TODO Hack for now, hardcode the address of the target service
-                        // Derive it from the component / service name
-                        string componentName;
-                        string serviceName;
-                        Utils::tokeniseString("/", binding->getURI(), componentName, serviceName);
-                        string saddress = "http://" + componentName + ":9090/axis2/services/" + serviceName;
-                        address = (axis2_char_t*)saddress.c_str();
+                        bindingURI = runtime->getDefaultBaseURI() + bindingURI;
                     }
+                    address = (axis2_char_t*)bindingURI.c_str();
                 }
                 else
                 {



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