summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/ReferenceFactory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/Ice/ReferenceFactory.cpp')
-rw-r--r--cpp/src/Ice/ReferenceFactory.cpp91
1 files changed, 68 insertions, 23 deletions
diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp
index 37ccafa1976..b4193f3a374 100644
--- a/cpp/src/Ice/ReferenceFactory.cpp
+++ b/cpp/src/Ice/ReferenceFactory.cpp
@@ -55,7 +55,8 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
return 0;
}
- return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), endpoints, "", "");
+ return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), tmpl->getProtocol(), tmpl->getEncoding(),
+ endpoints, "", "");
}
ReferencePtr
@@ -69,7 +70,8 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
return 0;
}
- return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), vector<EndpointIPtr>(), adapterId, "");
+ return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), tmpl->getProtocol(), tmpl->getEncoding(),
+ vector<EndpointIPtr>(), adapterId, "");
}
ReferencePtr
@@ -80,8 +82,6 @@ IceInternal::ReferenceFactory::create(const Identity& ident, const Ice::Connecti
return 0;
}
- DefaultsAndOverridesPtr defaultsAndOverrides = _instance->defaultsAndOverrides();
-
//
// Create new reference
//
@@ -91,7 +91,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, const Ice::Connecti
"", // Facet
connection->endpoint()->datagram() ? Reference::ModeDatagram : Reference::ModeTwoway,
connection->endpoint()->secure(),
- defaultsAndOverrides->defaultEncoding,
+ _instance->defaultsAndOverrides()->defaultEncoding,
connection);
}
@@ -189,6 +189,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
string facet;
Reference::Mode mode = Reference::ModeTwoway;
bool secure = false;
+ Ice::EncodingVersion encoding = _instance->defaultsAndOverrides()->defaultEncoding;
string adapter;
while(true)
@@ -362,6 +363,28 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
break;
}
+ case 'e':
+ {
+ if(argument.empty())
+ {
+ Ice::ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = "no argument provided for -e option in `" + s + "'";
+ throw ex;
+ }
+
+ try
+ {
+ encoding = Ice::stringToEncodingVersion(argument);
+ }
+ catch(const Ice::VersionParseException& e)
+ {
+ Ice::ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = "invalid encoding version `" + argument + "' in `" + s + "':\n" + e.str;
+ throw ex;
+ }
+ break;
+ }
+
default:
{
ProxyParseException ex(__FILE__, __LINE__);
@@ -371,14 +394,12 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
}
}
-
if(beg == string::npos)
{
- return create(ident, facet, mode, secure, vector<EndpointIPtr>(), "", propertyPrefix);
+ return create(ident, facet, mode, secure, Protocol_1_0, encoding, vector<EndpointIPtr>(), "", propertyPrefix);
}
vector<EndpointIPtr> endpoints;
-
switch(s[beg])
{
case ':':
@@ -463,7 +484,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
}
}
- return create(ident, facet, mode, secure, endpoints, "", propertyPrefix);
+ return create(ident, facet, mode, secure, Protocol_1_0, encoding, endpoints, "", propertyPrefix);
break;
}
case '@':
@@ -527,7 +548,7 @@ IceInternal::ReferenceFactory::create(const string& str, const string& propertyP
adapter = Ice::UTF8ToNative(_instance->initializationData().stringConverter, adapter);
- return create(ident, facet, mode, secure, vector<EndpointIPtr>(), adapter, propertyPrefix);
+ return create(ident, facet, mode, secure, Protocol_1_0, encoding, endpoints, adapter, propertyPrefix);
break;
}
default:
@@ -580,6 +601,19 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
bool secure;
s->read(secure);
+ Ice::ProtocolVersion protocol;
+ Ice::EncodingVersion encoding;
+ if(s->getReadEncoding() != Ice::Encoding_1_0)
+ {
+ s->read(protocol);
+ s->read(encoding);
+ }
+ else
+ {
+ protocol = Ice::Protocol_1_0;
+ encoding = Ice::Encoding_1_0;
+ }
+
vector<EndpointIPtr> endpoints;
string adapterId;
@@ -599,7 +633,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
s->read(adapterId);
}
- return create(ident, facet, mode, secure, endpoints, adapterId, "");
+ return create(ident, facet, mode, secure, protocol, encoding, endpoints, adapterId, "");
}
ReferenceFactoryPtr
@@ -656,7 +690,6 @@ IceInternal::ReferenceFactory::checkForUnknownProperties(const string& prefix)
"EndpointSelection",
"ConnectionCached",
"PreferSecure",
- "EncodingVersion",
"LocatorCacheTimeout",
"Locator",
"Router",
@@ -711,6 +744,8 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
const string& facet,
Reference::Mode mode,
bool secure,
+ const Ice::ProtocolVersion& protocol,
+ const Ice::EncodingVersion& encoding,
const vector<EndpointIPtr>& endpoints,
const string& adapterId,
const string& propertyPrefix)
@@ -720,12 +755,22 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
//
// Default local proxy options.
//
- LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(_defaultLocator);
+ LocatorInfoPtr locatorInfo;
+ if(_defaultLocator)
+ {
+ if(_defaultLocator->ice_getEncodingVersion() != encoding)
+ {
+ locatorInfo = _instance->locatorManager()->get(_defaultLocator->ice_encodingVersion(encoding));
+ }
+ else
+ {
+ locatorInfo = _instance->locatorManager()->get(_defaultLocator);
+ }
+ }
RouterInfoPtr routerInfo = _instance->routerManager()->get(_defaultRouter);
bool collocationOptimized = defaultsAndOverrides->defaultCollocationOptimization;
bool cacheConnection = true;
bool preferSecure = defaultsAndOverrides->defaultPreferSecure;
- EncodingVersion encoding = defaultsAndOverrides->defaultEncoding;
Ice::EndpointSelectionType endpointSelection = defaultsAndOverrides->defaultEndpointSelection;
int locatorCacheTimeout = defaultsAndOverrides->defaultLocatorCacheTimeout;
@@ -746,7 +791,14 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
LocatorPrx locator = LocatorPrx::uncheckedCast(_communicator->propertyToProxy(property));
if(locator)
{
- locatorInfo = _instance->locatorManager()->get(locator);
+ if(locator->ice_getEncodingVersion() != encoding)
+ {
+ locatorInfo = _instance->locatorManager()->get(locator->ice_encodingVersion(encoding));
+ }
+ else
+ {
+ locatorInfo = _instance->locatorManager()->get(locator);
+ }
}
property = propertyPrefix + ".Router";
@@ -774,14 +826,6 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
property = propertyPrefix + ".PreferSecure";
preferSecure = properties->getPropertyAsIntWithDefault(property, preferSecure) > 0;
- property = propertyPrefix + ".EncodingVersion";
- string encodingStr = properties->getProperty(property);
- if(!encodingStr.empty())
- {
- encoding = stringToEncodingVersion(encodingStr);
- checkSupportedEncoding(encoding);
- }
-
property = propertyPrefix + ".EndpointSelection";
if(!properties->getProperty(property).empty())
{
@@ -815,6 +859,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
facet,
mode,
secure,
+ protocol,
encoding,
endpoints,
adapterId,