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 12:03:44 UTC
svn commit: r408626 - in /incubator/tuscany/cpp/sca: projects/tuscany_sca/
projects/tuscany_sca/tuscany_sca/ runtime/core/src/tuscany/sca/core/
runtime/core/src/tuscany/sca/model/ runtime/core/test/src/
Author: robbinspg
Date: Mon May 22 03:03:43 2006
New Revision: 408626
URL: http://svn.apache.org/viewvc?rev=408626&view=rev
Log:
TUSCANY-401 Add TuscanyRuntime class to control initialization
Modified:
incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca.ncb
incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca.opt
incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca/tuscany_sca.dsp
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/test/src/TestSCA.cpp
Modified: incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca.ncb
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca.ncb?rev=408626&r1=408625&r2=408626&view=diff
==============================================================================
Binary files - no diff available.
Modified: incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca.opt
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca.opt?rev=408626&r1=408625&r2=408626&view=diff
==============================================================================
Binary files - no diff available.
Modified: incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca/tuscany_sca.dsp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca/tuscany_sca.dsp?rev=408626&r1=408625&r2=408626&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca/tuscany_sca.dsp (original)
+++ incubator/tuscany/cpp/sca/projects/tuscany_sca/tuscany_sca/tuscany_sca.dsp Mon May 22 03:03:43 2006
@@ -223,6 +223,14 @@
SOURCE=..\..\..\runtime\core\src\tuscany\sca\core\ServiceWrapper.h
# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\runtime\core\src\tuscany\sca\core\TuscanyRuntime.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\runtime\core\src\tuscany\sca\core\TuscanyRuntime.h
+# End Source File
# End Group
# Begin Group "model"
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=408626&r1=408625&r2=408626&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 03:03:43 2006
@@ -47,8 +47,32 @@
// Initialize static class member to not pointing at anything
// ==========================================================
SCARuntime* SCARuntime::instance = 0;
+ string SCARuntime::systemRoot = "";
+ string SCARuntime::defaultModuleName = "";
+ // ==========================================================
+ // Set the system configuration root
+ // ==========================================================
+ void SCARuntime::setSystemRoot(const string& root)
+ {
+ LOGENTRY(1, "SCARuntime::");
+ systemRoot = root;
+ LOGINFO_1(3, "SCARuntime::setSystemRoot - set to %s", root.c_str());
+ LOGEXIT(1, "SCARuntime::setSystemRoot");
+ }
+
+ // ==========================================================
+ // Set the default ModuleComponent name
+ // ==========================================================
+ void SCARuntime::setDefaultModuleComponent(const string& moduleComponent)
+ {
+ LOGENTRY(1, "SCARuntime::setDefaultModuleComponent");
+ defaultModuleName = moduleComponent;
+ LOGINFO_1(3, "SCARuntime::setDefaultModuleComponent - set to %s", moduleComponent.c_str());
+ LOGEXIT(1, "SCARuntime::setDefaultModuleComponent");
+ }
+
// ===================================================================
// Constructor for the SCARuntime class. This will be a singleton that
// holds all the information about the current runtime.
@@ -85,16 +109,23 @@
if (instance == NULL)
{
instance = new SCARuntime();
-
- // Load the runtime
- // Get root from environment variable TUSCANY_SCACPP_SYSTEM_ROOT
- char* systemRoot = getenv(TUSCANY_SCACPP_SYSTEM_ROOT);
- if (systemRoot == 0)
+
+ if (systemRoot == "")
{
- string msg = TUSCANY_SCACPP_SYSTEM_ROOT;
- msg += " environment variable not set";
- throw SystemConfigurationException(msg.c_str());
+
+ // Load the runtime
+ // Get root from environment variable TUSCANY_SCACPP_SYSTEM_ROOT
+ char* systemRootEnv = getenv(TUSCANY_SCACPP_SYSTEM_ROOT);
+ if (systemRootEnv == 0)
+ {
+ string msg = TUSCANY_SCACPP_SYSTEM_ROOT;
+ msg += " environment variable not set";
+ throw SystemConfigurationException(msg.c_str());
+ }
+
+ systemRoot = systemRootEnv;
}
+
instance->load(systemRoot);
}
@@ -107,12 +138,11 @@
// ======================================
// Load up all the details of the runtime
// ======================================
- void SCARuntime::load(const char *configurationRoot)
+ void SCARuntime::load(const string& configurationRoot)
{
LOGENTRY(1, "SCARuntime::load");
- std::string root = configurationRoot;
- LOGINFO_1(2,"configuration root: %s", configurationRoot);
+ LOGINFO_1(2,"configuration root: %s", configurationRoot.c_str());
ModelLoader loader(system);
// Load details of the module
@@ -234,16 +264,19 @@
// -------------------------------------------
// Get the default module from the environment
// -------------------------------------------
- const char* defMod = getenv(TUSCANY_SCACPP_DEFAULT_MODULE);
- if (!defMod)
+ if (defaultModuleName == "")
{
- message = TUSCANY_SCACPP_DEFAULT_MODULE;
- message += " environment variable not set";
- throw SystemConfigurationException(message.c_str());
+ const char* defMod = getenv(TUSCANY_SCACPP_DEFAULT_MODULE);
+ if (!defMod)
+ {
+ message = TUSCANY_SCACPP_DEFAULT_MODULE;
+ message += " environment variable not set";
+ throw SystemConfigurationException(message.c_str());
+ }
+ defaultModuleName = defMod;
}
-
string subsystemName, moduleName;
- Utils::tokeniseUri(defMod, subsystemName, moduleName);
+ Utils::tokeniseUri(defaultModuleName, subsystemName, moduleName);
// ---------------------------
// Subsystem must be specified
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=408626&r1=408625&r2=408626&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 03:03:43 2006
@@ -56,6 +56,19 @@
*/
SCA_API static SCARuntime* getInstance();
+
+ /**
+ * Set the system root
+ * @param root The path to the deployed system.
+ */
+ static void setSystemRoot(const string& root);
+
+ /**
+ * Set the default ModuleComponent for the system
+ * @param moduleComponent The name of the default moduleComponent.
+ */
+ static void setDefaultModuleComponent(const string& moduleComponent);
+
/**
* Set the current component for the current thread.
* @param component The current component.
@@ -113,7 +126,7 @@
* SCA runtime. Under this root will be the subsystems and modules
* directories.
*/
- void load(const char* configurationRoot);
+ void load(const string& configurationRoot);
/**
* The single instance of this class.
@@ -129,6 +142,16 @@
* The installed path of the Tuscany runtime.
*/
string SCARoot;
+
+ /**
+ * The path to the system root
+ */
+ static string systemRoot;
+
+ /**
+ * The default ModuleComponent.
+ */
+ static string defaultModuleName;
/**
* Get the default module set for this runtime.
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?rev=408626&r1=408625&r2=408626&view=diff
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/model/ModelLoader.cpp Mon May 22 03:03:43 2006
@@ -62,10 +62,10 @@
// This class has the responsibility for translating from
// the SCA scdl files to the SCA runtime's in memory model.
// =========================================================
- void ModelLoader::load(const char* configurationRoot)
+ void ModelLoader::load(const string& configurationRoot)
{
LOGENTRY(1, "ModelLoader::load");
- LOGINFO_1(2,"configuration root: %s", configurationRoot);
+ LOGINFO_1(2,"configuration root: %s", configurationRoot.c_str());
// The configuration root path will point to a directory structure:
// root/
@@ -86,7 +86,7 @@
// Load all the subsystems from any directory below the configuration root.
// Translate the subsystem information to the runtime information
// ========================================================================
- void ModelLoader::loadSubsystems(const char* configurationRoot)
+ void ModelLoader::loadSubsystems(const string& configurationRoot)
{
// Get all the sca.subsystem files in the module
LOGENTRY(1, "ModelLoader::loadSubsystems");
@@ -166,7 +166,7 @@
// Load all the modules from any directory below the configuration root.
// Translate the module information to the runtime information
// =====================================================================
- void ModelLoader::loadModules(const char* configurationRoot)
+ void ModelLoader::loadModules(const string& configurationRoot)
{
// Get all the sca.module files in the module
LOGENTRY(1, "ModelLoader::loadModules");
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?rev=408626&r1=408625&r2=408626&view=diff
==============================================================================
--- 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 Mon May 22 03:03:43 2006
@@ -58,7 +58,7 @@
* @param configurationRoot The location of the deployed SCA
* modules and subsystems.
*/
- void load(const char *configurationRoot);
+ void load(const string& configurationRoot);
private:
System* system;
@@ -70,11 +70,11 @@
const commonj::sdo::XSDHelperPtr getXSDHelper(void);
const commonj::sdo::XMLHelperPtr getXMLHelper(void);
- void loadSubsystems(const char *configurationRoot);
+ void loadSubsystems(const string& configurationRoot);
void loadSubsystemFile(const File& file);
void mapSubsystem(commonj::sdo::DataObjectPtr rootDO);
- void loadModules(const char *configurationRoot);
+ void loadModules(const string& configurationRoot);
void loadModuleFile(const File& file);
void mapModule(const string& moduleName, commonj::sdo::DataObjectPtr rootDO, std::string moduleRootDir);
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=408626&r1=408625&r2=408626&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 03:03:43 2006
@@ -22,6 +22,7 @@
#include "osoa/sca/sca.h"
#include <iostream>
using namespace osoa::sca;
+#include "tuscany/sca/core/TuscanyRuntime.h"
using namespace tuscany::sca;
#include "MyValue.h"
@@ -31,8 +32,13 @@
commonj::sdo::Logger::setLogging(20);
cout << "Start of SCA test" << endl;
+ // Set default module
+
try
{
+ TuscanyRuntime runtime("", "SubSystem1");
+ runtime.start();
+
// Locate a service
ModuleContext myContext = ModuleContext::getCurrent();
ModuleContext myContext2 = myContext;
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org