diff options
author | Benoit Foucher <benoit@zeroc.com> | 2009-11-23 13:28:08 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2009-11-23 13:28:08 +0100 |
commit | 2c578015edcb36cdc0acd0227295de1dcca1b995 (patch) | |
tree | e163980b5dabb43a40089a29fdf8ff47a3e07f1c /java/src/IceInternal/OutgoingAsyncMessageCallback.java | |
parent | no longer generating inspect method for each Ruby exception (diff) | |
download | ice-2c578015edcb36cdc0acd0227295de1dcca1b995.tar.bz2 ice-2c578015edcb36cdc0acd0227295de1dcca1b995.tar.xz ice-2c578015edcb36cdc0acd0227295de1dcca1b995.zip |
New AMI mapping
Diffstat (limited to 'java/src/IceInternal/OutgoingAsyncMessageCallback.java')
-rw-r--r-- | java/src/IceInternal/OutgoingAsyncMessageCallback.java | 174 |
1 files changed, 26 insertions, 148 deletions
diff --git a/java/src/IceInternal/OutgoingAsyncMessageCallback.java b/java/src/IceInternal/OutgoingAsyncMessageCallback.java index 3f875de3336..93a1fe94d02 100644 --- a/java/src/IceInternal/OutgoingAsyncMessageCallback.java +++ b/java/src/IceInternal/OutgoingAsyncMessageCallback.java @@ -9,152 +9,30 @@ package IceInternal; -abstract public class OutgoingAsyncMessageCallback +// +// This interface is used by the connection to handle OutgoingAsync +// and BatchOutgoingAsync messages. +// +public interface OutgoingAsyncMessageCallback { - public abstract void __sent(Ice.ConnectionI connection); - public abstract void __finished(Ice.LocalException ex); - public abstract void ice_exception(Ice.LocalException ex); - - public final BasicStream - __os() - { - return __os; - } - - public void - __sent(Instance instance) - { - try - { - ((Ice.AMISentCallback)this).ice_sent(); - } - catch(java.lang.Exception ex) - { - __warning(instance, ex); - } - } - - public void - __exception(Ice.LocalException exc) - { - try - { - ice_exception(exc); - } - catch(java.lang.Exception ex) - { - __warning(ex); - } - finally - { - __releaseCallback(); - } - } - - protected synchronized void - finalize() - throws Throwable - { - assert(__os == null); - assert(__is == null); - } - - protected void - __acquireCallback(Ice.ObjectPrx proxy) - { - synchronized(__monitor) - { - // - // We must first wait for other requests to finish. - // - while(__os != null) - { - try - { - __monitor.wait(); - } - catch(InterruptedException ex) - { - } - } - - Reference ref = ((Ice.ObjectPrxHelperBase)proxy).__reference(); - assert(__is == null); - __is = new BasicStream(ref.getInstance()); - assert(__os == null); - __os = new BasicStream(ref.getInstance()); - } - } - - protected void - __releaseCallback(final Ice.LocalException ex) - { - synchronized(__monitor) - { - assert(__os != null); - - // - // This is called by the invoking thread to release the callback following a direct - // failure to marhsall/send the request. We call the ice_exception() callback with - // the thread pool to avoid potential deadlocks in case the invoking thread locked - // some mutexes/resources (which couldn't be re-acquired by the callback). - // - - try - { - __os.instance().clientThreadPool().execute(new ThreadPoolWorkItem() - { - public void - execute(ThreadPoolCurrent current) - { - current.ioCompleted(); - __exception(ex); - } - }); - } - catch(Ice.CommunicatorDestroyedException exc) - { - __releaseCallback(); - throw exc; // CommunicatorDestroyedException is the only exception that can propagate directly. - } - } - } - - protected void - __releaseCallback() - { - synchronized(__monitor) - { - assert(__is != null); - __is = null; - - assert(__os != null); - __os = null; - - __monitor.notify(); - } - } - - protected void - __warning(java.lang.Exception ex) - { - if(__os != null) - { - __warning(__os.instance(), ex); - } - } - - protected void - __warning(Instance instance, java.lang.Exception ex) - { - if(instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0) - { - String s = "exception raised by AMI callback:\n" + Ex.toString(ex); - instance.initializationData().logger.warning(s); - } - } - - protected final java.lang.Object __monitor = new java.lang.Object(); - protected BasicStream __is; - protected BasicStream __os; -}; + // + // Called by the connection when the message is confirmed sent. The connection is locked + // when this is called so this method can call the sent callback. Instead, this method + // returns true if there's a sent callback and false otherwise. If true is returned, the + // connection will call the __sent() method bellow (which in turn should call the sent + // callback). + // + public abstract boolean __sent(Ice.ConnectionI connection); + + // + // Called by the connection to call the user sent callback. + // + public abstract void __sent(); + + // + // Called by the connection when the request failed. The boolean indicates whether or + // not the message was possibly sent (this is useful for retry to figure out whether + // or not the request can't be retried without breaking at-most-once semantics.) + // + public abstract void __finished(Ice.LocalException ex, boolean sent); +} |