diff options
Diffstat (limited to 'cppe/src')
-rw-r--r-- | cppe/src/IceE/Proxy.cpp | 90 | ||||
-rw-r--r-- | cppe/src/IceE/ProxyFactory.cpp | 6 | ||||
-rw-r--r-- | cppe/src/IceE/Reference.cpp | 44 | ||||
-rw-r--r-- | cppe/src/IceE/Reference.h | 11 |
4 files changed, 71 insertions, 80 deletions
diff --git a/cppe/src/IceE/Proxy.cpp b/cppe/src/IceE/Proxy.cpp index 9ae070e8d79..05de7bbd16b 100644 --- a/cppe/src/IceE/Proxy.cpp +++ b/cppe/src/IceE/Proxy.cpp @@ -18,6 +18,9 @@ #ifdef ICEE_HAS_ROUTER # include <IceE/RouterInfo.h> #endif +#ifdef ICEE_HAS_LOCATOR +# include <IceE/LocatorInfo.h> +#endif using namespace std; using namespace Ice; @@ -503,10 +506,19 @@ IceProxy::Ice::Object::ice_newFacet(const string& newFacet) const return ice_facet(newFacet); } +#ifdef ICEE_HAS_ROUTER + +RouterPrx +IceProxy::Ice::Object::ice_getRouter() const +{ + RouterInfoPtr ri = _reference->getRouterInfo(); + return ri ? ri->getRouter() : RouterPrx(); +} + ObjectPrx -IceProxy::Ice::Object::ice_twoway() const +IceProxy::Ice::Object::ice_router(const RouterPrx& router) const { - ReferencePtr ref = _reference->changeMode(Reference::ModeTwoway); + ReferencePtr ref = _reference->changeRouter(router); if(ref == _reference) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); @@ -519,16 +531,21 @@ IceProxy::Ice::Object::ice_twoway() const } } -bool -IceProxy::Ice::Object::ice_isTwoway() const +#endif + +#ifdef ICEE_HAS_LOCATOR + +LocatorPrx +IceProxy::Ice::Object::ice_getLocator() const { - return _reference->getMode() == Reference::ModeTwoway; + LocatorInfoPtr ri = _reference->getLocatorInfo(); + return ri ? ri->getLocator() : LocatorPrx(); } ObjectPrx -IceProxy::Ice::Object::ice_oneway() const +IceProxy::Ice::Object::ice_locator(const LocatorPrx& locator) const { - ReferencePtr ref = _reference->changeMode(Reference::ModeOneway); + ReferencePtr ref = _reference->changeLocator(locator); if(ref == _reference) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); @@ -541,78 +558,77 @@ IceProxy::Ice::Object::ice_oneway() const } } -bool -IceProxy::Ice::Object::ice_isOneway() const -{ - return _reference->getMode() == Reference::ModeOneway; -} +#endif -#ifdef ICEE_HAS_BATCH ObjectPrx -IceProxy::Ice::Object::ice_batchOneway() const +IceProxy::Ice::Object::ice_twoway() const { - ReferencePtr ref = _reference->changeMode(Reference::ModeBatchOneway); - if(ref == _reference) + if(_reference->getMode() == Reference::ModeTwoway) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } else { ObjectPrx proxy(new ::IceProxy::Ice::Object()); - proxy->setup(ref); + proxy->setup(_reference->changeMode(Reference::ModeTwoway)); return proxy; } } bool -IceProxy::Ice::Object::ice_isBatchOneway() const +IceProxy::Ice::Object::ice_isTwoway() const { - return _reference->getMode() == Reference::ModeBatchOneway; + return _reference->getMode() == Reference::ModeTwoway; } -#endif ObjectPrx -IceProxy::Ice::Object::ice_timeout(int t) const +IceProxy::Ice::Object::ice_oneway() const { - ReferencePtr ref = _reference->changeTimeout(t); - if(ref == _reference) + if(_reference->getMode() == Reference::ModeOneway) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } else { ObjectPrx proxy(new ::IceProxy::Ice::Object()); - proxy->setup(ref); + proxy->setup(_reference->changeMode(Reference::ModeOneway)); return proxy; } } -#ifdef ICEE_HAS_ROUTER +bool +IceProxy::Ice::Object::ice_isOneway() const +{ + return _reference->getMode() == Reference::ModeOneway; +} +#ifdef ICEE_HAS_BATCH ObjectPrx -IceProxy::Ice::Object::ice_router(const RouterPrx& router) const +IceProxy::Ice::Object::ice_batchOneway() const { - ReferencePtr ref = _reference->changeRouter(router); - if(ref == _reference) + if(_reference->getMode() == Reference::ModeBatchOneway) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); } else { ObjectPrx proxy(new ::IceProxy::Ice::Object()); - proxy->setup(ref); + proxy->setup(_reference->changeMode(Reference::ModeBatchOneway)); return proxy; } } +bool +IceProxy::Ice::Object::ice_isBatchOneway() const +{ + return _reference->getMode() == Reference::ModeBatchOneway; +} #endif -#ifdef ICEE_HAS_LOCATOR - ObjectPrx -IceProxy::Ice::Object::ice_locator(const LocatorPrx& locator) const +IceProxy::Ice::Object::ice_timeout(int t) const { - ReferencePtr ref = _reference->changeLocator(locator); + ReferencePtr ref = _reference->changeTimeout(t); if(ref == _reference) { return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this)); @@ -625,8 +641,6 @@ IceProxy::Ice::Object::ice_locator(const LocatorPrx& locator) const } } -#endif - ConnectionPtr IceProxy::Ice::Object::ice_connection() { @@ -642,10 +656,10 @@ IceProxy::Ice::Object::ice_connection() // object. // #ifdef ICEE_HAS_ROUTER - RoutableReferencePtr rr = RoutableReferencePtr::dynamicCast(_reference); - if(rr && rr->getRouterInfo()) + RouterInfoPtr ri = _reference->getRouterInfo(); + if(ri) { - rr->getRouterInfo()->addProxy(this); + ri->addProxy(this); } #endif } diff --git a/cppe/src/IceE/ProxyFactory.cpp b/cppe/src/IceE/ProxyFactory.cpp index 8f1cd6d1141..d4c7cd5a6e8 100644 --- a/cppe/src/IceE/ProxyFactory.cpp +++ b/cppe/src/IceE/ProxyFactory.cpp @@ -99,12 +99,12 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, co #ifdef ICEE_HAS_LOCATOR if(dynamic_cast<const ObjectNotExistException*>(&ex)) { - IndirectReferencePtr ir = IndirectReferencePtr::dynamicCast(ref); - if(!ir || !ir->getLocatorInfo()) + LocatorInfoPtr li = ref->getLocatorInfo(); + if(!li) { ex.ice_throw(); } - ir->getLocatorInfo()->clearObjectCache(ir); + li->clearObjectCache(IndirectReferencePtr::dynamicCast(ref)); } else #endif diff --git a/cppe/src/IceE/Reference.cpp b/cppe/src/IceE/Reference.cpp index 4c8123e5994..9f670541190 100644 --- a/cppe/src/IceE/Reference.cpp +++ b/cppe/src/IceE/Reference.cpp @@ -694,21 +694,7 @@ IceInternal::DirectReference::changeEndpoints(const vector<EndpointPtr>& newEndp ReferencePtr IceInternal::DirectReference::changeLocator(const LocatorPrx& newLocator) const { - if(newLocator) - { - LocatorInfoPtr newLocatorInfo = getInstance()->locatorManager()->get(newLocator); -#ifdef ICEE_HAS_ROUTER - return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(), - getSecure(), "", 0, newLocatorInfo); -#else - return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(), - getSecure(), "", newLocatorInfo); -#endif - } - else - { - return DirectReferencePtr(const_cast<DirectReference*>(this)); - } + return DirectReferencePtr(const_cast<DirectReference*>(this)); } #endif @@ -895,30 +881,14 @@ IceInternal::IndirectReference::getEndpoints() const ReferencePtr IceInternal::IndirectReference::changeLocator(const LocatorPrx& newLocator) const { - // - // Return a direct reference if a null locator is given. - // - if(!newLocator) + LocatorInfoPtr newLocatorInfo = getInstance()->locatorManager()->get(newLocator); + if(newLocatorInfo == _locatorInfo) { -#ifdef ICEE_HAS_ROUTER - return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(), - getSecure(), vector<EndpointPtr>(), getRouterInfo()); -#else - return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(), - getSecure(), vector<EndpointPtr>()); -#endif - } - else - { - LocatorInfoPtr newLocatorInfo = getInstance()->locatorManager()->get(newLocator); - if(newLocatorInfo == _locatorInfo) - { - return IndirectReferencePtr(const_cast<IndirectReference*>(this)); - } - IndirectReferencePtr r = IndirectReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this)); - r->_locatorInfo = newLocatorInfo; - return r; + return IndirectReferencePtr(const_cast<IndirectReference*>(this)); } + IndirectReferencePtr r = IndirectReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this)); + r->_locatorInfo = newLocatorInfo; + return r; } ReferencePtr diff --git a/cppe/src/IceE/Reference.h b/cppe/src/IceE/Reference.h index ebd937f1c49..7e0384edb3f 100644 --- a/cppe/src/IceE/Reference.h +++ b/cppe/src/IceE/Reference.h @@ -57,6 +57,12 @@ public: Ice::CommunicatorPtr getCommunicator() const; +#ifdef ICEE_HAS_ROUTER + virtual RouterInfoPtr getRouterInfo() const { return 0; } +#endif +#ifdef ICEE_HAS_LOCATOR + virtual LocatorInfoPtr getLocatorInfo() const { return 0; } +#endif virtual std::vector<EndpointPtr> getEndpoints() const = 0; // @@ -166,7 +172,7 @@ class RoutableReference : public Reference { public: - const RouterInfoPtr& getRouterInfo() const { return _routerInfo; } + virtual RouterInfoPtr getRouterInfo() const { return _routerInfo; } std::vector<EndpointPtr> getRoutedEndpoints() const; virtual ReferencePtr changeRouter(const Ice::RouterPrx&) const; @@ -263,7 +269,8 @@ public: , const LocatorInfoPtr&); const std::string& getAdapterId() const { return _adapterId; } - const LocatorInfoPtr& getLocatorInfo() const { return _locatorInfo; } + + virtual LocatorInfoPtr getLocatorInfo() const { return _locatorInfo; } virtual std::vector<EndpointPtr> getEndpoints() const; |