diff options
author | Michi Henning <michi@zeroc.com> | 2003-08-27 05:05:57 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2003-08-27 05:05:57 +0000 |
commit | 1000e26d3c7578d04b95ad8a42b61d009bb001cb (patch) | |
tree | 064f0d690eaff464b220625b373cba6af4213396 /cpp/src | |
parent | file XMLParser.h was initially added on branch binary_freeze. (diff) | |
download | ice-1000e26d3c7578d04b95ad8a42b61d009bb001cb.tar.bz2 ice-1000e26d3c7578d04b95ad8a42b61d009bb001cb.tar.xz ice-1000e26d3c7578d04b95ad8a42b61d009bb001cb.zip |
Added per-proxy contexts.
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.cpp | 9 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 75 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.cpp | 41 | ||||
-rw-r--r-- | cpp/src/Ice/Reference.h | 4 | ||||
-rw-r--r-- | cpp/src/Ice/ReferenceFactory.cpp | 7 | ||||
-rw-r--r-- | cpp/src/Ice/ReferenceFactory.h | 4 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 80 |
7 files changed, 177 insertions, 43 deletions
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index e5b3ea46093..72d58545ddf 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -345,7 +345,7 @@ Ice::ObjectAdapterI::createReverseProxy(const Identity& ident) // reference. // vector<EndpointPtr> endpoints; - ReferencePtr ref = _instance->referenceFactory()->create(ident, vector<string>(), Reference::ModeTwoway, + ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), vector<string>(), Reference::ModeTwoway, false, "", endpoints, 0, 0, this, true); return _instance->proxyFactory()->referenceToProxy(ref); } @@ -652,8 +652,9 @@ Ice::ObjectAdapterI::newProxy(const Identity& ident) const // Create a reference with the adapter id. // vector<EndpointPtr> endpoints; - ReferencePtr ref = _instance->referenceFactory()->create(ident, vector<string>(), Reference::ModeTwoway, - false, _id, endpoints, 0, _locatorInfo, 0, true); + ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), vector<string>(), + Reference::ModeTwoway, false, _id, + endpoints, 0, _locatorInfo, 0, true); // // Return a proxy for the reference. @@ -684,7 +685,7 @@ Ice::ObjectAdapterI::newDirectProxy(const Identity& ident) const // // Create a reference and return a proxy for this reference. // - ReferencePtr ref = _instance->referenceFactory()->create(ident, vector<string>(), Reference::ModeTwoway, + ReferencePtr ref = _instance->referenceFactory()->create(ident, Context(), vector<string>(), Reference::ModeTwoway, false, "", endpoints, 0, _locatorInfo, 0, true); return _instance->proxyFactory()->referenceToProxy(ref); diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index aadce898703..ba56ed55365 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -121,6 +121,12 @@ IceProxy::Ice::Object::ice_hash() const } bool +IceProxy::Ice::Object::ice_isA(const string& __id) +{ + return ice_isA(__id, _reference->context); +} + +bool IceProxy::Ice::Object::ice_isA(const string& __id, const Context& __context) { int __cnt = 0; @@ -143,6 +149,12 @@ IceProxy::Ice::Object::ice_isA(const string& __id, const Context& __context) } void +IceProxy::Ice::Object::ice_ping() +{ + return ice_ping(_reference->context); +} + +void IceProxy::Ice::Object::ice_ping(const Context& __context) { int __cnt = 0; @@ -166,6 +178,12 @@ IceProxy::Ice::Object::ice_ping(const Context& __context) } vector<string> +IceProxy::Ice::Object::ice_ids() +{ + return ice_ids(_reference->context); +} + +vector<string> IceProxy::Ice::Object::ice_ids(const Context& __context) { int __cnt = 0; @@ -188,6 +206,12 @@ IceProxy::Ice::Object::ice_ids(const Context& __context) } string +IceProxy::Ice::Object::ice_id() +{ + return ice_id(_reference->context); +} + +string IceProxy::Ice::Object::ice_id(const Context& __context) { int __cnt = 0; @@ -210,6 +234,12 @@ IceProxy::Ice::Object::ice_id(const Context& __context) } FacetPath +IceProxy::Ice::Object::ice_facets() +{ + return ice_facets(_reference->context); +} + +FacetPath IceProxy::Ice::Object::ice_facets(const Context& __context) { int __cnt = 0; @@ -235,6 +265,15 @@ bool IceProxy::Ice::Object::ice_invoke(const string& operation, OperationMode mode, const vector<Byte>& inParams, + vector<Byte>& outParams) +{ + return ice_invoke(operation, mode, inParams, outParams, _reference->context); +} + +bool +IceProxy::Ice::Object::ice_invoke(const string& operation, + OperationMode mode, + const vector<Byte>& inParams, vector<Byte>& outParams, const Context& context) { @@ -269,6 +308,15 @@ void IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb, const string& operation, OperationMode mode, + const vector<Byte>& inParams) +{ + return ice_invoke_async(cb, operation, mode, inParams, _reference->context); +} + +void +IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb, + const string& operation, + OperationMode mode, const vector<Byte>& inParams, const Context& context) { @@ -288,6 +336,27 @@ IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb, } } +Context +IceProxy::Ice::Object::ice_getContext() const +{ + return _reference->context; +} + +ObjectPrx +IceProxy::Ice::Object::ice_newContext(const Context& newContext) const +{ + if(newContext == _reference->context) + { + return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); + } + else + { + ObjectPrx proxy(new ::IceProxy::Ice::Object()); + proxy->setup(_reference->changeContext(newContext)); + return proxy; + } +} + Identity IceProxy::Ice::Object::ice_getIdentity() const { @@ -767,6 +836,12 @@ IceProxy::Ice::Object::__createDelegateD() return Handle< ::IceDelegateD::Ice::Object>(new ::IceDelegateD::Ice::Object); } +const Context& +IceProxy::Ice::Object::__defaultContext() const +{ + return _reference->context; +} + void IceProxy::Ice::Object::setup(const ReferencePtr& ref) { diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index bffa4b46929..0f7da04d1c0 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -366,7 +366,22 @@ IceInternal::Reference::changeIdentity(const Identity& newIdentity) const } else { - return instance->referenceFactory()->create(newIdentity, facet, mode, secure, adapterId, + return instance->referenceFactory()->create(newIdentity, context, facet, mode, secure, adapterId, + endpoints, routerInfo, locatorInfo, reverseAdapter, + collocationOptimization); + } +} + +ReferencePtr +IceInternal::Reference::changeContext(const Context& newContext) const +{ + if(newContext == context) + { + return ReferencePtr(const_cast<Reference*>(this)); + } + else + { + return instance->referenceFactory()->create(identity, newContext, facet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -381,7 +396,7 @@ IceInternal::Reference::changeFacet(const FacetPath& newFacet) const } else { - return instance->referenceFactory()->create(identity, newFacet, mode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, newFacet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -432,7 +447,7 @@ IceInternal::Reference::changeTimeout(int newTimeout) const newLocatorInfo = instance->locatorManager()->get(newLocator); } - return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, secure, adapterId, newEndpoints, newRouterInfo, newLocatorInfo, reverseAdapter, collocationOptimization); } @@ -446,7 +461,7 @@ IceInternal::Reference::changeMode(Mode newMode) const } else { - return instance->referenceFactory()->create(identity, facet, newMode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, newMode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -461,7 +476,7 @@ IceInternal::Reference::changeSecure(bool newSecure) const } else { - return instance->referenceFactory()->create(identity, facet, mode, newSecure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, newSecure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -512,7 +527,7 @@ IceInternal::Reference::changeCompress(bool newCompress) const newLocatorInfo = instance->locatorManager()->get(newLocator); } - return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, secure, adapterId, newEndpoints, newRouterInfo, newLocatorInfo, reverseAdapter, collocationOptimization); } @@ -526,7 +541,7 @@ IceInternal::Reference::changeAdapterId(const string& newAdapterId) const } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, newAdapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, secure, newAdapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -541,7 +556,7 @@ IceInternal::Reference::changeEndpoints(const vector<EndpointPtr>& newEndpoints) } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, secure, adapterId, newEndpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -558,7 +573,7 @@ IceInternal::Reference::changeRouter(const RouterPrx& newRouter) const } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, secure, adapterId, endpoints, newRouterInfo, locatorInfo, reverseAdapter, collocationOptimization); } @@ -575,7 +590,7 @@ IceInternal::Reference::changeLocator(const LocatorPrx& newLocator) const } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, secure, adapterId, endpoints, routerInfo, newLocatorInfo, reverseAdapter, collocationOptimization); } @@ -590,7 +605,7 @@ IceInternal::Reference::changeCollocationOptimization(bool newCollocationOptimiz } else { - return instance->referenceFactory()->create(identity, facet, mode, secure, adapterId, + return instance->referenceFactory()->create(identity, context, facet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, newCollocationOptimization); } @@ -602,12 +617,13 @@ IceInternal::Reference::changeDefault() const RouterInfoPtr defaultRouterInfo = instance->routerManager()->get(instance->referenceFactory()->getDefaultRouter()); LocatorInfoPtr defaultLocatorInfo = instance->locatorManager()->get(instance->referenceFactory()->getDefaultLocator()); - return instance->referenceFactory()->create(identity, FacetPath(), ModeTwoway, false, adapterId, + return instance->referenceFactory()->create(identity, context, FacetPath(), ModeTwoway, false, adapterId, endpoints, defaultRouterInfo, defaultLocatorInfo, 0, true); } IceInternal::Reference::Reference(const InstancePtr& inst, const Identity& ident, + const Context& ctx, const FacetPath& facPath, Mode md, bool sec, @@ -619,6 +635,7 @@ IceInternal::Reference::Reference(const InstancePtr& inst, bool collocationOptimization) : instance(inst), identity(ident), + context(ctx), facet(facPath), mode(md), secure(sec), diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index da7b83c6818..7f42a8e596d 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -65,6 +65,7 @@ public: // const InstancePtr instance; const Ice::Identity identity; + const Ice::Context context; const Ice::FacetPath facet; const Mode mode; const bool secure; @@ -81,6 +82,7 @@ public: // certain values. // ReferencePtr changeIdentity(const Ice::Identity&) const; + ReferencePtr changeContext(const Ice::Context&) const; ReferencePtr changeFacet(const Ice::FacetPath&) const; ReferencePtr changeTimeout(int) const; ReferencePtr changeMode(Mode) const; @@ -95,7 +97,7 @@ public: private: - Reference(const InstancePtr&, const Ice::Identity&, const Ice::FacetPath&, Mode, bool, + Reference(const InstancePtr&, const Ice::Identity&, const Ice::Context&, const Ice::FacetPath&, Mode, bool, const std::string&, const std::vector<EndpointPtr>&, const RouterInfoPtr&, const LocatorInfoPtr&, const Ice::ObjectAdapterPtr&, bool); friend class ReferenceFactory; diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index fb3264f98e8..b3782c18f4c 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -32,6 +32,7 @@ void IceInternal::decRef(::IceInternal::ReferenceFactory* p) { p->__decRef(); } ReferencePtr IceInternal::ReferenceFactory::create(const Identity& ident, + const Context& context, const vector<string>& facet, Reference::Mode mode, bool secure, @@ -57,7 +58,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, // // Create new reference // - ReferencePtr ref = new Reference(_instance, ident, facet, mode, secure, adapterId, + ReferencePtr ref = new Reference(_instance, ident, context, facet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, reverseAdapter, collocationOptimization); @@ -500,7 +501,7 @@ IceInternal::ReferenceFactory::create(const string& str) RouterInfoPtr routerInfo = _instance->routerManager()->get(getDefaultRouter()); LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(getDefaultLocator()); - return create(ident, facet, mode, secure, adapter, endpoints, routerInfo, locatorInfo, 0, true); + return create(ident, Context(), facet, mode, secure, adapter, endpoints, routerInfo, locatorInfo, 0, true); } ReferencePtr @@ -552,7 +553,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s) RouterInfoPtr routerInfo = _instance->routerManager()->get(getDefaultRouter()); LocatorInfoPtr locatorInfo = _instance->locatorManager()->get(getDefaultLocator()); - return create(ident, facet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, 0, true); + return create(ident, Context(), facet, mode, secure, adapterId, endpoints, routerInfo, locatorInfo, 0, true); } void diff --git a/cpp/src/Ice/ReferenceFactory.h b/cpp/src/Ice/ReferenceFactory.h index beedb4fa65f..c51b1f3c1d3 100644 --- a/cpp/src/Ice/ReferenceFactory.h +++ b/cpp/src/Ice/ReferenceFactory.h @@ -28,8 +28,8 @@ class ReferenceFactory : public ::IceUtil::Shared, public ::IceUtil::Mutex { public: - ReferencePtr create(const Ice::Identity&, const std::vector<std::string>&, Reference::Mode, bool, - const std::string&, const std::vector<EndpointPtr>&, + ReferencePtr create(const Ice::Identity&, const Ice::Context&, const std::vector<std::string>&, + Reference::Mode, bool, const std::string&, const std::vector<EndpointPtr>&, const RouterInfoPtr&, const LocatorInfoPtr&, const Ice::ObjectAdapterPtr&, bool); ReferencePtr create(const std::string&); ReferencePtr create(const Ice::Identity&, BasicStream*); diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index d7bf4a8adba..5fd71262f4e 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -1296,7 +1296,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) string params = "("; string paramsDecl = "("; // With declarators - string args = "("; + string args; ContainerPtr container = p->container(); ClassDefPtr cl = ClassDefPtr::dynamicCast(container); @@ -1304,8 +1304,8 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) string classScope = fixKwd(cl->scope()); string classScopedAMI = classScope + classNameAMI; - string paramsAMI = "(const " + classScopedAMI + '_' + name + "Ptr&, "; - string paramsDeclAMI = "(const " + classScopedAMI + '_' + name + "Ptr& __cb, "; // With declarators + string paramsAMI = "(const " + classScopedAMI + '_' + name + "Ptr&"; + string paramsDeclAMI = "(const " + classScopedAMI + '_' + name + "Ptr& __cb"; // With declarators string argsAMI = "(__cb, "; ParamDeclList paramList = p->parameters(); @@ -1330,42 +1330,65 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) string paramName = fixKwd((*q)->name()); + if(q != paramList.begin()) + { + params += ", "; + paramsDecl += ", "; + args += ", "; + } params += typeString; - params += ", "; paramsDecl += typeString; paramsDecl += ' '; paramsDecl += paramName; - paramsDecl += ", "; args += paramName; - args += ", "; if(!(*q)->isOutParam()) { - paramsAMI += typeString; paramsAMI += ", "; + paramsAMI += typeString; + paramsDeclAMI += ", "; paramsDeclAMI += typeString; paramsDeclAMI += ' '; paramsDeclAMI += paramName; - paramsDeclAMI += ", "; argsAMI += paramName; argsAMI += ", "; } } - params += "const ::Ice::Context& = ::Ice::Context())"; - paramsDecl += "const ::Ice::Context& __context)"; - args += "__context)"; - - paramsAMI += "const ::Ice::Context& = ::Ice::Context())"; - paramsDeclAMI += "const ::Ice::Context& __context)"; - argsAMI += "__context)"; - string thisPointer = fixKwd(scope.substr(0, scope.size() - 2)) + "*"; H << sp; - H << nl << retS << ' ' << name << params << ';'; + H << nl << retS << ' ' << name << params << ");"; + + H << nl << retS << ' ' << name << params; + if(!paramList.empty()) + { + H << ", "; + } + H << "const ::Ice::Context&);"; + + C << sp << nl << retS << nl << "IceProxy" << scoped << paramsDecl << ")"; + C << sb; + C << nl; + if(ret) + { + C << "return "; + } + C << name << '(' << args; + if(!paramList.empty()) + { + C << ", "; + } + C << "__defaultContext());"; + C << eb; + C << sp << nl << retS << nl << "IceProxy" << scoped << paramsDecl; + if(!paramList.empty()) + { + C << ", "; + } + C << "const ::Ice::Context& __ctx)"; C << sb; C << nl << "int __cnt = 0;"; C << nl << "while(true)"; @@ -1380,7 +1403,12 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { C << "return "; } - C << "__del->" << name << args << ";"; + C << "__del->" << name << '(' << args; + if(!args.empty()) + { + C << ", "; + } + C << "__ctx);"; if(!ret) { C << nl << "return;"; @@ -1406,8 +1434,18 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) if(cl->hasMetaData("ami") || p->hasMetaData("ami")) { - H << nl << "void " << name << "_async" << paramsAMI << ';'; - C << sp << nl << "void" << nl << "IceProxy" << scoped << "_async" << paramsDeclAMI; + H << nl << "void " << name << "_async" << paramsAMI << ");"; + + H << nl << "void " << name << "_async" << paramsAMI << ", const ::Ice::Context&);"; + + C << sp << nl << "void" << nl << "IceProxy" << scoped << "_async" << paramsDeclAMI << ")"; + C << sb; + C << nl; + C << name << "_async" << argsAMI << "__defaultContext());"; + C << eb; + + C << sp << nl << "void" << nl << "IceProxy" << scoped << "_async" << paramsDeclAMI + << ", const ::Ice::Context& __ctx)"; C << sb; C << nl << "int __cnt = 0;"; C << nl << "while(true)"; @@ -1418,7 +1456,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) C << nl << "::IceDelegate" << thisPointer << " __del = dynamic_cast< ::IceDelegate" << thisPointer << ">(__delBase.get());"; C << nl; - C << "__del->" << name << "_async" << argsAMI << ";"; + C << "__del->" << name << "_async" << argsAMI << "__ctx);"; C << nl << "return;"; C << eb; C << nl << "catch(const ::Ice::LocalException& __ex)"; |