diff options
author | Mark Spruiell <mes@zeroc.com> | 2004-02-02 23:50:35 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2004-02-02 23:50:35 +0000 |
commit | 09ca6de92dee97c1fe981127ddb2713c8fefcafc (patch) | |
tree | ae21c2e760d4decbd0e81516607dc0d3b47f0f80 /cpp | |
parent | changing <dump> semantics to make contents, base class optional (diff) | |
download | ice-09ca6de92dee97c1fe981127ddb2713c8fefcafc.tar.bz2 ice-09ca6de92dee97c1fe981127ddb2713c8fefcafc.tar.xz ice-09ca6de92dee97c1fe981127ddb2713c8fefcafc.zip |
adding IceBox.LoadOrder property
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/CHANGES | 3 | ||||
-rw-r--r-- | cpp/doc/Properties.sgml | 19 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesI.cpp | 1 | ||||
-rw-r--r-- | cpp/src/IceBox/ServiceManagerI.cpp | 114 | ||||
-rw-r--r-- | cpp/src/IceBox/ServiceManagerI.h | 1 |
5 files changed, 102 insertions, 36 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES index d100fb03bb0..357a30ac841 100644 --- a/cpp/CHANGES +++ b/cpp/CHANGES @@ -1,6 +1,9 @@ Changes since version 1.2.0 --------------------------- +- Added the IceBox.LoadOrder property, which specifies the order + in which IceBox services are loaded. + - Added support for the Intel C++ compiler (v8.0) on Linux x86 - Removed the Ice.Daemon, Ice.DaemonNoChdir and Ice.DaemonNoClose diff --git a/cpp/doc/Properties.sgml b/cpp/doc/Properties.sgml index f8d4b024e0f..1ac37ffa3e4 100644 --- a/cpp/doc/Properties.sgml +++ b/cpp/doc/Properties.sgml @@ -1297,6 +1297,25 @@ are ready to be used. </section> </section> +<section><title>IceBox.LoadOrder</title> +<section><title>Synopsis</title> +<synopsis> +IceBox.LoadOrder=<replaceable>names</replaceable> +</synopsis> +</section> +<section> +<title>Description</title> +<para> +Determines the order in which services are loaded. The service manager +loads the services in the order they appear in +<replaceable>names</replaceable>, where each service name is separated +by a comma or whitespace. Any services not mentioned in +<replaceable>names</replaceable> are loaded afterward, in an undefined +order. +</para> +</section> +</section> + <section><title>IceBox.Service.<replaceable>name</replaceable></title> <section><title>Synopsis</title> <synopsis> diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp index 79749f3bdb1..af9500ccfd1 100644 --- a/cpp/src/Ice/PropertiesI.cpp +++ b/cpp/src/Ice/PropertiesI.cpp @@ -150,6 +150,7 @@ static const string iceProps[] = static const string iceBoxProps[] = { "DBEnvName.*", + "LoadOrder", "PrintServicesReady", "Service.*", "ServiceManager.AdapterId", diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp index 2d958c959c5..afe09839c46 100644 --- a/cpp/src/IceBox/ServiceManagerI.cpp +++ b/cpp/src/IceBox/ServiceManagerI.cpp @@ -69,52 +69,58 @@ IceBox::ServiceManagerI::run() adapter->add(obj, stringToIdentity(identity)); // + // Parse the IceBox.LoadOrder property. + // + string order = properties->getProperty("IceBox.LoadOrder"); + StringSeq loadOrder; + if(!order.empty()) + { + string::size_type beg = order.find_first_not_of(",\t "); + while(beg != string::npos) + { + string::size_type end = order.find_first_of(",\t ", beg); + if(end == string::npos) + { + loadOrder.push_back(order.substr(beg)); + beg = end; + } + else + { + loadOrder.push_back(order.substr(beg, end - beg)); + beg = order.find_first_not_of(",\t ", end); + } + } + } + + // // Load and start the services defined in the property set // with the prefix "IceBox.Service.". These properties should // have the following format: // // IceBox.Service.Foo=entry_point [args] // + // We load the services specified in IceBox.LoadOrder first, + // then load any remaining services. + // const string prefix = "IceBox.Service."; - PropertyDict services = properties->getPropertiesForPrefix(prefix); - PropertyDict::const_iterator p; - for(p = services.begin(); p != services.end(); ++p) - { - string name = p->first.substr(prefix.size()); - const string& value = p->second; - - // - // Separate the entry point from the arguments. - // - string entryPoint; - StringSeq args; - string::size_type pos = value.find_first_of(" \t\n"); - if(pos == string::npos) - { - entryPoint = value; - } - else + PropertyDict::iterator p; + for(StringSeq::const_iterator q = loadOrder.begin(); q != loadOrder.end(); ++q) + { + p = services.find(prefix + *q); + if(p == services.end()) { - entryPoint = value.substr(0, pos); - string::size_type beg = value.find_first_not_of(" \t\n", pos); - while(beg != string::npos) - { - string::size_type end = value.find_first_of(" \t\n", beg); - if(end == string::npos) - { - args.push_back(value.substr(beg)); - beg = end; - } - else - { - args.push_back(value.substr(beg, end - beg)); - beg = value.find_first_not_of(" \t\n", end); - } - } + FailureException ex(__FILE__, __LINE__); + ex.reason = "ServiceManager: no service definition for `" + *q + "'"; + throw ex; } - - start(name, entryPoint, args); + load(*q, p->second); + services.erase(p); + } + for(p = services.begin(); p != services.end(); ++p) + { + string name = p->first.substr(prefix.size()); + load(name, p->second); } // @@ -181,6 +187,42 @@ IceBox::ServiceManagerI::run() } void +IceBox::ServiceManagerI::load(const string& name, const string& value) +{ + // + // Separate the entry point from the arguments. + // + string entryPoint; + StringSeq args; + string::size_type pos = value.find_first_of(" \t\n"); + if(pos == string::npos) + { + entryPoint = value; + } + else + { + entryPoint = value.substr(0, pos); + string::size_type beg = value.find_first_not_of(" \t\n", pos); + while(beg != string::npos) + { + string::size_type end = value.find_first_of(" \t\n", beg); + if(end == string::npos) + { + args.push_back(value.substr(beg)); + beg = end; + } + else + { + args.push_back(value.substr(beg, end - beg)); + beg = value.find_first_not_of(" \t\n", end); + } + } + } + + start(name, entryPoint, args); +} + +void IceBox::ServiceManagerI::start(const string& service, const string& entryPoint, const StringSeq& args) { // diff --git a/cpp/src/IceBox/ServiceManagerI.h b/cpp/src/IceBox/ServiceManagerI.h index 791ca9fd985..d3add45a099 100644 --- a/cpp/src/IceBox/ServiceManagerI.h +++ b/cpp/src/IceBox/ServiceManagerI.h @@ -46,6 +46,7 @@ public: private: + void load(const std::string&, const std::string&); void start(const std::string&, const std::string&, const ::Ice::StringSeq&); void stopAll(); |