summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/ObjectAdapterFactory.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2001-09-15 00:42:58 +0000
committerMarc Laukien <marc@zeroc.com>2001-09-15 00:42:58 +0000
commitc66468d7a202d6a013fbfb294872374463937455 (patch)
tree36ac0d4f0de03f0985d96b6c6abb044d9e926fc2 /cpp/src/Ice/ObjectAdapterFactory.cpp
parentendpoint selection fixes (diff)
downloadice-c66468d7a202d6a013fbfb294872374463937455.tar.bz2
ice-c66468d7a202d6a013fbfb294872374463937455.tar.xz
ice-c66468d7a202d6a013fbfb294872374463937455.zip
streamlined object adpater
Diffstat (limited to 'cpp/src/Ice/ObjectAdapterFactory.cpp')
-rw-r--r--cpp/src/Ice/ObjectAdapterFactory.cpp51
1 files changed, 46 insertions, 5 deletions
diff --git a/cpp/src/Ice/ObjectAdapterFactory.cpp b/cpp/src/Ice/ObjectAdapterFactory.cpp
index adbe8e80f71..0de58ac0ee6 100644
--- a/cpp/src/Ice/ObjectAdapterFactory.cpp
+++ b/cpp/src/Ice/ObjectAdapterFactory.cpp
@@ -47,21 +47,62 @@ IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name, const
}
ObjectPtr
-IceInternal::ObjectAdapterFactory::proxyToObject(const ObjectPrx& proxy)
+IceInternal::ObjectAdapterFactory::proxyToServant(const ObjectPrx& proxy)
{
- map<string, ObjectAdapterPtr>::iterator p;
- for (p = _adapters.begin(); p != _adapters.end(); ++p)
+ if (_adapters.empty())
+ {
+ //
+ // If there are no adapters at all, no endpoint can ever be
+ // local, and no object can exist locally. We indicate this by
+ // returning null to the caller.
+ //
+ return 0;
+ }
+
+ bool allEndpointsLocal = true;
+
+ for (map<string, ObjectAdapterPtr>::iterator p = _adapters.begin(); p != _adapters.end(); ++p)
{
try
{
- return p->second->proxyToObject(proxy);
+ ObjectPtr servant = p->second->proxyToServant(proxy);
+ if (servant)
+ {
+ //
+ // Servant found, return it to the caller
+ //
+ return servant;
+ }
}
catch(const WrongObjectAdapterException&)
{
+ //
+ // A WrongObjectAdapter exception indicates that there is
+ // no endpoint from the proxy that matches at least one
+ // endpoint from the object adapter. That means that we
+ // have at least one non-local endpoint in the proxy.
+ //
+ allEndpointsLocal = false;
}
}
- return 0;
+ if (allEndpointsLocal)
+ {
+ //
+ // If we didn't find a servant even though all endpoints are
+ // local, we throw an ObjectNotExistException.
+ //
+ throw ObjectNotExistException(__FILE__, __LINE__);
+ }
+ else
+ {
+ //
+ // If at least one of the endpoints from the proxy are not
+ // local, it might be possible that the object exists
+ // remotely. We indicate this by returning null to the caller.
+ //
+ return 0;
+ }
}
IceInternal::ObjectAdapterFactory::ObjectAdapterFactory(const InstancePtr& instance) :