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

svn commit: r437637 [2/8] - in /incubator/tuscany/cpp/sca: runtime/core/src/ runtime/core/src/osoa/sca/ runtime/core/src/tuscany/sca/core/ runtime/core/src/tuscany/sca/cpp/ runtime/core/src/tuscany/sca/extension/ runtime/core/src/tuscany/sca/model/ run...

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

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

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp Mon Aug 28 03:42:10 2006
@@ -24,7 +24,6 @@
 #include "tuscany/sca/core/SCARuntime.h"
 
 
-
 namespace tuscany
 {
     namespace sca

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?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- 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 Aug 28 03:42:10 2006
@@ -18,14 +18,13 @@
 /* $Rev$ $Date: 2005/12/22 11:33:21 $ */
 
 #include "tuscany/sca/core/SCARuntime.h"
-#include "tuscany/sca/core/ComponentServiceWrapper.h"
 #include "tuscany/sca/util/Logging.h"
 #include "tuscany/sca/util/Utils.h"
-#include "tuscany/sca/util/Exceptions.h"
-
-#include "tuscany/sca/model/System.h"
-#include "tuscany/sca/model/Subsystem.h"
 #include "tuscany/sca/model/ModelLoader.h"
+#include "tuscany/sca/util/File.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Component.h"
 
 #if defined(WIN32)  || defined (_WINDOWS)
 #include <windows.h> 
@@ -40,7 +39,7 @@
          */
         static const char* TUSCANY_SCACPP = "TUSCANY_SCACPP";
         static const char* TUSCANY_SCACPP_SYSTEM_ROOT = "TUSCANY_SCACPP_SYSTEM_ROOT";
-        static const char* TUSCANY_SCACPP_DEFAULT_COMPOSITE = "TUSCANY_SCACPP_DEFAULT_COMPOSITE";
+        static const char* TUSCANY_SCACPP_DEFAULT_COMPONENT = "TUSCANY_SCACPP_DEFAULT_COMPONENT";
             
  
         // ==========================================================
@@ -48,7 +47,7 @@
         // ==========================================================
         SCARuntime* SCARuntime::instance = 0;
         string SCARuntime::systemRoot = "";
-        string SCARuntime::defaultCompositeName = "";
+        string SCARuntime::defaultComponentName = "";
         
 
         // ==========================================================
@@ -63,21 +62,21 @@
         }
 
         // ==========================================================
-        // Set the default CompositeComponent name
+        // Set the default component name
         // ==========================================================
-        void SCARuntime::setDefaultCompositeComponent(const string& compositeComponent)
+        void SCARuntime::setDefaultComponentName(const string& componentName)
         {
-            LOGENTRY(1, "SCARuntime::setDefaultCompositeComponent");
-            defaultCompositeName = compositeComponent;
-            LOGINFO_1(3, "SCARuntime::setDefaultCompositeComponent - set to %s", compositeComponent.c_str());
-            LOGEXIT(1, "SCARuntime::setDefaultCompositeComponent");
+            LOGENTRY(1, "SCARuntime::setDefaultComponentName");
+            defaultComponentName = componentName;
+            LOGINFO_1(3, "SCARuntime::setDefaultComponentName - set to %s", componentName.c_str());
+            LOGEXIT(1, "SCARuntime::setDefaultComponentName");
         }
 
         // ===================================================================
         // Constructor for the SCARuntime class. This will be a singleton that
         // holds all the information about the current runtime.
         // ===================================================================
-        SCARuntime::SCARuntime() : system(0), defaultComposite(0)
+        SCARuntime::SCARuntime() : system(0), defaultComponent(0)
         { 
             LOGENTRY(1, "SCARuntime::constructor");
             
@@ -164,7 +163,7 @@
                 delete instance;
                 instance = 0;
                 systemRoot = "";
-                defaultCompositeName = "";        
+                defaultComponentName = "";        
             }
             
             LOGEXIT(1, "SCARuntime::releaseInstance");           
@@ -272,11 +271,11 @@
         // ===================================
         // Return the top of the runtime model
         // ===================================
-        System* SCARuntime::getSystem()
+        Composite* SCARuntime::getSystem()
         {
             if (!system)
             {
-                system = new System();
+                system = new Composite("tuscany/sca/system", "");
                 load();
             }
             return system;
@@ -362,81 +361,40 @@
             
         }
         
-
         // ===========================================
-        // getCurrentComposite: return the current composite
+        // getCurrentCompositeComponent: return the current composite component
         // ===========================================
-        Composite* SCARuntime::getCurrentComposite()
+        Component* SCARuntime::getDefaultComponent()
         {
-            // ---------------------------------------------
-            // Get composite from current component if possible
-            // ---------------------------------------------
-            Component* comp = getCurrentComponent();
-            if (comp != 0)
-            {
-                return comp->getComposite();
-            }
 
             // ----------------------
-            // Get the default Composite
+            // Get the default Component
             // ----------------------
-            string message;
-            if (!defaultComposite)
+            if (!defaultComponent)
             {
                 // -------------------------------------------
                 // Get the default composite from the environment
                 // -------------------------------------------
-                if (defaultCompositeName == "")
+                if (defaultComponentName == "")
                 {
-                    const char* defMod = getenv(TUSCANY_SCACPP_DEFAULT_COMPOSITE);
+                    const char* defMod = getenv(TUSCANY_SCACPP_DEFAULT_COMPONENT);
                     if (!defMod)
                     {
-                        message = TUSCANY_SCACPP_DEFAULT_COMPOSITE;
+                        string message = TUSCANY_SCACPP_DEFAULT_COMPONENT;
                         message += " environment variable not set";
                         throw SystemConfigurationException(message.c_str());
                     }
-                    defaultCompositeName = defMod;
-                }
-                string subsystemName, compositeName;
-                Utils::tokeniseUri(defaultCompositeName, subsystemName, compositeName);
-
-                // ---------------------------
-                // Subsystem must be specified
-                // ---------------------------
-                Subsystem* subsystem = getSystem()->findSubsystem(subsystemName);
-                if (!subsystem)
-                {
-                    message = "Default subsystem \'" + subsystemName + "\' not found";
-                    throw SystemConfigurationException(message.c_str());
+                    defaultComponentName = defMod;
                 }
                 
-                // --------------------------------------------------------------------------
-                // If composite is not specified then get the default composite for this subsystem.
-                // This will be the ONLY composite for this subsystem
-                // --------------------------------------------------------------------------
-                if (compositeName == "")
+                defaultComponent = getSystem()->findComponent(defaultComponentName);
+                if (!defaultComponent)
                 {
-                    defaultComposite = subsystem->getDefaultComposite();
-                    if (!defaultComposite)
-                    {
-                        message = "Default composite not found for subsystem \'" + subsystemName + "\'";
-                        throw SystemConfigurationException(message.c_str());
-                    }
-                }
-                else 
-                {
-                    // -----------------------------
-                    // get the named CompositeComponent
-                    // -----------------------------
-                    defaultComposite = subsystem->findCompositeByComponentName(compositeName);
-                    if (!defaultComposite)
-                    {
-                        message = "Default composite \'" + compositeName  + "\' not found in subsystem \'" + subsystemName +"\'";
-                        throw SystemConfigurationException(message.c_str());
-                    }
+                    string message = "Default component \'" + defaultComponentName + "\' not found";
+                    throw SystemConfigurationException(message.c_str());
                 }
             }
-            return defaultComposite;        
+            return defaultComponent;        
         }
                 
     } // End namespace sca

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?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- 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 Aug 28 03:42:10 2006
@@ -22,15 +22,10 @@
 
 #include "osoa/sca/export.h"
 
-#include "osoa/sca/ComponentContext.h"
-using osoa::sca::ComponentContext;
-
-#include "tuscany/sca/core/ServiceWrapper.h"
-#include "tuscany/sca/model/System.h"
-using namespace tuscany::sca::model;
-
 #include "tuscany/sca/extension/InterfaceExtension.h"
 #include "tuscany/sca/extension/ImplementationExtension.h"
+#include "tuscany/sca/model/Composite.h"
+#include "tuscany/sca/model/Component.h"
 #include "tuscany/sca/util/Library.h"
 
 #if defined(WIN32)  || defined (_WINDOWS)
@@ -45,6 +40,9 @@
 #include <list>
 using namespace std;
 
+using namespace tuscany::sca::model;
+
+
 namespace tuscany
 {
     namespace sca
@@ -55,6 +53,7 @@
          */
         class SCARuntime {
         public:
+
             /**
              * Get the single instance.
              * @return The single instance of the runtime.
@@ -82,9 +81,9 @@
 
             /**
              * Set the default CompositeComponent for the system
-             * @param compositeComponent The name of the default compositeComponent.
+             * @param componentName The name of the default component.
              */
-            static void setDefaultCompositeComponent(const string& compositeComponent);
+            static void setDefaultComponentName(const string& componentName);
 
             /**
              * Set the current component for the current thread.
@@ -106,7 +105,7 @@
              * the System.
              * @return The configured SCA system.
              */
-            SCA_API System* getSystem();
+            SCA_API Composite* getSystem();
 
             /**
              * The directory in which the Tuscany runtime has been installed.
@@ -120,21 +119,31 @@
             SCA_API Component* getCurrentComponent();
 
             /**
-             * Get the current composite. The current composite will either
-             * be the composite in which the current component for this thread
-             * is defined, or it will be the default composite if there is no current
-             * component. There will not be a current component if a client of
-             * the SCA runtime is making a call into the SCA runtime.
+             * Get the default component set for this runtime.
+             * @return The default composite.
              */
-            SCA_API Composite* getCurrentComposite();
+            SCA_API Component* getDefaultComponent();
 
+            /**
+             * Register an implementation extension
+             */
             SCA_API void registerImplementationExtension(ImplementationExtension* extension);
 
+            /**
+             * Returns the implementation extension associated with
+             * the specified qname
+             */
             SCA_API ImplementationExtension* getImplementationExtension(const string& typeQname);
 
-
+            /**
+             * Register an interface extension
+             */
             SCA_API void registerInterfaceExtension(InterfaceExtension* extension);
 
+            /**
+             * Returns the interface extension associated with
+             * the specified qname
+             */
             SCA_API InterfaceExtension* getInterfaceExtension(const string& typeQname);
 
         private:
@@ -153,7 +162,7 @@
             /**
              * Pointer to the top of the runtime model.
              */
-            System* system;
+            Composite* system;
 
             /**
              * The installed path of the Tuscany runtime.
@@ -168,18 +177,12 @@
             /**
              * The default CompositeComponent.
              */
-            static string defaultCompositeName;
-
-            /**
-             * Get the default composite set for this runtime.
-             * @return The default composite.
-             */
-            Composite* getDefaultComposite() {return defaultComposite;}
+            static string defaultComponentName;
 
             /**
-             * The default composite set for this runtime.
+             * The default component set for this runtime.
              */
-            Composite* defaultComposite;
+            Component* defaultComponent;
             
             
             typedef stack<Component*> COMPONENT_STACK; 
@@ -208,13 +211,10 @@
 
         };
 
-        
     } // End namespace sca
 } // End namespace tuscany
 
 typedef void (* TUSCANY_IMPLEMENTATION_EXTENSION_INITIALIZE) ();
-
-
 
 #endif // tuscany_sca_core_scaruntime_h
 

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.cpp Mon Aug 28 03:42:10 2006
@@ -18,11 +18,8 @@
 /* $Rev$ $Date: 2005/12/22 11:33:21 $ */
 
 #include "tuscany/sca/core/ServiceProxy.h"
-
 #include "tuscany/sca/util/Logging.h"
 #include "tuscany/sca/util/Exceptions.h"
-#include "tuscany/sca/core/SCARuntime.h"
-#include "tuscany/sca/model/CPPImplementation.h"
 
 using namespace osoa::sca;
 
@@ -33,70 +30,10 @@
         // ============================
         // Constructor: Create a proxy
         // ============================
-        ServiceProxy::ServiceProxy(Component* component, const string& name, ServiceWrapper* target)
+        ServiceProxy::ServiceProxy(Reference* reference)
+            : reference(reference)
         {
             LOGENTRY(1,"ServiceProxy::constructor");
-            string msg;
-
-            // ----------------------
-            // Get the implementation
-            // ----------------------
-            Implementation* impl = component->getImplementation();
-            if (!impl)
-            {
-                msg = "Component " + component->getName() + " has no implementation defined";
-                throw ServiceNotFoundException(msg.c_str());
-            }
-            
-            // TODO: This only handle CPP implementation for now
-            if (impl->getImplementationType() == "cpp")
-            {
-                // ----------------------------------------------------
-                // Get implementation dll name and service factory name
-                // ----------------------------------------------------
-                string dllName = ((CPPImplementation*)impl)->getLibrary();
-                string headerStub = ((CPPImplementation*)impl)->getHeaderStub();
-
-                string fullDllName = component->getComposite()->getRoot() + "/" + dllName;
-                string proxyFactoryName = headerStub + "_" + name + "_Proxy_Factory";
-                string proxyDestructorName = headerStub + "_" + name + "_Proxy_Destructor";        
-                typedef void* (* PROXYFACTORY) (ServiceWrapper*);
-                
-                // ------------
-                // Load the dll
-                // ------------
-                proxyLibrary = Library(fullDllName);
-
-                // -------------------------
-                // Locate the factory method
-                // -------------------------
-                PROXYFACTORY proxyFactory = (PROXYFACTORY)proxyLibrary.getSymbol(proxyFactoryName);        
-                if (!proxyFactory)
-                {
-                    LOGERROR_2(1, "ComponentContextImpl::getServiceProxy: Unable to locate %s in library %s",
-                        proxyFactoryName.c_str(), fullDllName.c_str());
-                    msg = "Unable to locate " + proxyFactoryName + " in library " + fullDllName;
-                    throw ServiceNotFoundException(msg.c_str());
-                }
-                
-                // -----------------------------------
-                // Now create an instance of the proxy                
-                // -----------------------------------
-                proxy = proxyFactory(target); 
-                if (!proxy)
-                {
-                    LOGERROR_2(1, "ComponentContextImpl::getServiceProxy: Factory method %s in library %s returned null",
-                        proxyFactoryName.c_str(), fullDllName.c_str());
-                    msg = "Factory method " + proxyFactoryName + " in library " + fullDllName + " returned null";
-                    throw ServiceNotFoundException(msg.c_str());
-                }
-
-                // -------------------------
-                // Get the destructor method
-                // -------------------------
-                destructor  = (PROXYDESTRUCTOR)proxyLibrary.getSymbol(proxyDestructorName);        
-            }
-            
             LOGEXIT(1,"ServiceProxy::constructor");
             
         }
@@ -107,15 +44,8 @@
         ServiceProxy::~ServiceProxy()
         {
             LOGENTRY(1,"ServiceProxy::destructor");
-
-            // Delete the proxy
-            if (destructor)
-            {
-                destructor(proxy);
-            }
             LOGEXIT(1,"ServiceProxy::destructor");
         }
-    
         
     } // End namespace sca
 } // End namespace tuscany

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.h?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceProxy.h Mon Aug 28 03:42:10 2006
@@ -21,17 +21,21 @@
 #define tuscany_sca_core_serviceproxy_h
 
 #include "osoa/sca/export.h"
-
-#include "tuscany/sca/core/ServiceWrapper.h"
 #include "tuscany/sca/model/Component.h"
-#include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+
+#include <vector>
+using std::vector;
 
 using namespace tuscany::sca::model;
 
+
 namespace tuscany
 {
     namespace sca
     {
+        
         /**
          * Holds a proxy for a given component and reference.
          * The proxy which is held inside a ServiceProxy will be specific to the component
@@ -42,46 +46,44 @@
         {
         public:
             /**
-             * Create a new service proxy for a given component and reference name. The
-             * create proxy will contain a pointer to the target ServiceWrapper.
-             * @param component The component for which this proxy will be created (the
-             * source component).
-             * @param name The name of the reference on the component.
-             * @param target The wrapper of the component which is wired to this component and
-             * reference.
+             * Create a new service proxy for a reference. The proxy will contain a pointer to
+             * the target ServiceWrapper.
+             * @param reference The reference on the source component.
+             * @param target The wrapper of the service which is wired to this reference.
              */
-            ServiceProxy(Component* component, const string& name, ServiceWrapper* target);
+            ServiceProxy(Reference* reference);
 
             /**
              * Destructor.
              */
             virtual    ~ServiceProxy();
+            
+            /**
+             * Returns the reference represented by this proxy.
+             * @return The Reference represented by this proxy.
+             */
+            Reference* getReference() const { return reference; };
 
             /**
              * Return an instance of the proxy created for this particular component and reference.
              * @return The proxy.
              */
-            void* getProxy() {return proxy;}
-
-
-        private:
-            /**
-             * Holds the instance of the code generated proxy.
-             */ 
-            void* proxy;
-
-            typedef void (* PROXYDESTRUCTOR) (void*);
-
+            virtual void* getProxy() = 0;
+            
             /**
-             * A function pointer to the destructor of the proxy.
+             * Return a list of the proxies created for this particular component and reference.
+             * @return The proxies.
              */
-            PROXYDESTRUCTOR destructor;
+            typedef vector<void*> PROXIES;
+            virtual PROXIES getProxies() = 0;
             
+        private:
+        
             /**
-             * The library which contains the code for the proxy.
+             * The reference represented by this proxy.
              */
-            Library proxyLibrary;
-
+            Reference* reference;
+        
         };
     } // End namespace sca
 } // End namespace tuscany

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.cpp Mon Aug 28 03:42:10 2006
@@ -18,12 +18,7 @@
 /* $Rev$ $Date: 2005/12/22 11:33:21 $ */
 
 #include "tuscany/sca/core/ServiceWrapper.h"
-#include <stdarg.h>
-
 #include "tuscany/sca/util/Logging.h"
-#include "tuscany/sca/core/SCARuntime.h"
-
-
 
 namespace tuscany
 {
@@ -33,8 +28,8 @@
         // ===========
         // Constructor
         // ===========
-        ServiceWrapper::ServiceWrapper(WireTarget* targ)
-            : target(targ)
+        ServiceWrapper::ServiceWrapper(Service* service)
+            : service(service)
         {
             LOGENTRY(1,"ServiceWrapper::constructor");
             

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.h?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/ServiceWrapper.h Mon Aug 28 03:42:10 2006
@@ -21,15 +21,17 @@
 #define tuscany_sca_core_servicewrapper_h
 
 #include "osoa/sca/export.h"
-
 #include "tuscany/sca/core/Operation.h"
-#include "tuscany/sca/model/WireTarget.h"
-using tuscany::sca::model::WireTarget;
+#include "tuscany/sca/model/Service.h"
+
+using namespace tuscany::sca::model;
+
 
 namespace tuscany
 {
     namespace sca
     {
+        
         /**
          * An abstract class that wraps a component implementation or an external
          * service.
@@ -41,7 +43,7 @@
              * Constructor.
              * @param target The service wrapper wraps the target of a wire.
              */
-            ServiceWrapper(WireTarget* target);
+            ServiceWrapper(Service* service);
 
             /**
              * Destructor.
@@ -49,10 +51,10 @@
             virtual    ~ServiceWrapper();
 
             /** 
-             * Get the target represented by this wrapper.
-             * @return The target represented by this wrapper.
+             * Get the service represented by this wrapper.
+             * @return The service represented by this wrapper.
              */
-            virtual WireTarget* getTarget() {return target;}
+            Service* getService() const { return service; }
 
             /**
              * All business method calls on the target service are performed through
@@ -61,11 +63,13 @@
              * business method to be called on the target service.
              */
             virtual void invoke(Operation& operation) = 0;
+            
         private:
             /**
              * The target represented by this wrapper.
              */
-            WireTarget* target;
+            Service* service;
+            
         };
     } // End namespace sca
 } // End namespace tuscany

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.cpp?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.cpp Mon Aug 28 03:42:10 2006
@@ -23,8 +23,6 @@
 #include "tuscany/sca/util/Exceptions.h"
 #include "tuscany/sca/core/SCARuntime.h"
 
-#include "tuscany/sca/model/System.h"
-
 namespace tuscany
 {
     namespace sca
@@ -42,24 +40,24 @@
         }
 
         // ==========================================================
-        // Set the default CompositeComponent name
+        // Set the default component name
         // ==========================================================
-        void TuscanyRuntime::setDefaultCompositeComponent(const string& compositeComponent)
+        void TuscanyRuntime::setDefaultComponentName(const string& componentName)
         {
-            LOGENTRY(1, "TuscanyRuntime::setDefaultCompositeComponent");
-            defaultCompositeComponent = compositeComponent;
-            LOGINFO_1(3, "TuscanyRuntime::setDefaultCompositeComponent - set to %s", compositeComponent.c_str());
-            LOGEXIT(1, "TuscanyRuntime::setDefaultCompositeComponent");
+            LOGENTRY(1, "TuscanyRuntime::setDefaultComponentName");
+            defaultComponentName = defaultComponentName;
+            LOGINFO_1(3, "TuscanyRuntime::setDefaultComponentName - set to %s", componentName.c_str());
+            LOGEXIT(1, "TuscanyRuntime::setDefaultComponentName");
         }
 
         // ===================================================================
         // Constructor for the TuscanyRuntime class. 
         // ===================================================================
-        TuscanyRuntime::TuscanyRuntime(const string& compositeComponent, const string& root)
+        TuscanyRuntime::TuscanyRuntime(const string& componentName, const string& root)
         { 
             LOGENTRY(1, "TuscanyRuntime::constructor");
             setSystemRoot(root);
-            setDefaultCompositeComponent(compositeComponent);           
+            setDefaultComponentName(componentName);           
             LOGEXIT(1, "TuscanyRuntime::constructor");
         }
 
@@ -79,7 +77,7 @@
         { 
             LOGENTRY(1, "TuscanyRuntime::start");
             SCARuntime::setSystemRoot(systemRoot);
-            SCARuntime::setDefaultCompositeComponent(defaultCompositeComponent);
+            SCARuntime::setDefaultComponentName(defaultComponentName);
             SCARuntime::getInstance();
             LOGEXIT(1, "TuscanyRuntime::start");
         }
@@ -94,7 +92,5 @@
             LOGEXIT(1, "TuscanyRuntime::stop");
         }
 
-
-                
     } // End namespace sca
 } // End namespace tuscany

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.h?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/TuscanyRuntime.h Mon Aug 28 03:42:10 2006
@@ -38,7 +38,7 @@
             /**
             * Default constructor
             */
-            TuscanyRuntime(const string& compositeComponent = "", const string& root = "");            
+            TuscanyRuntime(const string& defaultComponentName = "", const string& root = "");            
             
             /**
             * Destructor
@@ -53,10 +53,10 @@
             void setSystemRoot(const string& root);
             
             /**
-            * Set the default CompositeComponent for the system
-            * @param compositeComponent The name of the default compositeComponent.
+            * Set the default component for the system
+            * @param componentName The name of the default component.
             */
-            void setDefaultCompositeComponent(const string& compositeComponent);
+            void setDefaultComponentName(const string& componentName);
             
             /**
             * start the runtime
@@ -71,7 +71,7 @@
             
         private:
             string systemRoot;
-            string defaultCompositeComponent;
+            string defaultComponentName;
         };
 
         

Propchange: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/cpp/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Aug 28 03:42:10 2006
@@ -0,0 +1,29 @@
+configure
+Makefile.in
+config.log
+depcomp
+config.guess
+config.h
+config.sub
+ltmain.sh
+Makefile
+config.status
+stamp-h1
+config.h.in
+libtool
+autom4te.cache
+missing
+aclocal.m4
+install-sh
+.deps
+*.dat
+.libs
+tmp
+bld
+.project
+.cdtproject
+.settings
+*_Proxy.cpp
+*_Proxy.h
+*_Wrapper.cpp
+*_Wrapper.h

Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/cpp/CPPServiceWrapper.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/cpp/CPPServiceWrapper.h?rev=437637&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/cpp/CPPServiceWrapper.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/cpp/CPPServiceWrapper.h Mon Aug 28 03:42:10 2006
@@ -0,0 +1,162 @@
+/*
+ *
+ *  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$ */
+
+#ifndef tuscany_sca_extension_cpp_model_cppservicewrapper_h
+#define tuscany_sca_extension_cpp_model_cppservicewrapper_h
+
+#include "osoa/sca/export.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/core/Operation.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/util/Library.h"
+
+using namespace tuscany::sca;
+using namespace tuscany::sca::model;
+
+//TODO Temporarily copied here to get included in the
+// distribution as generated proxies and wrappers include it
+
+namespace tuscany
+{
+    namespace sca
+    {
+        namespace cpp
+        {
+            class CPPInterface;
+            
+            /**
+             * 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 CPPServiceWrapper : public ServiceWrapper
+            {
+            public:
+                /**
+                 * Factory method to create a new CPPServiceWrapper 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 CPPServiceWrapper* getServiceWrapper(Service* service);
+    
+                /**
+                 * Constructor.
+                 * @param target The component service to which this wrapper refers.
+                 */
+                SCA_API CPPServiceWrapper(Service* service);
+    
+                /**
+                 * Destructor.
+                 */ 
+                SCA_API virtual    ~CPPServiceWrapper();
+    
+                /**
+                 * 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() const { 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 CPPServiceWrapper#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 composite.
+                 */
+                static void* staticImpl;
+    
+                /**
+                 * The component to which this wrapper refers.
+                 */
+                Component* component;
+    
+                /**
+                 * 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 cpp
+    } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_extension_cpp_model_cppservicewrapper_h

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

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

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/ImplementationExtension.h Mon Aug 28 03:42:10 2006
@@ -24,11 +24,15 @@
 #include <string>
 using std::string;
 
-#include <tuscany/sca/model/Component.h>
-#include <tuscany/sca/model/Service.h>
-#include <tuscany/sca/core/ServiceWrapper.h>
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/core/ServiceWrapper.h"
+#include "tuscany/sca/model/Composite.h"
 
-#include <commonj/sdo/SDO.h>
+#include "commonj/sdo/SDO.h"
+
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
 
 namespace tuscany
 {
@@ -58,9 +62,12 @@
             */
             virtual const string& getExtensionTypeQName() = 0;
 
-            virtual tuscany::sca::model::Implementation* getImplementation(commonj::sdo::DataObjectPtr scdlImplementation) = 0;
+            /**
+             * Get an implementation from a DataObject representing
+             * an SCDL implementation element
+             */ 
+            virtual ComponentType* getImplementation(Composite* composite, DataObjectPtr scdlImplementation) = 0;
 
-            //virtual ServiceWrapper* getServiceWrapper(model::Service* service) = 0;
          };
 
         

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/InterfaceExtension.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/InterfaceExtension.h?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/InterfaceExtension.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/extension/InterfaceExtension.h Mon Aug 28 03:42:10 2006
@@ -24,8 +24,12 @@
 #include <string>
 using std::string;
 
-#include <tuscany/sca/model/Interface.h>
-#include <commonj/sdo/SDO.h>
+#include "tuscany/sca/model/Interface.h"
+#include "tuscany/sca/model/Composite.h"
+#include "commonj/sdo/SDO.h"
+
+using namespace commonj::sdo;
+using namespace tuscany::sca::model;
 
 namespace tuscany
 {
@@ -55,7 +59,12 @@
             */
             virtual const string& getExtensionTypeQName() = 0;
 
-            virtual tuscany::sca::model::Interface* getInterface(commonj::sdo::DataObjectPtr scdlInterface) = 0;
+            /**
+             * Get an interface from a DataObject representing an
+             * SCDL interface
+             */
+            virtual Interface* getInterface(Composite *composite, DataObjectPtr scdlInterface) = 0;
+            
         };
 
         

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Binding.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Binding.cpp?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Binding.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Binding.cpp Mon Aug 28 03:42:10 2006
@@ -34,11 +34,11 @@
             {
             }
 
+            // Destructor
             Binding::~Binding()
             {
             }
 
         } // End namespace model
-
     } // End namespace sca
 } // End namespace tuscany

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?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- 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 Aug 28 03:42:10 2006
@@ -22,7 +22,6 @@
 #include <string>
 using std::string;
 
-
 namespace tuscany
 {
     namespace sca
@@ -30,49 +29,47 @@
         namespace model
         {
             /**
-             * Information about the binding for CompositeServiceType and CompositeReferenceType. An
-             * abstract class which will be extended by classes that hold specific
-             * information for each type of binding.
+             * Represents a binding.
+             * Bindings are used by services and references. References use bindings
+             * to describe the access mechanism used to call an external service (which can
+             * be a service provided by another SCA composite). Services use bindings to describe
+             * the access mechanism that clients (which can be a client from another SCA composite)
+             * have to use to call the service.
+             * This interface will typically be extended by binding implementations to allow
+             * specification of binding/transport specific information.
              */
             class Binding 
             {
                 
             public:
-                /**
-                 * Supported binding types.
-                 */
-                enum Type
-                {
-                    WS,
-                    SCA
-                };
-                
+
                 /**
                  * Constructor to create a new binding.
-                 * @param uri The uri specified in the scdl file.
+                 * @param uri The binding URI.
                  */ 
-                Binding(const string& uri);  
+                Binding(const string& uri);
 
                 /**
                  * Destructor.
                  */ 
                 virtual ~Binding();
-                            
+                
                 /**
-                 * Return the enumerated type of binding.
-                 * @return The type of the binding (see Binding#Type).
-                 */ 
-                virtual Type getBindingType() = 0;
-
+                 * Returns the binding type
+                 * @return The binding type.
+                 */
+                virtual string getType() = 0;
+                            
                 /**
-                 * Return the uri of the binding.
-                 * @return The uri of the binding.
+                 * Returns the binding URI.
+                 * @return The binding URI.
                  */
-                string getUri() {return uri;};
+                string getURI() const { return uri; };
                 
             private:
+            
                 /**
-                 * The uri of the binding.
+                 * The binding URI.
                  */ 
                 string uri;
             };
@@ -82,4 +79,3 @@
 } // End namespace tuscany
 
 #endif // tuscany_sca_model_binding_h
-

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.cpp?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.cpp Mon Aug 28 03:42:10 2006
@@ -17,12 +17,15 @@
 
 /* $Rev$ $Date: 2005/12/22 11:33:21 $ */
 
-// Component.cpp : Represent a loaded Component
-//
 #include "tuscany/sca/util/Logging.h"
 #include "tuscany/sca/util/Exceptions.h"
 #include "tuscany/sca/util/Utils.h"
 #include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/Reference.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/ComponentType.h"
 
 using namespace commonj::sdo;
 #include <iostream>
@@ -34,11 +37,15 @@
         namespace model
         {
            // Constructor
-            Component::Component(const std::string& componentName, Composite* composite) 
-                : name(componentName), containingComposite(composite), implementation(0)
+            Component::Component(Composite* composite, const std::string& componentName, ComponentType *componentType) 
+                : name(componentName), composite(composite), type(componentType)
             {
                 LOGENTRY(1, "Component::constructor");
                 LOGINFO_1(3, "Component::constructor: Component name: %s", name.c_str());
+                
+                // Initialize the component from its component type
+                componentType->initializeComponent(this);
+                
                 LOGEXIT(1, "Component::constructor");
             }
 
@@ -46,16 +53,14 @@
             {
             }
 
-            Service* Component::addService(const std::string& serviceName)
+            void Component::addService(Service* service)
             {
-                Service* service = new Service(serviceName, this);
-                services[serviceName] = service;
-                return service;
+                services[service->getType()->getName()] = service;
             }
             
-            Service* Component::findService(const std::string& serviceName)
+            Service* Component::findService(const string& serviceName)
             {
-                // If serviceName is null then return the ONLY service
+                // If serviceName is empty then return the ONLY service
                 if (serviceName == "" 
                     && services.size() == 1)
                 {
@@ -67,185 +72,21 @@
                 }
             }
             
-            ServiceReference* Component::findReference(const std::string& referenceName)
+            void Component::addReference(Reference* reference)
             {
-                return references[referenceName];
+                references[reference->getType()->getName()] = reference;
             }
             
-            ServiceReference* Component::addReference(const std::string& referenceName)
+            Reference* Component::findReference(const std::string& referenceName)
             {
-                ServiceReference* serviceReference = references[referenceName];
-                if (!serviceReference)
-                {
-                    references[referenceName] = new ServiceReference(referenceName);
-                }
                 return references[referenceName];
             }
-            
-            void Component::setImplementation(Implementation* impl)
-            {
-                implementation = impl;
-            }
-            
-            void Component::addProperty(const string& name,
-                const string& type,
-                bool many,
-                DataObjectPtr defaultValue)
-            {
-                // Create a Type in the Properties dataFactory
-                DataFactoryPtr factory = getPropertyDataFactory();
-                
-                string typeUri, typeName;
-                Utils::tokeniseQName(type, typeUri, typeName);
-                
-                if (typeUri == "http://www.w3.org/2001/XMLSchema")                                
-                {
-                    typeUri = Type::SDOTypeNamespaceURI;
-                    if (typeName == "string")
-                    {
-                        typeName = "String";
-                    }
-                    else if (typeName == "anyType")
-                    {
-                        typeName = "DataObject";
-                    }
-                    else if (typeName == "int")
-                    {
-                        typeName = "Integer";
-                    }
-                    else if (typeName == "integer")
-                    {
-                        typeName = "Integer";
-                    }
-                    else if (typeName == "negativeInteger")
-                    {
-                        typeName = "Integer";
-                    }
-                    else if (typeName == "nonNegativeInteger")
-                    {
-                        typeName = "Integer";
-                    }
-                    else if (typeName == "positiveInteger")
-                    {
-                        typeName = "Integer";
-                    }
-                    else if (typeName == "nonPositiveInteger")
-                    {
-                        typeName = "Integer";
-                    }
-                    else if (typeName == "unsignedLong")
-                    {
-                        typeName = "Integer";
-                    }
-                    else if (typeName == "unsignedShort")
-                    {
-                        typeName = "Integer";
-                    }
-                    else if (typeName == "unsignedInt")
-                    {
-                        typeName = "Long";
-                    }
-                    else if (typeName == "long")
-                    {
-                        typeName = "Long";
-                    }
-                    else if (typeName == "double")
-                    {
-                        typeName = "Double";
-                    }
-                    else if (typeName == "short")
-                    {
-                        typeName = "Short";
-                    }
-                    else if (typeName == "unsignedByte")
-                    {
-                        typeName = "Short";
-                    }
-                    else if (typeName == "float")
-                    {
-                        typeName = "Float";
-                    }
-                    else if (typeName == "boolean")
-                    {
-                        typeName = "Boolean";
-                    }
-                    else if (typeName == "byte")
-                    {
-                        typeName = "Byte";
-                    }
-                    else if (typeName == "base64Binary")
-                    {
-                        typeName = "Bytes";
-                    }
-                    else if (typeName == "hexBinary")
-                    {
-                        typeName = "Bytes";
-                    }
-                    else if (typeName == "anyURI")
-                    {
-                        typeName = "URI";
-                    }
-                    else if (typeName == "QName")
-                    {
-                        typeName = "URI";
-                    }
-                    else
-                    {
-                        // Default unknown xs: types to string??
-                        typeName = "String";
-                    }
-                }
-                else
-                {
-                    // It's not an XML type
-                }
-
-
-                factory->addPropertyToType(
-                    "org/osoa/sca",
-                    "Properties",
-                    name.c_str(),
-                    typeUri.c_str(), 
-                    typeName.c_str(),
-                    many,
-                    false,
-                    true);
-
-                // Set the default for a dataType
-                try
-                {
-                    const Type& propType = factory->getType(typeUri.c_str(), typeName.c_str());
-                    if (propType.isDataType())
-                    {
-                        factory->setDefault("org/osoa/sca", "Properties",
-                            name.c_str(),
-                            (char*)defaultValue->getCString(""));
-                    }
-                }
-                catch (SDOTypeNotFoundException&)
-                {
-                    // cout << "setting default failed" <<endl;
-                }
 
-                
-            }
-            
-            DataFactoryPtr Component::getPropertyDataFactory()
-            {
-                if (!propertyFactory)
-                {
-                    propertyFactory = DataFactory::getDataFactory();
-                    // Add the root type
-                    propertyFactory->addType("org/osoa/sca", "Properties", false, false, false, false);
-                }
-                return propertyFactory;
-            }
-            
             DataObjectPtr Component::getProperties()
             {
                 if (!properties)
                 {
-                    properties = getPropertyDataFactory()->create("org/osoa/sca", "Properties");
+                    properties = type->getPropertyDataFactory()->create("org/osoa/sca", "Properties");
                 }
                 return properties;
             }

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.h?rev=437637&r1=437636&r2=437637&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/Component.h Mon Aug 28 03:42:10 2006
@@ -22,17 +22,13 @@
 
 #include <string>
 using std::string;
-
+   
 #include <map>
 
-#include "tuscany/sca/model/Service.h"
-#include "tuscany/sca/model/Implementation.h"
-#include "tuscany/sca/model/ServiceReference.h"
-
 #include "commonj/sdo/SDO.h"
-using commonj::sdo::DataObjectPtr;
-using commonj::sdo::DataFactoryPtr;
-using commonj::sdo::DataObjectList;
+
+using namespace commonj::sdo;
+
 
 namespace tuscany
 {
@@ -42,19 +38,29 @@
         {
 
             class Composite;
+            class ComponentType;
+            class Reference;
+            class ReferenceType;
+            class Service;
+            class ServiceType;
 
             /**
-             * Information about an SCA component.
+             * A component is a configured instance of an implementation. Components provide
+             * and consume services. More than one component can use and configure the same
+             * implementation, where each component configures the implementation differently.
+             * For example each component may configure a reference of the same implementation
+             * to consume a different service.
              */
             class Component
             {
             public:
+            
                 /**
                  * Constructor
+                 * @param composite The composite containing the component.
                  * @param name The name of the component.
-                 * @param composite The composite containing this component.
                  */
-                SCA_API Component(const std::string& name, Composite* composite);
+                Component(Composite *composite, const std::string& name, ComponentType *type);
 
                 /**
                  * Destructor.
@@ -62,23 +68,28 @@
                 SCA_API virtual ~Component();
 
                 /**
-                 * Returns the name of the component.
-                 * @return The name of the component.
+                 * Returns the name of this component.
+                 * @return the name of this component
                  */
-                SCA_API const string& getName() {return name;}
-
-                /** 
-                 * Get the composite containing this component.
-                 * @return The containing composite.
+                const string& getName() const { return name; }
+            
+                /**
+                 * Returns the composite containing this component.
+                 * @return The composite containing this component.
                  */
-                SCA_API Composite* getComposite() {return containingComposite;}
-
+                Composite* getComposite() const { return composite; }
+            
+                /**
+                 * Returns the type of this component.
+                 * @return The type of this component.
+                 */
+                ComponentType* getType() const { return type; }
+                
                 /**
                  * Add a new service to this component.
-                 * @param serviceName The name of the service to add.
-                 * @return The newly added service.
+                 * @param service The service to add.
                  */
-                SCA_API Service* addService(const std::string& serviceName);
+                void addService(Service* service);
 
                 /**
                  * Find an existing service on this component.
@@ -87,105 +98,78 @@
                  * only one service it will be returned.
                  * @return The found service, or 0 if not found.
                  */
-                SCA_API Service* findService(const std::string& serviceName);
+                Service* findService(const string& serviceName);
 
                 /**
                  * Add a new reference to this component.
-                 * @param referenceName The name of the reference to add.
-                 * @return The newly added reference.
+                 * @param reference The reference to add.
                  */
-                SCA_API ServiceReference* addReference(const std::string& referenceName);
+                void addReference(Reference* reference);
 
                 /**
                  * Find an existing reference on this component.
                  * @param referenceName The name of the reference to find.
                  * @return The found reference, or 0 if not found.
                  */
-                SCA_API ServiceReference* findReference(const std::string& referenceName);
+                Reference* findReference(const string& referenceName);
 
                 /**
-                 * Set the details of the implementation of this component.
-                 * @param impl The details of the implementation.
+                 * Returns all the services defined on this component.
+                 * @return All the services defined on this component.
                  */
-                SCA_API void setImplementation(Implementation* impl);
+                typedef std::map<std::string, Service*> SERVICE_MAP;
+                SERVICE_MAP getServices() const { return services; }; 
 
                 /**
-                 * Returns the details of the implementation of this component.
-                 * @return The details of the implementation.
+                 * Returns all the references defined on this component.
+                 * @return All the references defined on this component.
                  */
-                SCA_API Implementation* getImplementation() {return implementation;}
-
+                typedef std::map<std::string, Reference*> REFERENCE_MAP;
+                REFERENCE_MAP getReferences() const { return references; }; 
+                
                 /**
-                 * Add a new property to this component. Properties are 
-                 * added one at a time. The property definitions come from the component
-                 * type file.
+                 * Set the value of a property defined on this component. The values
+                 * will usually come from a component declaration in a composite file.
                  * @param name The name of the property.
-                 * @param type The full name of the type (including uri and local name).
-                 * @param many True if this is a many valued property.
-                 * @param defaultValue The default value if the property does not have a
-                 * value set.
-                 */
-                SCA_API void addProperty(const string& name,
-                    const string& type,
-                    bool many,
-                    DataObjectPtr defaultValue);
-    
-                /**
-                 * Add the property values to the properties defined on this 
-                 * component. The values will come from the sca.composite file.
-                 * @param properties A data object representing all the values set
-                 * for this component.
+                 * @param value The value of the property.
                  */
-                SCA_API void setProperty(const string& name, DataObjectPtr value);
+                void setProperty(const string& name, DataObjectPtr value);
 
                 /**
-                 * Returns a data object from which all the properties and their
-                 * values can be accessed.
+                 * Returns a data object from which all the properties of the component
+                 * and their values can be accessed.
                  * @return A data object holding the property values.
                  */
-                SCA_API DataObjectPtr getProperties();
+                DataObjectPtr getProperties();
+
             private:
+                
                 /**
                  * Name of the component.
                  */
                 string name;
-
+                
                 /**
-                 * Composite containing this component for navigating up the tree.
+                 * Composite containing the component.
                  */
-                Composite* containingComposite;
+                 Composite* composite;
 
                 /**
-                 * Information about the implementation of this component.
+                 * Type of the component.
                  */
-                Implementation* implementation;
+                ComponentType* type;
 
-                typedef std::map<std::string, Service*> SERVICE_MAP;
                 /**
                  * Map of all the services defined on this component.
                  */
                 SERVICE_MAP services;
 
-                typedef std::map<std::string, ServiceReference*> REFERENCE_MAP;
                 /**
                  * Map of all the references defined on this component.
                  */
                 REFERENCE_MAP references;
 
                 /**
-                 * SDO data factory which has all the property types defined from
-                 * the component type file
-                 */
-                DataFactoryPtr propertyFactory;
-
-                /**
-                 * Return the SDO data factory which has the property types defined
-                 * in it.
-                 * @return The data factory.
-                 */
-                DataFactoryPtr getPropertyDataFactory();
-
-                /**
                  * The properties and their values for this component.
                  */ 
                 DataObjectPtr properties;
@@ -193,9 +177,7 @@
            };
 
         } // End namespace model
-
     } // End namespace sca
 } // End namespace tuscany
 
 #endif // tuscany_sca_model_component_h
-

Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ComponentType.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ComponentType.cpp?rev=437637&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ComponentType.cpp (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ComponentType.cpp Mon Aug 28 03:42:10 2006
@@ -0,0 +1,255 @@
+/*
+ *
+ *  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$ */
+
+#include "tuscany/sca/util/Logging.h"
+#include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/util/Utils.h"
+#include "tuscany/sca/model/ComponentType.h"
+#include "tuscany/sca/model/ServiceType.h"
+#include "tuscany/sca/model/ReferenceType.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/Reference.h"
+
+#include <iostream>
+
+using namespace commonj::sdo;
+using namespace std;
+
+namespace tuscany
+{
+    namespace sca
+    {
+        namespace model
+        {
+            
+           // Constructor
+            ComponentType::ComponentType(const string& name)
+            : name(name)
+            {
+                LOGENTRY(1, "ComponentType::constructor");
+                LOGEXIT(1, "ComponentType::constructor");
+            }
+
+            // Destructor
+            ComponentType::~ComponentType()
+            {
+            }
+
+            void ComponentType::addServiceType(ServiceType* serviceType)
+            {
+                serviceTypes[serviceType->getName()] = serviceType;
+            }
+            
+            ServiceType* ComponentType::findServiceType(const string& serviceName)
+            {
+                // If serviceName is empty then return the ONLY service
+                if (serviceName == "" 
+                    && serviceTypes.size() == 1)
+                {
+                    return serviceTypes.begin()->second;
+                }
+                else
+                {
+                    return serviceTypes[serviceName];
+                }
+            }
+            
+            void ComponentType::addReferenceType(ReferenceType* referenceType)
+            {
+                referenceTypes[referenceType->getName()] = referenceType;
+            }
+            
+            ReferenceType* ComponentType::findReferenceType(const string& referenceName)
+            {
+                return referenceTypes[referenceName];
+            }
+            
+            void ComponentType::addPropertyType(const string& name,
+                const string& type,
+                bool many,
+                DataObjectPtr defaultValue)
+            {
+                // Create a Type in the Properties dataFactory
+                DataFactoryPtr factory = getPropertyDataFactory();
+                
+                string typeUri, typeName;
+                Utils::tokeniseQName(type, typeUri, typeName);
+                
+                if (typeUri == "http://www.w3.org/2001/XMLSchema")                                
+                {
+                    typeUri = Type::SDOTypeNamespaceURI;
+                    if (typeName == "string")
+                    {
+                        typeName = "String";
+                    }
+                    else if (typeName == "anyType")
+                    {
+                        typeName = "DataObject";
+                    }
+                    else if (typeName == "int")
+                    {
+                        typeName = "Integer";
+                    }
+                    else if (typeName == "integer")
+                    {
+                        typeName = "Integer";
+                    }
+                    else if (typeName == "negativeInteger")
+                    {
+                        typeName = "Integer";
+                    }
+                    else if (typeName == "nonNegativeInteger")
+                    {
+                        typeName = "Integer";
+                    }
+                    else if (typeName == "positiveInteger")
+                    {
+                        typeName = "Integer";
+                    }
+                    else if (typeName == "nonPositiveInteger")
+                    {
+                        typeName = "Integer";
+                    }
+                    else if (typeName == "unsignedLong")
+                    {
+                        typeName = "Integer";
+                    }
+                    else if (typeName == "unsignedShort")
+                    {
+                        typeName = "Integer";
+                    }
+                    else if (typeName == "unsignedInt")
+                    {
+                        typeName = "Long";
+                    }
+                    else if (typeName == "long")
+                    {
+                        typeName = "Long";
+                    }
+                    else if (typeName == "double")
+                    {
+                        typeName = "Double";
+                    }
+                    else if (typeName == "short")
+                    {
+                        typeName = "Short";
+                    }
+                    else if (typeName == "unsignedByte")
+                    {
+                        typeName = "Short";
+                    }
+                    else if (typeName == "float")
+                    {
+                        typeName = "Float";
+                    }
+                    else if (typeName == "boolean")
+                    {
+                        typeName = "Boolean";
+                    }
+                    else if (typeName == "byte")
+                    {
+                        typeName = "Byte";
+                    }
+                    else if (typeName == "base64Binary")
+                    {
+                        typeName = "Bytes";
+                    }
+                    else if (typeName == "hexBinary")
+                    {
+                        typeName = "Bytes";
+                    }
+                    else if (typeName == "anyURI")
+                    {
+                        typeName = "URI";
+                    }
+                    else if (typeName == "QName")
+                    {
+                        typeName = "URI";
+                    }
+                    else
+                    {
+                        // Default unknown xs: types to string??
+                        typeName = "String";
+                    }
+                }
+                else
+                {
+                    // It's not an XML type
+                }
+
+                factory->addPropertyToType(
+                    "org/osoa/sca",
+                    "Properties",
+                    name.c_str(),
+                    typeUri.c_str(), 
+                    typeName.c_str(),
+                    many,
+                    false,
+                    true);
+
+                // Set the default for a dataType
+                try
+                {
+                    const Type& propType = factory->getType(typeUri.c_str(), typeName.c_str());
+                    if (propType.isDataType())
+                    {
+                        factory->setDefault("org/osoa/sca", "Properties",
+                            name.c_str(),
+                            (char*)defaultValue->getCString(""));
+                    }
+                }
+                catch (SDOTypeNotFoundException&)
+                {
+                    // cout << "setting default failed" <<endl;
+                }
+            }
+            
+            DataFactoryPtr ComponentType::getPropertyDataFactory()
+            {
+                if (!propertyFactory)
+                {
+                    propertyFactory = DataFactory::getDataFactory();
+                    // Add the root type
+                    propertyFactory->addType("org/osoa/sca", "Properties", false, false, false, false);
+                }
+                return propertyFactory;
+            }
+            
+            void ComponentType::initializeComponent(Component* component)
+            {
+                for (SERVICETYPE_MAP::iterator iter = serviceTypes.begin();
+                iter != serviceTypes.end();
+                iter++)
+                {
+                    Service* service = new Service(component, iter->second);
+                    component->addService(service);    
+                }
+                for (REFERENCETYPE_MAP::iterator iter = referenceTypes.begin();
+                iter != referenceTypes.end();
+                iter++)
+                {
+                    Reference* reference = new Reference(component, iter->second);
+                    component->addReference(reference);    
+                }
+            }
+            
+        } // End namespace model
+    } // End namespace sca
+} // End namespace tuscany

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

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

Added: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ComponentType.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ComponentType.h?rev=437637&view=auto
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ComponentType.h (added)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ComponentType.h Mon Aug 28 03:42:10 2006
@@ -0,0 +1,168 @@
+/*
+ *
+ *  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$ */
+
+#ifndef tuscany_sca_model_componenttype_h
+#define tuscany_sca_model_componenttype_h
+
+#include <string>
+using std::string;
+
+#include <map>
+
+#include "commonj/sdo/SDO.h"
+
+#include "tuscany/sca/model/ReferenceType.h"
+
+namespace tuscany
+{
+    namespace sca
+    {
+        namespace model
+        {
+            class ServiceType;
+            class ReferenceType;
+            class Interface;
+            class Component;
+
+            /**
+             * Component type represents the configurable aspects of an implementation.
+             * A component type consists of services that are offered, references to other services
+             * that can be wired and properties that can be set. The settable properties and the settable
+             * references to services are configured by a component which uses the implementation.
+             * The component type can be thought of as the contract which is honoured by an implementation.
+             */
+            class ComponentType
+            {
+            public:
+             
+                /**
+                 * Constructor
+                 */
+                ComponentType(const string& name);
+
+                /**
+                 * Destructor.
+                 */
+                virtual ~ComponentType();
+                
+                /**
+                 * Returns the name of the component type
+                 */
+                 const string& getName() { return name; };
+
+                /**
+                 * Add a new service type to this component type.
+                 * @param serviceType The service type to add.
+                 */
+                void addServiceType(ServiceType* serviceType);
+
+                /**
+                 * Find an existing service type on this component type.
+                 * @param serviceName The name of the service type to find.
+                 * If the serviceName is the zero length string then if there is
+                 * only one service type it will be returned.
+                 * @return The found service, or 0 if not found.
+                 */
+                ServiceType* findServiceType(const string& serviceName);
+
+                /**
+                 * Add a new reference type to this component type.
+                 * @param referenceType The reference type to add.
+                 */
+                void addReferenceType(ReferenceType* referenceType);
+
+                /**
+                 * Find an existing reference type on this component type.
+                 * @param referenceName The name of the reference type to find.
+                 * @return The found reference type, or 0 if not found.
+                 */
+                ReferenceType* findReferenceType(const string& referenceName);
+
+                /**
+                 * Returns the service types defined on this component.
+                 * @return The service types defined on this component.
+                 */
+                typedef std::map<std::string, ServiceType*> SERVICETYPE_MAP;
+                SERVICETYPE_MAP getServiceTypes() const { return serviceTypes; }; 
+                                            
+                /**
+                 * Returns the reference types defined on this component.
+                 * @return The reference types defined on this component.
+                 */
+                typedef std::map<std::string, ReferenceType*> REFERENCETYPE_MAP;
+                REFERENCETYPE_MAP getReferenceTypes() const { return referenceTypes; };                
+            
+                /**
+                 * Add a new property type to this component type. Property types are added
+                 * one at a time. The property definitions usually come from a component type file.
+                 * @param name The name of the property type.
+                 * @param type The full name of the property data type (including uri and local name).
+                 * @param many True if this is a many valued property.
+                 * @param defaultValue The default value if the property does not have a
+                 * value set.
+                 */
+                void addPropertyType(const string& name,
+                    const string& type,
+                    bool many,
+                    commonj::sdo::DataObjectPtr defaultValue);
+    
+                /**
+                 * Return the SDO data factory which has the types of the properties defined
+                 * in this component type.
+                 * @return The data factory.
+                 */
+                commonj::sdo::DataFactoryPtr getPropertyDataFactory();
+
+                /**
+                 * Initialize a component of this type.
+                 * @param component The component to initialize.
+                 */
+                virtual void initializeComponent(Component* component);
+
+            private:
+            
+                /**
+                 * The name of the component type
+                 */
+                string name;
+                
+                /**
+                 * Map of all the service types defined on this component.
+                 */
+                SERVICETYPE_MAP serviceTypes;
+
+                /**
+                 * Map of all the reference types defined on this component.
+                 */
+                REFERENCETYPE_MAP referenceTypes;
+
+                /**
+                 * SDO data factory which has all the types of the properties defined in
+                 * this component type
+                 */
+                commonj::sdo::DataFactoryPtr propertyFactory;
+
+           };
+
+        } // End namespace model
+    } // End namespace sca
+} // End namespace tuscany
+
+#endif // tuscany_sca_model_componenttype_h
+

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

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



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