diff options
Diffstat (limited to 'cpp/src/Ice/ReferenceFactory.cpp')
-rw-r--r-- | cpp/src/Ice/ReferenceFactory.cpp | 656 |
1 files changed, 328 insertions, 328 deletions
diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index 9e2105beaa7..13348367d9a 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -38,7 +38,7 @@ IceInternal::ReferenceFactory::copy(const Reference* r) const if(!_instance) { - throw CommunicatorDestroyedException(__FILE__, __LINE__); + throw CommunicatorDestroyedException(__FILE__, __LINE__); } const Ice::Identity& ident = r->getIdentity(); @@ -52,14 +52,14 @@ IceInternal::ReferenceFactory::copy(const Reference* r) const ReferencePtr IceInternal::ReferenceFactory::create(const Identity& ident, - const SharedContextPtr& context, - const string& facet, - Reference::Mode mode, - bool secure, - bool preferSecure, - const vector<EndpointIPtr>& endpoints, - const RouterInfoPtr& routerInfo, - bool collocationOptimization, + const SharedContextPtr& context, + const string& facet, + Reference::Mode mode, + bool secure, + bool preferSecure, + const vector<EndpointIPtr>& endpoints, + const RouterInfoPtr& routerInfo, + bool collocationOptimization, bool cacheConnection, EndpointSelectionType endpointSelection, bool threadPerConnection) @@ -68,7 +68,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, if(!_instance) { - throw CommunicatorDestroyedException(__FILE__, __LINE__); + throw CommunicatorDestroyedException(__FILE__, __LINE__); } if(ident.name.empty() && ident.category.empty()) @@ -80,31 +80,31 @@ IceInternal::ReferenceFactory::create(const Identity& ident, // Create new reference // return new DirectReference(_instance, _communicator, ident, context, facet, mode, secure, preferSecure, - endpoints, routerInfo, collocationOptimization, cacheConnection, endpointSelection, + endpoints, routerInfo, collocationOptimization, cacheConnection, endpointSelection, threadPerConnection); } ReferencePtr IceInternal::ReferenceFactory::create(const Identity& ident, - const SharedContextPtr& context, - const string& facet, - Reference::Mode mode, - bool secure, - bool preferSecure, - const string& adapterId, - const RouterInfoPtr& routerInfo, - const LocatorInfoPtr& locatorInfo, - bool collocationOptimization, + const SharedContextPtr& context, + const string& facet, + Reference::Mode mode, + bool secure, + bool preferSecure, + const string& adapterId, + const RouterInfoPtr& routerInfo, + const LocatorInfoPtr& locatorInfo, + bool collocationOptimization, bool cacheConnection, EndpointSelectionType endpointSelection, bool threadPerConnection, - int locatorCacheTimeout) + int locatorCacheTimeout) { IceUtil::Mutex::Lock sync(*this); if(!_instance) { - throw CommunicatorDestroyedException(__FILE__, __LINE__); + throw CommunicatorDestroyedException(__FILE__, __LINE__); } if(ident.name.empty() && ident.category.empty()) @@ -116,22 +116,22 @@ IceInternal::ReferenceFactory::create(const Identity& ident, // Create new reference // return new IndirectReference(_instance, _communicator, ident, context, facet, mode, secure, preferSecure, - adapterId, routerInfo, locatorInfo, collocationOptimization, cacheConnection, + adapterId, routerInfo, locatorInfo, collocationOptimization, cacheConnection, endpointSelection, threadPerConnection, locatorCacheTimeout); } ReferencePtr IceInternal::ReferenceFactory::create(const Identity& ident, - const SharedContextPtr& context, - const string& facet, - Reference::Mode mode, - const vector<Ice::ConnectionIPtr>& fixedConnections) + const SharedContextPtr& context, + const string& facet, + Reference::Mode mode, + const vector<Ice::ConnectionIPtr>& fixedConnections) { IceUtil::Mutex::Lock sync(*this); if(!_instance) { - throw CommunicatorDestroyedException(__FILE__, __LINE__); + throw CommunicatorDestroyedException(__FILE__, __LINE__); } if(ident.name.empty() && ident.category.empty()) @@ -162,9 +162,9 @@ IceInternal::ReferenceFactory::create(const string& str) beg = s.find_first_not_of(delim, end); if(beg == string::npos) { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; } // @@ -175,9 +175,9 @@ IceInternal::ReferenceFactory::create(const string& str) end = IceUtil::checkQuote(s, beg); if(end == string::npos) { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; } else if(end == 0) { @@ -197,9 +197,9 @@ IceInternal::ReferenceFactory::create(const string& str) if(beg == end) { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; } // @@ -243,54 +243,54 @@ IceInternal::ReferenceFactory::create(const string& str) while(true) { - beg = s.find_first_not_of(delim, end); - if(beg == string::npos) - { - break; - } + beg = s.find_first_not_of(delim, end); + if(beg == string::npos) + { + break; + } if(s[beg] == ':' || s[beg] == '@') { break; } - end = s.find_first_of(delim + ":@", beg); - if(end == string::npos) - { - end = s.length(); - } - - if(beg == end) - { - break; - } - - string option = s.substr(beg, end - beg); - if(option.length() != 2 || option[0] != '-') - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } + end = s.find_first_of(delim + ":@", beg); + if(end == string::npos) + { + end = s.length(); + } + + if(beg == end) + { + break; + } + + string option = s.substr(beg, end - beg); + if(option.length() != 2 || option[0] != '-') + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } // // Check for the presence of an option argument. The // argument may be enclosed in single or double // quotation marks. // - string argument; - string::size_type argumentBeg = s.find_first_not_of(delim, end); - if(argumentBeg != string::npos) - { + string argument; + string::size_type argumentBeg = s.find_first_not_of(delim, end); + if(argumentBeg != string::npos) + { if(s[argumentBeg] != '@' && s[argumentBeg] != ':' && s[argumentBeg] != '-') { beg = argumentBeg; end = IceUtil::checkQuote(s, beg); if(end == string::npos) { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; } else if(end == 0) { @@ -307,122 +307,122 @@ IceInternal::ReferenceFactory::create(const string& str) argument = s.substr(beg, end - beg); end++; // Skip trailing quote } - } - } - - // - // If any new options are added here, - // IceInternal::Reference::toString() and its derived classes must be updated as well. - // - switch(option[1]) - { - case 'f': - { - if(argument.empty()) - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } - - if(!IceUtil::unescapeString(argument, 0, argument.size(), facet)) - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } - - if(_instance->initializationData().stringConverter) - { - string tmpFacet; - _instance->initializationData().stringConverter->fromUTF8( - reinterpret_cast<const Byte*>(facet.data()), - reinterpret_cast<const Byte*>(facet.data() + facet.size()), tmpFacet); - facet = tmpFacet; - } - - break; - } - - case 't': - { - if(!argument.empty()) - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } - mode = Reference::ModeTwoway; - break; - } - - case 'o': - { - if(!argument.empty()) - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } - mode = Reference::ModeOneway; - break; - } - - case 'O': - { - if(!argument.empty()) - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } - mode = Reference::ModeBatchOneway; - break; - } - - case 'd': - { - if(!argument.empty()) - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } - mode = Reference::ModeDatagram; - break; - } - - case 'D': - { - if(!argument.empty()) - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } - mode = Reference::ModeBatchDatagram; - break; - } - - case 's': - { - if(!argument.empty()) - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } - secure = true; - break; - } - - default: - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } - } + } + } + + // + // If any new options are added here, + // IceInternal::Reference::toString() and its derived classes must be updated as well. + // + switch(option[1]) + { + case 'f': + { + if(argument.empty()) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } + + if(!IceUtil::unescapeString(argument, 0, argument.size(), facet)) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } + + if(_instance->initializationData().stringConverter) + { + string tmpFacet; + _instance->initializationData().stringConverter->fromUTF8( + reinterpret_cast<const Byte*>(facet.data()), + reinterpret_cast<const Byte*>(facet.data() + facet.size()), tmpFacet); + facet = tmpFacet; + } + + break; + } + + case 't': + { + if(!argument.empty()) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } + mode = Reference::ModeTwoway; + break; + } + + case 'o': + { + if(!argument.empty()) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } + mode = Reference::ModeOneway; + break; + } + + case 'O': + { + if(!argument.empty()) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } + mode = Reference::ModeBatchOneway; + break; + } + + case 'd': + { + if(!argument.empty()) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } + mode = Reference::ModeDatagram; + break; + } + + case 'D': + { + if(!argument.empty()) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } + mode = Reference::ModeBatchDatagram; + break; + } + + case 's': + { + if(!argument.empty()) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } + secure = true; + break; + } + + default: + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } + } } RouterInfoPtr routerInfo = _instance->routerManager()->get(getDefaultRouter()); @@ -430,9 +430,9 @@ IceInternal::ReferenceFactory::create(const string& str) if(beg == string::npos) { - return create(ident, _instance->getDefaultContext(), facet, mode, secure, - _instance->defaultsAndOverrides()->defaultPreferSecure, "", routerInfo, - locatorInfo, _instance->defaultsAndOverrides()->defaultCollocationOptimization, + return create(ident, _instance->getDefaultContext(), facet, mode, secure, + _instance->defaultsAndOverrides()->defaultPreferSecure, "", routerInfo, + locatorInfo, _instance->defaultsAndOverrides()->defaultCollocationOptimization, true, _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection(), _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout); } @@ -441,118 +441,118 @@ IceInternal::ReferenceFactory::create(const string& str) switch(s[beg]) { - case ':': - { - vector<string> unknownEndpoints; - end = beg; - - while(end < s.length() && s[end] == ':') - { - beg = end + 1; - - end = s.find(':', beg); - if(end == string::npos) - { - end = s.length(); - } - - string es = s.substr(beg, end - beg); - EndpointIPtr endp = _instance->endpointFactoryManager()->create(es); - if(endp != 0) - { - vector<EndpointIPtr> endps = endp->expand(false); - endpoints.insert(endpoints.end(), endps.begin(), endps.end()); - } - else - { - unknownEndpoints.push_back(es); - } - } - if(endpoints.size() == 0) - { - EndpointParseException ex(__FILE__, __LINE__); - ex.str = unknownEndpoints.front(); - throw ex; - } - else if(unknownEndpoints.size() != 0 && - _instance->initializationData().properties-> - getPropertyAsIntWithDefault("Ice.Warn.Endpoints", 1) > 0) - { - Warning out(_instance->initializationData().logger); - out << "Proxy contains unknown endpoints:"; - for(unsigned int idx = 0; idx < unknownEndpoints.size(); ++idx) - { - out << " `" << unknownEndpoints[idx] << "'"; - } - } - - return create(ident, _instance->getDefaultContext(), facet, mode, secure, - _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, routerInfo, - _instance->defaultsAndOverrides()->defaultCollocationOptimization, true, + case ':': + { + vector<string> unknownEndpoints; + end = beg; + + while(end < s.length() && s[end] == ':') + { + beg = end + 1; + + end = s.find(':', beg); + if(end == string::npos) + { + end = s.length(); + } + + string es = s.substr(beg, end - beg); + EndpointIPtr endp = _instance->endpointFactoryManager()->create(es); + if(endp != 0) + { + vector<EndpointIPtr> endps = endp->expand(false); + endpoints.insert(endpoints.end(), endps.begin(), endps.end()); + } + else + { + unknownEndpoints.push_back(es); + } + } + if(endpoints.size() == 0) + { + EndpointParseException ex(__FILE__, __LINE__); + ex.str = unknownEndpoints.front(); + throw ex; + } + else if(unknownEndpoints.size() != 0 && + _instance->initializationData().properties-> + getPropertyAsIntWithDefault("Ice.Warn.Endpoints", 1) > 0) + { + Warning out(_instance->initializationData().logger); + out << "Proxy contains unknown endpoints:"; + for(unsigned int idx = 0; idx < unknownEndpoints.size(); ++idx) + { + out << " `" << unknownEndpoints[idx] << "'"; + } + } + + return create(ident, _instance->getDefaultContext(), facet, mode, secure, + _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, routerInfo, + _instance->defaultsAndOverrides()->defaultCollocationOptimization, true, _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection()); - break; - } - case '@': - { - beg = s.find_first_not_of(delim, beg + 1); - if(beg == string::npos) - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } - - end = IceUtil::checkQuote(s, beg); - if(end == string::npos) - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } - else if(end == 0) - { - end = s.find_first_of(delim, beg); - if(end == string::npos) - { - end = s.size(); - } - } - else - { - beg++; // Skip leading quote - } - - - if(!IceUtil::unescapeString(s, beg, end, adapter) || adapter.size() == 0) - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } + break; + } + case '@': + { + beg = s.find_first_not_of(delim, beg + 1); + if(beg == string::npos) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } + + end = IceUtil::checkQuote(s, beg); + if(end == string::npos) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } + else if(end == 0) + { + end = s.find_first_of(delim, beg); + if(end == string::npos) + { + end = s.size(); + } + } + else + { + beg++; // Skip leading quote + } + + + if(!IceUtil::unescapeString(s, beg, end, adapter) || adapter.size() == 0) + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } if(_instance->initializationData().stringConverter) { - string tmpAdapter; + string tmpAdapter; _instance->initializationData().stringConverter->fromUTF8( - reinterpret_cast<const Byte*>(adapter.data()), - reinterpret_cast<const Byte*>(adapter.data() + adapter.size()), tmpAdapter); - adapter = tmpAdapter; + reinterpret_cast<const Byte*>(adapter.data()), + reinterpret_cast<const Byte*>(adapter.data() + adapter.size()), tmpAdapter); + adapter = tmpAdapter; } - - return create(ident, _instance->getDefaultContext(), facet, mode, secure, - _instance->defaultsAndOverrides()->defaultPreferSecure, adapter, routerInfo, locatorInfo, - _instance->defaultsAndOverrides()->defaultCollocationOptimization, true, + + return create(ident, _instance->getDefaultContext(), facet, mode, secure, + _instance->defaultsAndOverrides()->defaultPreferSecure, adapter, routerInfo, locatorInfo, + _instance->defaultsAndOverrides()->defaultCollocationOptimization, true, _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection(), - _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout); - break; - } - default: - { - ProxyParseException ex(__FILE__, __LINE__); - ex.str = str; - throw ex; - } + _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout); + break; + } + default: + { + ProxyParseException ex(__FILE__, __LINE__); + ex.str = str; + throw ex; + } } return 0; // Unreachable, prevents compiler warning. @@ -573,7 +573,7 @@ IceInternal::ReferenceFactory::createFromProperties(const string& propertyPrefix if(!properties->getProperty(property).empty()) { ref = ref->changeLocator( - LocatorPrx::uncheckedCast(_communicator->propertyToProxy(property))); + LocatorPrx::uncheckedCast(_communicator->propertyToProxy(property))); } property = propertyPrefix + ".LocatorCacheTimeout"; @@ -586,7 +586,7 @@ IceInternal::ReferenceFactory::createFromProperties(const string& propertyPrefix if(!properties->getProperty(property).empty()) { ref = ref->changeRouter( - RouterPrx::uncheckedCast(_communicator->propertyToProxy(property))); + RouterPrx::uncheckedCast(_communicator->propertyToProxy(property))); } property = propertyPrefix + ".PreferSecure"; @@ -606,19 +606,19 @@ IceInternal::ReferenceFactory::createFromProperties(const string& propertyPrefix { 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; - } + { + 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"; @@ -646,7 +646,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) if(ident.name.empty() && ident.category.empty()) { - return 0; + return 0; } // @@ -657,10 +657,10 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) string facet; if(!facetPath.empty()) { - if(facetPath.size() > 1) - { - throw ProxyUnmarshalException(__FILE__, __LINE__); - } + if(facetPath.size() > 1) + { + throw ProxyUnmarshalException(__FILE__, __LINE__); + } facet.swap(facetPath[0]); } @@ -669,7 +669,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) Reference::Mode mode = static_cast<Reference::Mode>(modeAsByte); if(mode < 0 || mode > Reference::ModeLast) { - throw ProxyUnmarshalException(__FILE__, __LINE__); + throw ProxyUnmarshalException(__FILE__, __LINE__); } bool secure; @@ -686,25 +686,25 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) if(sz > 0) { - endpoints.reserve(sz); - while(sz--) - { - EndpointIPtr endpoint = _instance->endpointFactoryManager()->read(s); - endpoints.push_back(endpoint); - } - return create(ident, _instance->getDefaultContext(), facet, mode, secure, - _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, routerInfo, - _instance->defaultsAndOverrides()->defaultCollocationOptimization, true, - _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection()); + endpoints.reserve(sz); + while(sz--) + { + EndpointIPtr endpoint = _instance->endpointFactoryManager()->read(s); + endpoints.push_back(endpoint); + } + return create(ident, _instance->getDefaultContext(), facet, mode, secure, + _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, routerInfo, + _instance->defaultsAndOverrides()->defaultCollocationOptimization, true, + _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection()); } else { - s->read(adapterId); - return create(ident, _instance->getDefaultContext(), facet, mode, secure, - _instance->defaultsAndOverrides()->defaultPreferSecure, adapterId, routerInfo, locatorInfo, - _instance->defaultsAndOverrides()->defaultCollocationOptimization, true, - _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection(), - _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout); + s->read(adapterId); + return create(ident, _instance->getDefaultContext(), facet, mode, secure, + _instance->defaultsAndOverrides()->defaultPreferSecure, adapterId, routerInfo, locatorInfo, + _instance->defaultsAndOverrides()->defaultCollocationOptimization, true, + _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection(), + _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout); } } @@ -749,7 +749,7 @@ IceInternal::ReferenceFactory::destroy() if(!_instance) { - throw CommunicatorDestroyedException(__FILE__, __LINE__); + throw CommunicatorDestroyedException(__FILE__, __LINE__); } _instance = 0; |