diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/ConnectionI.java | 60 | ||||
-rw-r--r-- | java/src/Ice/ObjectPrxHelperBase.java | 13 | ||||
-rw-r--r-- | java/src/Ice/_ObjectDel.java | 2 | ||||
-rw-r--r-- | java/src/Ice/_ObjectDelD.java | 4 | ||||
-rw-r--r-- | java/src/Ice/_ObjectDelM.java | 5 | ||||
-rw-r--r-- | java/src/IceInternal/Outgoing.java | 2 | ||||
-rw-r--r-- | java/src/IceInternal/OutgoingAsync.java | 105 | ||||
-rw-r--r-- | java/src/IceInternal/Protocol.java | 48 |
8 files changed, 92 insertions, 147 deletions
diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java index e73618364f9..7241b60172f 100644 --- a/java/src/Ice/ConnectionI.java +++ b/java/src/Ice/ConnectionI.java @@ -478,31 +478,6 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } } - private final static byte[] _requestHdr = - { - IceInternal.Protocol.magic[0], - IceInternal.Protocol.magic[1], - IceInternal.Protocol.magic[2], - IceInternal.Protocol.magic[3], - IceInternal.Protocol.protocolMajor, - IceInternal.Protocol.protocolMinor, - IceInternal.Protocol.encodingMajor, - IceInternal.Protocol.encodingMinor, - IceInternal.Protocol.requestMsg, - (byte)0, // Compression status. - (byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder). - (byte)0, (byte)0, (byte)0, (byte)0 // Request ID (placeholder). - }; - - // - // TODO: Should not be a member function of ConnectionI. - // - public void - prepareRequest(IceInternal.BasicStream os) - { - os.writeBlob(_requestHdr); - } - public void sendRequest(IceInternal.BasicStream os, IceInternal.Outgoing out, boolean compress) throws IceInternal.LocalExceptionWrapper @@ -721,22 +696,6 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne } } - private final static byte[] _requestBatchHdr = - { - IceInternal.Protocol.magic[0], - IceInternal.Protocol.magic[1], - IceInternal.Protocol.magic[2], - IceInternal.Protocol.magic[3], - IceInternal.Protocol.protocolMajor, - IceInternal.Protocol.protocolMinor, - IceInternal.Protocol.encodingMajor, - IceInternal.Protocol.encodingMinor, - IceInternal.Protocol.requestBatchMsg, - 0, // Compression status. - (byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder). - (byte)0, (byte)0, (byte)0, (byte)0 // Number of requests in batch (placeholder). - }; - public synchronized void prepareBatchRequest(IceInternal.BasicStream os) { @@ -763,7 +722,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne { try { - _batchStream.writeBlob(_requestBatchHdr); + _batchStream.writeBlob(IceInternal.Protocol.requestBatchHdr); } catch(LocalException ex) { @@ -1099,21 +1058,6 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne // } - private final static byte[] _replyHdr = - { - IceInternal.Protocol.magic[0], - IceInternal.Protocol.magic[1], - IceInternal.Protocol.magic[2], - IceInternal.Protocol.magic[3], - IceInternal.Protocol.protocolMajor, - IceInternal.Protocol.protocolMinor, - IceInternal.Protocol.encodingMajor, - IceInternal.Protocol.encodingMinor, - IceInternal.Protocol.replyMsg, - (byte)0, // Compression status. - (byte)0, (byte)0, (byte)0, (byte)0 // Message size (placeholder). - }; - public void message(IceInternal.BasicStream stream, IceInternal.ThreadPool threadPool) { @@ -1972,7 +1916,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne if(response) { assert(invokeNum == 1); // No further invocations if a response is expected. - os.writeBlob(_replyHdr); + os.writeBlob(IceInternal.Protocol.replyHdr); // // Add the request ID. diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java index a8b36b7f0e8..aafa0088ce4 100644 --- a/java/src/Ice/ObjectPrxHelperBase.java +++ b/java/src/Ice/ObjectPrxHelperBase.java @@ -612,7 +612,7 @@ public class ObjectPrxHelperBase implements ObjectPrx try { _ObjectDel __del = __getDelegate(); - return __del.ice_connection(); + return __del.__getConnection(new BooleanHolder()); } catch(LocalException __ex) { @@ -682,6 +682,12 @@ public class ObjectPrxHelperBase implements ObjectPrx if(_reference.getCacheConnection()) { + // + // The _delegate attribute is only used if "cache connection" + // is enabled. If it's not enabled, we don't keep track of the + // delegate -- a new delegate is created for each invocations. + // + if(delegateD != null) { _ObjectDelD delegate = __createDelegateD(); @@ -816,6 +822,11 @@ public class ObjectPrxHelperBase implements ObjectPrx if(_reference.getCacheConnection()) { + // + // The _delegate attribute is only used if "cache connection" + // is enabled. If it's not enabled, we don't keep track of the + // delegate -- a new delegate is created for each invocations. + // _delegate = delegate; } diff --git a/java/src/Ice/_ObjectDel.java b/java/src/Ice/_ObjectDel.java index 4ed42f655f6..2a5d5eda56a 100644 --- a/java/src/Ice/_ObjectDel.java +++ b/java/src/Ice/_ObjectDel.java @@ -27,5 +27,5 @@ public interface _ObjectDel java.util.Map context) throws IceInternal.LocalExceptionWrapper; - Connection ice_connection(); + ConnectionI __getConnection(BooleanHolder compress); } diff --git a/java/src/Ice/_ObjectDelD.java b/java/src/Ice/_ObjectDelD.java index ee6dc660b6c..29274f33be8 100644 --- a/java/src/Ice/_ObjectDelD.java +++ b/java/src/Ice/_ObjectDelD.java @@ -100,8 +100,8 @@ public class _ObjectDelD implements _ObjectDel throw new CollocationOptimizationException(); } - public Connection - ice_connection() + public ConnectionI + __getConnection(BooleanHolder compress) { throw new CollocationOptimizationException(); } diff --git a/java/src/Ice/_ObjectDelM.java b/java/src/Ice/_ObjectDelM.java index 845dd00e507..594acf0b526 100644 --- a/java/src/Ice/_ObjectDelM.java +++ b/java/src/Ice/_ObjectDelM.java @@ -207,9 +207,10 @@ public class _ObjectDelM implements _ObjectDel } } - public Connection - ice_connection() + public ConnectionI + __getConnection(BooleanHolder compress) { + compress.value = __compress; return __connection; } diff --git a/java/src/IceInternal/Outgoing.java b/java/src/IceInternal/Outgoing.java index 5c7cb51b29e..09979f49f11 100644 --- a/java/src/IceInternal/Outgoing.java +++ b/java/src/IceInternal/Outgoing.java @@ -421,7 +421,7 @@ public final class Outgoing case Reference.ModeOneway: case Reference.ModeDatagram: { - _connection.prepareRequest(_os); + _os.writeBlob(IceInternal.Protocol.requestHdr); break; } diff --git a/java/src/IceInternal/OutgoingAsync.java b/java/src/IceInternal/OutgoingAsync.java index edcd9a274c0..ad2264eb543 100644 --- a/java/src/IceInternal/OutgoingAsync.java +++ b/java/src/IceInternal/OutgoingAsync.java @@ -175,8 +175,6 @@ public abstract class OutgoingAsync { if(__os != null) // Don't retry if cleanup() was already called. { - boolean doRetry = false; - // // A CloseConnectionException indicates graceful // server shutdown, and is therefore always repeatable @@ -194,29 +192,14 @@ public abstract class OutgoingAsync { try { - ProxyFactory proxyFactory = _reference.getInstance().proxyFactory(); - if(proxyFactory != null) - { - _cnt = proxyFactory.checkRetryAfterException(exc, _reference, _cnt); - } - else - { - throw exc; // The communicator is already destroyed, so we cannot retry. - } - - doRetry = true; + _cnt = ((Ice.ObjectPrxHelperBase)_proxy).__handleException(exc, _cnt); + __send(); + return; } catch(Ice.LocalException ex) { } } - - if(doRetry) - { - _connection = null; - __send(); - return; - } } try @@ -280,49 +263,24 @@ public abstract class OutgoingAsync // ((Ice.ObjectPrxHelperBase)prx).__checkTwowayOnly(operation); - Reference ref = ((Ice.ObjectPrxHelperBase)prx).__reference(); - - // - // Optimization: Don't update the connection if it is not - // necessary. - // - if(_connection == null || _reference == null || !_reference.equals(ref)) - { - _connection = ref.getConnection(_compress); - } - - _reference = ref; + _proxy = prx; _cnt = 0; _mode = mode; + + Reference ref = ((Ice.ObjectPrxHelperBase)_proxy).__reference(); assert(__is == null); - __is = new BasicStream(_reference.getInstance()); + __is = new BasicStream(ref.getInstance()); assert(__os == null); - __os = new BasicStream(_reference.getInstance()); - - // - // If we are using a router, then add the proxy to the router info object. - // - try - { - RoutableReference rr = (RoutableReference)_reference; - if(rr != null && rr.getRouterInfo() != null) - { - rr.getRouterInfo().addProxy(prx); - } - - } - catch(ClassCastException ex) - { - } + __os = new BasicStream(ref.getInstance()); - _connection.prepareRequest(__os); + __os.writeBlob(IceInternal.Protocol.requestHdr); - _reference.getIdentity().__write(__os); + ref.getIdentity().__write(__os); // // For compatibility with the old FacetPath. // - String facet = _reference.getFacet(); + String facet = ref.getFacet(); if(facet == null || facet.length() == 0) { __os.writeStringSeq(null); @@ -376,14 +334,11 @@ public abstract class OutgoingAsync { while(true) { - if(_connection == null) - { - _connection = _reference.getConnection(_compress); - } - - if(_connection.timeout() >= 0) + Ice.BooleanHolder comp = new Ice.BooleanHolder(); + Ice.ConnectionI con = ((Ice.ObjectPrxHelperBase)_proxy).__getDelegate().__getConnection(comp); + if(con.timeout() >= 0) { - _absoluteTimeoutMillis = System.currentTimeMillis() + _connection.timeout(); + _absoluteTimeoutMillis = System.currentTimeMillis() + con.timeout(); } else { @@ -392,7 +347,7 @@ public abstract class OutgoingAsync try { - _connection.sendAsyncRequest(__os, this, _compress.value); + con.sendAsyncRequest(__os, this, comp.value); // // Don't do anything after sendAsyncRequest() returned @@ -405,25 +360,12 @@ public abstract class OutgoingAsync } catch(LocalExceptionWrapper ex) { - if(!ex.retry()) - { - throw ex.get(); - } + ((Ice.ObjectPrxHelperBase)_proxy).__handleExceptionWrapper(ex); } catch(Ice.LocalException ex) { - ProxyFactory proxyFactory = _reference.getInstance().proxyFactory(); - if(proxyFactory != null) - { - _cnt = proxyFactory.checkRetryAfterException(ex, _reference, _cnt); - } - else - { - throw ex; // The communicator is already destroyed, so we cannot retry. - } - } - - _connection = null; + _cnt = ((Ice.ObjectPrxHelperBase)_proxy).__handleException(ex, _cnt); + } } } catch(Ice.LocalException ex) @@ -440,7 +382,8 @@ public abstract class OutgoingAsync { if(__os != null) // Don't print anything if cleanup() was already called. { - if(_reference.getInstance().properties().getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0) + Reference ref = ((Ice.ObjectPrxHelperBase)_proxy).__reference(); + if(ref.getInstance().properties().getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0) { java.io.StringWriter sw = new java.io.StringWriter(); java.io.PrintWriter pw = new java.io.PrintWriter(sw); @@ -449,7 +392,7 @@ public abstract class OutgoingAsync out.print("exception raised by AMI callback:\n"); ex.printStackTrace(pw); pw.flush(); - _reference.getInstance().logger().warning(sw.toString()); + ref.getInstance().logger().warning(sw.toString()); } } } @@ -466,11 +409,9 @@ public abstract class OutgoingAsync protected BasicStream __is; protected BasicStream __os; - private Reference _reference; - private Ice.ConnectionI _connection; + private Ice.ObjectPrx _proxy; private int _cnt; private Ice.OperationMode _mode; - private Ice.BooleanHolder _compress = new Ice.BooleanHolder(); // // Must be volatile, because we don't want to lock the monitor diff --git a/java/src/IceInternal/Protocol.java b/java/src/IceInternal/Protocol.java index 0d1dcbcd954..e2b24481156 100644 --- a/java/src/IceInternal/Protocol.java +++ b/java/src/IceInternal/Protocol.java @@ -46,4 +46,52 @@ final public class Protocol public final static byte replyMsg = 2; public final static byte validateConnectionMsg = 3; public final static byte closeConnectionMsg = 4; + + public final static byte[] requestHdr = + { + IceInternal.Protocol.magic[0], + IceInternal.Protocol.magic[1], + IceInternal.Protocol.magic[2], + IceInternal.Protocol.magic[3], + IceInternal.Protocol.protocolMajor, + IceInternal.Protocol.protocolMinor, + IceInternal.Protocol.encodingMajor, + IceInternal.Protocol.encodingMinor, + IceInternal.Protocol.requestMsg, + (byte)0, // Compression status. + (byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder). + (byte)0, (byte)0, (byte)0, (byte)0 // Request ID (placeholder). + }; + + public final static byte[] requestBatchHdr = + { + IceInternal.Protocol.magic[0], + IceInternal.Protocol.magic[1], + IceInternal.Protocol.magic[2], + IceInternal.Protocol.magic[3], + IceInternal.Protocol.protocolMajor, + IceInternal.Protocol.protocolMinor, + IceInternal.Protocol.encodingMajor, + IceInternal.Protocol.encodingMinor, + IceInternal.Protocol.requestBatchMsg, + 0, // Compression status. + (byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder). + (byte)0, (byte)0, (byte)0, (byte)0 // Number of requests in batch (placeholder). + }; + + public final static byte[] replyHdr = + { + IceInternal.Protocol.magic[0], + IceInternal.Protocol.magic[1], + IceInternal.Protocol.magic[2], + IceInternal.Protocol.magic[3], + IceInternal.Protocol.protocolMajor, + IceInternal.Protocol.protocolMinor, + IceInternal.Protocol.encodingMajor, + IceInternal.Protocol.encodingMinor, + IceInternal.Protocol.replyMsg, + (byte)0, // Compression status. + (byte)0, (byte)0, (byte)0, (byte)0 // Message size (placeholder). + }; + } |