diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-11-30 15:27:49 -0500 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-11-30 15:27:49 -0500 |
commit | e5c6f17ce67f71bacdc4d2a01be487907e08f8cc (patch) | |
tree | 1289b3dd8e93fe0e36be8ecdff2f024bb1c57271 /cpp/src/IceBox/ServiceManagerI.cpp | |
parent | Merge branch 'master' of ssh://cvs.zeroc.com/home/git/ice (diff) | |
download | ice-e5c6f17ce67f71bacdc4d2a01be487907e08f8cc.tar.bz2 ice-e5c6f17ce67f71bacdc4d2a01be487907e08f8cc.tar.xz ice-e5c6f17ce67f71bacdc4d2a01be487907e08f8cc.zip |
Added Properties facet to IceBox services
Diffstat (limited to 'cpp/src/IceBox/ServiceManagerI.cpp')
-rw-r--r-- | cpp/src/IceBox/ServiceManagerI.cpp | 74 |
1 files changed, 59 insertions, 15 deletions
diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp index d85a4f2f1ca..88ee6a99ed4 100644 --- a/cpp/src/IceBox/ServiceManagerI.cpp +++ b/cpp/src/IceBox/ServiceManagerI.cpp @@ -52,9 +52,31 @@ private: ServiceObserverPrx _observer; }; -} +class PropertiesAdminI : public PropertiesAdmin +{ +public: + + PropertiesAdminI(const PropertiesPtr& properties) : + _properties(properties) + { + } + + virtual string getProperty(const string& name, const Current&) + { + return _properties->getProperty(name); + } + + virtual PropertyDict getPropertiesForPrefix(const string& prefix, const Current&) + { + return _properties->getPropertiesForPrefix(prefix); + } + +private: + const PropertiesPtr _properties; +}; +} IceBox::ServiceManagerI::ServiceManagerI(CommunicatorPtr communicator, int& argc, char* argv[]) : @@ -355,20 +377,6 @@ IceBox::ServiceManagerI::start() cout << bundleName << " ready" << endl; } - if(adapter) - { - try - { - adapter->activate(); - } - catch(const ObjectAdapterDeactivatedException&) - { - // - // Expected if the communicator has been shutdown. - // - } - } - // // Register "this" as a facet to the Admin object, and then create // Admin object @@ -376,6 +384,18 @@ IceBox::ServiceManagerI::start() try { _communicator->addAdminFacet(this, "IceBox.ServiceManager"); + + // + // Add a Properties facet for each service + // + for(vector<ServiceInfo>::iterator r = _services.begin(); r != _services.end(); ++r) + { + const ServiceInfo& info = *r; + CommunicatorPtr communicator = info.communicator != 0 ? info.communicator : _communicator; + _communicator->addAdminFacet(new PropertiesAdminI(communicator->getProperties()), + "IceBox.Service." + info.name + ".Properties"); + } + _communicator->getAdmin(); } catch(const ObjectAdapterDeactivatedException&) @@ -384,6 +404,20 @@ IceBox::ServiceManagerI::start() // Expected if the communicator has been shutdown. // } + + if(adapter) + { + try + { + adapter->activate(); + } + catch(const ObjectAdapterDeactivatedException&) + { + // + // Expected if the communicator has been shutdown. + // + } + } } catch(const FailureException& ex) { @@ -702,6 +736,7 @@ IceBox::ServiceManagerI::stopAll() for(p = _services.rbegin(); p != _services.rend(); ++p) { ServiceInfo& info = *p; + if(info.active) { try @@ -734,6 +769,15 @@ IceBox::ServiceManagerI::stopAll() { try { + _communicator->removeAdminFacet("IceBox.Service." + info.name + ".Properties"); + } + catch(const LocalException&) + { + // Ignored + } + + try + { info.communicator->shutdown(); info.communicator->waitForShutdown(); } |