diff options
-rw-r--r-- | cpp/src/slice2cppe/Gen.cpp | 8 | ||||
-rw-r--r-- | cpp/src/slice2javae/Gen.cpp | 6 | ||||
-rw-r--r-- | cppe/include/IceE/Proxy.h | 4 | ||||
-rw-r--r-- | cppe/src/IceE/Proxy.cpp | 76 | ||||
-rw-r--r-- | javae/src/Ice/ObjectPrxHelperBase.java | 75 |
5 files changed, 79 insertions, 90 deletions
diff --git a/cpp/src/slice2cppe/Gen.cpp b/cpp/src/slice2cppe/Gen.cpp index 85e3d119727..58c0d0dbcca 100644 --- a/cpp/src/slice2cppe/Gen.cpp +++ b/cpp/src/slice2cppe/Gen.cpp @@ -1425,17 +1425,17 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) C << nl << "__checkTwowayOnly(\"" << name << "\");"; } C << nl << "static const ::std::string __operation(\"" << p->name() << "\");"; - C << nl << "__checkConnection();"; + C << nl << "::Ice::ConnectionPtr __connection = ice_connection();"; C.zeroIndent(); C << nl << "#ifdef ICEE_BLOCKING_CLIENT"; C << nl << "# ifndef ICEE_PURE_BLOCKING_CLIENT"; C.restoreIndent(); - C << nl << "if(_connection->blocking())"; + C << nl << "if(__connection->blocking())"; C.zeroIndent(); C << nl << "# endif"; C.restoreIndent(); C << sb; - C << nl << "::IceInternal::Outgoing __out(_connection.get(), _reference.get(), __operation, " + C << nl << "::IceInternal::Outgoing __out(__connection.get(), _reference.get(), __operation, " << "static_cast< ::Ice::OperationMode>(" << p->mode() << "), __ctx);"; C << nl; if(ret) @@ -1454,7 +1454,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) C << nl << "#ifndef ICEE_PURE_BLOCKING_CLIENT"; C.restoreIndent(); C << sb; - C << nl << "::IceInternal::OutgoingM __out(_connection.get(), _reference.get(), __operation, " + C << nl << "::IceInternal::OutgoingM __out(__connection.get(), _reference.get(), __operation, " << "static_cast< ::Ice::OperationMode>(" << p->mode() << "), __ctx);"; C << nl; if(ret) diff --git a/cpp/src/slice2javae/Gen.cpp b/cpp/src/slice2javae/Gen.cpp index 9aa17daedda..8a6baaba8ef 100644 --- a/cpp/src/slice2javae/Gen.cpp +++ b/cpp/src/slice2javae/Gen.cpp @@ -2212,8 +2212,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) { out << nl << "__checkTwowayOnly(\"" << opName << "\");"; } - out << nl << "__checkConnection();"; - out << nl << "IceInternal.Outgoing __og = _connection.getOutgoing(_reference, \"" << op->name() << "\", " + out << nl << "Ice.Connection __connection = ice_connection();"; + out << nl << "IceInternal.Outgoing __og = __connection.getOutgoing(_reference, \"" << op->name() << "\", " << sliceModeToIceMode(op) << ", __ctx);"; out << nl << "try"; out << sb; @@ -2280,7 +2280,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) out << eb; out << nl << "finally"; out << sb; - out << nl << "_connection.reclaimOutgoing(__og);"; + out << nl << "__connection.reclaimOutgoing(__og);"; out << eb; if(!ret) { diff --git a/cppe/include/IceE/Proxy.h b/cppe/include/IceE/Proxy.h index 0fe604ef7ad..694303f8575 100644 --- a/cppe/include/IceE/Proxy.h +++ b/cppe/include/IceE/Proxy.h @@ -156,9 +156,7 @@ public: protected: const ::Ice::Context& __defaultContext() const; - void __checkConnection(); - ::Ice::ConnectionPtr _connection; ::IceInternal::ReferencePtr _reference; private: @@ -170,6 +168,8 @@ private: void setup(const ::IceInternal::ReferencePtr&); friend class ::IceInternal::ProxyFactory; + + ::Ice::ConnectionPtr _connection; }; } } diff --git a/cppe/src/IceE/Proxy.cpp b/cppe/src/IceE/Proxy.cpp index 6412de2d777..206180f720c 100644 --- a/cppe/src/IceE/Proxy.cpp +++ b/cppe/src/IceE/Proxy.cpp @@ -172,13 +172,13 @@ IceProxy::Ice::Object::ice_isA(const string& __id, const Context& __context) { __checkTwowayOnly("ice_isA"); static const string __operation("ice_isA"); - __checkConnection(); + ConnectionPtr __connection = ice_connection(); #ifdef ICEE_BLOCKING_CLIENT # ifndef ICEE_PURE_BLOCKING_CLIENT - if(_connection->blocking()) + if(__connection->blocking()) # endif { - Outgoing __og(_connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); + Outgoing __og(__connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); return __ice_isA(__id, __og); } # ifndef ICEE_PURE_BLOCKING_CLIENT @@ -187,7 +187,7 @@ IceProxy::Ice::Object::ice_isA(const string& __id, const Context& __context) #endif #ifndef ICEE_PURE_BLOCKING_CLIENT { - OutgoingM __og(_connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); + OutgoingM __og(__connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); return __ice_isA(__id, __og); } #endif @@ -264,13 +264,13 @@ IceProxy::Ice::Object::ice_ping(const Context& __context) try { static const string __operation("ice_ping"); - __checkConnection(); + ConnectionPtr __connection = ice_connection(); #ifdef ICEE_BLOCKING_CLIENT # ifndef ICEE_PURE_BLOCKING_CLIENT - if(_connection->blocking()) + if(__connection->blocking()) # endif { - Outgoing __og(_connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); + Outgoing __og(__connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); __ice_ping(__og); } # ifndef ICEE_PURE_BLOCKING_CLIENT @@ -279,7 +279,7 @@ IceProxy::Ice::Object::ice_ping(const Context& __context) #endif #ifndef ICEE_PURE_BLOCKING_CLIENT { - OutgoingM __og(_connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); + OutgoingM __og(__connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); __ice_ping(__og); } #endif @@ -348,13 +348,13 @@ IceProxy::Ice::Object::ice_ids(const Context& __context) { __checkTwowayOnly("ice_ids"); static const string __operation("ice_ids"); - __checkConnection(); + ConnectionPtr __connection = ice_connection(); #ifdef ICEE_BLOCKING_CLIENT # ifndef ICEE_PURE_BLOCKING_CLIENT - if(_connection->blocking()) + if(__connection->blocking()) # endif { - Outgoing __og(_connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); + Outgoing __og(__connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); return __ice_ids(__og); } # ifndef ICEE_PURE_BLOCKING_CLIENT @@ -363,7 +363,7 @@ IceProxy::Ice::Object::ice_ids(const Context& __context) #endif #ifndef ICEE_PURE_BLOCKING_CLIENT { - OutgoingM __og(_connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); + OutgoingM __og(__connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); return __ice_ids(__og); } #endif @@ -432,13 +432,13 @@ IceProxy::Ice::Object::ice_id(const Context& __context) { __checkTwowayOnly("ice_id"); static const string __operation("ice_id"); - __checkConnection(); + ConnectionPtr __connection = ice_connection(); #ifdef ICEE_BLOCKING_CLIENT #ifndef ICEE_PURE_BLOCKING_CLIENT - if(_connection->blocking()) + if(__connection->blocking()) #endif { - Outgoing __og(_connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); + Outgoing __og(__connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); return __ice_id(__og); } # ifndef ICEE_PURE_BLOCKING_CLIENT @@ -447,7 +447,7 @@ IceProxy::Ice::Object::ice_id(const Context& __context) #endif #ifndef ICEE_PURE_BLOCKING_CLIENT { - OutgoingM __og(_connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); + OutgoingM __og(__connection.get(), _reference.get(), __operation, ::Ice::Nonmutating, __context); return __ice_id(__og); } #endif @@ -692,6 +692,25 @@ IceProxy::Ice::Object::ice_locator(const LocatorPrx& locator) const ConnectionPtr IceProxy::Ice::Object::ice_connection() { + ::IceUtil::Mutex::Lock sync(*this); + + if(!_connection) + { + _connection = _reference->getConnection(); + + // + // If this proxy is for a non-local object, and we are + // using a router, then add this proxy to the router info + // object. + // +#ifdef ICEE_HAS_ROUTER + RoutableReferencePtr rr = RoutableReferencePtr::dynamicCast(_reference); + if(rr && rr->getRouterInfo()) + { + rr->getRouterInfo()->addProxy(this); + } +#endif + } return _connection; } @@ -788,31 +807,6 @@ IceProxy::Ice::Object::__defaultContext() const } void -IceProxy::Ice::Object::__checkConnection() -{ - ::IceUtil::Mutex::Lock sync(*this); - - if(!_connection) - { - _connection = _reference->getConnection(); - - // - // If this proxy is for a non-local object, and we are - // using a router, then add this proxy to the router info - // object. - // -#ifdef ICEE_HAS_ROUTER - RoutableReferencePtr rr = RoutableReferencePtr::dynamicCast(_reference); - if(rr && rr->getRouterInfo()) - { - rr->getRouterInfo()->addProxy(this); - } -#endif - } -} - - -void IceProxy::Ice::Object::setup(const ReferencePtr& ref) { // diff --git a/javae/src/Ice/ObjectPrxHelperBase.java b/javae/src/Ice/ObjectPrxHelperBase.java index e39cde22d44..167441ddd8f 100644 --- a/javae/src/Ice/ObjectPrxHelperBase.java +++ b/javae/src/Ice/ObjectPrxHelperBase.java @@ -53,8 +53,8 @@ public class ObjectPrxHelperBase implements ObjectPrx try { __checkTwowayOnly("ice_isA"); - __checkConnection(); - IceInternal.Outgoing __og = _connection.getOutgoing(_reference, "ice_isA", OperationMode.Nonmutating, + Connection __connection = ice_connection(); + IceInternal.Outgoing __og = __connection.getOutgoing(_reference, "ice_isA", OperationMode.Nonmutating, __context); try { @@ -88,7 +88,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } finally { - _connection.reclaimOutgoing(__og); + __connection.reclaimOutgoing(__og); } } catch(IceInternal.NonRepeatable __ex) @@ -117,8 +117,8 @@ public class ObjectPrxHelperBase implements ObjectPrx try { __checkTwowayOnly("ice_ping"); - __checkConnection(); - IceInternal.Outgoing __og = _connection.getOutgoing(_reference, "ice_ping", OperationMode.Nonmutating, + Connection __connection = ice_connection(); + IceInternal.Outgoing __og = __connection.getOutgoing(_reference, "ice_ping", OperationMode.Nonmutating, __context); try { @@ -142,7 +142,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } finally { - _connection.reclaimOutgoing(__og); + __connection.reclaimOutgoing(__og); } return; } @@ -172,8 +172,8 @@ public class ObjectPrxHelperBase implements ObjectPrx try { __checkTwowayOnly("ice_ids"); - __checkConnection(); - IceInternal.Outgoing __og = _connection.getOutgoing(_reference, "ice_ids", OperationMode.Nonmutating, + Connection __connection = ice_connection(); + IceInternal.Outgoing __og = __connection.getOutgoing(_reference, "ice_ids", OperationMode.Nonmutating, __context); try { @@ -198,7 +198,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } finally { - _connection.reclaimOutgoing(__og); + __connection.reclaimOutgoing(__og); } } catch(IceInternal.NonRepeatable __ex) @@ -227,8 +227,8 @@ public class ObjectPrxHelperBase implements ObjectPrx try { __checkTwowayOnly("ice_id"); - __checkConnection(); - IceInternal.Outgoing __og = _connection.getOutgoing(_reference, "ice_id", OperationMode.Nonmutating, + Connection __connection = ice_connection(); + IceInternal.Outgoing __og = __connection.getOutgoing(_reference, "ice_id", OperationMode.Nonmutating, __context); try { @@ -253,7 +253,7 @@ public class ObjectPrxHelperBase implements ObjectPrx } finally { - _connection.reclaimOutgoing(__og); + __connection.reclaimOutgoing(__og); } } catch(IceInternal.NonRepeatable __ex) @@ -450,9 +450,30 @@ public class ObjectPrxHelperBase implements ObjectPrx } } - public final Connection + public synchronized final Connection ice_connection() { + if(_connection == null) + { + _connection = _reference.getConnection(); + + // + // If this proxy is for a non-local object, and we are + // using a router, then add this proxy to the router info + // object. + // + try + { + IceInternal.RoutableReference rr = (IceInternal.RoutableReference)_reference; + if(rr != null && rr.getRouterInfo() != null) + { + rr.getRouterInfo().addProxy(this); + } + } + catch(ClassCastException e) + { + } + } return _connection; } @@ -552,32 +573,6 @@ public class ObjectPrxHelperBase implements ObjectPrx return _reference.getContext(); } - protected synchronized void - __checkConnection() - { - if(_connection == null) - { - _connection = _reference.getConnection(); - - // - // If this proxy is for a non-local object, and we are - // using a router, then add this proxy to the router info - // object. - // - try - { - IceInternal.RoutableReference rr = (IceInternal.RoutableReference)_reference; - if(rr != null && rr.getRouterInfo() != null) - { - rr.getRouterInfo().addProxy(this); - } - } - catch(ClassCastException e) - { - } - } - } - // // Only for use by IceInternal.ProxyFactory // @@ -599,5 +594,5 @@ public class ObjectPrxHelperBase implements ObjectPrx } protected IceInternal.Reference _reference; - protected Connection _connection; + private Connection _connection; } |