diff options
author | Benoit Foucher <benoit@zeroc.com> | 2002-12-05 22:31:29 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2002-12-05 22:31:29 +0000 |
commit | 7abe0bb2e951d22f67f34d38bd4892f30ad901bb (patch) | |
tree | 4844d8f0ed9c4988f5ec8988aa313b1f47f15162 /cpp/src/IcePack/ComponentBuilder.cpp | |
parent | Added support for object lookup by identity (diff) | |
download | ice-7abe0bb2e951d22f67f34d38bd4892f30ad901bb.tar.bz2 ice-7abe0bb2e951d22f67f34d38bd4892f30ad901bb.tar.xz ice-7abe0bb2e951d22f67f34d38bd4892f30ad901bb.zip |
Added IcePack object registry.
Added support for locator object lookup by identity.
Added Query interface to lookup objects by type.
Changed the IcePack.Registry.Locator properties to IcePack.Registry.Client
Changed the IcePack.Registry.LocatorRegistry properties to
IcePack.Registry.Se rver
Added IcePack demo
Minor fixes and clean-up
Diffstat (limited to 'cpp/src/IcePack/ComponentBuilder.cpp')
-rw-r--r-- | cpp/src/IcePack/ComponentBuilder.cpp | 100 |
1 files changed, 98 insertions, 2 deletions
diff --git a/cpp/src/IcePack/ComponentBuilder.cpp b/cpp/src/IcePack/ComponentBuilder.cpp index 5edfa69f486..03d5b36bddf 100644 --- a/cpp/src/IcePack/ComponentBuilder.cpp +++ b/cpp/src/IcePack/ComponentBuilder.cpp @@ -14,6 +14,7 @@ #include <Ice/Ice.h> #include <IcePack/ComponentBuilder.h> +#include <IcePack/Internal.h> #include <Yellow/Yellow.h> #include <xercesc/parsers/SAXParser.hpp> @@ -23,7 +24,6 @@ #include <unistd.h> #include <dirent.h> -#include <stack> #include <iterator> #include <fstream> @@ -273,6 +273,83 @@ private: Ice::ObjectPrx _proxy; }; +// +// Register an identity. +// +class RegisterObject : public Task +{ +public: + + RegisterObject(const ObjectRegistryPrx& registry, const ObjectDescription& desc) : + _registry(registry), + _desc(desc) + { + } + + virtual void + execute() + { + try + { + _registry->add(_desc); + } + catch(const ObjectExistsException& lex) + { + ostringstream os; + os << "couldn't add the object:\n" << lex << ends; + + ObjectDeploymentException ex; + ex.reason = os.str(); + ex.proxy = _desc.proxy; + throw ex; + } + catch(const Ice::LocalException& lex) + { + ostringstream os; + os << "couldn't contact the object registry:\n" << lex << ends; + + ObjectDeploymentException ex; + ex.reason = os.str(); + ex.proxy = _desc.proxy; + throw ex; + } + } + + virtual void + undo() + { + try + { + _registry->remove(_desc.proxy); + } + catch(const ObjectNotExistException& ex) + { + ostringstream os; + os << "couldn't remove the object:\n" << ex << ends; + + ObjectDeploymentException ex; + ex.reason = os.str(); + ex.proxy = _desc.proxy; + throw ex; + } + catch(const Ice::LocalException& lex) + { + ostringstream os; + os << "couldn't contact the object registry:\n" << lex << ends; + + ObjectDeploymentException ex; + ex.reason = os.str(); + ex.proxy = _desc.proxy; + throw ex; + } + } + +private: + + ObjectRegistryPrx _registry; + ObjectDescription _desc; +}; + } IcePack::DeploySAXParseException::DeploySAXParseException(const string& msg, const Locator*const locator) @@ -378,9 +455,15 @@ IcePack::ComponentHandler::startElement(const XMLCh *const name, AttributeList & else if(str == "offer") { _builder.addOffer(getAttributeValue(attrs, "interface"), - _currentAdapterId, + _currentAdapterId, getAttributeValue(attrs, "identity")); } + else if(str == "object") + { + _builder.addObject(getAttributeValue(attrs, "identity"), + _currentAdapterId, + getAttributeValue(attrs, "type")); + } else if(str == "target") { if(!_currentTarget.empty()) @@ -734,6 +817,19 @@ IcePack::ComponentBuilder::addOffer(const string& offer, const string& adapterId } void +IcePack::ComponentBuilder::addObject(const string& id, const string& adapterId, const string& type) +{ + assert(!adapterId.empty()); + + ObjectDescription desc; + desc.proxy = _communicator->stringToProxy(id + "@" + adapterId); + desc.type = type; + desc.adapterId = adapterId; + + _tasks.push_back(new RegisterObject(_objectRegistry, desc)); +} + +void IcePack::ComponentBuilder::overrideBaseDir(const string& basedir) { if(basedir[0] == '/') |