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/11 07:14:41 UTC
svn commit: r495137 - in /incubator/tuscany/cpp/sca/runtime:
core/src/tuscany/sca/core/
extensions/rest/service/httpd/src/tuscany/sca/rest/
extensions/ws/service/axis2c/src/tuscany/sca/ws/
Author: jsdelfino
Date: Wed Jan 10 22:14:40 2007
New Revision: 495137
URL: http://svn.apache.org/viewvc?view=rev&rev=495137
Log:
Changed initialization of SCARuntime to atomic in a multithreaded environment. Adjusted WS and REST bindings to this change. Added missing config parameters to configure the Tuscany install directory and SCA system base URI.
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/extensions/rest/service/httpd/src/tuscany/sca/rest/ModREST.cpp
incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.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?view=diff&rev=495137&r1=495136&r2=495137
==============================================================================
--- 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 10 22:14:40 2007
@@ -293,15 +293,61 @@
}
// =============================================================
- // Set the runtime associated with the current process.
+ // Initialize the runtime associated with the current process.
// =============================================================
- void SCARuntime::setSharedRuntime(SCARuntime* runtime)
+ SCARuntime* SCARuntime::initializeSharedRuntime(const string& installRoot, const string& systemRoot,
+ const string& systemPath, const string& baseURI, const string& defaultComponentName)
{
logentry();
+
+ SCARuntime* runtime;
sharedRuntimeLock.lock();
- sharedRuntime = runtime;
+ try
+ {
+ if (sharedRuntime == NULL)
+ {
+ sharedRuntime = new SCARuntime(installRoot, systemRoot, systemPath, baseURI, defaultComponentName);
+ }
+ else
+ {
+ if (installRoot.size() != 0 && sharedRuntime->getInstallRoot() != installRoot)
+ {
+ string msg = "Cannot reconfigure runtime installation directory: " + string(installRoot);
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ if (systemRoot.size() != 0 && sharedRuntime->getSystemRoot() != systemRoot)
+ {
+ string msg = "Cannot reconfigure SCA system root: " + string(systemRoot);
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ if (systemPath.size() != 0 && sharedRuntime->getSystemPath() != systemPath)
+ {
+ string msg = "Cannot reconfigure SCA system path: " + string(systemPath);
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ if (baseURI.size() != 0 && sharedRuntime->getDefaultBaseURI() != baseURI)
+ {
+ string msg = "Cannot reconfigure SCA system URI: " + string(baseURI);
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ if (defaultComponentName.size() != 0 && sharedRuntime->getDefaultComponentName() != defaultComponentName)
+ {
+ string msg = "Cannot reconfigure main SCA component: " + string(baseURI);
+ throwException(SystemConfigurationException, msg.c_str());
+ }
+ }
+
+ runtime = sharedRuntime;
+ }
+ catch (...)
+ {
+ sharedRuntimeLock.unlock();
+ throw;
+ }
sharedRuntimeLock.unlock();
+
+ return runtime;
}
// ======================================
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=495137&r1=495136&r2=495137
==============================================================================
--- 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 10 22:14:40 2007
@@ -87,10 +87,12 @@
SCA_API static SCARuntime* getSharedRuntime();
/**
- * Get the runtime associated with the current process.
+ * Initialize the runtime associated with the current process.
* @return The runtime associated with the current process.
*/
- SCA_API static void setSharedRuntime(SCARuntime* runtime);
+ SCA_API static SCARuntime* initializeSharedRuntime(const std::string& installRoot = "",
+ const std::string& systemRoot = "", const std::string& systemPath = "",
+ const std::string& baseURI = "", const std::string& defaultComponentName = "");
/**
* Returns the directory in which the Tuscany runtime has been installed.
@@ -152,8 +154,8 @@
SCA_API tuscany::sca::model::Component* getDefaultComponent();
/**
- * Get the default component set for the current thread.
- * @return The default composite.
+ * Set the default component for the current thread.
+ * @return The default component.
*/
SCA_API void setDefaultComponent(tuscany::sca::model::Component* component);
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=495137&r1=495136&r2=495137
==============================================================================
--- 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 10 22:14:40 2007
@@ -91,11 +91,12 @@
{
char * root;
char * path;
+ char * base_uri;
char * component;
} rest_dir_config_rec_t;
- CompositeService* initializeSCARuntime(
- const char* home, const char* root, const char* path, const char *component, const char* service);
+ CompositeService* initializeSCARuntime(const char* home, const char* root,
+ const char* path, const char* baseURI, const char *component, const char* service);
DataObjectPtr createPayload(DataFactoryPtr dataFactory,
Operation& operation, const WSDLOperation& wsdlOperation);
@@ -107,35 +108,20 @@
/**
* Initialize the SCA runtime
*/
- CompositeService* initializeSCARuntime(const char* home, const char* root, const char* path, const char *component, const char* service)
+ CompositeService* initializeSCARuntime(const char* home, const char* root,
+ const char* path, const char* baseURI, const char *component, const char* service)
{
logentry();
- loginfo("Root: %s, path: %s, component: %s, service: %s", root, path, component, service);
+ loginfo("Home: %s", home);
+ loginfo("Root: %s", root);
+ loginfo("Path: %s", path);
+ loginfo("Base URI: %s", baseURI);
+ loginfo("Component: %s", component);
+ loginfo("Service: %s", service);
try
{
- SCARuntime* runtime = SCARuntime::getSharedRuntime();
- if (runtime == NULL)
- {
- runtime = new SCARuntime("", root, path, "", "");
- SCARuntime::setSharedRuntime(runtime);
- }
- 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());
- }
- }
- }
+ SCARuntime* runtime = SCARuntime::initializeSharedRuntime(home, root, path, baseURI);
string componentName;
if (strlen(component))
@@ -365,7 +351,7 @@
// Initialize the SCA runtime
CompositeService* compositeService = initializeSCARuntime(
- server_conf->home, dir_conf->root, dir_conf->path, component.c_str(), service.c_str());
+ server_conf->home, dir_conf->root, dir_conf->path, dir_conf->base_uri, component.c_str(), service.c_str());
if(!compositeService)
{
@@ -1270,6 +1256,14 @@
return NULL;
}
+ const char *rest_set_base_uri(cmd_parms *cmd, void *c,
+ const char *arg)
+ {
+ rest_dir_config_rec_t *conf = (rest_dir_config_rec_t*)c;
+ conf->base_uri = apr_pstrdup(cmd->pool, arg);
+ return NULL;
+ }
+
const char *rest_set_component(cmd_parms *cmd, void *c,
const char *arg)
{
@@ -1286,6 +1280,8 @@
"Tuscany SCA composite search path"),
AP_INIT_TAKE1("TuscanyRoot", (const char*(*)())tuscany::sca::rest::rest_set_root, NULL, ACCESS_CONF,
"Tuscany root SCA configuration path"),
+ AP_INIT_TAKE1("TuscanyBaseURI", (const char*(*)())tuscany::sca::rest::rest_set_base_uri, NULL, ACCESS_CONF,
+ "Tuscany SCA system base URI"),
AP_INIT_TAKE1("TuscanyComponent", (const char*(*)())tuscany::sca::rest::rest_set_component, NULL, ACCESS_CONF,
"SCA component name"),
{NULL}
@@ -1322,6 +1318,7 @@
rest_dir_config_rec_t* conf = (rest_dir_config_rec_t* )apr_palloc(p, sizeof(*conf));
conf->path = "";
conf->root = "";
+ conf->base_uri = "";
conf->component = "";
return conf;
}
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=495137&r1=495136&r2=495137
==============================================================================
--- 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 10 22:14:40 2007
@@ -132,35 +132,20 @@
/**
* Initialize the SCA runtime
*/
- CompositeService* initializeSCARuntime(const char* root, const char* path, const char *component, const char* service)
+ CompositeService* initializeSCARuntime(const char*home, const char* root,
+ const char* path, const char* baseURI, const char *component, const char* service)
{
logentry();
- loginfo("Root: %s, path: %s, component: %s, service: %s", root, path, component, service);
+ loginfo("Home: %s", home);
+ loginfo("Root: %s", root);
+ loginfo("Path: %s", path);
+ loginfo("Base URI: %s", baseURI);
+ loginfo("Component: %s", component);
+ loginfo("Service: %s", service);
try
{
- SCARuntime* runtime = SCARuntime::getSharedRuntime();
- if (runtime == NULL)
- {
- runtime = new SCARuntime("", root, path, "", "");
- SCARuntime::setSharedRuntime(runtime);
- }
- 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());
- }
- }
- }
+ SCARuntime* runtime = SCARuntime::initializeSharedRuntime(home, root, path, baseURI);
string componentName;
if (strlen(component))
@@ -255,8 +240,12 @@
{
CompositeService* compositeService;
- // Get the Tuscany system root, path and composite service name from the Axis2
+ // Get the Tuscany home, system root, path and composite service name from the Axis2
// service parameters
+ char* homeParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyHome");
+ if (homeParam == NULL)
+ homeParam = "";
+
char* rootParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyRoot");
if (rootParam == NULL)
rootParam = "";
@@ -265,6 +254,10 @@
if (pathParam == NULL)
pathParam = "";
+ char* baseURIParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyBaseURI");
+ if (baseURIParam == NULL)
+ baseURIParam = "";
+
char* serviceParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyService");
if (serviceParam != NULL)
{
@@ -274,11 +267,11 @@
string component, service;
Utils::rTokeniseString("/", serviceParam, component, service);
- compositeService = initializeSCARuntime(rootParam, pathParam, component.c_str(), service.c_str());
+ compositeService = initializeSCARuntime(homeParam, rootParam, pathParam, baseURIParam, component.c_str(), service.c_str());
}
else {
- // Use the default system root and component, the service is
+ // Use the default home, system root and component, the service is
// derived from the target address
axis2_endpoint_ref_t *endpoint_ref = NULL;
endpoint_ref = AXIS2_MSG_CTX_GET_FROM(msg_ctx, env);
@@ -311,7 +304,7 @@
loginfo("System root: %s, component name: %s, service name: %s, operation name: %s",
rootParam, component.c_str(), service.c_str(), op_name.c_str());
- compositeService = initializeSCARuntime(rootParam, pathParam, component.c_str(), service.c_str());
+ compositeService = initializeSCARuntime(homeParam, rootParam, pathParam, baseURIParam, component.c_str(), service.c_str());
}
if(!compositeService)
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org