tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robbin...@apache.org
Subject svn commit: r366157 [5/33] - in /incubator/tuscany/cpp/sca: ./ bin/ include/ include/osoa/ include/osoa/sca/ include/tuscany/ include/tuscany/sca/ include/tuscany/sca/core/ include/tuscany/sca/model/ include/tuscany/sca/util/ include/tuscany/sca/ws/ li...
Date Thu, 05 Jan 2006 10:59:14 GMT
Added: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContext.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContext.cpp?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContext.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContext.cpp Thu Jan  5 02:54:16 2006
@@ -0,0 +1,93 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#include "osoa/sca/ModuleContext.h"
+#include "tuscany/sca/util/Logging.h"
+#include "osoa/sca/ModuleContextImpl.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+using namespace tuscany::sca;
+
+namespace osoa
+{
+    namespace sca
+    {
+        // ===========
+        // Constructor
+        // ===========    
+        ModuleContext::ModuleContext(ModuleContextImpl* implementation)
+            : impl(implementation)
+        {
+        }
+
+        // ===================================
+        // Copy constructor: create a new impl
+        // ===================================
+        ModuleContext::ModuleContext(const ModuleContext& ctx)
+        {
+            impl = new ModuleContextImpl(SCARuntime::getInstance()->getCurrentModule());
+        }
+        
+        // =============================
+        // operator= : create a new impl
+        // =============================
+        ModuleContext& ModuleContext::operator=(const ModuleContext& ctx)
+        {
+            if (this != &ctx)
+            {
+                impl = new ModuleContextImpl(SCARuntime::getInstance()->getCurrentModule());
+            }
+            return *this;
+        }
+        
+        // ==========
+        // Destructor
+        // ==========
+        ModuleContext::~ModuleContext()
+        {
+            LOGENTRY(1, "ModuleContext::destructor");
+            delete impl;
+            LOGEXIT(1, "ModuleContext::destructor");
+        }
+        
+        // ====================================================
+        // getCurrent: create a context from the current module
+        // ====================================================
+        ModuleContext ModuleContext::getCurrent()
+        {
+            LOGENTRY(1, "ModuleContext::getCurrent");
+            ModuleContextImpl* mci = new ModuleContextImpl(SCARuntime::getInstance()->getCurrentModule());
+            LOGEXIT(1, "ModuleContext::getCurrent");
+            return ModuleContext(mci);
+        }
+
+        // =============
+        // locateService
+        // =============
+        void* ModuleContext::locateService(const char* serviceName)
+        {
+            LOGENTRY(1, "ModuleContext::locateService");
+            void* sp = impl->locateService(serviceName);
+            LOGEXIT(1, "ModuleContext::locateService");
+            return sp;
+        }
+
+        
+    } // End namespace sca
+} // End namespace osoa

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

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContext.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContext.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContext.h?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContext.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContext.h Thu Jan  5 02:54:16 2006
@@ -0,0 +1,80 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_modulecontext_h
+#define osoa_sca_modulecontext_h
+
+#include "osoa/sca/export.h"
+
+namespace osoa
+{
+    namespace sca
+    {
+        class ModuleContextImpl;
+
+        /**
+         * An SCA component implementation, or a non-SCA client, uses the 
+         * ModuleContext class to retrieve information about the configured 
+         * SCA module.
+         */
+        class SCA_API ModuleContext  
+        {
+        
+        public:
+            /** 
+             * Return a new ModuleContext for the current Component.
+             */
+            static ModuleContext getCurrent();
+
+            /** 
+             * Resolve a service name into a single component service.
+             * @param serviceName The name of the service in the form
+             * "component name"/"service name". The service name is
+             * optional in the component has one service.
+             * @return A pointer to an object which can be cast to the
+             * business interface of the target service.
+             */
+            void* locateService(const char* serviceName);
+
+            /**
+             * Destructor.
+             */
+            virtual ~ModuleContext();
+
+            ModuleContext(const ModuleContext&);
+            ModuleContext& operator=(const ModuleContext&);
+            
+        private:
+            /**
+             * Constructor to create an interface class from the contained
+             * implementation.
+             * @param  implementation The actual implementation class.
+             */
+            ModuleContext(ModuleContextImpl* implementation);
+
+            /**
+             * Pointer to the class which provides the actual implementation.
+             */
+            ModuleContextImpl* impl;
+            
+        };
+    } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_modulecontext_h

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

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContext.h
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContextImpl.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContextImpl.cpp?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContextImpl.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContextImpl.cpp Thu Jan  5 02:54:16 2006
@@ -0,0 +1,102 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/CPPImplementation.h"
+#include "osoa/sca/ModuleContextImpl.h"
+#include "tuscany/sca/core/ComponentServiceWrapper.h"
+
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+
+namespace osoa
+{
+    namespace sca
+    {
+        // ===========
+        // Constructor 
+        // ===========
+        ModuleContextImpl::ModuleContextImpl(Module* mod)
+            : module(mod)
+        {
+        }
+
+        // ==========
+        // Destructor
+        // ==========
+        ModuleContextImpl::~ModuleContextImpl()
+        {
+            // --------------------------------------------
+            // Delete the proxies served up by this context
+            // --------------------------------------------
+            for (PROXIES::iterator iter = proxies.begin(); iter != proxies.end(); iter++)
+            {
+                delete (ServiceProxy*)*iter;
+            }
+        }
+
+        // ===========================================================================
+        // locateService: return a proxy connected to a wrapper for the target service
+        // ===========================================================================
+        void* ModuleContextImpl::locateService(const char* serviceName)
+        {
+            LOGENTRY(1, "ModuleContextImpl::locateService");
+                
+
+            // ----------------------------
+            // Locate the component service
+            // ----------------------------
+            Service* service = module->findComponentService(serviceName);
+            string msg;
+            if (!service)
+            {
+                msg = "Service not found: ";
+                msg = msg + serviceName;
+                throw ServiceNotFoundException(msg.c_str());
+            }
+
+            // -------------------------
+            // Create the ServiceWrapper
+            // -------------------------
+            ComponentServiceWrapper* serviceWrapper = ComponentServiceWrapper::createServiceWrapper(service);
+            
+            // ----------------------------
+            // Get a Proxy for this service
+            // ----------------------------
+            try
+            {
+                ServiceProxy* serviceProxy =  new ServiceProxy(service->getComponent(), service->getName(), serviceWrapper);
+                proxies.push_back(serviceProxy);
+                LOGEXIT(1, "ModuleContextImpl::locateService");
+                return serviceProxy->getProxy();
+            }
+            catch (ServiceRuntimeException&)
+            {
+                delete serviceWrapper;
+                throw ;
+            }
+
+        }
+        
+        
+        
+    } // End namespace sca
+} // End namespace osoa

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

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContextImpl.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContextImpl.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContextImpl.h?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContextImpl.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContextImpl.h Thu Jan  5 02:54:16 2006
@@ -0,0 +1,71 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_modulecontextimpl_h
+#define osoa_sca_modulecontextimpl_h
+#include "tuscany/sca/model/Module.h"
+#include "tuscany/sca/core/ServiceProxy.h"
+
+namespace osoa
+{
+    namespace sca
+    {
+        /** 
+         * Contains the actual implementation of a ModuleContext interface.
+         */
+        class ModuleContextImpl  
+        {
+        
+        public:
+            /** 
+             * Constructor that takes a Module which represents the runtime
+             * model for this context.
+             */
+            ModuleContextImpl(tuscany::sca::model::Module* module);
+
+            /**
+             * See ModuleContext#locateService.
+             */
+            void* locateService(const char* serviceName);
+            
+            /**
+             * Destructor.
+             */
+            virtual ~ModuleContextImpl();
+        private:
+            ModuleContextImpl(const ModuleContextImpl&);
+            ModuleContextImpl& operator=(const ModuleContextImpl&);
+
+            /**
+             * Pointer to the runtime model Module object to which this
+             * context refers.
+             */
+            tuscany::sca::model::Module* module;
+
+            typedef vector<tuscany::sca::ServiceProxy*> PROXIES;
+            /**
+             * Vector of proxies created from calls to the locateService
+             * method.
+             */
+            PROXIES proxies;
+        };
+    } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_modulecontextimpl_h

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

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ModuleContextImpl.h
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/SCA.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/SCA.cpp?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/SCA.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/SCA.cpp Thu Jan  5 02:54:16 2006
@@ -0,0 +1,21 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#include "osoa/sca/sca.h"
+        

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

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/SCA.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceList.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceList.cpp?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceList.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceList.cpp Thu Jan  5 02:54:16 2006
@@ -0,0 +1,105 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#include "osoa/sca/ServiceList.h"
+
+#include "osoa/sca/ServiceRuntimeException.h"
+
+namespace osoa
+{
+    namespace sca
+    {
+        // ===========
+        // Constructor
+        // ===========
+        ServiceList::ServiceList(unsigned int numTargets)
+            : maxServices(numTargets), numServices(0)
+        {
+            services = new void*[numTargets];
+        }
+        
+        // ==========================================
+        // Copy comstructor: create new service array
+        // ==========================================
+        ServiceList::ServiceList(const ServiceList& sl)
+            : maxServices(sl.maxServices), numServices(sl.numServices)
+        {
+            services = new void*[maxServices];
+            for (unsigned int i=0; i<numServices; i++)
+            {
+                services[i] = sl.services[i];
+            }
+        }
+        
+        // ===================================
+        // operator=: create new service array
+        // ===================================
+        ServiceList& ServiceList::operator=(const ServiceList& sl)
+        {
+            if (this != &sl)
+            {
+                maxServices = sl.maxServices;
+                numServices = sl.numServices;
+                
+                services = new void*[maxServices];
+                for (unsigned int i=0; i<numServices; i++)
+                {
+                    services[i] = sl.services[i];
+                }
+            }
+            return *this;
+        }
+        
+        // ==========
+        // Destructor
+        // ==========
+        ServiceList::~ServiceList()
+        {
+            delete [] services;
+        }
+
+        // =================================
+        // operator[]: return service at pos
+        // =================================
+        void* ServiceList::operator[] (unsigned int pos)
+        {
+            if (pos < numServices)
+            {
+                return services[pos];
+            }
+            else
+            {
+                throw ServiceRuntimeException("ServiceList: index out of bounds");
+            }
+        }
+
+        // ====================================
+        // addService: add service to the array
+        // ====================================
+        void ServiceList::addService(void* service)
+        {
+            if (numServices < maxServices)
+            {
+                services[numServices] = service;
+                numServices++;
+            }
+        }
+        
+    } // End namespace sca
+} // End namespace osoa

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

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceList.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceList.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceList.h?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceList.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceList.h Thu Jan  5 02:54:16 2006
@@ -0,0 +1,84 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_servicelist_h
+#define osoa_sca_servicelist_h
+
+#include "osoa/sca/export.h"
+
+namespace osoa
+{
+    namespace sca
+    {
+
+        /**
+         * Holds a list of services that can be accessed from an SCA
+         * component. Each entry can be cast to the business interface
+         * of the target component. All the entries will be of the
+         * same type.
+         */
+        class SCA_API ServiceList  
+        {
+        
+        public:
+            /**
+             * Return the number of services in the list.
+             * @return Number of services.
+             */
+            unsigned int size() {return numServices;}
+
+            /**
+             * Return the service at this position.
+             */
+            void* operator[] (unsigned int pos);
+
+            ServiceList(const ServiceList& serviceList);
+            ServiceList& operator=(const ServiceList& serviceList);
+            virtual ~ServiceList();
+            
+        private:
+            friend class ComponentContextImpl;
+
+            /**
+             * Create a new service list with the known number of 
+             * target services. Once created, the service list can only
+             * have services added to it up to the number of targets
+             * specified on this constructor.
+             * @param numTargets Number of target services to be held in this list.
+             */
+            ServiceList(unsigned int numTargets);
+
+            /**
+             * Add a service to this list.
+             */
+            void addService(void* service);
+
+            unsigned int maxServices;
+            unsigned int numServices;
+
+            /** 
+             * Pointer to an array of services. 
+             */
+            void** services;
+                        
+        };
+    } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_servicelist_h

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

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceList.h
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp Thu Jan  5 02:54:16 2006
@@ -0,0 +1,208 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#include "osoa/sca/ServiceRuntimeException.h"
+using namespace std;
+
+namespace osoa
+{
+    namespace sca
+    {
+        
+        // ========================================================================
+        // Constructor
+        // ========================================================================
+        ServiceRuntimeException :: ServiceRuntimeException(const char* name,
+            severity_level sev,
+            const char* msg_text)
+            : severity(sev), location_set(0)
+        {
+            class_name = new char[strlen(name) + 1];
+            strcpy(class_name,name);
+            message_text = new char[strlen(msg_text)+1];
+            strcpy(message_text,msg_text);
+            
+        } // end ServiceRuntimeException constuctor
+        
+        // ========================================================================
+        // Constructor
+        // ========================================================================
+        ServiceRuntimeException ::  ServiceRuntimeException(const ServiceRuntimeException& c)
+            : 
+        severity(c.getSeverity()), location_set(c.location_set)
+            
+        {
+            class_name = new char[strlen(c.getEClassName()) + 1];
+            strcpy(class_name, c.getEClassName());
+            message_text = new char[strlen(c.getMessageText())+1];
+            strcpy(message_text,c.getMessageText());
+            for (int i=0;i<c.location_set;i++)
+            {
+                locations[i].file = new char[strlen(c.locations[i].file) + 1];
+                strcpy(locations[i].file,c.locations[i].file);
+                locations[i].line = c.locations[i].line;
+                locations[i].function = new char[strlen(c.locations[i].function) + 1];
+                strcpy(locations[i].function, c.locations[i].function);
+            }
+        }
+        
+        // ========================================================================
+        // Destructor
+        // ========================================================================
+        ServiceRuntimeException :: ~ServiceRuntimeException()
+        {
+            if (class_name) delete class_name;
+            if (message_text) delete message_text;
+            for (int i=0;i<location_set;i++)
+            {
+                if (locations[i].file) delete locations[i].file;
+                if (locations[i].function) delete locations[i].function;
+            }
+            
+        } // end ServiceRuntimeException destructor
+        
+        // ========================================================================
+        // Return class name of this exception
+        // ========================================================================
+        const char* ServiceRuntimeException :: getEClassName() const
+        {
+            return class_name;
+        } // end getClassName()
+        
+        // ========================================================================
+        // Return severity
+        // ========================================================================
+        ServiceRuntimeException::severity_level ServiceRuntimeException :: getSeverity() const
+        {
+            return severity;
+        } // end getSeverity()
+        
+        // ========================================================================
+        // Return message text associated with exception
+        // ========================================================================
+        const char* ServiceRuntimeException :: getMessageText() const
+        {
+            return message_text;
+        } // end getMessageText()
+        
+        // ========================================================================
+        // Return file name where exception was raised
+        // ========================================================================
+        const char* ServiceRuntimeException :: getFileName() const
+        {
+            return locations[0].file;
+        } // end getFileName()
+        
+        // ========================================================================
+        // Return line number where exception was raised
+        // ========================================================================
+        unsigned long ServiceRuntimeException :: getLineNumber() const
+        {
+            return locations[0].line;
+        } // end getLineNumber()
+        
+        // ========================================================================
+        // Return function name where exception was raised
+        // ========================================================================
+        const char* ServiceRuntimeException :: getFunctionName() const
+        {
+            return locations[0].function;
+        } // end getFunctionName()
+        
+        
+        // ========================================================================
+        // set severity of exception
+        // ========================================================================
+        void ServiceRuntimeException :: setSeverity(severity_level sev)
+        {
+            severity = sev;
+        } // end setSeverity(severity_level sev) const
+        
+        // ========================================================================
+        // set message text associated with exception
+        // ========================================================================
+        void ServiceRuntimeException :: setMessageText(const char* msg_text)
+        {
+            if (message_text != 0) delete message_text;
+            message_text = new char[strlen(msg_text) + 1];
+            strcpy(message_text,msg_text);
+        } // end setMessageText(const string &msg_text) const
+        
+        // ========================================================================
+        // set location of most recent throw/handling of the exception
+        // ========================================================================
+        void ServiceRuntimeException :: setLocation(const char* file,    
+            unsigned long line,       
+            const char* function)
+        {
+            if (location_set < num_locations)
+            {
+                locations[location_set].file = new char[strlen(file) + 1];
+                strcpy(locations[location_set].file,file);
+                locations[location_set].line = line;
+                locations[location_set].function = new char[strlen(function) + 1];
+                strcpy(locations[location_set].function,function);
+                
+                location_set++;
+            }
+        } // end setLocation()
+        
+        
+        // ========================================================================
+        // print self
+        // ========================================================================
+        ostream& ServiceRuntimeException :: PrintSelf(ostream &os) const
+        { 
+            
+            os << "Exception object :" << endl;
+            os << " class:           " << class_name << endl;
+            os << " description:     " << message_text << endl;
+            if (location_set != 0)
+            {
+                os << " file name:       " << locations[0].file << endl;
+                char lineNumber[100];
+                sprintf(lineNumber, "%lu",locations[0].line);
+                os << " line number:     " << lineNumber << endl;
+                os << " function:        " << locations[0].function << endl;
+                os << " location history:" << endl;
+                
+                int i=1;
+                while (i < location_set)
+                {
+                    os << "  " <<  i << ")" << endl;
+                    os << "   file:          " << locations[i].file << endl;
+                    os << "   line:          " << locations[i].line << endl;
+                    os << "   function:      " << locations[i].function << endl;
+                    i++;
+                }
+            }
+            return os;
+        } // end ostream operator <<
+        
+        // ========================================================================
+        // ostream operator <<
+        // ========================================================================
+        SCA_API ostream& operator<< (ostream &os, const ServiceRuntimeException &except)
+        {
+            return except.PrintSelf(os);
+        } // end ostream operator <<
+        
+        
+    } // End namespace sca
+} // End namespace osoa

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

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.h?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.h Thu Jan  5 02:54:16 2006
@@ -0,0 +1,236 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_serviceruntimeexception_h
+#define osoa_sca_serviceruntimeexception_h
+
+#include "osoa/sca/export.h"
+
+#include <ostream>
+
+namespace osoa
+{
+    namespace sca
+    {
+        
+        /**
+         * Top level exception to represent all the exceptions that may be 
+         * thrown by an SCA runtime implementation.
+         */
+        class SCA_API ServiceRuntimeException
+        {
+        public:
+            /**
+             * Represents the possible severity levels for an exception.
+             */
+            enum severity_level
+            {
+                Normal,    
+                    Warning,
+                    Error,
+                    Severe
+            };
+            
+            /**
+             * Constructor.
+             * @param name Class name of the exception.
+             * @param sev Severity level.
+             * @param msg_text Detailed description of the exception.
+             */
+            ServiceRuntimeException(
+                const char *name="ServiceRuntimeException",
+                severity_level sev=Severe,
+                const char* msg_text="");
+            
+            ServiceRuntimeException(const ServiceRuntimeException& c);
+            
+            // Destructor
+            virtual  ~ServiceRuntimeException();
+            
+            /**
+             * Return class name of this exception.
+             */
+            const char* getEClassName() const;
+            
+            /**
+             * Return severity.
+             */
+            severity_level getSeverity() const;
+            
+            /**
+             * Return message text associated with exception.
+             */
+            const char* getMessageText() const;
+            
+            /*
+             * Return file name where the exception was raised.
+             */
+            const char* getFileName() const;
+            
+            /**
+             * Return line number where the exception was raised.
+             */
+            unsigned long getLineNumber() const;
+            
+            /**
+             * Return function name where the exception was raised.
+             */
+            const char* getFunctionName() const;
+            
+            /**
+             * Set the exception severity.
+             */
+            void setSeverity(severity_level sev);
+            
+            /**
+             * Set the message text associated with exception.
+             */
+            void setMessageText(const char* msg_text);
+                    
+            /**
+             * Set the location where the exception was raised.
+             * @param file Name of the file.
+             * @param line Line number in the file.
+             * @param function Name of the function.
+             */
+            void setLocation(const char* file,
+                unsigned long line,
+                const char* function="");
+            
+            /**
+             * Append exception details to ostream.
+             */
+            virtual std::ostream& PrintSelf(std::ostream &os) const;
+            
+            /**
+             * Operator to send exceptions details to a stream.
+             */
+            SCA_API friend std::ostream& operator<< (std::ostream &os, const ServiceRuntimeException &except);
+        protected:
+            
+        private:
+            /**
+             * Class name of the exception.
+             */ 
+            char*        class_name;
+            
+            /**
+             * Severity level of the exception.
+             */
+            severity_level   severity;
+            
+            /**
+             * Description of the exception.
+             */
+            char*        message_text;     // Description of exception
+            
+            /**
+             * Location where the exception was thrown or handled and thrown.
+             */            
+            class location
+            {
+            public:
+                char*            file;       // File name (from __FILE__)
+                unsigned long   line;       // Line number (from __LINE__)
+                char*            function;   // Function name
+            };
+            
+            
+            enum {num_locations=5};
+            /**
+             * Array of locations where the exception has been handled and thrown.
+             */
+            location         locations[num_locations];
+            
+            /**
+             * The current location (index into ServiceRuntimeException#location).
+             */
+            int              location_set;
+            
+            
+        }; // End ServiceRuntimeException class definition
+        
+
+        /**
+         * A remotable service is currently unavailable. It is possible that a retry
+         * may resolve this exception.
+         */
+        class SCA_API ServiceUnavailableException: public ServiceRuntimeException
+        {
+        public:
+            ServiceUnavailableException(const char* serviceName)
+                : ServiceRuntimeException("ServiceUnavailableException", Warning,
+                serviceName)
+            {
+            }
+        private:
+        }; // End ServiceUnavailableException class definition
+
+
+        /**
+         * The target of a wire cannot be found, or the reference has not been
+         * configured.
+         */
+        class ServiceNotFoundException: public ServiceRuntimeException
+        {
+        public:
+            ServiceNotFoundException(const char* msg)
+                : ServiceRuntimeException("ServiceNotFoundException", Error,
+                msg)
+            {
+            }
+        private:
+        }; // End ServiceNotFoundException class definition
+
+
+        /**
+         * There is no current component (for example, if a non-SCA component
+         * tries to get the current ComponentContext).
+         */
+        class ComponentContextException: public ServiceRuntimeException
+        {
+        public:
+            ComponentContextException(const char* msg)
+                : ServiceRuntimeException("ComponentContextException", Error,
+                msg)
+            {
+            }
+        private:
+        }; // End ComponentContextException class definition
+
+        /**
+         * Unable to find the specified entry point in the module.
+         */
+        class EntryPointNotFoundException: public ServiceRuntimeException
+        {
+        public:
+            EntryPointNotFoundException(const char* msg)
+                : ServiceRuntimeException("EntryPointNotFoundException", Error,
+                msg)
+            {
+            }
+        private:
+        }; // End EntryPointNotFoundException class definition
+
+        
+        
+    } // End namespace sca
+} // End namespace osoa
+
+#endif // osoa_sca_serviceruntimeexception_h

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

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/ServiceRuntimeException.h
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/export.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/export.h?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/export.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/export.h Thu Jan  5 02:54:16 2006
@@ -0,0 +1,39 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_export_h
+#define osoa_sca_export_h
+
+#if defined(WIN32)  || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+
+#ifdef SCA_EXPORTS
+#define SCA_API __declspec(dllexport)
+#else
+#define SCA_API __declspec(dllimport)
+#endif
+
+#else
+#include <sys/time.h>
+#include <inttypes.h> 
+#include <stdlib.h>
+#define SCA_API 
+#endif
+
+#endif // osoa_sca_export_h

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

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/export.h
------------------------------------------------------------------------------
    svn:keywords = Rev,Date

Added: incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/sca.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/sca.h?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/sca.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/osoa/sca/sca.h Thu Jan  5 02:54:16 2006
@@ -0,0 +1,29 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#ifndef osoa_sca_sca_h
+#define osoa_sca_sca_h
+
+#include "osoa/sca/export.h"
+#include "osoa/sca/ModuleContext.h"
+#include "osoa/sca/ComponentContext.h"
+#include "osoa/sca/ServiceList.h"
+#include "osoa/sca/ServiceRuntimeException.h"
+
+#endif // osoa_sca_sca_h

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

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

Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.cpp?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.cpp Thu Jan  5 02:54:16 2006
@@ -0,0 +1,202 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/core/ComponentServiceWrapper.h"
+
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/model/CPPImplementation.h"
+using namespace osoa::sca;
+
+namespace tuscany
+{
+    namespace sca
+    {
+        // ===================
+        // Static data members
+        // ===================
+        void* ComponentServiceWrapper::staticImpl = 0;
+
+        // ===========
+        // Constructor
+        // ===========
+        ComponentServiceWrapper::ComponentServiceWrapper(Service* target)
+            : ServiceWrapper(target), service(target)
+        {
+            LOGENTRY(1,"ComponentServiceWrapper::constructor");
+            if (target->getServiceType() != WireTarget::ComponentServiceType)
+            {
+                throw ServiceRuntimeException("ComponentServiceWrapper: target is not a component service");
+            }
+            
+            component = target->getComponent();
+            interf = (CPPInterface*)target->getInterface();
+
+            remotable = interf->getRemotable();
+
+            
+            LOGEXIT(1,"ComponentServiceWrapper::constructor");
+            
+        }
+        
+        // ==========
+        // Destructor
+        // ==========
+        ComponentServiceWrapper::~ComponentServiceWrapper()
+        {
+            LOGENTRY(1,"ComponentServiceWrapper::destructor");
+            LOGEXIT(1,"ComponentServiceWrapper::destructor");
+        }
+        
+        
+        // ======================================================================
+        // getImplementation: get an implementation for this scope
+        // ======================================================================
+        void* ComponentServiceWrapper::getImplementation()
+        {
+            CPPInterface::SCOPE scope = interf->getScope();
+            if (scope == CPPInterface::MODULE)
+            {
+                if (!staticImpl)
+                {
+                    staticImpl = newImplementation();
+                }
+                return staticImpl;
+            }
+            else // (scope == CPPInterface::STATELESS)
+            {
+                return newImplementation();
+            }        
+        }
+        
+        // ======================================================================
+        // releaseImplementation: release the implementation for this scope
+        // ======================================================================
+        void ComponentServiceWrapper::releaseImplementation()
+        {
+            CPPInterface::SCOPE scope = interf->getScope();
+            if (scope == CPPInterface::STATELESS)
+            {
+                deleteImplementation();
+            }            
+        }
+        
+        // ======================================================================
+        // invoke: wrapper call to service with setting the component context
+        // ======================================================================
+        void ComponentServiceWrapper::invoke(Operation& operation)
+        {
+
+            SCARuntime* runtime = SCARuntime::getInstance();
+            runtime->setCurrentComponent(component);
+            
+            try
+            {
+                invokeService(operation);
+            }
+            catch (...)
+            {
+                runtime->unsetCurrentComponent();
+                throw;
+            }
+            runtime->unsetCurrentComponent();
+            
+        }
+        
+        void ComponentServiceWrapper::setLibrary(Library* lib)
+        {
+            wrapperLibrary = lib;
+        }
+        
+        // ======================================================================
+        // createServiceWrapper: create a wrapper for the target ComponentService
+        // ======================================================================
+        ComponentServiceWrapper* ComponentServiceWrapper::createServiceWrapper(Service* service)
+        {            
+            string msg;
+            ComponentServiceWrapper* serviceWrapper = 0;
+            
+            // -----------------------------------------------
+            // Get the implementation for the target component
+            // -----------------------------------------------
+            Component* targetComponent = service->getComponent();
+            Implementation* impl = targetComponent->getImplementation();
+            if (!impl)
+            {
+                msg = "Component " + targetComponent->getName() + " has no implementation defined";
+                throw ServiceNotFoundException(msg.c_str());
+            }
+            
+            // TODO: This only handle CPP implementation for now
+            if (impl->getImplementationType() == Implementation::CPP)
+            {
+                // ----------------------------------------------------
+                // Get implementation dll name and wrapper factory name
+                // ----------------------------------------------------
+                string dllName = ((CPPImplementation*)impl)->getDll();
+                string wrapperFactoryName = ((CPPImplementation*)impl)->getHeaderStub() 
+                    + "_" + service->getName() + "_Wrapper_Factory";
+                
+                // ------------
+                // Load the dll
+                // ------------
+                string fullDllName = targetComponent->getModule()->getRoot() + "/" + dllName;
+                typedef ComponentServiceWrapper* (* WRAPPERFACTORY) (Service*);                
+                Library* wrapperLib = new Library(fullDllName);
+                
+                // -------------------------
+                // Locate the factory method
+                // -------------------------
+                WRAPPERFACTORY wrapperFactory = (WRAPPERFACTORY)wrapperLib->getSymbol(wrapperFactoryName);
+                if (!wrapperFactory)
+                {
+                    LOGERROR_2(1, "ComponentContextImpl::getServiceWrapper: Unable to locate %s in library %s",
+                        wrapperFactoryName.c_str(), fullDllName.c_str());
+                    msg = "Unable to locate " + wrapperFactoryName + " in library " + fullDllName;
+                    throw ServiceNotFoundException(msg.c_str());
+                }
+                
+                // -------------------------------------
+                // Now create an instance of the wrapper
+                // -------------------------------------                
+                serviceWrapper = wrapperFactory(service);
+                if (!serviceWrapper)
+                {
+                    LOGERROR_2(1, "ComponentContextImpl::getServiceWrapper: Factory method %s in library %s returned null",
+                        wrapperFactoryName.c_str(), fullDllName.c_str());
+                    msg = "Factory method " + wrapperFactoryName + " in library " + fullDllName + " returned null";
+                    throw ServiceNotFoundException(msg.c_str());
+                }                
+                serviceWrapper->setLibrary(wrapperLib);
+            }
+            else
+            {
+                // ----------------------
+                // Non CPP Implementation
+                // ----------------------
+                msg = "Unsupported implementation type for service: " + service->getName();
+                throw ServiceNotFoundException(msg.c_str());
+            }        
+            
+            return serviceWrapper;
+        }    
+        
+    } // End namespace sca
+} // End namespace tuscany

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

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

Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.h?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ComponentServiceWrapper.h Thu Jan  5 02:54:16 2006
@@ -0,0 +1,156 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_core_componentservicewrapper_h
+#define tuscany_sca_core_componentservicewrapper_h
+
+#include "osoa/sca/export.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/CPPInterface.h"
+#include "tuscany/sca/util/Library.h"
+
+using namespace tuscany::sca::model;
+
+namespace tuscany
+{
+    namespace sca
+    {
+        /**
+         * Wraps the service on a component implementation.
+         * This abstract class is extended by generated code which provides 
+         * the implementation of some of the methods. 
+         * An instance of this class wraps the actual component implementation which 
+         * has been written by a developer of an SCA application.
+         */
+        class ComponentServiceWrapper : public ServiceWrapper
+        {
+        public:
+            /**
+             * Factory method to create a new ComponentServiceWrapper for a given target
+             * service. This method will provide all the loading of dlls required to 
+             * create the target component.
+             * @param target The service on the component for which this wrapper is to be
+             * created.
+             * @return A wrapper that references the given target.
+             */
+            static SCA_API ComponentServiceWrapper* createServiceWrapper(Service* target);
+
+            /**
+             * Constructor.
+             * @param target The component service to which this wrapper refers.
+             */
+            SCA_API ComponentServiceWrapper(Service* target);
+
+            /**
+             * Destructor.
+             */ 
+            SCA_API virtual    ~ComponentServiceWrapper();
+
+            /**
+             * All business method calls to the target component go through the invoke method.
+             * @param operation The details of the method, paramaters and return value for the
+             * business method to be called on the target component.
+             */
+            SCA_API virtual void invoke(Operation& operation);
+
+            /**
+             * Return the loaded shared library for the target component.
+             */
+            Library* getLibrary() {return wrapperLibrary;}
+        protected:
+            /**
+             * Delegated method to invoke the correct method on the target component. 
+             * Implemented by the subtype.
+             */
+            SCA_API virtual void invokeService(Operation& operation) = 0;
+
+            /**
+             * Delegated method to create a new component implementation.
+             * Implemented by the subtype.
+             * @return A pointer to an instance of the component implementation class.
+             */
+            SCA_API virtual void* newImplementation() = 0;
+
+            /**
+             * Delegated method to delete the current instance of the component
+             * implementation.
+             * Implemented by the subtype.
+             */
+            SCA_API virtual void deleteImplementation() = 0;
+
+            /**
+             * Return the current instance of the component implementation.
+             * @return A pointer to an instance of the component implementation class.
+             */
+            SCA_API virtual void* getImplementation();
+
+            /**
+             * Indicates that the current instance of the component implementation
+             * has been finished with. 
+             * Will call ComponentServiceWrapper#deleteImplementation if the
+             * implementation is stateless (so that a new instance is returned
+             * for each call).
+             */
+            SCA_API virtual void releaseImplementation();
+
+        private:
+            /**
+             * Holds an implementation instance if the scope is set to module.
+             */
+            static void* staticImpl;
+
+            /**
+             * The component to which this wrapper refers.
+             */
+            Component* component;
+
+            /**
+             * The service on the component to which this wrapper refers.
+             */
+            Service* service;
+
+            /**
+             * A pointer to the interface which the service exposes.
+             */
+            CPPInterface* interf;
+
+            /**
+             * Set to true if the service is remotable.
+             */
+            bool remotable;
+            
+            /**
+             * Pointer to the loaded library which contains the component
+             * implementation.
+             */
+            Library* wrapperLibrary;
+
+            /**
+             * Set the loaded library which contains the component 
+             * implementation.
+             * @param lib The library.
+             */
+            void setLibrary(Library* lib);
+        };
+    } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_core_componentservicewrapper_h

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

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

Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.cpp?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.cpp Thu Jan  5 02:54:16 2006
@@ -0,0 +1,102 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/core/ExternalServiceWrapper.h"
+#include <stdarg.h>
+
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+#include "tuscany/sca/ws/WSServiceWrapper.h"
+using tuscany::sca::ws::WSServiceWrapper;
+
+using namespace osoa::sca;
+
+
+namespace tuscany
+{
+    namespace sca
+    {
+        
+        //////////////////////////////////////////////////////////////////////
+        // Construction/Destruction
+        //////////////////////////////////////////////////////////////////////
+        
+        ExternalServiceWrapper::ExternalServiceWrapper(tuscany::sca::model::WireTarget* target)
+            : ServiceWrapper(target)
+        {
+            LOGENTRY(1,"ExternalServiceWrapper::constructor");
+            if (target->getServiceType() != WireTarget::ExternalServiceType)
+            {
+                throw ServiceRuntimeException("ExternalServiceWrapper: target is not an ExternalService");
+            }
+            
+            LOGEXIT(1,"ExternalServiceWrapper::constructor");
+            
+        }
+        
+        ExternalServiceWrapper::~ExternalServiceWrapper()
+        {
+            LOGENTRY(1,"ExternalServiceWrapper::destructor");
+            LOGEXIT(1,"ExternalServiceWrapper::destructor");
+        }
+
+        // ======================================================================
+        // createServiceWrapper: create a wrapper for the target ExternalService
+        // ======================================================================
+        ExternalServiceWrapper* ExternalServiceWrapper::createServiceWrapper(ExternalService* service)
+        {            
+            string msg;
+            ExternalServiceWrapper* serviceWrapper = 0;
+
+            // -----------------------------------------------
+            // Get the binding for the target component
+            // -----------------------------------------------
+            Binding* targetBinding = service->getBinding();
+            if (!targetBinding)
+            {
+                msg = "External service " + service->getName() + " has no binding defined";
+                throw ServiceNotFoundException(msg.c_str());
+            }
+            
+            // TODO: This only handles ws implementation for now
+            if (targetBinding->getBindingType() == Binding::WS)
+            {
+                // -------------------------------------
+                // Create an instance of the wrapper
+                // -------------------------------------                
+                serviceWrapper = new WSServiceWrapper(service);
+                
+            }
+            else
+            {
+                // ----------------------
+                // Non WS Binding
+                // ----------------------
+                msg = "Unsupported binding type for externalService: " + service->getName();
+                throw ServiceNotFoundException(msg.c_str());
+            }        
+            
+            return serviceWrapper;
+        }    
+    
+        
+    } // End namespace sca
+} // End namespace tuscany

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

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

Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.h?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ExternalServiceWrapper.h Thu Jan  5 02:54:16 2006
@@ -0,0 +1,81 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_core_externalservicewrapper_h
+#define tuscany_sca_core_externalservicewrapper_h
+
+#include "osoa/sca/export.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/ExternalService.h"
+using tuscany::sca::model::ExternalService;
+
+namespace tuscany
+{
+    namespace sca
+    {
+        
+        /**
+         * Wraps an SCA external service so that it can be called by a 
+         * proxy.
+         * This abstract class will be extended by a class which supports
+         * a specific external service binding (for example, the web services binding).
+         */
+        class SCA_API ExternalServiceWrapper : public ServiceWrapper
+        {
+        public:
+            /**
+             * Factory method to create a new ExternaServiceWrapper for a given
+             * external service described in the SCA module.
+             */
+            static ExternalServiceWrapper* createServiceWrapper(ExternalService* service);
+
+            /**
+             * Constructor.
+             * @param target The target external service for which this wrapper is to be
+             * created.
+             * @return A wrapper that references the given target.
+             */
+            ExternalServiceWrapper(tuscany::sca::model::WireTarget* target);
+
+            /**
+             * Destructor.
+             */
+            virtual    ~ExternalServiceWrapper();
+
+            /**
+             * Return the external service (in the runtime model) that is wrapped by 
+             * the instance of this class.
+             */
+            virtual ExternalService* getExternalService() {return (ExternalService*)getTarget();};
+
+            /**
+             * All business method calls to the external service go through the invoke method.
+             * This is a delegated method which will be implemented by the subclass.
+             * @param operation The details of the method, paramaters and return value for the
+             * business method to be called on the external service.
+             */
+            virtual void invoke(Operation& operation) = 0;
+        private:
+            
+        };
+    } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_core_externalservicewrapper_h

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

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

Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp Thu Jan  5 02:54:16 2006
@@ -0,0 +1,88 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/core/Operation.h"
+#include <stdarg.h>
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+
+
+
+namespace tuscany
+{
+    namespace sca
+    {
+        // ===========
+        // Constructor
+        // ===========
+        Operation::Operation(const char* operationName, unsigned int numParameters)
+            : name(operationName), nparms(numParameters)
+        {
+            LOGENTRY(1,"Operation::constructor");
+
+            parameters = new void*[nparms];
+            
+            LOGEXIT(1,"Operation::constructor");
+        }
+
+        // ==========
+        // Destructor
+        // ==========
+        Operation::~Operation()
+        {
+            LOGENTRY(1,"Operation::destructor");
+            LOGEXIT(1,"Operation::destructor");
+        }
+    
+
+        // ==============================================
+        // getParameter: return parameter at position pos
+        // ==============================================
+        void* Operation::getParameter(unsigned int pos)
+        {
+            if (pos < nparms)
+            {
+                return parameters[pos];
+            }
+
+            return 0;
+        }
+
+        // ===========================================
+        // setParameter: set parameter at position pos
+        // ===========================================
+        void Operation::setParameter(unsigned int pos, void* parm)
+        {
+            if (pos < nparms)
+            {
+                parameters[pos] = parm;
+            }
+        }
+
+        // ====================================
+        // setReturnValue: set the return value
+        // ====================================
+        void Operation::setReturnValue(void* val)
+        {
+            returnType = val;
+        }
+        
+    } // End namespace sca
+} // End namespace tuscany

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

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

Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h Thu Jan  5 02:54:16 2006
@@ -0,0 +1,115 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#ifndef tuscany_sca_core_operation_h
+#define tuscany_sca_core_operation_h
+#include "osoa/sca/export.h"
+
+#include <string>
+using std::string;
+
+namespace tuscany
+{
+    namespace sca
+    {
+        /**
+         * Holds the details of a single invocation of a business method.
+         * This class is used to pass the parameters and operation name from the
+         * client to a service. It will also hold the return value on the 
+         * return from the business method.
+         */
+        class Operation 
+        {
+        public:
+            /**
+             * Create a new operation.
+             * @param operationName The method name of the business method to be invoked.
+             * @param numParameters The number of parameters to be passed.
+             */
+            SCA_API Operation(const char* operationName, unsigned int numParameters);
+
+            /**
+             * Destructor.
+             */
+            SCA_API virtual    ~Operation();
+
+            /**
+             * Return the operation name.
+             * @return The name of the operation.
+             */
+            SCA_API const char* getName() {return name;}
+
+            /**
+             * Set a parameter on the operation.
+             * @param pos The position of the parameter in the parameter list.
+             * @param parm Pointer to the parameter to be passed.
+             */
+            SCA_API void setParameter(unsigned int pos, void* parm);
+
+            /**
+             * Get a parameter from the operation.
+             * @param pos The position of the parameter in the parameter list.
+             * @return Pointer to the paramter at the given postion. Should be
+             * cast to the appropriate type.
+             */
+            SCA_API void* getParameter(unsigned int pos);
+
+            /**
+             * Get the return value on the operation.
+             * Normally the client
+             * would set the return value and the service will get this
+             * return value pointer and set the return value.
+             * @return Pointer to the return type.
+             */
+            SCA_API void* getReturnValue() {return returnType;}
+
+            /**
+             * Set the return value on the operation.
+             * Normally the client
+             * would set the return value pointer so that the service can 
+             * return a value
+             * @param valPtr Pointer to the return type.
+             */
+            SCA_API void setReturnValue(void* valPtr);
+
+        private:
+            /**
+             * Operation name (method name).
+             */ 
+            const char* name;
+
+            /**
+             * Number of paramaters passed for this operation.
+             */ 
+            unsigned int nparms;
+
+            /**
+             * Pointer to the array of parameters.
+             */
+            void** parameters;
+
+            /**
+             * The return value.
+             */ 
+            void* returnType;
+        };
+    } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_core_operation_h

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

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

Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp
URL: http://svn.apache.org/viewcvs/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp?rev=366157&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCAEntryPoint.cpp Thu Jan  5 02:54:16 2006
@@ -0,0 +1,215 @@
+/*
+ *
+ *  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.
+ *  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: 2005/12/22 11:33:21 $ */
+
+#include "tuscany/sca/core/SCAEntryPoint.h"
+
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/core/ComponentServiceWrapper.h"
+#include "tuscany/sca/core/ExternalServiceWrapper.h"
+using namespace osoa::sca;
+
+namespace tuscany
+{
+    namespace sca
+    {
+        // ===========
+        // Constructor
+        // ===========
+        SCAEntryPoint::SCAEntryPoint(const char* epName)
+            : subsystem(0), entrypoint(0), module(0)
+        {
+            LOGENTRY(1,"SCAEntryPoint::constructor");
+            string message;
+    
+            // initialize the system if necessary
+            System* system = SCARuntime::getInstance()->getSystem();
+
+            string subsystemName;
+            string entrypointName;
+
+            Utils::tokeniseUri(epName, subsystemName, entrypointName);
+
+            // --------------------
+            // locate the Subsystem
+            // --------------------
+            subsystem = system->findSubsystem(subsystemName);
+            if (!subsystem)
+            {
+                throw EntryPointNotFoundException(epName);
+            }
+
+            // ---------------------
+            // locate the EntryPoint
+            // ---------------------
+            entrypoint =  subsystem->findEntryPoint(entrypointName);
+            if (entrypoint)
+            {
+                // found Subsystem EntryPoint
+                throw EntryPointNotFoundException("Subsystem EntryPoint not yet supported");
+            }
+            else
+            {
+                // -----------------------------------
+                // locate the EntryPoint in the Module
+                // -----------------------------------
+                string moduleComponentName;
+                Utils::tokeniseUri(entrypointName, moduleComponentName, entrypointName);
+                module = subsystem->findModuleByComponentName(moduleComponentName);
+                if (module)
+                {
+                    dataFactory = module->getDataFactory();
+                    entrypoint = module->findEntryPoint(entrypointName);
+                }
+            }
+    
+            if (!entrypoint)
+            {
+                throw EntryPointNotFoundException(epName);
+            }
+
+            // ---------------------------------
+            // Get Wrappers for each wire target
+            // ---------------------------------
+
+            // Get the target services from the EntryPoint
+            const EntryPoint::TARGETS& targets = entrypoint->getTargets();
+            
+            // --------------------
+            // Validate the request
+            // --------------------
+            switch (entrypoint->getMultiplicity())
+            {
+            case EntryPoint::ONE_MANY:
+            case EntryPoint::ONE_ONE:
+                {
+                    if (targets.size() == 0)
+                    {
+                        message = "EntryPoint " + entrypoint->getName() + " not wired";
+                        throw ServiceNotFoundException(message.c_str());
+                    }
+                }
+            default:
+                {
+                }
+            } // end switch
+
+            for (EntryPoint::TARGETS::const_iterator iter = targets.begin();
+            iter!=targets.end();
+            iter++)
+            {
+                ServiceWrapper* service = getServiceWrapper(*iter);
+                if (service)
+                {
+                    services.push_back(service);
+                }
+            }
+        
+            LOGEXIT(1,"SCAEntryPoint::constructor");
+        }
+        
+        // ==========
+        // Destructor
+        // ==========
+        SCAEntryPoint::~SCAEntryPoint()
+        {
+            LOGENTRY(1,"SCAEntryPoint::destructor");
+
+            // Delete any ServiceWrappers
+            for (SERVICES::iterator iter = services.begin(); iter < services.end(); iter++)
+            {                
+                delete (*iter);
+            }
+            LOGEXIT(1,"SCAEntryPoint::destructor");
+        }
+        
+
+        // ======================================================================
+        // invoke: 
+        // ======================================================================
+        SCA_API DataObjectPtr SCAEntryPoint::invoke(const char* operationName, DataObjectPtr inDataObject)
+        {
+            string message;
+
+            // --------------------
+            // Validate the request
+            // --------------------
+            if (services.size() == 0)
+            {
+                message = "EntryPoint " + entrypoint->getName() + " not wired";
+                throw ServiceNotFoundException(message.c_str());
+            }
+
+            // -------------------
+            // Invoke each target
+            // -------------------
+            Operation operation(operationName, 1);
+            operation.setParameter(0, &inDataObject);
+            DataObjectPtr ret;
+            operation.setReturnValue((void *)&ret);
+
+            for (SERVICES::iterator iter = services.begin(); iter < services.end(); iter++)
+            {                
+                (*iter)->invoke(operation);
+            }
+
+            return ret;
+        }
+
+
+        // ======================================================================
+        // getServiceWrapper: Create and return an instance of the ServiceWrapper
+        // ======================================================================
+        ServiceWrapper* SCAEntryPoint::getServiceWrapper(WireTarget* target)
+        {    
+            // -------------------------
+            // Determine type of Service
+            // -------------------------
+            switch (target->getServiceType())
+            {
+            case WireTarget::ExternalServiceType:
+                {
+                    // ----------------
+                    // External Service
+                    // ----------------
+                    return ExternalServiceWrapper::createServiceWrapper((ExternalService*)target);
+                }
+                
+            case WireTarget::ComponentServiceType:
+                {
+                    // -----------------
+                    // Component Service
+                    // -----------------
+                    return ComponentServiceWrapper::createServiceWrapper((Service*)target);
+                }
+                
+            default:
+                {
+                    string message = "Undefined wire target type for : ";
+                    message = message + target->getName();
+                    throw ServiceNotFoundException(message.c_str());
+                }
+            } // end switch
+        }
+        
+        
+    } // End namespace sca
+} // End namespace tuscany

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

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



Mime
View raw message