summaryrefslogtreecommitdiff
path: root/cppe/src/IceE/ReferenceFactory.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2008-06-03 19:32:20 -0700
committerMark Spruiell <mes@zeroc.com>2008-06-03 19:32:20 -0700
commit3d649bed4328992f41f567136025f58a019a5159 (patch)
tree470be901fbbfe5c6cd4269884412b0d36b48dc92 /cppe/src/IceE/ReferenceFactory.cpp
parentlocal interface fixes for slice2javae (diff)
downloadice-3d649bed4328992f41f567136025f58a019a5159.tar.bz2
ice-3d649bed4328992f41f567136025f58a019a5159.tar.xz
ice-3d649bed4328992f41f567136025f58a019a5159.zip
Various Ice-E fixes:
- Bug fix in slice2javae for local interfaces/classes - Added Ice.LocalObjectHolder - Reviewed Java/C++ demos and aligned with Ice - Source code clean up (removed tabs, etc.)
Diffstat (limited to 'cppe/src/IceE/ReferenceFactory.cpp')
-rw-r--r--cppe/src/IceE/ReferenceFactory.cpp498
1 files changed, 249 insertions, 249 deletions
diff --git a/cppe/src/IceE/ReferenceFactory.cpp b/cppe/src/IceE/ReferenceFactory.cpp
index 9667390915a..1820be6c1a1 100644
--- a/cppe/src/IceE/ReferenceFactory.cpp
+++ b/cppe/src/IceE/ReferenceFactory.cpp
@@ -39,7 +39,7 @@ IceInternal::ReferenceFactory::copy(const Reference* r) const
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
const Ice::Identity& ident = r->getIdentity();
@@ -53,21 +53,21 @@ IceInternal::ReferenceFactory::copy(const Reference* r) const
ReferencePtr
IceInternal::ReferenceFactory::create(const Identity& ident,
- const Context& context,
- const string& facet,
- ReferenceMode mode,
- bool secure,
- const vector<EndpointPtr>& endpoints
+ const Context& context,
+ const string& facet,
+ ReferenceMode mode,
+ bool secure,
+ const vector<EndpointPtr>& endpoints
#ifdef ICEE_HAS_ROUTER
- , const RouterInfoPtr& routerInfo
+ , const RouterInfoPtr& routerInfo
#endif
- )
+ )
{
Mutex::Lock sync(*this);
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
if(ident.name.empty() && ident.category.empty())
@@ -89,21 +89,21 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
ReferencePtr
IceInternal::ReferenceFactory::create(const Identity& ident,
- const Context& context,
- const string& facet,
- ReferenceMode mode,
- bool secure,
- const string& adapterId
+ const Context& context,
+ const string& facet,
+ ReferenceMode mode,
+ bool secure,
+ const string& adapterId
#ifdef ICEE_HAS_ROUTER
- , const RouterInfoPtr& routerInfo
+ , const RouterInfoPtr& routerInfo
#endif
- , const LocatorInfoPtr& locatorInfo)
+ , const LocatorInfoPtr& locatorInfo)
{
Mutex::Lock sync(*this);
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
if(ident.name.empty() && ident.category.empty())
@@ -116,7 +116,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
//
#ifdef ICEE_HAS_ROUTER
return new IndirectReference(_instance, _communicator, ident, context, facet, mode, secure, adapterId, routerInfo,
- locatorInfo);
+ locatorInfo);
#else
return new IndirectReference(_instance, _communicator, ident, context, facet, mode, secure, adapterId, locatorInfo);
#endif
@@ -126,16 +126,16 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
ReferencePtr
IceInternal::ReferenceFactory::create(const Identity& ident,
- const Context& context,
- const string& facet,
- ReferenceMode mode,
- const vector<Ice::ConnectionPtr>& fixedConnections)
+ const Context& context,
+ const string& facet,
+ ReferenceMode mode,
+ const vector<Ice::ConnectionPtr>& fixedConnections)
{
Mutex::Lock sync(*this);
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
if(ident.name.empty() && ident.category.empty())
@@ -166,7 +166,7 @@ IceInternal::ReferenceFactory::create(const string& str)
beg = s.find_first_not_of(delim, end);
if(beg == string::npos)
{
- throw ProxyParseException(__FILE__, __LINE__, str);
+ throw ProxyParseException(__FILE__, __LINE__, str);
}
//
@@ -177,7 +177,7 @@ IceInternal::ReferenceFactory::create(const string& str)
end = IceUtil::checkQuote(s, beg);
if(end == string::npos)
{
- throw ProxyParseException(__FILE__, __LINE__, str);
+ throw ProxyParseException(__FILE__, __LINE__, str);
}
else if(end == 0)
{
@@ -197,7 +197,7 @@ IceInternal::ReferenceFactory::create(const string& str)
if(beg == end)
{
- throw ProxyParseException(__FILE__, __LINE__, str);
+ throw ProxyParseException(__FILE__, __LINE__, str);
}
//
@@ -238,50 +238,50 @@ 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] != '-')
- {
+ 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] != '-')
+ {
throw ProxyParseException(__FILE__, __LINE__, str);
- }
+ }
//
// 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)
{
- throw ProxyParseException(__FILE__, __LINE__, str);
+ throw ProxyParseException(__FILE__, __LINE__, str);
}
else if(end == 0)
{
@@ -298,26 +298,26 @@ 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())
- {
- throw ProxyParseException(__FILE__, __LINE__, str);
- }
-
- if(!IceUtil::unescapeString(argument, 0, argument.size(), facet))
- {
- throw ProxyParseException(__FILE__, __LINE__, str);
- }
+ }
+ }
+
+ //
+ // 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())
+ {
+ throw ProxyParseException(__FILE__, __LINE__, str);
+ }
+
+ if(!IceUtil::unescapeString(argument, 0, argument.size(), facet))
+ {
+ throw ProxyParseException(__FILE__, __LINE__, str);
+ }
#ifdef ICEE_HAS_WSTRING
if(_instance->initializationData().stringConverter)
{
@@ -328,74 +328,74 @@ IceInternal::ReferenceFactory::create(const string& str)
facet = tmpFacet;
}
#endif
- break;
- }
-
- case 't':
- {
- if(!argument.empty())
- {
- throw ProxyParseException(__FILE__, __LINE__, str);
- }
- mode = ReferenceModeTwoway;
- break;
- }
-
- case 'o':
- {
- if(!argument.empty())
- {
- throw ProxyParseException(__FILE__, __LINE__, str);
- }
- mode = ReferenceModeOneway;
- break;
- }
-
- case 'O':
- {
- if(!argument.empty())
- {
- throw ProxyParseException(__FILE__, __LINE__, str);
- }
- mode = ReferenceModeBatchOneway;
- break;
- }
-
- case 'd':
- {
- if(!argument.empty())
- {
- throw ProxyParseException(__FILE__, __LINE__, str);
- }
- mode = ReferenceModeDatagram;
- break;
- }
-
- case 'D':
- {
- if(!argument.empty())
- {
- throw ProxyParseException(__FILE__, __LINE__, str);
- }
- mode = ReferenceModeBatchDatagram;
- break;
- }
-
- case 's':
- {
- if(!argument.empty())
- {
- throw ProxyParseException(__FILE__, __LINE__, str);
- }
- secure = true;
- break;
- }
-
- default:
- {
- throw ProxyParseException(__FILE__, __LINE__, str);
- }
- }
+ break;
+ }
+
+ case 't':
+ {
+ if(!argument.empty())
+ {
+ throw ProxyParseException(__FILE__, __LINE__, str);
+ }
+ mode = ReferenceModeTwoway;
+ break;
+ }
+
+ case 'o':
+ {
+ if(!argument.empty())
+ {
+ throw ProxyParseException(__FILE__, __LINE__, str);
+ }
+ mode = ReferenceModeOneway;
+ break;
+ }
+
+ case 'O':
+ {
+ if(!argument.empty())
+ {
+ throw ProxyParseException(__FILE__, __LINE__, str);
+ }
+ mode = ReferenceModeBatchOneway;
+ break;
+ }
+
+ case 'd':
+ {
+ if(!argument.empty())
+ {
+ throw ProxyParseException(__FILE__, __LINE__, str);
+ }
+ mode = ReferenceModeDatagram;
+ break;
+ }
+
+ case 'D':
+ {
+ if(!argument.empty())
+ {
+ throw ProxyParseException(__FILE__, __LINE__, str);
+ }
+ mode = ReferenceModeBatchDatagram;
+ break;
+ }
+
+ case 's':
+ {
+ if(!argument.empty())
+ {
+ throw ProxyParseException(__FILE__, __LINE__, str);
+ }
+ secure = true;
+ break;
+ }
+
+ default:
+ {
+ throw ProxyParseException(__FILE__, __LINE__, str);
+ }
+ }
}
#ifdef ICEE_HAS_ROUTER
@@ -409,111 +409,111 @@ IceInternal::ReferenceFactory::create(const string& str)
{
#ifdef ICEE_HAS_LOCATOR
# ifdef ICEE_HAS_ROUTER
- return create(ident, Ice::Context(), facet, mode, secure, "", routerInfo, locatorInfo);
+ return create(ident, Ice::Context(), facet, mode, secure, "", routerInfo, locatorInfo);
# else
- return create(ident, Ice::Context(), facet, mode, secure, "", locatorInfo);
+ return create(ident, Ice::Context(), facet, mode, secure, "", locatorInfo);
# endif
-#else
+#else
throw FeatureNotSupportedException(__FILE__, __LINE__,
- "indirect proxy `" + str + "' (no locator support built-in)");
+ "indirect proxy `" + str + "' (no locator support built-in)");
#endif
}
vector<EndpointPtr> endpoints;
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);
- EndpointPtr endp = _instance->endpointFactory()->create(es);
- if(endp != 0)
- {
- vector<EndpointPtr> endps = endp->expand(false);
- endpoints.insert(endpoints.end(), endps.begin(), endps.end());
- }
- else
- {
- unknownEndpoints.push_back(es);
- }
- }
- if(endpoints.size() == 0)
- {
- throw EndpointParseException(__FILE__, __LINE__, unknownEndpoints.front());
- }
- 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] << "'";
- }
- }
+ 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);
+ EndpointPtr endp = _instance->endpointFactory()->create(es);
+ if(endp != 0)
+ {
+ vector<EndpointPtr> endps = endp->expand(false);
+ endpoints.insert(endpoints.end(), endps.begin(), endps.end());
+ }
+ else
+ {
+ unknownEndpoints.push_back(es);
+ }
+ }
+ if(endpoints.size() == 0)
+ {
+ throw EndpointParseException(__FILE__, __LINE__, unknownEndpoints.front());
+ }
+ 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] << "'";
+ }
+ }
#ifdef ICEE_HAS_ROUTER
- return create(ident, Ice::Context(), facet, mode, secure, endpoints, routerInfo);
+ return create(ident, Ice::Context(), facet, mode, secure, endpoints, routerInfo);
#else
- return create(ident, Ice::Context(), facet, mode, secure, endpoints);
+ return create(ident, Ice::Context(), facet, mode, secure, endpoints);
#endif
- break;
- }
+ break;
+ }
- case '@':
- {
+ case '@':
+ {
#ifdef ICEE_HAS_LOCATOR
- beg = s.find_first_not_of(delim, beg + 1);
- if(beg == string::npos)
- {
- throw ProxyParseException(__FILE__, __LINE__, str);
- }
+ beg = s.find_first_not_of(delim, beg + 1);
+ if(beg == string::npos)
+ {
+ throw ProxyParseException(__FILE__, __LINE__, str);
+ }
string adapterstr;
- end = IceUtil::checkQuote(s, beg);
- if(end == string::npos)
- {
- throw ProxyParseException(__FILE__, __LINE__, str);
- }
- else if(end == 0)
- {
- end = s.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = s.size();
- }
+ end = IceUtil::checkQuote(s, beg);
+ if(end == string::npos)
+ {
+ throw ProxyParseException(__FILE__, __LINE__, str);
+ }
+ else if(end == 0)
+ {
+ end = s.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = s.size();
+ }
adapterstr = s.substr(beg, end - beg);
- }
- else
- {
- beg++; // Skip leading quote
+ }
+ else
+ {
+ beg++; // Skip leading quote
adapterstr = s.substr(beg, end - beg);
end++; // Skip trailing quote.
- }
+ }
// Check for trailing whitespace.
if(end != string::npos && s.find_first_not_of(delim, end) != string::npos)
{
- throw ProxyParseException(__FILE__, __LINE__, str);
+ throw ProxyParseException(__FILE__, __LINE__, str);
}
- if(!IceUtil::unescapeString(adapterstr, 0, adapterstr.size(), adapter) || adapter.size() == 0)
- {
- throw ProxyParseException(__FILE__, __LINE__, str);
- }
+ if(!IceUtil::unescapeString(adapterstr, 0, adapterstr.size(), adapter) || adapter.size() == 0)
+ {
+ throw ProxyParseException(__FILE__, __LINE__, str);
+ }
#ifdef ICEE_HAS_WSTRING
if(_instance->initializationData().stringConverter)
{
@@ -526,21 +526,21 @@ IceInternal::ReferenceFactory::create(const string& str)
#endif
#ifdef ICEE_HAS_ROUTER
- return create(ident, Ice::Context(), facet, mode, secure, adapter, routerInfo, locatorInfo);
+ return create(ident, Ice::Context(), facet, mode, secure, adapter, routerInfo, locatorInfo);
#else
- return create(ident, Ice::Context(), facet, mode, secure, adapter, locatorInfo);
+ return create(ident, Ice::Context(), facet, mode, secure, adapter, locatorInfo);
#endif
#else
throw FeatureNotSupportedException(__FILE__, __LINE__,
- "indirect proxy `" + str + "' (no locator support built-in)");
+ "indirect proxy `" + str + "' (no locator support built-in)");
#endif
- break;
- }
+ break;
+ }
- default:
- {
- throw ProxyParseException(__FILE__, __LINE__, str);
- }
+ default:
+ {
+ throw ProxyParseException(__FILE__, __LINE__, str);
+ }
}
return 0; // Unreachable, fixes compiler warning.
@@ -603,7 +603,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
if(ident.name.empty() && ident.category.empty())
{
- return 0;
+ return 0;
}
//
@@ -614,11 +614,11 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
string facet;
if(!facetPath.empty())
{
- if(facetPath.size() > 1)
- {
- throwProxyUnmarshalException(__FILE__, __LINE__);
- }
- facet.swap(facetPath[0]);
+ if(facetPath.size() > 1)
+ {
+ throwProxyUnmarshalException(__FILE__, __LINE__);
+ }
+ facet.swap(facetPath[0]);
}
Byte modeAsByte;
@@ -626,7 +626,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
ReferenceMode mode = static_cast<ReferenceMode>(modeAsByte);
if(mode < 0 || mode > ReferenceModeLast)
{
- throwProxyUnmarshalException(__FILE__, __LINE__);
+ throwProxyUnmarshalException(__FILE__, __LINE__);
}
vector<EndpointPtr> endpoints;
@@ -644,30 +644,30 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
if(sz > 0)
{
- endpoints.reserve(sz);
- while(sz--)
- {
- EndpointPtr endpoint = _instance->endpointFactory()->read(s);
- endpoints.push_back(endpoint);
- }
+ endpoints.reserve(sz);
+ while(sz--)
+ {
+ EndpointPtr endpoint = _instance->endpointFactory()->read(s);
+ endpoints.push_back(endpoint);
+ }
#ifdef ICEE_HAS_ROUTER
- return create(ident, Ice::Context(), facet, mode, secure, endpoints, routerInfo);
+ return create(ident, Ice::Context(), facet, mode, secure, endpoints, routerInfo);
#else
- return create(ident, Ice::Context(), facet, mode, secure, endpoints);
+ return create(ident, Ice::Context(), facet, mode, secure, endpoints);
#endif
}
else
{
#ifdef ICEE_HAS_LOCATOR
- LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(getDefaultLocator());
- s->read(adapterId);
+ LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(getDefaultLocator());
+ s->read(adapterId);
# ifdef ICEE_HAS_ROUTER
- return create(ident, Ice::Context(), facet, mode, secure, adapterId, routerInfo, locatorInfo);
+ return create(ident, Ice::Context(), facet, mode, secure, adapterId, routerInfo, locatorInfo);
# else
- return create(ident, Ice::Context(), facet, mode, secure, adapterId, locatorInfo);
+ return create(ident, Ice::Context(), facet, mode, secure, adapterId, locatorInfo);
# endif
#else
- throwProxyUnmarshalException(__FILE__, __LINE__);
+ throwProxyUnmarshalException(__FILE__, __LINE__);
return 0; // Unreachable, fixes compiler warning.
#endif
}
@@ -710,7 +710,7 @@ IceInternal::ReferenceFactory::getDefaultLocator() const
#endif
IceInternal::ReferenceFactory::ReferenceFactory(const InstancePtr& instance,
- const CommunicatorPtr& communicator) :
+ const CommunicatorPtr& communicator) :
_instance(instance),
_communicator(communicator)
{
@@ -723,7 +723,7 @@ IceInternal::ReferenceFactory::destroy()
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
_instance = 0;