summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2006-03-30 13:30:28 +0000
committerBenoit Foucher <benoit@zeroc.com>2006-03-30 13:30:28 +0000
commit798a2e1405f74702d17b343511a2da5298927d54 (patch)
tree1a886a2e745c26e46fabb5a0c9ca6b7f86bbeecf /cpp/src
parentFixed windows comile error (diff)
downloadice-798a2e1405f74702d17b343511a2da5298927d54.tar.bz2
ice-798a2e1405f74702d17b343511a2da5298927d54.tar.xz
ice-798a2e1405f74702d17b343511a2da5298927d54.zip
Finished fixing bug 847.
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Proxy.cpp130
-rw-r--r--cpp/src/Ice/ProxyFactory.cpp6
-rw-r--r--cpp/src/Ice/Reference.cpp119
-rw-r--r--cpp/src/Ice/Reference.h13
4 files changed, 167 insertions, 101 deletions
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index 3bfdc14610a..f380d58efd7 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -9,6 +9,7 @@
#include <Ice/Proxy.h>
#include <Ice/ProxyFactory.h>
+#include <Ice/ReferenceFactory.h>
#include <Ice/Object.h>
#include <Ice/ObjectAdapterFactory.h>
#include <Ice/Outgoing.h>
@@ -582,32 +583,38 @@ IceProxy::Ice::Object::ice_endpointSelection(EndpointSelectionType newType) cons
}
}
+bool
+IceProxy::Ice::Object::ice_getSecure() const
+{
+ return _reference->getSecure();
+}
+
ObjectPrx
-IceProxy::Ice::Object::ice_twoway() const
+IceProxy::Ice::Object::ice_secure(bool b) const
{
- ReferencePtr ref = _reference->changeMode(Reference::ModeTwoway);
- if(ref == _reference)
+ if(b == _reference->getSecure())
{
return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(ref);
+ proxy->setup(_reference->changeSecure(b));
return proxy;
}
}
-bool
-IceProxy::Ice::Object::ice_isTwoway() const
+RouterPrx
+IceProxy::Ice::Object::ice_getRouter() const
{
- return _reference->getMode() == Reference::ModeTwoway;
+ RouterInfoPtr ri = _reference->getRouterInfo();
+ return ri ? ri->getRouter() : RouterPrx();
}
ObjectPrx
-IceProxy::Ice::Object::ice_oneway() const
+IceProxy::Ice::Object::ice_router(const RouterPrx& router) const
{
- ReferencePtr ref = _reference->changeMode(Reference::ModeOneway);
+ ReferencePtr ref = _reference->changeRouter(router);
if(ref == _reference)
{
return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
@@ -620,16 +627,17 @@ IceProxy::Ice::Object::ice_oneway() const
}
}
-bool
-IceProxy::Ice::Object::ice_isOneway() const
+LocatorPrx
+IceProxy::Ice::Object::ice_getLocator() const
{
- return _reference->getMode() == Reference::ModeOneway;
+ LocatorInfoPtr ri = _reference->getLocatorInfo();
+ return ri ? ri->getLocator() : LocatorPrx();
}
ObjectPrx
-IceProxy::Ice::Object::ice_batchOneway() const
+IceProxy::Ice::Object::ice_locator(const LocatorPrx& locator) const
{
- ReferencePtr ref = _reference->changeMode(Reference::ModeBatchOneway);
+ ReferencePtr ref = _reference->changeLocator(locator);
if(ref == _reference)
{
return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
@@ -643,123 +651,135 @@ IceProxy::Ice::Object::ice_batchOneway() const
}
bool
-IceProxy::Ice::Object::ice_isBatchOneway() const
+IceProxy::Ice::Object::ice_getCollocationOptimization() const
{
- return _reference->getMode() == Reference::ModeBatchOneway;
+ return _reference->getCollocationOptimization();
}
ObjectPrx
-IceProxy::Ice::Object::ice_datagram() const
+IceProxy::Ice::Object::ice_collocationOptimization(bool b) const
{
- ReferencePtr ref = _reference->changeMode(Reference::ModeDatagram);
- if(ref == _reference)
+ if(b == _reference->getCollocationOptimization())
{
return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(ref);
+ proxy->setup(_reference->changeCollocationOptimization(b));
return proxy;
}
}
-bool
-IceProxy::Ice::Object::ice_isDatagram() const
-{
- return _reference->getMode() == Reference::ModeDatagram;
-}
-
ObjectPrx
-IceProxy::Ice::Object::ice_batchDatagram() const
+IceProxy::Ice::Object::ice_twoway() const
{
- ReferencePtr ref = _reference->changeMode(Reference::ModeBatchDatagram);
- 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_isBatchDatagram() const
+IceProxy::Ice::Object::ice_isTwoway() const
{
- return _reference->getMode() == Reference::ModeBatchDatagram;
+ return _reference->getMode() == Reference::ModeTwoway;
}
ObjectPrx
-IceProxy::Ice::Object::ice_secure(bool b) const
+IceProxy::Ice::Object::ice_oneway() const
{
- ReferencePtr ref = _reference->changeSecure(b);
- 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;
}
}
+bool
+IceProxy::Ice::Object::ice_isOneway() const
+{
+ return _reference->getMode() == Reference::ModeOneway;
+}
+
ObjectPrx
-IceProxy::Ice::Object::ice_compress(bool b) const
+IceProxy::Ice::Object::ice_batchOneway() const
{
- ReferencePtr ref = _reference->changeCompress(b);
- 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;
+}
+
ObjectPrx
-IceProxy::Ice::Object::ice_timeout(int t) const
+IceProxy::Ice::Object::ice_datagram() const
{
- ReferencePtr ref = _reference->changeTimeout(t);
- if(ref == _reference)
+ if(_reference->getMode() == Reference::ModeDatagram)
{
return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(ref);
+ proxy->setup(_reference->changeMode(Reference::ModeDatagram));
return proxy;
}
}
+bool
+IceProxy::Ice::Object::ice_isDatagram() const
+{
+ return _reference->getMode() == Reference::ModeDatagram;
+}
+
ObjectPrx
-IceProxy::Ice::Object::ice_router(const RouterPrx& router) const
+IceProxy::Ice::Object::ice_batchDatagram() const
{
- ReferencePtr ref = _reference->changeRouter(router);
- if(ref == _reference)
+ if(_reference->getMode() == Reference::ModeBatchDatagram)
{
return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(ref);
+ proxy->setup(_reference->changeMode(Reference::ModeBatchDatagram));
return proxy;
}
}
+bool
+IceProxy::Ice::Object::ice_isBatchDatagram() const
+{
+ return _reference->getMode() == Reference::ModeBatchDatagram;
+}
+
ObjectPrx
-IceProxy::Ice::Object::ice_locator(const LocatorPrx& locator) const
+IceProxy::Ice::Object::ice_compress(bool b) const
{
- ReferencePtr ref = _reference->changeLocator(locator);
+ ReferencePtr ref = _reference->changeCompress(b);
if(ref == _reference)
{
return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
@@ -773,9 +793,9 @@ IceProxy::Ice::Object::ice_locator(const LocatorPrx& locator) const
}
ObjectPrx
-IceProxy::Ice::Object::ice_collocationOptimization(bool b) const
+IceProxy::Ice::Object::ice_timeout(int t) const
{
- ReferencePtr ref = _reference->changeCollocationOptimization(b);
+ ReferencePtr ref = _reference->changeTimeout(t);
if(ref == _reference)
{
return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
@@ -1007,10 +1027,10 @@ IceProxy::Ice::Object::__getDelegate()
// using a router, then add this proxy to the router info
// object.
//
- RoutableReferencePtr rr = RoutableReferencePtr::dynamicCast(_reference);
- if(rr && rr->getRouterInfo())
+ RouterInfoPtr ri = _reference->getRouterInfo();
+ if(ri)
{
- rr->getRouterInfo()->addProxy(this);
+ ri->addProxy(this);
}
}
diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp
index a2eaa1911c7..67f6c695ced 100644
--- a/cpp/src/Ice/ProxyFactory.cpp
+++ b/cpp/src/Ice/ProxyFactory.cpp
@@ -97,12 +97,12 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, co
//
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 if(dynamic_cast<const RequestFailedException*>(&ex))
{
diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp
index 29280b2e5b3..d2aa754439d 100644
--- a/cpp/src/Ice/Reference.cpp
+++ b/cpp/src/Ice/Reference.cpp
@@ -1055,18 +1055,7 @@ IceInternal::DirectReference::getLocatorCacheTimeout() const
ReferencePtr
IceInternal::DirectReference::changeLocator(const LocatorPrx& newLocator) const
{
- if(newLocator)
- {
- LocatorInfoPtr newLocatorInfo = getInstance()->locatorManager()->get(newLocator);
- return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(),
- getSecure(), "", 0, newLocatorInfo,
- getCollocationOptimization(),
- getLocatorCacheTimeout());
- }
- else
- {
- return DirectReferencePtr(const_cast<DirectReference*>(this));
- }
+ return DirectReferencePtr(const_cast<DirectReference*>(this));
}
ReferencePtr
@@ -1275,6 +1264,10 @@ IceInternal::IndirectReference::IndirectReference(const InstancePtr& inst, const
int locatorCacheTimeout) :
RoutableReference(inst, com, ident, ctx, fs, md, sec, rtrInfo, collocationOpt),
_adapterId(adptid),
+ _overrideCompress(false),
+ _compress(false),
+ _overrideTimeout(false),
+ _timeout(0),
_locatorInfo(locInfo),
_locatorCacheTimeout(locatorCacheTimeout)
{
@@ -1301,49 +1294,39 @@ IceInternal::IndirectReference::getLocatorCacheTimeout() 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)
{
- return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(),
- getSecure(), vector<EndpointIPtr>(), getRouterInfo(),
- getCollocationOptimization());
- }
- 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
IceInternal::IndirectReference::changeCompress(bool newCompress) const
{
- IndirectReferencePtr r = IndirectReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
- if(_locatorInfo)
+ if(_overrideCompress && newCompress == _compress)
{
- LocatorPrx newLocator = LocatorPrx::uncheckedCast(_locatorInfo->getLocator()->ice_compress(newCompress));
- r->_locatorInfo = getInstance()->locatorManager()->get(newLocator);
+ return IndirectReferencePtr(const_cast<IndirectReference*>(this));
}
+ IndirectReferencePtr r = IndirectReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
+ r->_compress = newCompress;
+ r->_overrideCompress = true;
return r;
}
ReferencePtr
IceInternal::IndirectReference::changeTimeout(int newTimeout) const
{
- IndirectReferencePtr r = IndirectReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
- if(_locatorInfo)
+ if(_overrideTimeout && newTimeout == _timeout)
{
- LocatorPrx newLocator = LocatorPrx::uncheckedCast(_locatorInfo->getLocator()->ice_timeout(newTimeout));
- r->_locatorInfo = getInstance()->locatorManager()->get(newLocator);
+ return IndirectReferencePtr(const_cast<IndirectReference*>(this));
}
+ IndirectReferencePtr r = IndirectReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
+ r->_timeout = newTimeout;
+ r->_overrideTimeout = true;
return r;
}
@@ -1453,11 +1436,19 @@ IceInternal::IndirectReference::getConnection(bool& comp) const
}
//
- // Apply the cached connection id to each endpoint.
+ // Apply the endpoint overrides to each endpoint.
//
for(vector<EndpointIPtr>::iterator p = endpts.begin(); p != endpts.end(); ++p)
{
*p = (*p)->connectionId(_connectionId);
+ if(_overrideCompress)
+ {
+ *p = (*p)->compress(_compress);
+ }
+ if(_overrideTimeout)
+ {
+ *p = (*p)->timeout(_timeout);
+ }
}
try
@@ -1543,7 +1534,11 @@ IceInternal::IndirectReference::operator==(const Reference& r) const
return false;
}
- return _adapterId == rhs->_adapterId && _connectionId == rhs->_connectionId && _locatorInfo == rhs->_locatorInfo &&
+ return _adapterId == rhs->_adapterId &&
+ _connectionId == rhs->_connectionId &&
+ _overrideCompress == rhs->_overrideCompress && (!_overrideCompress || _compress == rhs->_compress) &&
+ _overrideTimeout == rhs->_overrideTimeout && (!_overrideTimeout || _timeout == rhs->_timeout) &&
+ _locatorInfo == rhs->_locatorInfo &&
_locatorCacheTimeout == rhs->_locatorCacheTimeout;
}
@@ -1587,6 +1582,46 @@ IceInternal::IndirectReference::operator<(const Reference& r) const
return false;
}
+ if(!_overrideCompress && rhs->_overrideCompress)
+ {
+ return true;
+ }
+ else if(rhs->_overrideCompress < _overrideCompress)
+ {
+ return false;
+ }
+ else if(_overrideCompress)
+ {
+ if(!_compress && rhs->_compress)
+ {
+ return true;
+ }
+ else if(rhs->_compress < _compress)
+ {
+ return false;
+ }
+ }
+
+ if(!_overrideTimeout && rhs->_overrideTimeout)
+ {
+ return true;
+ }
+ else if(rhs->_overrideTimeout < _overrideTimeout)
+ {
+ return false;
+ }
+ else if(_overrideTimeout)
+ {
+ if(_timeout < rhs->_timeout)
+ {
+ return true;
+ }
+ else if(rhs->_timeout < _timeout)
+ {
+ return false;
+ }
+ }
+
if(_locatorInfo < rhs->_locatorInfo)
{
return true;
@@ -1612,6 +1647,10 @@ IceInternal::IndirectReference::IndirectReference(const IndirectReference& r) :
RoutableReference(r),
_adapterId(r._adapterId),
_connectionId(r._connectionId),
+ _overrideCompress(r._overrideCompress),
+ _compress(r._compress),
+ _overrideTimeout(r._overrideTimeout),
+ _timeout(r._timeout),
_locatorInfo(r._locatorInfo),
_locatorCacheTimeout(r._locatorCacheTimeout)
{
diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h
index a014666fe10..4afdac3fe29 100644
--- a/cpp/src/Ice/Reference.h
+++ b/cpp/src/Ice/Reference.h
@@ -52,6 +52,9 @@ public:
Ice::CommunicatorPtr getCommunicator() const;
+ virtual RouterInfoPtr getRouterInfo() const { return 0; }
+ virtual LocatorInfoPtr getLocatorInfo() const { return 0; }
+
virtual bool getSecure() const = 0;
virtual std::string getAdapterId() const = 0;
virtual std::vector<EndpointIPtr> getEndpoints() const = 0;
@@ -139,10 +142,10 @@ public:
const std::vector<Ice::ConnectionIPtr>& getFixedConnections() const;
virtual bool getSecure() const;
- virtual int getLocatorCacheTimeout() const;
virtual std::string getAdapterId() const;
virtual std::vector<EndpointIPtr> getEndpoints() const;
virtual bool getCollocationOptimization() const;
+ virtual int getLocatorCacheTimeout() const;
virtual bool getCacheConnection() const;
virtual Ice::EndpointSelectionType getEndpointSelection() const;
@@ -185,7 +188,7 @@ class RoutableReference : public Reference
{
public:
- const RouterInfoPtr& getRouterInfo() const { return _routerInfo; }
+ virtual RouterInfoPtr getRouterInfo() const { return _routerInfo; }
std::vector<EndpointIPtr> getRoutedEndpoints() const;
virtual bool getSecure() const;
@@ -272,7 +275,7 @@ public:
const std::string&, Mode, bool, const std::string&, const RouterInfoPtr&, const LocatorInfoPtr&,
bool, int);
- const LocatorInfoPtr& getLocatorInfo() const { return _locatorInfo; }
+ virtual LocatorInfoPtr getLocatorInfo() const { return _locatorInfo; }
virtual int getLocatorCacheTimeout() const;
virtual std::string getAdapterId() const;
@@ -306,6 +309,10 @@ private:
std::string _adapterId;
std::string _connectionId;
+ bool _overrideCompress;
+ bool _compress; // Only used if _overrideCompress == true
+ bool _overrideTimeout;
+ int _timeout; // Only used if _overrideTimeout == true
LocatorInfoPtr _locatorInfo;
int _locatorCacheTimeout;
};