You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ro...@apache.org on 2006/05/22 18:05:19 UTC

svn commit: r408703 - in /incubator/tuscany/cpp/sca/runtime/core: src/tuscany/sca/core/SCARuntime.cpp src/tuscany/sca/core/SCARuntime.h src/tuscany/sca/core/TuscanyRuntime.cpp test/src/TestSCA.cpp

Author: robbinspg
Date: Mon May 22 09:05:18 2006
New Revision: 408703

URL: http://svn.apache.org/viewvc?rev=408703&view=rev
Log:
TUSCANY-401 Add TuscanyRuntime class to control initialization

Modified:
    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/core/TuscanyRuntime.cpp
    incubator/tuscany/cpp/sca/runtime/core/test/src/TestSCA.cpp

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/core/SCARuntime.cpp?rev=408703&r1=408702&r2=408703&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 May 22 09:05:18 2006
@@ -98,6 +98,21 @@
             LOGEXIT(1, "SCARuntime::constructor");
         }
 
+        // ===================================================================
+        // Destructor for the SCARuntime class. 
+        // ===================================================================
+        SCARuntime::~SCARuntime()
+        { 
+            LOGENTRY(1, "SCARuntime::destructor");
+
+            if (system)
+            {
+                delete system;
+            }
+            
+            LOGEXIT(1, "SCARuntime::destructor");
+        }
+
         // =============================================================
         // Get the instance of the runtime, creates it if does not exist
         // static method
@@ -133,6 +148,25 @@
             
             return instance;
             
+        }
+
+
+        // =============================================================
+        // Release the instance of the runtime.
+        // =============================================================
+        void SCARuntime::releaseInstance()
+        {
+            LOGENTRY(1, "SCARuntime::releaseInstance");
+            
+            if (instance) 
+            {
+                delete instance;
+                instance = 0;
+                systemRoot = "";
+                defaultModuleName = "";        
+            }
+            
+            LOGEXIT(1, "SCARuntime::releaseInstance");           
         }
 
         // ======================================

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=408703&r1=408702&r2=408703&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 May 22 09:05:18 2006
@@ -56,7 +56,11 @@
              */
             SCA_API static SCARuntime* getInstance();
 
-            
+            /**
+             * Release the single instance.
+             */
+            SCA_API static void releaseInstance();
+          
             /**
              * Set the system root
              * @param root The path to the deployed system.
@@ -116,6 +120,8 @@
              * Default constructor is private to prevent more than one instance.
              */
             SCARuntime();            
+
+            virtual ~SCARuntime();            
 
             /**
              * Load the SCA configuration from the scdl files (sca.module, 

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=408703&r1=408702&r2=408703&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 May 22 09:05:18 2006
@@ -89,7 +89,8 @@
         // ===================================================================
         void TuscanyRuntime::stop()
         { 
-            LOGENTRY(1, "TuscanyRuntime::stop");          
+            LOGENTRY(1, "TuscanyRuntime::stop");
+            SCARuntime::releaseInstance();
             LOGEXIT(1, "TuscanyRuntime::stop");
         }
 

Modified: incubator/tuscany/cpp/sca/runtime/core/test/src/TestSCA.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/test/src/TestSCA.cpp?rev=408703&r1=408702&r2=408703&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/test/src/TestSCA.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/test/src/TestSCA.cpp Mon May 22 09:05:18 2006
@@ -34,16 +34,15 @@
 
     // Set default module
 
+    TuscanyRuntime runtime("", "SubSystem1");
     try
     {
-        TuscanyRuntime runtime("", "SubSystem1");
         runtime.start();
 
         // Locate a service
         ModuleContext myContext = ModuleContext::getCurrent();
         ModuleContext myContext2 = myContext;
-
-        
+       
         MyValue* myService = (MyValue*) myContext.locateService("MyValueServiceComponent");
         if (myService == 0)
         {
@@ -79,5 +78,7 @@
     {
         cout << ex << endl;
     }
+
+    runtime.stop();
     return 0;
 }



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