summaryrefslogtreecommitdiff
path: root/java/src/IceInternal/IndirectReference.java
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2005-02-08 20:17:26 +0000
committerMark Spruiell <mes@zeroc.com>2005-02-08 20:17:26 +0000
commit6b669e5ba099f8ae780faae2a4865fc611f178a9 (patch)
treea34ba4e9bcf23352147a8b95fc8d67ec6a08d65a /java/src/IceInternal/IndirectReference.java
parentchanging sequence unmarshaling for fixed-length types (diff)
downloadice-6b669e5ba099f8ae780faae2a4865fc611f178a9.tar.bz2
ice-6b669e5ba099f8ae780faae2a4865fc611f178a9.tar.xz
ice-6b669e5ba099f8ae780faae2a4865fc611f178a9.zip
Reference fixes:
- Moving _secure to RoutableReference - Fixing changeDefault() - Fixing changeRouter() and changeLocator() to return appropriate values
Diffstat (limited to 'java/src/IceInternal/IndirectReference.java')
-rw-r--r--java/src/IceInternal/IndirectReference.java63
1 files changed, 45 insertions, 18 deletions
diff --git a/java/src/IceInternal/IndirectReference.java b/java/src/IceInternal/IndirectReference.java
index 46c125c5175..5aad271d681 100644
--- a/java/src/IceInternal/IndirectReference.java
+++ b/java/src/IceInternal/IndirectReference.java
@@ -47,26 +47,49 @@ public class IndirectReference extends RoutableReference
}
public Reference
- changeLocator(Ice.LocatorPrx newLocator)
+ changeDefault()
{
- LocatorInfo newLocatorInfo = getInstance().locatorManager().get(newLocator);
-
- if((newLocatorInfo == _locatorInfo) ||
- (_locatorInfo != null && newLocatorInfo != null && newLocatorInfo.equals(_locatorInfo)))
- {
- return this;
- }
- IndirectReference r = (IndirectReference)getInstance().referenceFactory().copy(this);
- r._locatorInfo = newLocatorInfo;
- return this;
+ //
+ // Return a direct reference if no default locator is defined.
+ //
+ Ice.LocatorPrx loc = getInstance().referenceFactory().getDefaultLocator();
+ if(loc == null)
+ {
+ return getInstance().referenceFactory().create(getIdentity(), null, "", ModeTwoway, false,
+ new Endpoint[0], getRouterInfo(), false);
+ }
+ else
+ {
+ IndirectReference r = (IndirectReference)super.changeDefault();
+ r._locatorInfo = getInstance().locatorManager().get(loc);
+ return r;
+ }
}
public Reference
- changeDefault()
+ changeLocator(Ice.LocatorPrx newLocator)
{
- IndirectReference r = (IndirectReference)super.changeDefault();
- r._locatorInfo = getInstance().locatorManager().get(getInstance().referenceFactory().getDefaultLocator());
- return r;
+ //
+ // Return a direct reference if a null locator is given.
+ //
+ if(newLocator == null)
+ {
+ return getInstance().referenceFactory().create(getIdentity(), getContext(), getFacet(), getMode(),
+ getSecure(), new Endpoint[0], getRouterInfo(),
+ getCollocationOptimization());
+ }
+ else
+ {
+ LocatorInfo newLocatorInfo = getInstance().locatorManager().get(newLocator);
+ if((newLocatorInfo == _locatorInfo) ||
+ (_locatorInfo != null && newLocatorInfo != null && newLocatorInfo.equals(_locatorInfo)))
+ {
+ return this;
+ }
+ IndirectReference r = (IndirectReference)getInstance().referenceFactory().copy(this);
+ r._locatorInfo = newLocatorInfo;
+ return this;
+ }
}
public Reference
@@ -146,8 +169,7 @@ public class IndirectReference extends RoutableReference
while(true)
{
Endpoint[] endpts = super.getRoutedEndpoints();
- Ice.BooleanHolder cached = new Ice.BooleanHolder();
- cached.value = false;
+ Ice.BooleanHolder cached = new Ice.BooleanHolder(false);
if(endpts.length == 0 && _locatorInfo != null)
{
endpts = _locatorInfo.getEndpoints(this, cached);
@@ -225,7 +247,12 @@ public class IndirectReference extends RoutableReference
{
return false;
}
- return _adapterId.equals(rhs._adapterId) && _locatorInfo.equals(rhs._locatorInfo);
+ if(!_adapterId.equals(rhs._adapterId))
+ {
+ return false;
+ }
+ return (_locatorInfo == rhs._locatorInfo) ||
+ (_locatorInfo != null && rhs._locatorInfo != null && rhs._locatorInfo.equals(_locatorInfo));
}
private String _adapterId;