diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/ImplicitContextI.cpp | 14 | ||||
-rw-r--r-- | cpp/src/Ice/ImplicitContextI.h | 4 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 15 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 70 |
4 files changed, 68 insertions, 35 deletions
diff --git a/cpp/src/Ice/ImplicitContextI.cpp b/cpp/src/Ice/ImplicitContextI.cpp index 7e29f61102b..8ac03fdba2a 100644 --- a/cpp/src/Ice/ImplicitContextI.cpp +++ b/cpp/src/Ice/ImplicitContextI.cpp @@ -29,7 +29,7 @@ public: virtual void remove(const string&); virtual void write(const Context&, ::IceInternal::BasicStream*) const; - virtual void write(const Context&, Context&) const; + virtual void combine(const Context&, Context&) const; protected: @@ -49,7 +49,7 @@ public: virtual void remove(const string&); virtual void write(const Context&, ::IceInternal::BasicStream*) const; - virtual void write(const Context&, Context&) const; + virtual void combine(const Context&, Context&) const; private: @@ -73,7 +73,7 @@ public: virtual void remove(const string&); virtual void write(const Context&, ::IceInternal::BasicStream*) const; - virtual void write(const Context&, Context&) const; + virtual void combine(const Context&, Context&) const; static void threadDestructor(void*); @@ -236,7 +236,7 @@ SharedImplicitContextWithoutLocking::write(const Context& proxyCtx, ::IceInterna } void -SharedImplicitContextWithoutLocking::write(const Context& proxyCtx, Context& ctx) const +SharedImplicitContextWithoutLocking::combine(const Context& proxyCtx, Context& ctx) const { if(proxyCtx.size() == 0) { @@ -323,10 +323,10 @@ SharedImplicitContext::write(const Context& proxyCtx, ::IceInternal::BasicStream } void -SharedImplicitContext::write(const Context& proxyCtx, Context& ctx) const +SharedImplicitContext::combine(const Context& proxyCtx, Context& ctx) const { IceUtil::Mutex::Lock lock(_mutex); - SharedImplicitContextWithoutLocking::write(proxyCtx, ctx); + SharedImplicitContextWithoutLocking::combine(proxyCtx, ctx); } // @@ -640,7 +640,7 @@ PerThreadImplicitContext::write(const Context& proxyCtx, ::IceInternal::BasicStr } void -PerThreadImplicitContext::write(const Context& proxyCtx, Context& ctx) const +PerThreadImplicitContext::combine(const Context& proxyCtx, Context& ctx) const { Context* threadCtx = getThreadContext(false); diff --git a/cpp/src/Ice/ImplicitContextI.h b/cpp/src/Ice/ImplicitContextI.h index 8f20828eb19..f92f02a6734 100644 --- a/cpp/src/Ice/ImplicitContextI.h +++ b/cpp/src/Ice/ImplicitContextI.h @@ -37,11 +37,11 @@ public: virtual void write(const Context&, ::IceInternal::BasicStream*) const = 0; // - // Writes the underlying context plus the given context + // Combines the underlying context plus the given context // (entries in the given context overwrite entries in // the underlying context) // - virtual void write(const Context&, Context&) const = 0; + virtual void combine(const Context&, Context&) const = 0; }; diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index f0cc77ca80e..642e3a7f651 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -1369,7 +1369,14 @@ IceDelegateD::Ice::Object::__initCurrent(Current& current, const string& op, Ope current.facet = __reference->getFacet(); current.operation = op; current.mode = mode; - if(context == 0) + if(context != 0) + { + // + // Explicit context + // + current.ctx = *context; + } + else { // // Implicit context @@ -1385,13 +1392,9 @@ IceDelegateD::Ice::Object::__initCurrent(Current& current, const string& op, Ope } else { - implicitContext->write(prxContext, current.ctx); + implicitContext->combine(prxContext, current.ctx); } } - else - { - current.ctx = *context; - } current.requestId = -1; } diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 6b6547423d2..61204ed45ae 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -3277,6 +3277,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) bool java5 = p->definitionContext()->findMetaData("java:java5") == "java:java5"; string contextType = java5 ? "java.util.Map<String, String>" : "java.util.Map"; string contextParam = contextType + " __ctx"; + string explicitContextParam = "boolean __explicitCtx"; OperationList ops = p->allOperations(); @@ -3302,17 +3303,6 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) // context parameter // out << sp; - // - // TODO: If we eventually drop support for Java2, we can remove this - // SupressWarnings annotation. Meanwhile, it is necessary to prevent - // a compiler warning about an unchecked conversion. This is caused - // by the fact that __defaultContext() returns the unchecked type - // java.util.Map but Ice.Context is mapped to Map<String, String>. - // - if(java5) - { - out << nl << "@SuppressWarnings(\"unchecked\")"; - } out << nl << "public " << retS << nl << opName << spar << params << epar; writeThrowsClause(package, throws); out << sb; @@ -3321,13 +3311,41 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) { out << "return "; } - out << opName << spar << args << "__defaultContext()" << epar << ';'; + out << opName << spar << args << "null, false" << epar << ';'; out << eb; - out << sp; + out << sp; out << nl << "public " << retS << nl << opName << spar << params << contextParam << epar; writeThrowsClause(package, throws); out << sb; + out << nl; + if(ret) + { + out << "return "; + } + out << opName << spar << args << "__ctx, true" << epar << ';'; + out << eb; + + out << sp; + // + // TODO: If we eventually drop support for Java2, we can remove this + // SupressWarnings annotation. Meanwhile, it is necessary to prevent + // a compiler warning about an unchecked conversion. This is caused + // by the fact that _emptyContext returns the unchecked type + // java.util.Map but Ice.Context is mapped to Map<String, String>. + // + if(java5) + { + out << nl << "@SuppressWarnings(\"unchecked\")"; + } + out << nl << "private " << retS << nl << opName << spar << params << contextParam + << explicitContextParam << epar; + writeThrowsClause(package, throws); + out << sb; + out << nl << "if(__explicitCtx && __ctx == null)"; + out << sb; + out << nl << "__ctx = _emptyContext;"; + out << eb; out << nl << "int __cnt = 0;"; out << nl << "while(true)"; out << sb; @@ -3378,25 +3396,37 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) // context parameter // out << sp; + out << nl << "public void" << nl << op->name() << "_async" << spar << paramsAMI << epar; + out << sb; + out << nl << op->name() << "_async" << spar << argsAMI << "null, false" << epar << ';'; + out << eb; + + out << sp; + out << nl << "public void" << nl << op->name() << "_async" << spar << paramsAMI + << contextParam << epar; + out << sb; + out << nl << op->name() << "_async" << spar << argsAMI << "__ctx, true" << epar << ';'; + out << eb; + + out << sp; // // TODO: If we eventually drop support for Java2, we can remove this // SupressWarnings annotation. Meanwhile, it is necessary to prevent // a compiler warning about an unchecked conversion. This is caused - // by the fact that __defaultContext() returns the unchecked type + // by the fact that _emptyContext returns the unchecked type // java.util.Map but Ice.Context is mapped to Map<String, String>. // if(java5) { out << nl << "@SuppressWarnings(\"unchecked\")"; } - out << nl << "public void" << nl << op->name() << "_async" << spar << paramsAMI << epar; + out << nl << "private void" << nl << op->name() << "_async" << spar << paramsAMI + << contextParam << explicitContextParam << epar; out << sb; - out << nl << op->name() << "_async" << spar << argsAMI << "__defaultContext()" << epar << ';'; - out << eb; - - out << sp; - out << nl << "public void" << nl << op->name() << "_async" << spar << paramsAMI << contextParam << epar; + out << nl << "if(__explicitCtx && __ctx == null)"; out << sb; + out << nl << "__ctx = _emptyContext;"; + out << eb; out << nl << "__cb.__invoke" << spar << "this" << argsAMI << "__ctx" << epar << ';'; out << eb; } |