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/LocatorI.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/LocatorI.cpp')
-rw-r--r-- | cpp/src/IcePack/LocatorI.cpp | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/cpp/src/IcePack/LocatorI.cpp b/cpp/src/IcePack/LocatorI.cpp index 57af5cf4a48..032d18a1fd4 100644 --- a/cpp/src/IcePack/LocatorI.cpp +++ b/cpp/src/IcePack/LocatorI.cpp @@ -19,12 +19,58 @@ using namespace std; using namespace IcePack; IcePack::LocatorI::LocatorI(const AdapterRegistryPtr& adapterRegistry, + const ObjectRegistryPtr& objectRegistry, const Ice::LocatorRegistryPrx& locatorRegistry) : _adapterRegistry(adapterRegistry), + _objectRegistry(objectRegistry), _locatorRegistry(locatorRegistry) { } +// +// Find an object by identity. The object is searched in the object +// registry. If found and if the object was registered with an +// adapter, we get the adapter direct proxy and return a proxy created +// from the adapter direct proxy and the object identity. We could +// just return the registered proxy but this would be less efficient +// since the client would have to make a second call to find out the +// adapter direct proxy. +// +Ice::ObjectPrx +IcePack::LocatorI::findObjectById(const Ice::Identity& id, const Ice::Current& current) const +{ + ObjectDescription obj; + + try + { + obj = _objectRegistry->getObjectDescription(id); + } + catch(const ObjectNotExistException&) + { + throw Ice::ObjectNotFoundException(); + } + + if(!obj.adapterId.empty()) + { + try + { + Ice::ObjectPrx directProxy = findAdapterById(obj.adapterId, current); + if(directProxy) + { + return directProxy->ice_newIdentity(id); + } + } + catch(Ice::AdapterNotFoundException&) + { + // + // Ignore. + // + } + } + + return obj.proxy; +} + Ice::ObjectPrx IcePack::LocatorI::findAdapterById(const string& id, const Ice::Current&) const { @@ -44,14 +90,14 @@ IcePack::LocatorI::findAdapterById(const string& id, const Ice::Current&) const } catch(const AdapterNotExistException&) { - throw Ice::AdapterNotRegisteredException(); + throw Ice::AdapterNotFoundException(); } catch(const Ice::ObjectNotExistException&) { // // Expected if the adapter is destroyed. // - throw Ice::AdapterNotRegisteredException(); + throw Ice::AdapterNotFoundException(); } catch(const Ice::NoEndpointException&) { |