diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2009-10-26 14:55:24 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2009-10-26 14:55:24 -0230 |
commit | 20899304e74276a6d9c12ae9f713901e6ebfc840 (patch) | |
tree | 5970a5ff612c59e4bc3147908756ec742a1d09aa /cpp/src | |
parent | Fixed Windows link error (diff) | |
download | ice-20899304e74276a6d9c12ae9f713901e6ebfc840.tar.bz2 ice-20899304e74276a6d9c12ae9f713901e6ebfc840.tar.xz ice-20899304e74276a6d9c12ae9f713901e6ebfc840.zip |
Bug 3137 - add proxyToProperty
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/CommunicatorI.cpp | 23 | ||||
-rw-r--r-- | cpp/src/Ice/CommunicatorI.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 1 | ||||
-rw-r--r-- | cpp/src/Ice/ProxyFactory.cpp | 13 | ||||
-rw-r--r-- | cpp/src/Ice/ProxyFactory.h | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.cpp | 45 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.h | 8 |
7 files changed, 79 insertions, 14 deletions
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp index 86e1fc4fba1..52f92570241 100644 --- a/cpp/src/Ice/CommunicatorI.cpp +++ b/cpp/src/Ice/CommunicatorI.cpp @@ -171,6 +171,12 @@ Ice::CommunicatorI::propertyToProxy(const string& p) const return _instance->proxyFactory()->propertyToProxy(p); } +PropertyDict +Ice::CommunicatorI::proxyToProperty(const ObjectPrx& proxy, const string& property) const +{ + return _instance->proxyFactory()->proxyToProperty(proxy, property); +} + Identity Ice::CommunicatorI::stringToIdentity(const string& s) const { @@ -198,6 +204,7 @@ Ice::CommunicatorI::createObjectAdapterWithEndpoints(const string& name, const s ex.reason = "Cannot configure endpoints with nameless object adapter"; throw ex; } + getProperties()->setProperty(name + ".Endpoints", endpoints); return _instance->objectAdapterFactory()->createObjectAdapter(name, 0); } @@ -215,21 +222,11 @@ Ice::CommunicatorI::createObjectAdapterWithRouter(const string& name, const Rout // // We set the proxy properties here, although we still use the proxy supplied. // - getProperties()->setProperty(name + ".Router", proxyToString(router)); - if(router->ice_getLocator() != 0) + PropertyDict properties = proxyToProperty(router, name + ".Router"); + for(PropertyDict::const_iterator p = properties.begin(); p != properties.end(); ++p) { - ObjectPrx locator = ::IceInternal::upCast(router->ice_getLocator().get()); - getProperties()->setProperty(name + ".Router.Locator", proxyToString(locator)); + getProperties()->setProperty(p->first, p->second); } - getProperties()->setProperty(name + ".Router.CollocationOptimized", - router->ice_isCollocationOptimized() ? "0" : "1"); - getProperties()->setProperty(name + ".Router.ConnectionCached", router->ice_isConnectionCached() ? "0" : "1"); - getProperties()->setProperty(name + ".Router.PreferSecure", router->ice_isPreferSecure() ? "0" : "1"); - getProperties()->setProperty(name + ".Router.EndpointSelection", - router->ice_getEndpointSelection() == Random ? "Random" : "Ordered"); - ostringstream s; - s << router->ice_getLocatorCacheTimeout(); - getProperties()->setProperty(name + ".Router.LocatorCacheTimeout", s.str()); return _instance->objectAdapterFactory()->createObjectAdapter(name, router); } diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h index 0d4b42fb4f6..5dde3ec2231 100644 --- a/cpp/src/Ice/CommunicatorI.h +++ b/cpp/src/Ice/CommunicatorI.h @@ -32,6 +32,7 @@ public: virtual std::string proxyToString(const ObjectPrx&) const; virtual ObjectPrx propertyToProxy(const std::string&) const; + virtual PropertyDict proxyToProperty(const ObjectPrx&, const std::string&) const; virtual Identity stringToIdentity(const std::string&) const; virtual std::string identityToString(const Identity&) const; diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index d455a3d917b..17ed6098795 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -513,7 +513,6 @@ IceInternal::Instance::identityToString(const Identity& ident) const } } - Ice::ObjectPrx IceInternal::Instance::getAdmin() { diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp index f139c87222d..37ffe383e64 100644 --- a/cpp/src/Ice/ProxyFactory.cpp +++ b/cpp/src/Ice/ProxyFactory.cpp @@ -55,6 +55,19 @@ IceInternal::ProxyFactory::propertyToProxy(const string& prefix) const return referenceToProxy(ref); } +PropertyDict +IceInternal::ProxyFactory::proxyToProperty(const ObjectPrx& proxy, const string& prefix) const +{ + if(proxy) + { + return proxy->__reference()->toProperty(prefix); + } + else + { + return PropertyDict(); + } +} + ObjectPrx IceInternal::ProxyFactory::streamToProxy(BasicStream* s) const { diff --git a/cpp/src/Ice/ProxyFactory.h b/cpp/src/Ice/ProxyFactory.h index c50adb86bcf..a3fee45fc6c 100644 --- a/cpp/src/Ice/ProxyFactory.h +++ b/cpp/src/Ice/ProxyFactory.h @@ -18,6 +18,7 @@ #include <Ice/ProxyF.h> #include <Ice/Exception.h> #include <Ice/OutgoingAsyncF.h> +#include <Ice/Properties.h> namespace IceInternal { @@ -32,6 +33,7 @@ public: std::string proxyToString(const Ice::ObjectPrx&) const; Ice::ObjectPrx propertyToProxy(const std::string&) const; + Ice::PropertyDict proxyToProperty(const Ice::ObjectPrx&, const std::string&) const; Ice::ObjectPrx streamToProxy(BasicStream*) const; void proxyToStream(const Ice::ObjectPrx&, BasicStream*) const; diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index a4e41555f85..b29b0843b1d 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -637,6 +637,15 @@ IceInternal::FixedReference::toString() const return string(); // To keep the compiler from complaining. } +PropertyDict +IceInternal::FixedReference::toProperty(const string&) const +{ + throw FixedProxyException(__FILE__, __LINE__); + + assert(false); // Cannot be reached. + return PropertyDict(); // To keep the compiler from complaining. +} + ConnectionIPtr IceInternal::FixedReference::getConnection(bool& compress) const { @@ -1133,6 +1142,42 @@ IceInternal::RoutableReference::toString() const return result; } +PropertyDict +IceInternal::RoutableReference::toProperty(const string& prefix) const +{ + Ice::PropertyDict properties; + + properties[prefix] = toString(); + properties[prefix + ".CollocationOptimized"] = _collocationOptimized ? "1" : "0"; + properties[prefix + ".ConnectionCached"] = _cacheConnection ? "1" : "0"; + properties[prefix + ".PreferSecure"] = _preferSecure ? "1" : "0"; + properties[prefix + ".EndpointSelection"] = _endpointSelection == Random ? "Random" : "Ordered"; + + ostringstream s; + s << _locatorCacheTimeout; + properties[prefix + ".LocatorCacheTimeout"] = s.str(); + + if(_routerInfo) + { + PropertyDict routerProperties = _routerInfo->getRouter()->__reference()->toProperty(prefix + ".Router"); + for(PropertyDict::const_iterator p = routerProperties.begin(); p != routerProperties.end(); ++p) + { + properties[p->first] = p->second; + } + } + + if(_locatorInfo) + { + PropertyDict locatorProperties = _locatorInfo->getLocator()->__reference()->toProperty(prefix + ".Locator"); + for(PropertyDict::const_iterator p = locatorProperties.begin(); p != locatorProperties.end(); ++p) + { + properties[p->first] = p->second; + } + } + + return properties; +} + int IceInternal::RoutableReference::hashInit() const { diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index 3d2b9b4701c..cba3efb6d39 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -23,6 +23,7 @@ #include <Ice/ConnectionIF.h> #include <Ice/SharedContext.h> #include <Ice/Identity.h> +#include <Ice/Properties.h> namespace IceInternal { @@ -117,6 +118,11 @@ public: virtual std::string toString() const; // + // Convert the refernce to its property form. + // + virtual Ice::PropertyDict toProperty(const std::string&) const = 0; + + // // Get a suitable connection for this reference. // virtual Ice::ConnectionIPtr getConnection(bool&) const = 0; @@ -189,6 +195,7 @@ public: virtual void streamWrite(BasicStream*) const; virtual std::string toString() const; + virtual Ice::PropertyDict toProperty(const std::string&) const; virtual Ice::ConnectionIPtr getConnection(bool&) const; virtual void getConnection(const GetConnectionCallbackPtr&) const; @@ -244,6 +251,7 @@ public: virtual void streamWrite(BasicStream*) const; virtual std::string toString() const; + virtual Ice::PropertyDict toProperty(const std::string&) const; virtual bool operator==(const Reference&) const; virtual bool operator!=(const Reference&) const; |