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 2007/01/04 07:51:35 UTC

svn commit: r492428 - in /incubator/tuscany/cpp/sca/runtime: core/src/tuscany/sca/core/ core/src/tuscany/sca/model/ core/src/tuscany/sca/util/ extensions/cpp/src/osoa/sca/ extensions/cpp/src/tuscany/sca/cpp/ extensions/php/src/tuscany/sca/php/ extensio...

Author: jsdelfino
Date: Wed Jan  3 22:51:33 2007
New Revision: 492428

URL: http://svn.apache.org/viewvc?view=rev&rev=492428
Log:
Changes to SCARuntime to make it thread safe. Adjusted the rest of the runtime, in particular Axis2Service and ModREST to these changes.

Modified:
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.cpp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.h
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Logger.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h
    incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/rest/interface/src/tuscany/sca/rest/RESTInterfaceExtension.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceBindingExtension.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/ModREST.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTReferenceBindingExtension.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/SCAServiceBindingExtension.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/SCAReferenceBindingExtension.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp

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?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- 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 Wed Jan  3 22:51:33 2007
@@ -459,7 +459,7 @@
             parameters.insert(parameters.end(), Parameter((void*)new DataObjectPtr(*parm), DATAOBJECT, (string&) name));
         }
 
-        Operation::Parameter::Parameter(void* val, Operation::ParameterType typ, string& nam)
+        Operation::Parameter::Parameter(void* val, Operation::ParameterType typ, const string& nam)
             : value(val), type(typ), name(nam)
         {
         }

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/Operation.h Wed Jan  3 22:51:33 2007
@@ -95,7 +95,7 @@
             class Parameter
             {
                 public:
-                    SCA_API Parameter(void* value = NULL, ParameterType type = VOID_TYPE, std::string& name = std::string(""));
+                    SCA_API Parameter(void* value = NULL, ParameterType type = VOID_TYPE, const std::string& name = "");
                     SCA_API void* getValue() const {return value;}
                     SCA_API ParameterType getType() const {return type;}
                     SCA_API const std::string& getName() const {return name;}

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- 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 Wed Jan  3 22:51:33 2007
@@ -53,26 +53,153 @@
         static const char* TUSCANY_SCACPP_COMPONENT = "TUSCANY_SCACPP_COMPONENT";
         static const char* TUSCANY_SCACPP_PATH = "TUSCANY_SCACPP_PATH";
         static const char* TUSCANY_SCACPP_BASE_URI = "TUSCANY_SCACPP_BASE_URI";
+
+        // Initialize statics        
+        SCARuntime* SCARuntime::sharedRuntime = NULL;
+        Mutex SCARuntime::sharedRuntimeLock;
+        ThreadLocal SCARuntime::current;
  
-        // ==========================================================
-        // Initialize static class member to not pointing at anything
-        // ==========================================================
-        SCARuntime* SCARuntime::instance = 0;
-        string SCARuntime::installRoot = "";
-        string SCARuntime::systemRoot = "";
-        string SCARuntime::systemPath = "";
-        string SCARuntime::defaultComponentName = "";
-        string SCARuntime::defaultBaseURI = "";
+
+        // ===================================================================
+        // Constructor for the SCARuntime class. This will 
+        // hold all the information about the current runtime.
+        // ===================================================================
+        SCARuntime::SCARuntime(const string& insRoot,
+                const string& sysRoot, const string& sysPath,
+                const string& base, const string& defName)  
+            :   system(0),
+                installRoot(insRoot), systemRoot(sysRoot), systemPath(sysPath),
+                defaultBaseURI(base), defaultComponentName(defName)
+        { 
+            logentry();
+
+            if (installRoot == "")
+            {
+                // Get install dir from environment variable TUSCANY_SCACPP
+                const char* root = getenv(TUSCANY_SCACPP);
+                if (root != NULL)
+                {
+                    installRoot = root;
+                }
+                else
+                {
+                    string msg = TUSCANY_SCACPP;
+                    msg += " environment variable not set";
+                    throwException(SystemConfigurationException, msg.c_str());
+                }
+            }
+            loginfo("SCA runtime install root: %s", installRoot.c_str());
         
+            if (systemRoot == "")
+            {
+                // Get root from environment variable TUSCANY_SCACPP_ROOT
+                char* systemRootEnv = getenv(TUSCANY_SCACPP_ROOT);
+                if (systemRootEnv == 0)
+                {
+                    // Get root from environment variable TUSCANY_SCACPP_SYSTEM_ROOT
+                    systemRootEnv = getenv(TUSCANY_SCACPP_SYSTEM_ROOT);
+                }
+                if (systemRootEnv == 0)
+                {
+                    string msg = TUSCANY_SCACPP_ROOT;
+                    msg += " environment variable not set";
+                    throwException(SystemConfigurationException, msg.c_str());
+                } 
 
-        // ==========================================================
-        // Set the system configuration root
-        // ==========================================================
-        void SCARuntime::setSystemRoot(const string& root)
-        {
+                systemRoot = systemRootEnv;
+            }
+            else
+            {
+                loginfo("System root: %s", systemRoot.c_str());
+            }
+            
+            if (systemPath == "")
+            {
+                
+                // Get system path from environment variable TUSCANY_SCACPP_PATH
+                char* systemPathEnv = getenv(TUSCANY_SCACPP_PATH);
+                if (systemPathEnv != 0)
+                {
+                    systemPath = systemPathEnv;
+                }
+            }
+            else
+            {
+                loginfo("System path: %s", systemPath.c_str());
+            }
+
+            if (defaultBaseURI == "")
+            {
+                
+                // Get default base URI from environment variable TUSCANY_SCACPP_BASE_URI
+                char* baseURI = getenv(TUSCANY_SCACPP_BASE_URI);
+                if (baseURI != 0)
+                {
+                    defaultBaseURI = baseURI;
+                }
+            }
+            else
+            {
+                loginfo("Default base URI: %s", defaultBaseURI.c_str());
+            }
+
+            if (defaultComponentName == "")
+            {
+                const char* defComp = getenv(TUSCANY_SCACPP_COMPONENT);
+                if (!defComp)
+                {
+                    defComp = getenv(TUSCANY_SCACPP_DEFAULT_COMPONENT);
+                }
+                if (defComp)
+                {
+                    defaultComponentName = defComp;
+                }
+            }
+            loginfo("Default component: %s", defaultComponentName.c_str());
+            
+            SCARuntime* currentRuntime = (SCARuntime*)current.getValue();
+            current.setValue(this);
+            try
+            {
+
+                // Load the runtime extensions
+                loadExtensions();
+    
+                // Load the system composite
+                loadSystem();
+            }
+            catch (...)
+            {
+                current.setValue(currentRuntime);
+                throw;
+            }
+            current.setValue(currentRuntime);
+    
+            // Find the default component
+            if (defaultComponentName != "")
+            {
+                Component* comp = system->findComponent(defaultComponentName);
+                if (!comp)
+                {
+                    string message = "Component \'" + defaultComponentName + "\' not found";
+                    throwException(SystemConfigurationException, message.c_str());
+                }
+                defaultComponent.setValue(comp);
+            }
+                    
+        }
+
+        // ===================================================================
+        // Destructor for the SCARuntime class. 
+        // ===================================================================
+        SCARuntime::~SCARuntime()
+        { 
             logentry();
-            systemRoot = root;
-            loginfo("System root: %s", root.c_str());
+
+            if (system)
+            {
+                delete system;
+            }
         }
 
         // ==========================================================
@@ -84,17 +211,7 @@
         }
 
         // ==========================================================
-        // Set the system configuration root
-        // ==========================================================
-        void SCARuntime::setSystemPath(const string& path)
-        {
-            logentry();
-            systemPath = path;
-            loginfo("System path: %s", path.c_str());
-        }
-
-        // ==========================================================
-        // Set the system configuration root
+        // Returns the system path
         // ==========================================================
         const string& SCARuntime::getSystemPath()
         {
@@ -102,16 +219,6 @@
         }
 
         // ==========================================================
-        // Set the default component name
-        // ==========================================================
-        void SCARuntime::setDefaultComponentName(const string& componentName)
-        {
-            logentry();
-            defaultComponentName = componentName;
-            loginfo("Default component name: %s", componentName.c_str());
-        }
-
-        // ==========================================================
         // Returns the default component name
         // ==========================================================
         const string& SCARuntime::getDefaultComponentName()
@@ -120,16 +227,6 @@
         }
 
         // ==========================================================
-        // Set the default base URI
-        // ==========================================================
-        void SCARuntime::setDefaultBaseURI(const string& baseURI)
-        {
-            logentry();
-            defaultBaseURI = baseURI;
-            loginfo("Default base URI: %s", baseURI.c_str());
-        }
-
-        // ==========================================================
         // Returns the default base URI
         // ==========================================================
         const string& SCARuntime::getDefaultBaseURI()
@@ -138,16 +235,6 @@
         }
 
         // ==========================================================
-        // Set the install root
-        // ==========================================================
-        void SCARuntime::setInstallRoot(const string& root)
-        {
-            logentry();
-            installRoot = root;
-            loginfo("SCA runtime install root: %s", installRoot.c_str());
-        }
-
-        // ==========================================================
         // Returns the install root
         // ==========================================================
         const string& SCARuntime::getInstallRoot()
@@ -155,144 +242,80 @@
             return installRoot;
         }
 
-        // ===================================================================
-        // Constructor for the SCARuntime class. This will be a singleton that
-        // holds all the information about the current runtime.
-        // ===================================================================
-        SCARuntime::SCARuntime() : system(0), defaultComponent(0)
-        { 
-            logentry();
-        }
-
-        // ===================================================================
-        // Destructor for the SCARuntime class. 
-        // ===================================================================
-        SCARuntime::~SCARuntime()
-        { 
-            logentry();
-
-            if (system)
-            {
-                delete system;
-            }
-            
-        }
-
         // =============================================================
-        // Get the instance of the runtime, creates it if does not exist
-        // static method
+        // Get the runtime associated with the current thread.
         // =============================================================
-        SCARuntime* SCARuntime::getInstance()
+        SCARuntime* SCARuntime::getCurrentRuntime()
         {
             logentry();
             
-            if (instance == NULL) 
+            SCARuntime* runtime = (SCARuntime*)current.getValue();
+            if (runtime == NULL)
             {
-                if (installRoot == "")
-                {
-                    // Get install dir from environment variable TUSCANY_SCACPP
-                    const char* root = getenv(TUSCANY_SCACPP);
-                    if (root != NULL)
-                    {
-                        loginfo("SCA runtime install root: %s", root);
-                        installRoot = root;
-                    }
-                    else
-                    {
-                        string msg = TUSCANY_SCACPP;
-                        msg += " environment variable not set";
-                        throwException(SystemConfigurationException, msg.c_str());
-                    }
-                }
-            
-                if (systemRoot == "")
-                {
-                    // Get root from environment variable TUSCANY_SCACPP_ROOT
-                    char* systemRootEnv = getenv(TUSCANY_SCACPP_ROOT);
-                    if (systemRootEnv == 0)
-                    {
-                        // Get root from environment variable TUSCANY_SCACPP_SYSTEM_ROOT
-                        systemRootEnv = getenv(TUSCANY_SCACPP_SYSTEM_ROOT);
-                    }
-                    if (systemRootEnv == 0)
-                    {
-                        string msg = TUSCANY_SCACPP_ROOT;
-                        msg += " environment variable not set";
-                        throwException(SystemConfigurationException, msg.c_str());
-                    } 
-
-                    loginfo("System root: %s", systemRootEnv);
-                    systemRoot = systemRootEnv;
-                }
-                if (systemPath == "")
+                runtime = getSharedRuntime();
+                if (runtime != NULL)
                 {
-                    
-                    // Get system path from environment variable TUSCANY_SCACPP_PATH
-                    char* systemPathEnv = getenv(TUSCANY_SCACPP_PATH);
-                    if (systemPathEnv != 0)
-                    {
-                        loginfo("System path: %s", systemPathEnv);
-                        systemPath = systemPathEnv;
-                    }
+                    setCurrentRuntime(runtime);
                 }
-                if (defaultBaseURI == "")
+                else
                 {
-                    
-                    // Get default base URI from environment variable TUSCANY_SCACPP_BASE_URI
-                    char* baseURI = getenv(TUSCANY_SCACPP_BASE_URI);
-                    if (baseURI != 0)
-                    {
-                        loginfo("Default base URI: %s", baseURI);
-                        defaultBaseURI = baseURI;
-                    }
+                    runtime = new SCARuntime();
+                    setCurrentRuntime(runtime);
                 }
+            }
+            loginfo("Runtime: %p", runtime);            
+            return runtime;
+        }
 
-                // Create new instance of the runtime
-                instance = new SCARuntime();
-                
-                // load extensions
-                instance->loadExtensions();
+        // =============================================================
+        // Set the runtime associated with the current thread.
+        // =============================================================
+        void SCARuntime::setCurrentRuntime(SCARuntime* runtime)
+        {
+            logentry();
 
-            }
+            loginfo("Runtime: %p", runtime);            
+            current.setValue(runtime);
+        }
+
+        // =============================================================
+        // Get the runtime associated with the current process.
+        // =============================================================
+        SCARuntime* SCARuntime::getSharedRuntime()
+        {
+            logentry();
             
-            return instance;
+            sharedRuntimeLock.lock();
+            SCARuntime* runtime = sharedRuntime;
+            sharedRuntimeLock.unlock();
             
+            return runtime;
         }
 
-
         // =============================================================
-        // Release the instance of the runtime.
+        // Set the runtime associated with the current process.
         // =============================================================
-        void SCARuntime::releaseInstance()
+        void SCARuntime::setSharedRuntime(SCARuntime* runtime)
         {
             logentry();
             
-            if (instance) 
-            {
-                delete instance;
-                instance = 0;
-                systemRoot = "";
-                systemPath = "";
-                defaultComponentName = "";        
-            }
+            sharedRuntimeLock.lock();
+            sharedRuntime = runtime;
+            sharedRuntimeLock.unlock();
         }
 
         // ======================================
-        // Load up all the details of the runtime
+        // Load the system composite
         // ======================================
-        void SCARuntime::load()
+        void SCARuntime::loadSystem()
         {
             logentry();
-            
-            loginfo("Configuration root: %s", systemRoot.c_str());
-            loginfo("Configuration path: %s", systemPath.c_str());
-            
-            // Load the system composite
-            ModelLoader loader(system);
+
+            system = new Composite("tuscany/sca/system", "");
+            ModelLoader loader(this, system);
             loader.load(systemRoot, systemPath);
         }
         
-        
         // ======================================
         // Load up extensions to the runtime
         // ======================================
@@ -422,11 +445,7 @@
         Composite* SCARuntime::getSystem()
         {
             logentry();
-            if (!system)
-            {
-                system = new Composite("tuscany/sca/system", "");
-                load();
-            }
+
             return system;
         }
 
@@ -438,22 +457,14 @@
         {
             logentry();
 
-#if defined(WIN32)  || defined (_WINDOWS)
-            DWORD currentThreadId = GetCurrentThreadId();
-#else
-            pthread_t currentThreadId = pthread_self();
-#endif
-            COMPONENTS_MAP::iterator iter = components.find(currentThreadId);
-            if (iter == components.end())
+            COMPONENT_STACK* compStack = (COMPONENT_STACK*)componentStack.getValue();
+            if (compStack == NULL)
             {
-                components[currentThreadId] = COMPONENT_STACK();
-                iter = components.find(currentThreadId);
+                compStack = new COMPONENT_STACK();
+                componentStack.setValue(compStack);
             }
-            
-            COMPONENT_STACK& compStack = iter->second;
-            compStack.push(component);
+            compStack->push(component);
         }
-
         
         // ====================================================
         // unsetCurrentComponent: pop component for this thread
@@ -462,25 +473,18 @@
         {
             logentry();
             
-#if defined(WIN32)  || defined (_WINDOWS)
-            DWORD currentThreadId = GetCurrentThreadId();
-#else
-            pthread_t currentThreadId = pthread_self();
-#endif
-
-            COMPONENTS_MAP::iterator iter = components.find(currentThreadId);
-            if (iter != components.end())
-            {    
-                COMPONENT_STACK& compStack = iter->second;
-                if (compStack.size() > 0)
+            COMPONENT_STACK* compStack = (COMPONENT_STACK*)componentStack.getValue();
+            if (compStack != NULL)
+            {
+                if (compStack->size() > 0)
                 {
-                    Component* component = compStack.top();
-                    compStack.pop();
+                    Component* component = compStack->top();
+                    compStack->pop();
                     return component;
                 }
             }
             
-            return 0;
+            return NULL;
         }
         
         // =============================================================
@@ -490,29 +494,16 @@
         {
             logentry();
             
-#if defined(WIN32)  || defined (_WINDOWS)
-            DWORD currentThreadId = GetCurrentThreadId();
-#else
-            pthread_t currentThreadId = pthread_self();
-#endif
-
-            COMPONENTS_MAP::iterator iter = components.find(currentThreadId);
-            if (iter == components.end())
-            {
-                components[currentThreadId] = COMPONENT_STACK();
-                iter = components.find(currentThreadId);
-            }
-            
-            COMPONENT_STACK& compStack = iter->second;
-            if (compStack.size() > 0)
-            {
-                return compStack.top();
-            }
-            else
+            COMPONENT_STACK* compStack = (COMPONENT_STACK*)componentStack.getValue();
+            if (compStack != NULL)
             {
-                return 0;
+                if (compStack->size() > 0)
+                {
+                    return compStack->top();
+                }
             }
             
+            return NULL;
         }
         
         // ===========================================
@@ -521,44 +512,29 @@
         Component* SCARuntime::getDefaultComponent()
         {
             logentry();
-
-            // -------------------------------------------
-            // Get the default component name from the environment
-            // -------------------------------------------
-            if (defaultComponentName == "")
-            {
-                const char* defComp = getenv(TUSCANY_SCACPP_COMPONENT);
-                if (!defComp)
-                {
-                    defComp = getenv(TUSCANY_SCACPP_DEFAULT_COMPONENT);
-                }
-                if (!defComp)
-                {
-                    string message = TUSCANY_SCACPP_COMPONENT;
-                    message += " environment variable not set";
-                    throwException(SystemConfigurationException, message.c_str());
-                }
-                defaultComponentName = defComp;
-            }
-                    
-            // -------------------------------------------
-            // Get the default component
-            // -------------------------------------------
-            if (defaultComponent && defaultComponentName != defaultComponent->getName())
-            {
-                defaultComponent = NULL;
-            }
-            if (!defaultComponent)
+            
+            Component* comp = (Component*)defaultComponent.getValue();
+            if (comp == NULL && defaultComponentName != "")
             {
-                
-                defaultComponent = getSystem()->findComponent(defaultComponentName);
-                if (!defaultComponent)
+                comp = system->findComponent(defaultComponentName);
+                if (!comp)
                 {
                     string message = "Component \'" + defaultComponentName + "\' not found";
                     throwException(SystemConfigurationException, message.c_str());
                 }
+                defaultComponent.setValue(comp);
             }
-            return defaultComponent;        
+            return comp;
+        }
+                
+        // ===========================================
+        // Set the default composite component
+        // ===========================================
+        void SCARuntime::setDefaultComponent(Component* component)
+        {
+            logentry();
+            
+            return defaultComponent.setValue(component);
         }
                 
     } // 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?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- 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 Wed Jan  3 22:51:33 2007
@@ -41,6 +41,8 @@
 #include "tuscany/sca/model/Composite.h"
 #include "tuscany/sca/model/Component.h"
 #include "tuscany/sca/util/Library.h"
+#include "tuscany/sca/util/ThreadLocal.h"
+#include "tuscany/sca/util/Mutex.h"
 
 
 namespace tuscany
@@ -49,83 +51,71 @@
     {
         
         /**
-         * A singleton which represents the executing SCA runtime.
+         * Represents an executing SCA runtime.
          */
         class SCARuntime {
         public:
-
-            /**
-             * Get the single instance.
-             * @return The single instance of the runtime.
-             */
-            SCA_API static SCARuntime* getInstance();
-
-            /**
-             * Release the single instance.
-             */
-            SCA_API static void releaseInstance();
-          
+        
             /**
-             * Load the SCA configuration from the scdl files (sca.composite, 
-             * *.fragment, etc).
-             * This will create the runtime model from which the SCA runtime
-             * will operate.
+             * Constructor
              */
-            SCA_API void load();
+             SCA_API SCARuntime(const std::string& installRoot = "",
+                const std::string& systemRoot = "", const std::string& systemPath = "",
+                const std::string& baseURI = "", const std::string& defaultComponentName = "");
 
             /**
-             * Set the directory in which the Tuscany runtime has been installed.
+             * Destructor
              */
-            SCA_API static void setInstallRoot(const std::string& root);
+             SCA_API virtual ~SCARuntime();
 
             /**
-             * Returns the directory in which the Tuscany runtime has been installed.
+             * Get the runtime associated with the current thread.
+             * @return The runtime associated with the current thread.
              */
-            SCA_API static const std::string& getInstallRoot();
+            SCA_API static SCARuntime* getCurrentRuntime();
 
             /**
-             * Set the system root
-             * @param root The path to the system configuration.
+             * Get the runtime associated with the current thread.
+             * @return The runtime associated with the current thread.
              */
-            SCA_API static void setSystemRoot(const std::string& root);
+            SCA_API static void setCurrentRuntime(SCARuntime* runtime);
 
             /**
-             * Returns the system root
+             * Get the runtime associated with the current process.
+             * @return The runtime associated with the current process.
              */
-            SCA_API static const std::string& getSystemRoot();
+            SCA_API static SCARuntime* getSharedRuntime();
 
             /**
-             * Set the search path for composites.
-             * @param path The search path for composites.
+             * Get the runtime associated with the current process.
+             * @return The runtime associated with the current process.
              */
-            SCA_API static void setSystemPath(const std::string& path);
+            SCA_API static void setSharedRuntime(SCARuntime* runtime);
 
             /**
-             * Returns the search path for composites.
+             * Returns the directory in which the Tuscany runtime has been installed.
              */
-            SCA_API static const std::string& getSystemPath();
+            SCA_API const std::string& getInstallRoot();
 
             /**
-             * Set the default Component for the system
-             * @param componentName The name of the default component.
+             * Returns the system root
              */
-            SCA_API static void setDefaultComponentName(const std::string& componentName);
+            SCA_API const std::string& getSystemRoot();
 
             /**
-             * Returns the default Component for the system
+             * Returns the search path for composites.
              */
-            SCA_API static const std::string& getDefaultComponentName();
+            SCA_API const std::string& getSystemPath();
 
             /**
-             * Set the default base URI for the system
-             * @param baseURI The default base URI.
+             * Returns the default component name.
              */
-            SCA_API static void setDefaultBaseURI(const std::string& baseURI);
+            SCA_API const std::string& getDefaultComponentName();
 
             /**
              * Returns the default base URI for the system
              */
-            SCA_API static const std::string& getDefaultBaseURI();
+            SCA_API const std::string& getDefaultBaseURI();
 
             /**
              * Set the current component for the current thread.
@@ -156,12 +146,18 @@
             SCA_API tuscany::sca::model::Component* getCurrentComponent();
 
             /**
-             * Get the default component set for this runtime.
+             * Get the default component set for the current thread.
              * @return The default composite.
              */
             SCA_API tuscany::sca::model::Component* getDefaultComponent();
 
             /**
+             * Get the default component set for the current thread.
+             * @return The default composite.
+             */
+            SCA_API void setDefaultComponent(tuscany::sca::model::Component* component);
+
+            /**
              * Register an implementation extension
              */
             SCA_API void registerImplementationExtension(ImplementationExtension* extension);
@@ -206,17 +202,17 @@
             SCA_API InterfaceExtension* getInterfaceExtension(const std::string& typeQname);
 
         private:
+
             /**
-             * Default constructor is private to prevent more than one instance.
+             * The runtime associated with the current thread.
              */
-            SCARuntime();            
-
-            virtual ~SCARuntime();            
-
+            static tuscany::sca::util::ThreadLocal current;
+            
             /**
-             * The single instance of this class.
+             * The runtime shared by all threads of the current process.
              */
-            static SCARuntime* instance;
+             static tuscany::sca::util::Mutex sharedRuntimeLock;
+             static SCARuntime* sharedRuntime;
 
             /**
              * Pointer to the top of the runtime model.
@@ -226,46 +222,50 @@
             /**
              * The installed path of the Tuscany runtime.
              */
-            static std::string installRoot;
+            std::string installRoot;
  
             /**
              * The path to the system configuration
              */
-            static std::string systemRoot;
+            std::string systemRoot;
 
             /**
              * The search path for composites.
              */
-            static std::string systemPath;
+            std::string systemPath;
 
             /**
-             * The default CompositeComponent.
+             * The default base URI.
              */
-            static std::string defaultComponentName;
+            std::string defaultBaseURI;
 
             /**
-             * The default base URI.
+             * The default CompositeComponent name.
+             */
+            std::string defaultComponentName;
+
+            /**
+             * Load the SCA configuration from the scdl files (sca.composite, 
+             * *.fragment, etc).
+             * This will create the runtime model from which the SCA runtime
+             * will operate.
              */
-            static std::string defaultBaseURI;
+            void loadSystem();
 
             /**
-             * The default component set for this runtime.
+             * Component stack for the current thread.
              */
-            tuscany::sca::model::Component* defaultComponent;
-            
-            
             typedef std::stack<tuscany::sca::model::Component*> COMPONENT_STACK; 
-#if defined(WIN32)  || defined (_WINDOWS)
-            typedef std::map<DWORD, COMPONENT_STACK> COMPONENTS_MAP;
-#else
-            typedef std::map<pthread_t, COMPONENT_STACK> COMPONENTS_MAP;
-#endif
-
+            tuscany::sca::util::ThreadLocal componentStack;  
+ 
             /**
-             * A map of threads to components.
+             * The default component for the current thread.
              */
-            COMPONENTS_MAP components;
+            tuscany::sca::util::ThreadLocal defaultComponent;  
  
+            /**
+             *  Runtime Extensions
+             */
             typedef std::map<std::string, ImplementationExtension*> IMPLEMENTATION_EXTENSIONS_MAP;
             IMPLEMENTATION_EXTENSIONS_MAP implementationExtensions;
 
@@ -278,7 +278,6 @@
             typedef std::map<std::string, InterfaceExtension*> INTERFACE_EXTENSIONS_MAP;
             INTERFACE_EXTENSIONS_MAP interfaceExtensions;
 
-            // Runtime Extensions
             void loadExtensions();
 
             typedef std::list<tuscany::sca::util::Library> EXTENSIONS_LIST;

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp Wed Jan  3 22:51:33 2007
@@ -60,11 +60,10 @@
             // ===========
             // Constructor
             // ===========
-            ModelLoader::ModelLoader(Composite* system) : system(system)
+            ModelLoader::ModelLoader(SCARuntime* runtime, Composite* system)
+                : system(system), runtime(runtime)
             {
                 logentry(); 
-                
-                runtime = SCARuntime::getInstance();
             }
             
             // ==========
@@ -872,7 +871,7 @@
                     try {
                     
                         // Load the Assembly model schema    
-                        string root = SCARuntime::getInstance()->getInstallRoot();
+                        string root = runtime->getInstallRoot();
                         string filename = root + "/xsd/sca.xsd";
                         
                         myXSDHelper->defineFile(filename.c_str());

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.h Wed Jan  3 22:51:33 2007
@@ -51,7 +51,7 @@
                  * Constructor.
                  * @param system The SCA system to load.
                  */
-                ModelLoader(Composite* system);
+                ModelLoader(tuscany::sca::SCARuntime* runtime, Composite* system);
 
                 /**
                  * Destructor.

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Logger.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Logger.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Logger.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Logger.cpp Wed Jan  3 22:51:33 2007
@@ -23,9 +23,11 @@
 #include <stdarg.h>
 
 #if defined(WIN32)  || defined (_WINDOWS)
+#include <windows.h>
 #include <process.h>
 #else
 #include <unistd.h>
+#include <pthread.h>
 #endif
 
 #include "tuscany/sca/util/Logger.h"
@@ -50,11 +52,11 @@
                 {
                     setLogWriter(0);
                     
-                    pid = new char[10];
+                    pid = new char[21];
 #if defined(WIN32)  || defined (_WINDOWS)
-                    sprintf(pid, "%d", _getpid());
+                    sprintf(pid, "%lu:%lu", (unsigned long)_getpid(), (unsigned long)GetCurrentThreadId());
 #else
-                    sprintf(pid, "%d", getpid());
+                    sprintf(pid, "%lu:%lu", (unsigned long)getpid(), (unsigned long)pthread_self());
 #endif
                 }
                 return logWriter;

Modified: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/ComponentContext.cpp Wed Jan  3 22:51:33 2007
@@ -46,7 +46,7 @@
             logentry();
             try
             {
-                Component* component = tuscany::sca::SCARuntime::getInstance()->getCurrentComponent();
+                Component* component = tuscany::sca::SCARuntime::getCurrentRuntime()->getCurrentComponent();
                 if (!component)
                 {
                     throwException(ComponentContextException, "No current component");

Modified: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/osoa/sca/CompositeContext.cpp Wed Jan  3 22:51:33 2007
@@ -53,7 +53,7 @@
         {
             logentry();
             impl = new CompositeContextImpl(
-                tuscany::sca::SCARuntime::getInstance()->getDefaultComponent());
+                tuscany::sca::SCARuntime::getCurrentRuntime()->getDefaultComponent());
         }
         
         // =============================
@@ -65,7 +65,7 @@
             if (this != &ctx)
             {
                 impl = new CompositeContextImpl(
-                    tuscany::sca::SCARuntime::getInstance()->getDefaultComponent());
+                    tuscany::sca::SCARuntime::getCurrentRuntime()->getDefaultComponent());
             }
             return *this;
         }
@@ -88,7 +88,7 @@
             try
             {
                 CompositeContext* cci = new CompositeContextImpl(
-                    tuscany::sca::SCARuntime::getInstance()->getDefaultComponent());
+                    tuscany::sca::SCARuntime::getCurrentRuntime()->getDefaultComponent());
                     
                 return CompositeContext(cci);
             }

Modified: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPExtension.cpp Wed Jan  3 22:51:33 2007
@@ -62,8 +62,9 @@
             void CPPExtension::initialize()
             { 
                 logentry();
-                SCARuntime::getInstance()->registerImplementationExtension(new CPPImplementationExtension());
-                SCARuntime::getInstance()->registerInterfaceExtension(new CPPInterfaceExtension());
+                SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+                runtime->registerImplementationExtension(new CPPImplementationExtension());
+                runtime->registerInterfaceExtension(new CPPInterfaceExtension());
             }
 
         } // End namespace cpp

Modified: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/CPPServiceWrapper.cpp Wed Jan  3 22:51:33 2007
@@ -111,7 +111,7 @@
             {
                 logentry();
     
-                SCARuntime* runtime = SCARuntime::getInstance();
+                SCARuntime* runtime = SCARuntime::getCurrentRuntime();
                 runtime->setCurrentComponent(component);
                 
                 try

Modified: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.cpp Wed Jan  3 22:51:33 2007
@@ -40,9 +40,14 @@
             TuscanyRuntime::TuscanyRuntime(const string& componentName, const string& root, const string& path)
             { 
                 logentry();
-                setSystemRoot(root);
-                setSystemPath(path);
-                setDefaultComponentName(componentName);           
+                loginfo("System root: %s", root.c_str());
+                systemRoot = root;
+                loginfo("System path: %s", path.c_str());
+                systemPath = path;
+                loginfo("Default component name: %s", componentName.c_str());
+                defaultComponentName = componentName;
+
+                runtime = new SCARuntime("", systemRoot, systemPath, "", defaultComponentName);
             }
     
             // ===================================================================
@@ -51,36 +56,8 @@
             TuscanyRuntime::~TuscanyRuntime()
             { 
                 logentry();
-            }
-    
-            // ==========================================================
-            // Set the system configuration root path
-            // ==========================================================
-            void TuscanyRuntime::setSystemRoot(const string& root)
-            {
-                logentry();
-                systemRoot = root;
-                loginfo("System root: %s", root.c_str());
-            }
-    
-            // ==========================================================
-            // Set the search path for composites
-            // ==========================================================
-            void TuscanyRuntime::setSystemPath(const string& path)
-            {
-                logentry();
-                systemPath = path;
-                loginfo("System path: %s", path.c_str());
-            }
-    
-            // ==========================================================
-            // Set the default component name
-            // ==========================================================
-            void TuscanyRuntime::setDefaultComponentName(const string& componentName)
-            {
-                logentry();
-                defaultComponentName = componentName;
-                loginfo("Default component name: %s", componentName.c_str());
+
+                delete (SCARuntime*)runtime;
             }
     
             // ===================================================================
@@ -88,11 +65,8 @@
             // ===================================================================
             void TuscanyRuntime::start()
             {
-                logentry(); 
-                SCARuntime::setSystemRoot(systemRoot);
-                SCARuntime::setSystemPath(systemPath);
-                SCARuntime::setDefaultComponentName(defaultComponentName);
-                SCARuntime::getInstance();
+                logentry();
+                SCARuntime::setCurrentRuntime((SCARuntime*)runtime);
             }
     
             // ===================================================================
@@ -101,7 +75,7 @@
             void TuscanyRuntime::stop()
             { 
                 logentry();
-                SCARuntime::releaseInstance();
+                SCARuntime::setCurrentRuntime(NULL);
             }
 
         } // End namespace cpp

Modified: incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/cpp/src/tuscany/sca/cpp/TuscanyRuntime.h Wed Jan  3 22:51:33 2007
@@ -50,25 +50,6 @@
                 */
                 virtual ~TuscanyRuntime();            
                 
-                
-                /**
-                * Set the system root configuration path
-                * @param root The path to the system configuration.
-                */
-                void setSystemRoot(const std::string& root);
-                
-                /**
-                * Set the system composite search path
-                * @param root The search path for composites.
-                */
-                void setSystemPath(const std::string& path);
-                
-                /**
-                * Set the default component for the system
-                * @param componentName The name of the default component.
-                */
-                void setDefaultComponentName(const std::string& componentName);
-                
                 /**
                 * start the runtime
                 */
@@ -84,6 +65,9 @@
                 std::string systemRoot;
                 std::string systemPath;
                 std::string defaultComponentName;
+                
+                void* defaultComponent;
+                void* runtime;
             };
     
         } // End namespace cpp

Modified: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPExtension.cpp Wed Jan  3 22:51:33 2007
@@ -61,7 +61,7 @@
             void PHPExtension::initialize()
             { 
                 logentry();
-                SCARuntime::getInstance()->registerImplementationExtension(new PHPImplementationExtension());
+                SCARuntime::getCurrentRuntime()->registerImplementationExtension(new PHPImplementationExtension());
                 //SCARuntime::getInstance()->registerInterfaceExtension(new PHPInterfaceExtension());
             }
 

Modified: incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/php/src/tuscany/sca/php/PHPServiceWrapper.cpp Wed Jan  3 22:51:33 2007
@@ -137,7 +137,7 @@
             {
                 logentry();
     
-                SCARuntime* runtime = SCARuntime::getInstance();
+                SCARuntime* runtime = SCARuntime::getCurrentRuntime();
                 runtime->setCurrentComponent(component);
                 
                 try

Modified: incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonExtension.cpp Wed Jan  3 22:51:33 2007
@@ -66,8 +66,9 @@
             void PythonExtension::initialize()
             { 
                 logentry();
-                SCARuntime::getInstance()->registerImplementationExtension(new PythonImplementationExtension());
-                SCARuntime::getInstance()->registerInterfaceExtension(new PythonInterfaceExtension());
+                SCARuntime* runtime = SCARuntime::getCurrentRuntime();
+                runtime->registerImplementationExtension(new PythonImplementationExtension());
+                runtime->registerInterfaceExtension(new PythonInterfaceExtension());
             }
 
         } // End namespace python

Modified: incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/PythonServiceWrapper.cpp Wed Jan  3 22:51:33 2007
@@ -253,7 +253,7 @@
             {
                 logentry();
     
-                SCARuntime* runtime = SCARuntime::getInstance();
+                SCARuntime* runtime = SCARuntime::getCurrentRuntime();
                 runtime->setCurrentComponent(component);
                 
 

Modified: incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/python/src/tuscany/sca/python/sca_module.cpp Wed Jan  3 22:51:33 2007
@@ -121,7 +121,7 @@
     logentry();
 
     tuscany::sca::python::PythonServiceProxy* serviceProxy = NULL;
-    SCARuntime* runtime = SCARuntime::getInstance();
+    SCARuntime* runtime = SCARuntime::getCurrentRuntime();
 
     // The first argument holds the name
     string name;
@@ -195,7 +195,7 @@
 
     // Get the component from the reference or service provided
     Component* component = NULL; 
-    SCARuntime* runtime = SCARuntime::getInstance();
+    SCARuntime* runtime = SCARuntime::getCurrentRuntime();
 
     PyObject* isReference = PyTuple_GetItem(args, 1);   
     if(PyObject_IsTrue(isReference))

Modified: incubator/tuscany/cpp/sca/runtime/extensions/rest/interface/src/tuscany/sca/rest/RESTInterfaceExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/rest/interface/src/tuscany/sca/rest/RESTInterfaceExtension.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/rest/interface/src/tuscany/sca/rest/RESTInterfaceExtension.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/rest/interface/src/tuscany/sca/rest/RESTInterfaceExtension.cpp Wed Jan  3 22:51:33 2007
@@ -83,7 +83,7 @@
            void RESTInterfaceExtension::initialize()
             { 
                 logentry();
-                SCARuntime::getInstance()->registerInterfaceExtension(new RESTInterfaceExtension());
+                SCARuntime::getCurrentRuntime()->registerInterfaceExtension(new RESTInterfaceExtension());
             }
 
         } // End namespace rest

Modified: incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceBindingExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceBindingExtension.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceBindingExtension.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceBindingExtension.cpp Wed Jan  3 22:51:33 2007
@@ -89,7 +89,7 @@
             void RESTServiceBindingExtension::initialize()
             { 
                 logentry();
-                SCARuntime::getInstance()->registerServiceBindingExtension(new RESTServiceBindingExtension());
+                SCARuntime::getCurrentRuntime()->registerServiceBindingExtension(new RESTServiceBindingExtension());
             }
 
         } // End namespace rest

Modified: incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/rest/reference/curl/src/tuscany/sca/rest/RESTServiceWrapper.cpp Wed Jan  3 22:51:33 2007
@@ -897,7 +897,7 @@
                 // Get the binding URI configured on the top level component 
                 Service* service = getService();
                 CompositeReference* compositeReference = (CompositeReference*)service->getComponent();
-                SCARuntime* runtime = SCARuntime::getInstance();
+                SCARuntime* runtime = SCARuntime::getCurrentRuntime();
                 Component* component = runtime->getDefaultComponent();
                 Reference* reference = component->findReference(compositeReference->getName());
                 if (reference != NULL)

Modified: incubator/tuscany/cpp/sca/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/ModREST.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/ModREST.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/ModREST.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/ModREST.cpp Wed Jan  3 22:51:33 2007
@@ -114,65 +114,49 @@
                 
                 try
                 {
-                    bool restart = false;
-                    bool resolve = false;
-            
-                    string systemRoot = SCARuntime::getSystemRoot();
-                    if (systemRoot != root)
-                    {
-                        systemRoot = root;
-                        restart = true;
-                        resolve = true;
-                    }
-            
-                    string systemPath = SCARuntime::getSystemPath();
-                    if (systemPath != path)
-                    {
-                        systemPath = path;
-                        restart = true;
-                        resolve = true;
-                    }
-            
-                    string componentName = SCARuntime::getDefaultComponentName();
-                    if (componentName != component)
+                    SCARuntime* runtime = SCARuntime::getSharedRuntime();
+                    if (runtime == NULL)
                     {
-                        componentName = component;
-                        resolve = true;
+                        runtime = new SCARuntime("", root, path, "", "");
+                        SCARuntime::setSharedRuntime(runtime);
                     }
-                    
-                    string serviceName = service;
-            
-                    SCARuntime* scaRuntime;
-                    if (restart)
-                    {
-                        loginfo("Starting SCA runtime");
-                        SCARuntime::releaseInstance();
-                        SCARuntime::setSystemRoot(systemRoot);
-                        SCARuntime::setSystemPath(systemPath);
-                        SCARuntime::setDefaultComponentName(componentName);
-                        scaRuntime = SCARuntime::getInstance();
-                    }
-                    else if (resolve)
-                    {
-                        loginfo("Starting SCA runtime");
-                        SCARuntime::releaseInstance();
-                        SCARuntime::setSystemRoot(systemRoot);
-                        SCARuntime::setSystemPath(systemPath);
-                        SCARuntime::setDefaultComponentName(componentName);
-                        scaRuntime = SCARuntime::getInstance();
+                    else
+                    {
+                        if (strlen(root) != 0 && runtime->getSystemRoot() != root)
+                        {
+                            string msg = "Cannot switch to a different system root: " + string(root);
+                            throwException(SystemConfigurationException, msg.c_str());
+                        }
+                        else
+                        {
+                            if (strlen(path) != 0 && runtime->getSystemPath() != path)
+                            {
+                                string msg = "Cannot switch to a different system path: " + string(path);
+                                throwException(SystemConfigurationException, msg.c_str());
+                            }
+                        }
+                    }
+
+                    string componentName;
+                    if (strlen(component))
+                    {
+                        componentName = component;
                     }
                     else
                     {
-                        scaRuntime = SCARuntime::getInstance();
+                        componentName = runtime->getDefaultComponentName();
                     }
-            
+                    string serviceName = service;
+                    
                     loginfo("Resolving composite: %s, service: %s", componentName.c_str(), serviceName.c_str());
-                    Component* compositeComponent = scaRuntime->getDefaultComponent();
+                    Component* compositeComponent = runtime->getSystem()->findComponent(componentName);
                     if (compositeComponent == NULL)
                     {
                         string msg = "Component not found " + componentName;
                         throwException(SystemConfigurationException, msg.c_str());
                     }
+                    runtime->setDefaultComponent(compositeComponent);
+
                     Composite* composite = (Composite*)compositeComponent->getType();
                     CompositeService* compositeService = (CompositeService*)composite->findComponent(serviceName);
                     if (compositeService == NULL)
@@ -180,7 +164,7 @@
                         string msg = "Composite service not found " + serviceName;
                         throwException(SystemConfigurationException, msg.c_str());
                     }
-                    
+                
                     return compositeService;
                 }
                 catch(TuscanyRuntimeException &ex)

Modified: incubator/tuscany/cpp/sca/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTReferenceBindingExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTReferenceBindingExtension.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTReferenceBindingExtension.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/rest/service/httpd/src/tuscany/sca/rest/RESTReferenceBindingExtension.cpp Wed Jan  3 22:51:33 2007
@@ -86,7 +86,7 @@
            void RESTReferenceBindingExtension::initialize()
             { 
                 logentry();
-                SCARuntime::getInstance()->registerReferenceBindingExtension(new RESTReferenceBindingExtension());
+                SCARuntime::getCurrentRuntime()->registerReferenceBindingExtension(new RESTReferenceBindingExtension());
             }
 
         } // End namespace rest

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyCompositeContext.cpp Wed Jan  3 22:51:33 2007
@@ -40,7 +40,7 @@
     {
         
         // Get the default component
-        Component* defaultComponent = tuscany::sca::SCARuntime::getInstance()->getDefaultComponent();
+        Component* defaultComponent = tuscany::sca::SCARuntime::getCurrentRuntime()->getDefaultComponent();
         Composite* composite = (Composite*)defaultComponent->getType();
                 
         // Locate the service

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyExtension.cpp Wed Jan  3 22:51:33 2007
@@ -64,7 +64,7 @@
             void RubyExtension::initialize()
             { 
                 logentry();
-                SCARuntime::getInstance()->registerImplementationExtension(new RubyImplementationExtension());
+                SCARuntime::getCurrentRuntime()->registerImplementationExtension(new RubyImplementationExtension());
             }
 
         } // End namespace ruby

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ruby/src/tuscany/sca/ruby/RubyServiceWrapper.cpp Wed Jan  3 22:51:33 2007
@@ -118,7 +118,7 @@
             {
                 logentry();
     
-                SCARuntime* runtime = SCARuntime::getInstance();
+                SCARuntime* runtime = SCARuntime::getCurrentRuntime();
                 runtime->setCurrentComponent(component);
                 
                 try

Modified: incubator/tuscany/cpp/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/SCAServiceBindingExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/SCAServiceBindingExtension.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/SCAServiceBindingExtension.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/sca/reference/axis2c/src/tuscany/sca/binding/SCAServiceBindingExtension.cpp Wed Jan  3 22:51:33 2007
@@ -92,7 +92,7 @@
             void SCAServiceBindingExtension::initialize()
             { 
                 logentry();
-                SCARuntime::getInstance()->registerServiceBindingExtension(new SCAServiceBindingExtension());
+                SCARuntime::getCurrentRuntime()->registerServiceBindingExtension(new SCAServiceBindingExtension());
             }
 
         } // End namespace ws

Modified: incubator/tuscany/cpp/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/SCAReferenceBindingExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/SCAReferenceBindingExtension.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/SCAReferenceBindingExtension.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/sca/service/axis2c/src/tuscany/sca/binding/SCAReferenceBindingExtension.cpp Wed Jan  3 22:51:33 2007
@@ -91,7 +91,7 @@
            void SCAReferenceBindingExtension::initialize()
             { 
                 logentry();
-                SCARuntime::getInstance()->registerReferenceBindingExtension(new SCAReferenceBindingExtension());
+                SCARuntime::getCurrentRuntime()->registerReferenceBindingExtension(new SCAReferenceBindingExtension());
             }
 
         } // End namespace binding

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp Wed Jan  3 22:51:33 2007
@@ -180,7 +180,7 @@
 
                 // Get the URI configured on the top level component                
                 string bindingURI = "";
-                SCARuntime* runtime = SCARuntime::getInstance();
+                SCARuntime* runtime = SCARuntime::getCurrentRuntime();
                 Component* component = runtime->getDefaultComponent();
                 Reference* reference = component->findReference(compositeReference->getName());
                 if (reference != NULL)

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceBindingExtension.cpp Wed Jan  3 22:51:33 2007
@@ -103,7 +103,7 @@
             void WSServiceBindingExtension::initialize()
             { 
                 logentry();
-                SCARuntime::getInstance()->registerServiceBindingExtension(new WSServiceBindingExtension());
+                SCARuntime::getCurrentRuntime()->registerServiceBindingExtension(new WSServiceBindingExtension());
             }
 
         } // End namespace ws

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp Wed Jan  3 22:51:33 2007
@@ -139,65 +139,49 @@
                 
                 try
                 {
-                    bool restart = false;
-                    bool resolve = false;
-            
-                    string systemRoot = SCARuntime::getSystemRoot();
-                    if (systemRoot != root)
+                    SCARuntime* runtime = SCARuntime::getSharedRuntime();
+                    if (runtime == NULL)
                     {
-                        systemRoot = root;
-                        restart = true;
-                        resolve = true;
+                        runtime = new SCARuntime("", root, path, "", "");
+                        SCARuntime::setSharedRuntime(runtime);
                     }
-            
-                    string systemPath = SCARuntime::getSystemPath();
-                    if (systemPath != path)
+                    else
                     {
-                        systemPath = path;
-                        restart = true;
-                        resolve = true;
-                    }
-            
-                    string componentName = SCARuntime::getDefaultComponentName();
-                    if (componentName != component)
+                        if (strlen(root) != 0 && runtime->getSystemRoot() != root)
+                        {
+                            string msg = "Cannot switch to a different system root: " + string(root);
+                            throwException(SystemConfigurationException, msg.c_str());
+                        }
+                        else
+                        {
+                            if (strlen(path) != 0 && runtime->getSystemPath() != path)
+                            {
+                                string msg = "Cannot switch to a different system path: " + string(path);
+                                throwException(SystemConfigurationException, msg.c_str());
+                            }
+                        }
+                    }
+
+                    string componentName;
+                    if (strlen(component))
                     {
                         componentName = component;
-                        resolve = true;
-                    }
-                    
-                    string serviceName = service;
-            
-                    SCARuntime* scaRuntime;
-                    if (restart)
-                    {
-                        loginfo("Starting SCA runtime");
-                        SCARuntime::releaseInstance();
-                        SCARuntime::setSystemRoot(systemRoot);
-                        SCARuntime::setSystemPath(systemPath);
-                        SCARuntime::setDefaultComponentName(componentName);
-                        scaRuntime = SCARuntime::getInstance();
-                    }
-                    else if (resolve)
-                    {
-                        loginfo("Starting SCA runtime");
-                        SCARuntime::releaseInstance();
-                        SCARuntime::setSystemRoot(systemRoot);
-                        SCARuntime::setSystemPath(systemPath);
-                        SCARuntime::setDefaultComponentName(componentName);
-                        scaRuntime = SCARuntime::getInstance();
                     }
                     else
                     {
-                        scaRuntime = SCARuntime::getInstance();
+                        componentName = runtime->getDefaultComponentName();
                     }
-            
+                    string serviceName = service;
+                    
                     loginfo("Resolving composite: %s, service: %s", componentName.c_str(), serviceName.c_str());
-                    Component* compositeComponent = scaRuntime->getDefaultComponent();
+                    Component* compositeComponent = runtime->getSystem()->findComponent(componentName);
                     if (compositeComponent == NULL)
                     {
                         string msg = "Component not found " + componentName;
                         throwException(SystemConfigurationException, msg.c_str());
                     }
+                    runtime->setDefaultComponent(compositeComponent);
+
                     Composite* composite = (Composite*)compositeComponent->getType();
                     CompositeService* compositeService = (CompositeService*)composite->findComponent(serviceName);
                     if (compositeService == NULL)

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp?view=diff&rev=492428&r1=492427&r2=492428
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp Wed Jan  3 22:51:33 2007
@@ -102,7 +102,7 @@
            void WSReferenceBindingExtension::initialize()
             { 
                 logentry();
-                SCARuntime::getInstance()->registerReferenceBindingExtension(new WSReferenceBindingExtension());
+                SCARuntime::getCurrentRuntime()->registerReferenceBindingExtension(new WSReferenceBindingExtension());
             }
 
         } // End namespace ws



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