diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2006-11-24 17:29:58 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2006-11-24 17:29:58 +0000 |
commit | 1126cea5189d035934f98822078f2ae23d9739ec (patch) | |
tree | 759430bdf201db72abddcd9bb83bed6fb034a6d2 /cpp/src/Ice/ReferenceFactory.cpp | |
parent | Code cleanup (diff) | |
download | ice-1126cea5189d035934f98822078f2ae23d9739ec.tar.bz2 ice-1126cea5189d035934f98822078f2ae23d9739ec.tar.xz ice-1126cea5189d035934f98822078f2ae23d9739ec.zip |
Added propertyToProxy
Diffstat (limited to 'cpp/src/Ice/ReferenceFactory.cpp')
-rw-r--r-- | cpp/src/Ice/ReferenceFactory.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index 39770b2de32..c6b2a2a27f7 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -7,6 +7,7 @@ // // ********************************************************************** +#include <Ice/Communicator.h> #include <Ice/ReferenceFactory.h> #include <Ice/ProxyFactory.h> #include <Ice/LocalException.h> @@ -14,7 +15,9 @@ #include <Ice/EndpointI.h> #include <Ice/EndpointFactoryManager.h> #include <Ice/RouterInfo.h> +#include <Ice/Router.h> #include <Ice/LocatorInfo.h> +#include <Ice/Locator.h> #include <Ice/LoggerUtil.h> #include <Ice/BasicStream.h> #include <Ice/Properties.h> @@ -544,6 +547,78 @@ IceInternal::ReferenceFactory::create(const string& str) } ReferencePtr +IceInternal::ReferenceFactory::createFromProperties(const string& propertyPrefix) +{ + PropertiesPtr properties = _instance->initializationData().properties; + + ReferencePtr ref = create(properties->getProperty(propertyPrefix)); + if(!ref) + { + return 0; + } + + string property = propertyPrefix + ".Locator"; + if(!properties->getProperty(property).empty()) + { + ref = ref->changeLocator( + LocatorPrx::uncheckedCast(_communicator->propertyToProxy(property))); + } + + property = propertyPrefix + ".LocatorCacheTimeout"; + if(!properties->getProperty(property).empty()) + { + ref = ref->changeLocatorCacheTimeout(properties->getPropertyAsInt(property)); + } + + property = propertyPrefix + ".Router"; + if(!properties->getProperty(property).empty()) + { + ref = ref->changeRouter( + RouterPrx::uncheckedCast(_communicator->propertyToProxy(property))); + } + + property = propertyPrefix + ".PreferSecure"; + if(!properties->getProperty(property).empty()) + { + ref = ref->changePreferSecure(properties->getPropertyAsInt(property) > 0); + } + + property = propertyPrefix + ".ConnectionCached"; + if(!properties->getProperty(property).empty()) + { + ref = ref->changeCacheConnection(properties->getPropertyAsInt(property) > 0); + } + + property = propertyPrefix + ".EndpointSelection"; + if(!properties->getProperty(property).empty()) + { + string type = properties->getProperty(property); + if(type == "Random") + { + ref = ref->changeEndpointSelection(Random); + } + else if(type == "Ordered") + { + ref = ref->changeEndpointSelection(Ordered); + } + else + { + EndpointSelectionTypeParseException ex(__FILE__, __LINE__); + ex.str = type; + throw ex; + } + } + + property = propertyPrefix + ".CollocationOptimization"; + if(!properties->getProperty(property).empty()) + { + ref = ref->changeCollocationOptimization(properties->getPropertyAsInt(property) > 0); + } + + return ref; +} + +ReferencePtr IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) { // |