diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-03-30 13:42:38 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-03-30 13:42:38 +0000 |
commit | c0857ef56655107ebaa3099c0e500cfcbe0470e0 (patch) | |
tree | 86c4ad36081315996741131118c99deb347fc619 /java/src | |
parent | Initialize paramater (diff) | |
download | ice-c0857ef56655107ebaa3099c0e500cfcbe0470e0.tar.bz2 ice-c0857ef56655107ebaa3099c0e500cfcbe0470e0.tar.xz ice-c0857ef56655107ebaa3099c0e500cfcbe0470e0.zip |
Finished fixing bug 847
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/ObjectPrx.java | 16 | ||||
-rw-r--r-- | java/src/Ice/ObjectPrxHelperBase.java | 139 | ||||
-rw-r--r-- | java/src/IceInternal/DirectReference.java | 13 | ||||
-rw-r--r-- | java/src/IceInternal/IndirectReference.java | 84 | ||||
-rw-r--r-- | java/src/IceInternal/ProxyFactory.java | 13 | ||||
-rw-r--r-- | java/src/IceInternal/Reference.java | 12 |
6 files changed, 153 insertions, 124 deletions
diff --git a/java/src/Ice/ObjectPrx.java b/java/src/Ice/ObjectPrx.java index 4bff057a10c..cbf5f99e4e2 100644 --- a/java/src/Ice/ObjectPrx.java +++ b/java/src/Ice/ObjectPrx.java @@ -83,6 +83,18 @@ public interface ObjectPrx EndpointSelectionType ice_getEndpointSelection(); ObjectPrx ice_endpointSelection(EndpointSelectionType newType); + boolean ice_getSecure(); + ObjectPrx ice_secure(boolean b); + + Ice.RouterPrx ice_getRouter(); + ObjectPrx ice_router(Ice.RouterPrx router); + + Ice.LocatorPrx ice_getLocator(); + ObjectPrx ice_locator(Ice.LocatorPrx locator); + + boolean ice_getCollocationOptimization(); + ObjectPrx ice_collocationOptimization(boolean b); + ObjectPrx ice_twoway(); boolean ice_isTwoway(); ObjectPrx ice_oneway(); @@ -94,13 +106,9 @@ public interface ObjectPrx ObjectPrx ice_batchDatagram(); boolean ice_isBatchDatagram(); - ObjectPrx ice_secure(boolean b); ObjectPrx ice_compress(boolean co); ObjectPrx ice_timeout(int t); ObjectPrx ice_connectionId(String connectionId); - ObjectPrx ice_router(Ice.RouterPrx router); - ObjectPrx ice_locator(Ice.LocatorPrx locator); - ObjectPrx ice_collocationOptimization(boolean b); Connection ice_connection(); diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java index 16c9e769db9..a03e8143ec7 100644 --- a/java/src/Ice/ObjectPrxHelperBase.java +++ b/java/src/Ice/ObjectPrxHelperBase.java @@ -411,32 +411,38 @@ public class ObjectPrxHelperBase implements ObjectPrx } } + public final boolean + ice_getSecure() + { + return _reference.getSecure(); + } + public final ObjectPrx - ice_twoway() + ice_secure(boolean b) { - IceInternal.Reference ref = _reference.changeMode(IceInternal.Reference.ModeTwoway); - if(ref.equals(_reference)) + if(b == _reference.getSecure()) { return this; } else { ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(ref); + proxy.setup(_reference.changeSecure(b)); return proxy; } } - public final boolean - ice_isTwoway() + public final Ice.RouterPrx + ice_getRouter() { - return _reference.getMode() == IceInternal.Reference.ModeTwoway; + IceInternal.RouterInfo ri = _reference.getRouterInfo(); + return ri != null ? ri.getRouter() : null; } public final ObjectPrx - ice_oneway() + ice_router(Ice.RouterPrx router) { - IceInternal.Reference ref = _reference.changeMode(IceInternal.Reference.ModeOneway); + IceInternal.Reference ref = _reference.changeRouter(router); if(ref.equals(_reference)) { return this; @@ -449,16 +455,17 @@ public class ObjectPrxHelperBase implements ObjectPrx } } - public final boolean - ice_isOneway() + public final Ice.LocatorPrx + ice_getLocator() { - return _reference.getMode() == IceInternal.Reference.ModeOneway; + IceInternal.LocatorInfo ri = _reference.getLocatorInfo(); + return ri != null ? ri.getLocator() : null; } public final ObjectPrx - ice_batchOneway() + ice_locator(Ice.LocatorPrx locator) { - IceInternal.Reference ref = _reference.changeMode(IceInternal.Reference.ModeBatchOneway); + IceInternal.Reference ref = _reference.changeLocator(locator); if(ref.equals(_reference)) { return this; @@ -472,123 +479,135 @@ public class ObjectPrxHelperBase implements ObjectPrx } public final boolean - ice_isBatchOneway() + ice_getCollocationOptimization() { - return _reference.getMode() == IceInternal.Reference.ModeBatchOneway; + return _reference.getCollocationOptimization(); } public final ObjectPrx - ice_datagram() + ice_collocationOptimization(boolean b) { - IceInternal.Reference ref = _reference.changeMode(IceInternal.Reference.ModeDatagram); - if(ref.equals(_reference)) + if(b == _reference.getCollocationOptimization()) { return this; } else { ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(ref); + proxy.setup(_reference.changeCollocationOptimization(b)); return proxy; } } - public final boolean - ice_isDatagram() - { - return _reference.getMode() == IceInternal.Reference.ModeDatagram; - } - public final ObjectPrx - ice_batchDatagram() + ice_twoway() { - IceInternal.Reference ref = _reference.changeMode(IceInternal.Reference.ModeBatchDatagram); - if(ref.equals(_reference)) + if(_reference.getMode() == IceInternal.Reference.ModeTwoway) { return this; } else { ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(ref); + proxy.setup(_reference.changeMode(IceInternal.Reference.ModeTwoway)); return proxy; } } public final boolean - ice_isBatchDatagram() + ice_isTwoway() { - return _reference.getMode() == IceInternal.Reference.ModeBatchDatagram; + return _reference.getMode() == IceInternal.Reference.ModeTwoway; } public final ObjectPrx - ice_secure(boolean b) + ice_oneway() { - IceInternal.Reference ref = _reference.changeSecure(b); - if(ref.equals(_reference)) + if(_reference.getMode() == IceInternal.Reference.ModeOneway) { return this; } else { ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(ref); + proxy.setup(_reference.changeMode(IceInternal.Reference.ModeOneway)); return proxy; } } + public final boolean + ice_isOneway() + { + return _reference.getMode() == IceInternal.Reference.ModeOneway; + } + public final ObjectPrx - ice_compress(boolean co) + ice_batchOneway() { - IceInternal.Reference ref = _reference.changeCompress(co); - if(ref.equals(_reference)) + if(_reference.getMode() == IceInternal.Reference.ModeBatchOneway) { return this; } else { ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(ref); + proxy.setup(_reference.changeMode(IceInternal.Reference.ModeBatchOneway)); return proxy; } } + public final boolean + ice_isBatchOneway() + { + return _reference.getMode() == IceInternal.Reference.ModeBatchOneway; + } + public final ObjectPrx - ice_timeout(int t) + ice_datagram() { - IceInternal.Reference ref = _reference.changeTimeout(t); - if(ref.equals(_reference)) + if(_reference.getMode() == IceInternal.Reference.ModeDatagram) { return this; } else { ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(ref); + proxy.setup(_reference.changeMode(IceInternal.Reference.ModeDatagram)); return proxy; } } + public final boolean + ice_isDatagram() + { + return _reference.getMode() == IceInternal.Reference.ModeDatagram; + } + public final ObjectPrx - ice_connectionId(String id) + ice_batchDatagram() { - IceInternal.Reference ref = _reference.changeConnectionId(id); - if(ref.equals(_reference)) + if(_reference.getMode() == IceInternal.Reference.ModeBatchDatagram) { return this; } else { ObjectPrxHelperBase proxy = new ObjectPrxHelperBase(); - proxy.setup(ref); + proxy.setup(_reference.changeMode(IceInternal.Reference.ModeBatchDatagram)); return proxy; } } + public final boolean + ice_isBatchDatagram() + { + return _reference.getMode() == IceInternal.Reference.ModeBatchDatagram; + } + public final ObjectPrx - ice_router(Ice.RouterPrx router) + ice_compress(boolean co) { - IceInternal.Reference ref = _reference.changeRouter(router); + IceInternal.Reference ref = _reference.changeCompress(co); if(ref.equals(_reference)) { return this; @@ -602,9 +621,9 @@ public class ObjectPrxHelperBase implements ObjectPrx } public final ObjectPrx - ice_locator(Ice.LocatorPrx locator) + ice_timeout(int t) { - IceInternal.Reference ref = _reference.changeLocator(locator); + IceInternal.Reference ref = _reference.changeTimeout(t); if(ref.equals(_reference)) { return this; @@ -618,9 +637,9 @@ public class ObjectPrxHelperBase implements ObjectPrx } public final ObjectPrx - ice_collocationOptimization(boolean b) + ice_connectionId(String id) { - IceInternal.Reference ref = _reference.changeCollocationOptimization(b); + IceInternal.Reference ref = _reference.changeConnectionId(id); if(ref.equals(_reference)) { return this; @@ -837,16 +856,10 @@ public class ObjectPrxHelperBase implements ObjectPrx // 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) + IceInternal.RouterInfo ri = _reference.getRouterInfo(); + if(ri != null) { + ri.addProxy(this); } } diff --git a/java/src/IceInternal/DirectReference.java b/java/src/IceInternal/DirectReference.java index 928f1245913..f36eb64ab3c 100644 --- a/java/src/IceInternal/DirectReference.java +++ b/java/src/IceInternal/DirectReference.java @@ -48,18 +48,7 @@ public class DirectReference extends RoutableReference public Reference changeLocator(Ice.LocatorPrx newLocator) { - if(newLocator != null) - { - LocatorInfo newLocatorInfo = getInstance().locatorManager().get(newLocator); - return getInstance().referenceFactory().create(getIdentity(), getContext(), getFacet(), getMode(), - getSecure(), "", null, newLocatorInfo, - getCollocationOptimization(), - getLocatorCacheTimeout()); - } - else - { - return this; - } + return this; } public Reference diff --git a/java/src/IceInternal/IndirectReference.java b/java/src/IceInternal/IndirectReference.java index c2d045c9059..820631a1d49 100644 --- a/java/src/IceInternal/IndirectReference.java +++ b/java/src/IceInternal/IndirectReference.java @@ -58,58 +58,40 @@ public class IndirectReference extends RoutableReference public Reference changeLocator(Ice.LocatorPrx newLocator) { - // - // Return a direct reference if a null locator is given. - // - if(newLocator == null) - { - return getInstance().referenceFactory().create(getIdentity(), getContext(), getFacet(), getMode(), - getSecure(), new EndpointI[0], getRouterInfo(), - getCollocationOptimization()); - } - else + LocatorInfo newLocatorInfo = getInstance().locatorManager().get(newLocator); + if(_locatorInfo != null && newLocatorInfo != null && newLocatorInfo.equals(_locatorInfo)) { - LocatorInfo newLocatorInfo = getInstance().locatorManager().get(newLocator); - if(_locatorInfo != null && newLocatorInfo != null && newLocatorInfo.equals(_locatorInfo)) - { - return this; - } - IndirectReference r = (IndirectReference)getInstance().referenceFactory().copy(this); - r._locatorInfo = newLocatorInfo; return this; } + IndirectReference r = (IndirectReference)getInstance().referenceFactory().copy(this); + r._locatorInfo = newLocatorInfo; + return r; } public Reference changeCompress(boolean newCompress) { - // - // TODO: This is wrong. - // - IndirectReference r = (IndirectReference)getInstance().referenceFactory().copy(this); - if(_locatorInfo != null) + if(_overrideCompress && _compress == newCompress) { - Ice.LocatorPrx newLocator = Ice.LocatorPrxHelper.uncheckedCast( - _locatorInfo.getLocator().ice_compress(newCompress)); - r._locatorInfo = getInstance().locatorManager().get(newLocator); + return this; } - return r; + IndirectReference r = (IndirectReference)getInstance().referenceFactory().copy(this); + r._compress = newCompress; + r._overrideCompress = true; + return r; } public Reference changeTimeout(int newTimeout) { - // - // TODO: This is wrong. - // - IndirectReference r = (IndirectReference)getInstance().referenceFactory().copy(this); - if(_locatorInfo != null) + if(_overrideTimeout && _timeout == newTimeout) { - Ice.LocatorPrx newLocator = Ice.LocatorPrxHelper.uncheckedCast( - _locatorInfo.getLocator().ice_timeout(newTimeout)); - r._locatorInfo = getInstance().locatorManager().get(newLocator); + return this; } - return r; + IndirectReference r = (IndirectReference)getInstance().referenceFactory().copy(this); + r._timeout = newTimeout; + r._overrideTimeout = true; + return r; } public Reference @@ -216,9 +198,21 @@ public class IndirectReference extends RoutableReference { endpts = _locatorInfo.getEndpoints(this, _locatorCacheTimeout, cached); } + + // + // Apply the endpoint overrides to each endpoint. + // for(int i = 0; i < endpts.length; ++i) { endpts[i] = endpts[i].connectionId(_connectionId); + if(_overrideCompress) + { + endpts[i] = endpts[i].compress(_compress); + } + if(_overrideTimeout) + { + endpts[i] = endpts[i].timeout(_timeout); + } } try @@ -313,6 +307,22 @@ public class IndirectReference extends RoutableReference { return false; } + if(_overrideCompress != rhs._overrideCompress) + { + return false; + } + if(_overrideCompress && _compress != rhs._compress) + { + return false; + } + if(_overrideTimeout != rhs._overrideTimeout) + { + return false; + } + if(_overrideTimeout && _timeout != rhs._timeout) + { + return false; + } if(_locatorInfo == null ? rhs._locatorInfo != null : !_locatorInfo.equals(rhs._locatorInfo)) { return false; @@ -323,5 +333,9 @@ public class IndirectReference extends RoutableReference private String _adapterId; private String _connectionId = ""; private LocatorInfo _locatorInfo; + private boolean _overrideCompress; + private boolean _compress; // Only used if _overrideCompress == true + private boolean _overrideTimeout; + private int _timeout; // Only used if _overrideTimeout == true private int _locatorCacheTimeout; } diff --git a/java/src/IceInternal/ProxyFactory.java b/java/src/IceInternal/ProxyFactory.java index 767a56ad1ed..13f125e5e9b 100644 --- a/java/src/IceInternal/ProxyFactory.java +++ b/java/src/IceInternal/ProxyFactory.java @@ -86,19 +86,12 @@ public final class ProxyFactory // if(ex instanceof Ice.ObjectNotExistException) { - try - { - IceInternal.IndirectReference ir = (IceInternal.IndirectReference)ref; - if(ir.getLocatorInfo() == null) - { - throw ex; - } - ir.getLocatorInfo().clearObjectCache(ir); - } - catch(ClassCastException e) + LocatorInfo li = ref.getLocatorInfo(); + if(li == null) { throw ex; } + li.clearObjectCache((IceInternal.IndirectReference)ref); } else if(ex instanceof Ice.RequestFailedException) { diff --git a/java/src/IceInternal/Reference.java b/java/src/IceInternal/Reference.java index d2895e5f360..f1569b464e7 100644 --- a/java/src/IceInternal/Reference.java +++ b/java/src/IceInternal/Reference.java @@ -62,6 +62,18 @@ public abstract class Reference implements Cloneable return _communicator; } + public RouterInfo + getRouterInfo() + { + return null; + } + + public LocatorInfo + getLocatorInfo() + { + return null; + } + public abstract boolean getSecure(); public abstract String getAdapterId(); public abstract EndpointI[] getEndpoints(); |