summaryrefslogtreecommitdiff
path: root/javae/src
diff options
context:
space:
mode:
Diffstat (limited to 'javae/src')
-rw-r--r--javae/src/IceInternal/DirectReference.java22
-rw-r--r--javae/src/IceInternal/IndirectReference.java34
-rw-r--r--javae/src/IceInternal/Reference.java47
3 files changed, 61 insertions, 42 deletions
diff --git a/javae/src/IceInternal/DirectReference.java b/javae/src/IceInternal/DirectReference.java
index 07d8427a5ea..30204f1e08a 100644
--- a/javae/src/IceInternal/DirectReference.java
+++ b/javae/src/IceInternal/DirectReference.java
@@ -40,6 +40,7 @@ public class DirectReference extends RoutableReference
}
DirectReference r = (DirectReference)getInstance().referenceFactory().copy(this);
r._endpoints = newEndpoints;
+ r.applyOverrides(r._endpoints);
return r;
}
@@ -52,13 +53,16 @@ public class DirectReference extends RoutableReference
public Reference
changeTimeout(int newTimeout)
{
- DirectReference r = (DirectReference)getInstance().referenceFactory().copy(this);
- Endpoint[] newEndpoints = new Endpoint[_endpoints.length];
- for(int i = 0; i < _endpoints.length; i++)
- {
- newEndpoints[i] = _endpoints[i].timeout(newTimeout);
- }
- r._endpoints = newEndpoints;
+ DirectReference r = (DirectReference)super.changeTimeout(newTimeout);
+ if(r != this) // Also override the timeout on the endpoints if it was updated.
+ {
+ Endpoint[] newEndpoints = new Endpoint[_endpoints.length];
+ for(int i = 0; i < _endpoints.length; i++)
+ {
+ newEndpoints[i] = _endpoints[i].timeout(newTimeout);
+ }
+ r._endpoints = newEndpoints;
+ }
return r;
}
@@ -111,9 +115,11 @@ public class DirectReference extends RoutableReference
getConnection()
{
Endpoint[] endpts = super.getRoutedEndpoints();
+ applyOverrides(endpts);
+
if(endpts.length == 0)
{
- endpts = _endpoints;
+ endpts = _endpoints; // Endpoint overrides are already applied on these endpoints.
}
Endpoint[] filteredEndpoints = filterEndpoints(endpts);
if(filteredEndpoints.length == 0)
diff --git a/javae/src/IceInternal/IndirectReference.java b/javae/src/IceInternal/IndirectReference.java
index 0439e06fd35..777024f4001 100644
--- a/javae/src/IceInternal/IndirectReference.java
+++ b/javae/src/IceInternal/IndirectReference.java
@@ -59,19 +59,6 @@ public class IndirectReference extends RoutableReference
return r;
}
- public Reference
- changeTimeout(int newTimeout)
- {
- if(_overrideTimeout && _timeout == newTimeout)
- {
- return this;
- }
- IndirectReference r = (IndirectReference)getInstance().referenceFactory().copy(this);
- r._timeout = newTimeout;
- r._overrideTimeout = true;
- return r;
- }
-
public void
streamWrite(BasicStream s)
throws Ice.MarshalException
@@ -136,16 +123,7 @@ public class IndirectReference extends RoutableReference
endpts = _locatorInfo.getEndpoints(this, cached);
}
- //
- // Apply the endpoint overrides to each endpoint.
- //
- for(int i = 0; i < endpts.length; ++i)
- {
- if(_overrideTimeout)
- {
- endpts[i] = endpts[i].timeout(_timeout);
- }
- }
+ applyOverrides(endpts);
Endpoint[] filteredEndpoints = filterEndpoints(endpts);
if(filteredEndpoints.length == 0)
@@ -247,14 +225,6 @@ public class IndirectReference extends RoutableReference
{
return false;
}
- if(_overrideTimeout != rhs._overrideTimeout)
- {
- return false;
- }
- if(_overrideTimeout && _timeout != rhs._timeout)
- {
- return false;
- }
return _locatorInfo == null ? rhs._locatorInfo == null : _locatorInfo.equals(rhs._locatorInfo);
}
@@ -280,7 +250,5 @@ public class IndirectReference extends RoutableReference
}
private String _adapterId;
- private boolean _overrideTimeout;
- private int _timeout; // Only used if _overrideTimeout == true
private LocatorInfo _locatorInfo;
}
diff --git a/javae/src/IceInternal/Reference.java b/javae/src/IceInternal/Reference.java
index 74325593a6c..2472721612d 100644
--- a/javae/src/IceInternal/Reference.java
+++ b/javae/src/IceInternal/Reference.java
@@ -159,9 +159,21 @@ public abstract class Reference
return r;
}
+ public Reference
+ changeTimeout(int newTimeout)
+ {
+ if(_overrideTimeout && _timeout == newTimeout)
+ {
+ return this;
+ }
+ Reference r = getInstance().referenceFactory().copy(this);
+ r._timeout = newTimeout;
+ r._overrideTimeout = true;
+ return r;
+ }
+
public abstract Reference changeRouter(Ice.RouterPrx newRouter);
public abstract Reference changeLocator(Ice.LocatorPrx newLocator);
- public abstract Reference changeTimeout(int newTimeout);
public synchronized int
hashCode()
@@ -362,6 +374,15 @@ public abstract class Reference
return false;
}
+ if(_overrideTimeout != r._overrideTimeout)
+ {
+ return false;
+ }
+ if(_overrideTimeout && _timeout != r._timeout)
+ {
+ return false;
+ }
+
return true;
}
@@ -374,6 +395,8 @@ public abstract class Reference
dest._context = _context;
dest._emptyContext = _emptyContext;
dest._facet = _facet;
+ dest._timeout = _timeout;
+ dest._overrideTimeout = _overrideTimeout;
dest._hashInitialized = false;
}
@@ -397,6 +420,14 @@ public abstract class Reference
private static java.util.Hashtable _emptyContext = new java.util.Hashtable();
private String _facet;
+ //
+ // NOTE: The override timeout should theoritically be in
+ // RoutableReference. But for consistency with the C++ version we
+ // keep it here (see also comment in src/IceE/Reference.h)
+ //
+ private boolean _overrideTimeout;
+ private int _timeout; // Only used if _overrideTimeout == true
+
protected int _hashValue;
protected boolean _hashInitialized;
@@ -434,9 +465,23 @@ public abstract class Reference
_identity = ident;
_context = ctx == null ? _emptyContext : ctx;
_facet = fac;
+ _overrideTimeout = false;
+ _timeout = -1;
_hashInitialized = false;
}
+ protected void
+ applyOverrides(Endpoint[] endpts)
+ {
+ for(int i = 0; i < endpts.length; ++i)
+ {
+ if(_overrideTimeout)
+ {
+ endpts[i] = endpts[i].timeout(_timeout);
+ }
+ }
+ }
+
//
// Filter endpoints based on criteria from this reference.
//