diff options
author | Marc Laukien <marc@zeroc.com> | 2002-12-29 17:29:59 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-12-29 17:29:59 +0000 |
commit | 03bbf7b354c070280e457737c9784d0e1c55ade4 (patch) | |
tree | 4f9f15a481a672f838b3c633ae97a37d2f9b7151 /java/src | |
parent | finished AMI (diff) | |
download | ice-03bbf7b354c070280e457737c9784d0e1c55ade4.tar.bz2 ice-03bbf7b354c070280e457737c9784d0e1c55ade4.tar.xz ice-03bbf7b354c070280e457737c9784d0e1c55ade4.zip |
started with amd
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/IceInternal/Connection.java | 2 | ||||
-rw-r--r-- | java/src/IceInternal/Incoming.java | 105 | ||||
-rw-r--r-- | java/src/IceInternal/IncomingAsync.java | 167 | ||||
-rw-r--r-- | java/src/IceInternal/IncomingBase.java | 76 | ||||
-rw-r--r-- | java/src/IceInternal/OutgoingAsync.java | 25 |
5 files changed, 297 insertions, 78 deletions
diff --git a/java/src/IceInternal/Connection.java b/java/src/IceInternal/Connection.java index fe64ac25739..ec6fba846bd 100644 --- a/java/src/IceInternal/Connection.java +++ b/java/src/IceInternal/Connection.java @@ -1105,7 +1105,7 @@ public final class Connection extends EventHandler in = _incomingCache; _incomingCache = _incomingCache.next; in.next = null; - in.reset(_adapter, this, response); + in.reset(_instance, _adapter, this, response); } } diff --git a/java/src/IceInternal/Incoming.java b/java/src/IceInternal/Incoming.java index 441923cfbd6..42a109cf248 100644 --- a/java/src/IceInternal/Incoming.java +++ b/java/src/IceInternal/Incoming.java @@ -14,7 +14,7 @@ package IceInternal; -public class Incoming +final public class Incoming extends IncomingBase { public Incoming(Instance instance, Ice.ObjectAdapter adapter, Connection connection, boolean response) @@ -34,7 +34,7 @@ public class Incoming // reallocated. // public void - reset(Ice.ObjectAdapter adapter, Connection connection, boolean response) + reset(Instance instance, Ice.ObjectAdapter adapter, Connection connection, boolean response) { _current.adapter = adapter; if(_current.ctx != null) @@ -46,8 +46,22 @@ public class Incoming _cookie.value = null; _connection = connection; _response = response; - _is.reset(); - _os.reset(); + if(_is == null) + { + _is = new BasicStream(instance); + } + else + { + _is.reset(); + } + if(_os == null) + { + _os = new BasicStream(instance); + } + else + { + _os.reset(); + } } // @@ -56,8 +70,16 @@ public class Incoming public void destroy() { - _is.destroy(); - _os.destroy(); + if(_is != null) + { + _is.destroy(); + _is = null; + } + if(_os != null) + { + _os.destroy(); + _os = null; + } } public void @@ -165,7 +187,7 @@ public class Incoming ex.operation = _current.operation; } - warning(ex); + __warning(ex); if(_response) { @@ -192,12 +214,12 @@ public class Incoming _os.writeString(ex.operation); } - finishInvoke(); + __finishInvoke(); return; } catch(Ice.LocalException ex) { - warning(ex); + __warning(ex); if(_response) { @@ -207,7 +229,7 @@ public class Incoming _os.writeString(ex.toString()); } - finishInvoke(); + __finishInvoke(); return; } /* Not possible in Java - UserExceptions are checked exceptions @@ -218,7 +240,7 @@ public class Incoming */ catch(RuntimeException ex) { - warning(ex); + __warning(ex); if(_response) { @@ -228,7 +250,7 @@ public class Incoming _os.writeString(ex.toString()); } - finishInvoke(); + __finishInvoke(); return; } @@ -264,7 +286,7 @@ public class Incoming } } - finishInvoke(); + __finishInvoke(); } public BasicStream @@ -279,62 +301,5 @@ public class Incoming return _os; } - private void - finishInvoke() - { - if(_locator != null && _servant != null) - { - _locator.finished(_current, _servant, _cookie.value); - } - - _is.endReadEncaps(); - - // - // Send a response if necessary. If we don't need to send a - // response, we still need to tell the connection that we're - // finished with dispatching. - // - if(_response) - { - _connection.sendResponse(_os); - } - else - { - _connection.sendNoResponse(); - } - } - - private void - warning(Exception ex) - { - if(_os.instance().properties().getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) - { - java.io.StringWriter sw = new java.io.StringWriter(); - java.io.PrintWriter pw = new java.io.PrintWriter(sw); - IceUtil.OutputBase out = new IceUtil.OutputBase(pw); - out.setUseTab(false); - out.print("dispatch exception:"); - out.print("\nidentity: " + Ice.Util.identityToString(_current.id)); - out.print("\nfacet: "); - IceInternal.ValueWriter.write(_current.facet, out); - out.print("\noperation: " + _current.operation); - out.print("\n"); - ex.printStackTrace(pw); - pw.flush(); - _os.instance().logger().warning(sw.toString()); - } - } - - private Ice.Current _current; - private Ice.Object _servant; - private Ice.ServantLocator _locator; - private Ice.LocalObjectHolder _cookie; - - private Connection _connection; - private boolean _response; - - private BasicStream _is; - private BasicStream _os; - Incoming next; // For use by Connection. } diff --git a/java/src/IceInternal/IncomingAsync.java b/java/src/IceInternal/IncomingAsync.java new file mode 100644 index 00000000000..f99cbc733bb --- /dev/null +++ b/java/src/IceInternal/IncomingAsync.java @@ -0,0 +1,167 @@ +// ********************************************************************** +// +// Copyright (c) 2002 +// ZeroC, Inc. +// Billerica, MA, USA +// +// All Rights Reserved. +// +// Ice is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License version 2 as published by +// the Free Software Foundation. +// +// ********************************************************************** + +package IceInternal; + +public class IncomingAsync extends IncomingBase +{ + public + IncomingAsync(Incoming in) // Adopts the Incoming argument. It must not be used afterwards. + { + _current = in._current; + _servant = in._servant; + _locator = in._locator; + _cookie = in._cookie; + _connection = in._connection; + _response = in._response; + _is = in._is; + in._is = null; + _os = in._os; + in._os = null; + } + + final protected void + __response(boolean ok) + { + if(_response) + { + _os.endWriteEncaps(); + + int save = _os.pos(); + _os.pos(Protocol.headerSize + 4); // Dispatch status position. + + if(ok) + { + _os.writeByte((byte)DispatchStatus._DispatchOK); + } + else + { + _os.writeByte((byte)DispatchStatus._DispatchUserException); + } + + _os.pos(save); + } + + __finishInvoke(); + } + + final protected void + __exception(Exception exc) + { + try + { + throw exc; + } + catch(Ice.RequestFailedException ex) + { + if(ex.id == null) + { + ex.id = _current.id; + } + + if(ex.facet == null) + { + ex.facet = _current.facet; + } + + if(ex.operation == null || ex.operation.length() == 0) + { + ex.operation = _current.operation; + } + + __warning(ex); + + if(_response) + { + _os.endWriteEncaps(); + _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. + if(ex instanceof Ice.ObjectNotExistException) + { + _os.writeByte((byte)DispatchStatus._DispatchObjectNotExist); + } + else if(ex instanceof Ice.FacetNotExistException) + { + _os.writeByte((byte)DispatchStatus._DispatchFacetNotExist); + } + else if(ex instanceof Ice.OperationNotExistException) + { + _os.writeByte((byte)DispatchStatus._DispatchOperationNotExist); + } + else + { + assert(false); + } + ex.id.__write(_os); + _os.writeStringSeq(ex.facet); + _os.writeString(ex.operation); + } + + __finishInvoke(); + } + catch(Ice.LocalException ex) + { + __warning(ex); + + if(_response) + { + _os.endWriteEncaps(); + _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. + _os.writeByte((byte)DispatchStatus._DispatchUnknownLocalException); + _os.writeString(ex.toString()); + } + + __finishInvoke(); + } + catch(Ice.UserException ex) + { + __warning(ex); + + if(_response) + { + _os.endWriteEncaps(); + _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. + _os.writeByte((byte)DispatchStatus._DispatchUnknownUserException); + _os.writeString(ex.toString()); + } + + __finishInvoke(); + } + catch(Exception ex) + { + __warning(ex); + + if(_response) + { + _os.endWriteEncaps(); + _os.resize(Protocol.headerSize + 4, false); // Dispatch status position. + _os.writeByte((byte)DispatchStatus._DispatchUnknownException); + _os.writeString(ex.toString()); + } + + __finishInvoke(); + } + } + + final protected BasicStream + __is() + { + return _is; + } + + final protected BasicStream + __os() + { + return _os; + } +}; diff --git a/java/src/IceInternal/IncomingBase.java b/java/src/IceInternal/IncomingBase.java new file mode 100644 index 00000000000..3c552358c94 --- /dev/null +++ b/java/src/IceInternal/IncomingBase.java @@ -0,0 +1,76 @@ +// ********************************************************************** +// +// Copyright (c) 2002 +// ZeroC, Inc. +// Billerica, MA, USA +// +// All Rights Reserved. +// +// Ice is free software; you can redistribute it and/or modify it under +// the terms of the GNU General Public License version 2 as published by +// the Free Software Foundation. +// +// ********************************************************************** + +package IceInternal; + +public class IncomingBase +{ + final protected void + __finishInvoke() + { + if(_locator != null && _servant != null) + { + _locator.finished(_current, _servant, _cookie.value); + } + + _is.endReadEncaps(); + + // + // Send a response if necessary. If we don't need to send a + // response, we still need to tell the connection that we're + // finished with dispatching. + // + if(_response) + { + _connection.sendResponse(_os); + } + else + { + _connection.sendNoResponse(); + } + } + + final protected void + __warning(Exception ex) + { + if(_os.instance().properties().getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0) + { + java.io.StringWriter sw = new java.io.StringWriter(); + java.io.PrintWriter pw = new java.io.PrintWriter(sw); + IceUtil.OutputBase out = new IceUtil.OutputBase(pw); + out.setUseTab(false); + out.print("dispatch exception:"); + out.print("\nidentity: " + Ice.Util.identityToString(_current.id)); + out.print("\nfacet: "); + IceInternal.ValueWriter.write(_current.facet, out); + out.print("\noperation: " + _current.operation); + out.print("\n"); + ex.printStackTrace(pw); + pw.flush(); + _os.instance().logger().warning(sw.toString()); + } + } + + protected Ice.Current _current; + protected Ice.Object _servant; + protected Ice.ServantLocator _locator; + protected Ice.LocalObjectHolder _cookie; + + protected Connection _connection; + + protected boolean _response; + + protected BasicStream _is; + protected BasicStream _os; +}; diff --git a/java/src/IceInternal/OutgoingAsync.java b/java/src/IceInternal/OutgoingAsync.java index 723bc6b072c..a2a0c1d9f4d 100644 --- a/java/src/IceInternal/OutgoingAsync.java +++ b/java/src/IceInternal/OutgoingAsync.java @@ -75,13 +75,6 @@ public abstract class OutgoingAsync } public void - __destroy() - { - _os.destroy(); - _is.destroy(); - } - - public void __invoke() { _connection.incProxyCount(); @@ -92,6 +85,7 @@ public abstract class OutgoingAsync catch(RuntimeException ex) { _connection.decProxyCount(); + destroy(); throw ex; } } @@ -201,6 +195,7 @@ public abstract class OutgoingAsync finally { _connection.decProxyCount(); + destroy(); } } @@ -218,6 +213,7 @@ public abstract class OutgoingAsync finally { _connection.decProxyCount(); + destroy(); } } @@ -236,6 +232,21 @@ public abstract class OutgoingAsync protected abstract void __response(boolean ok); private void + destroy() + { + if(_is != null) + { + _is.destroy(); + _is = null; + } + if(_os != null) + { + _os.destroy(); + _os = null; + } + } + + private void warning(Exception ex) { if(_os.instance().properties().getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0) |