diff options
author | Rafael H. Schloming <rhs@apache.org> | 2008-02-04 21:06:35 +0000 |
---|---|---|
committer | Rafael H. Schloming <rhs@apache.org> | 2008-02-04 21:06:35 +0000 |
commit | 893609b9440efb00cbd870a0fb3680e7ba7758b0 (patch) | |
tree | 76035b10602dbb2c23a896c0b0f41495739050d3 | |
parent | ecda085c7bc131eae2ac7f30de7fdd9d23b8258d (diff) | |
download | qpid-python-893609b9440efb00cbd870a0fb3680e7ba7758b0.tar.gz |
added exception callback to ConnectonDelegate
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@618437 13f79535-47bb-0310-9956-ffa450edef68
12 files changed, 48 insertions, 2 deletions
diff --git a/java/client/src/main/java/org/apache/qpidity/nclient/Client.java b/java/client/src/main/java/org/apache/qpidity/nclient/Client.java index c3a879177c..08ad27fd54 100644 --- a/java/client/src/main/java/org/apache/qpidity/nclient/Client.java +++ b/java/client/src/main/java/org/apache/qpidity/nclient/Client.java @@ -54,6 +54,11 @@ public class Client implements org.apache.qpidity.nclient.Connection return new ClientSessionDelegate(); } + public void exception(Throwable t) + { + // XXX: need to propogate exception + } + @Override public void connectionClose(Channel context, ConnectionClose connectionClose) { ErrorCode errorCode = ErrorCode.get(connectionClose.getReplyCode()); diff --git a/java/common/src/main/java/org/apache/qpidity/ToyBroker.java b/java/common/src/main/java/org/apache/qpidity/ToyBroker.java index f927765166..2658dfcd09 100644 --- a/java/common/src/main/java/org/apache/qpidity/ToyBroker.java +++ b/java/common/src/main/java/org/apache/qpidity/ToyBroker.java @@ -272,6 +272,10 @@ class ToyBroker extends SessionDelegate { return new ToyBroker(exchange); } + public void exception(Throwable t) + { + t.printStackTrace(); + } }; //hack diff --git a/java/common/src/main/java/org/apache/qpidity/ToyClient.java b/java/common/src/main/java/org/apache/qpidity/ToyClient.java index 67f34f9bde..690e729540 100644 --- a/java/common/src/main/java/org/apache/qpidity/ToyClient.java +++ b/java/common/src/main/java/org/apache/qpidity/ToyClient.java @@ -69,6 +69,10 @@ class ToyClient extends SessionDelegate { return new ToyClient(); } + public void exception(Throwable t) + { + t.printStackTrace(); + } }); conn.send(new ConnectionEvent(0, new ProtocolHeader(1, 0, 10))); diff --git a/java/common/src/main/java/org/apache/qpidity/transport/Channel.java b/java/common/src/main/java/org/apache/qpidity/transport/Channel.java index 828d13d85a..7327697088 100644 --- a/java/common/src/main/java/org/apache/qpidity/transport/Channel.java +++ b/java/common/src/main/java/org/apache/qpidity/transport/Channel.java @@ -114,6 +114,11 @@ public class Channel extends Invoker throw new RuntimeException(error.getMessage()); } + public void exception(Throwable t) + { + session.exception(t); + } + public void closed() { log.debug("channel closed: ", this); diff --git a/java/common/src/main/java/org/apache/qpidity/transport/Connection.java b/java/common/src/main/java/org/apache/qpidity/transport/Connection.java index d7148cb532..fca7437dfd 100644 --- a/java/common/src/main/java/org/apache/qpidity/transport/Connection.java +++ b/java/common/src/main/java/org/apache/qpidity/transport/Connection.java @@ -110,6 +110,11 @@ public class Connection } } + public void exception(Throwable t) + { + delegate.exception(t); + } + public void closed() { log.debug("connection closed: %s", this); diff --git a/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java b/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java index 0d55dea7bd..b497a56f78 100644 --- a/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java +++ b/java/common/src/main/java/org/apache/qpidity/transport/ConnectionDelegate.java @@ -67,6 +67,8 @@ public abstract class ConnectionDelegate extends MethodDelegate<Channel> public abstract SessionDelegate getSessionDelegate(); + public abstract void exception(Throwable t); + public void setCondition(Lock negotiationCompleteLock,Condition negotiationComplete) { _negotiationComplete = negotiationComplete; diff --git a/java/common/src/main/java/org/apache/qpidity/transport/Echo.java b/java/common/src/main/java/org/apache/qpidity/transport/Echo.java index 03a684dd47..a3ac24dc48 100644 --- a/java/common/src/main/java/org/apache/qpidity/transport/Echo.java +++ b/java/common/src/main/java/org/apache/qpidity/transport/Echo.java @@ -70,6 +70,10 @@ public class Echo extends SessionDelegate { return new Echo(); } + public void exception(Throwable t) + { + t.printStackTrace(); + } }; //hack diff --git a/java/common/src/main/java/org/apache/qpidity/transport/Receiver.java b/java/common/src/main/java/org/apache/qpidity/transport/Receiver.java index 65edb3a6ec..8952ebf2a5 100644 --- a/java/common/src/main/java/org/apache/qpidity/transport/Receiver.java +++ b/java/common/src/main/java/org/apache/qpidity/transport/Receiver.java @@ -31,6 +31,8 @@ public interface Receiver<T> void received(T msg); + void exception(Throwable t); + void closed(); } diff --git a/java/common/src/main/java/org/apache/qpidity/transport/Session.java b/java/common/src/main/java/org/apache/qpidity/transport/Session.java index 1e630b69ca..08adb99c47 100644 --- a/java/common/src/main/java/org/apache/qpidity/transport/Session.java +++ b/java/common/src/main/java/org/apache/qpidity/transport/Session.java @@ -399,6 +399,11 @@ public class Session extends Invoker // XXX: channel.close(); } + public void exception(Throwable t) + { + log.error(t, "caught exception"); + } + public void closed() { closed.set(true); diff --git a/java/common/src/main/java/org/apache/qpidity/transport/network/Assembler.java b/java/common/src/main/java/org/apache/qpidity/transport/network/Assembler.java index f816ef4eff..1d501a7c6d 100644 --- a/java/common/src/main/java/org/apache/qpidity/transport/network/Assembler.java +++ b/java/common/src/main/java/org/apache/qpidity/transport/network/Assembler.java @@ -99,6 +99,11 @@ public class Assembler implements Receiver<NetworkEvent>, NetworkDelegate event.delegate(this); } + public void exception(Throwable t) + { + this.receiver.exception(t); + } + public void closed() { this.receiver.closed(); diff --git a/java/common/src/main/java/org/apache/qpidity/transport/network/InputHandler.java b/java/common/src/main/java/org/apache/qpidity/transport/network/InputHandler.java index b5e7a15854..871c45743e 100644 --- a/java/common/src/main/java/org/apache/qpidity/transport/network/InputHandler.java +++ b/java/common/src/main/java/org/apache/qpidity/transport/network/InputHandler.java @@ -245,6 +245,11 @@ public class InputHandler implements Receiver<ByteBuffer> } } + public void exception(Throwable t) + { + receiver.exception(t); + } + public void closed() { receiver.closed(); diff --git a/java/common/src/main/java/org/apache/qpidity/transport/network/mina/MinaHandler.java b/java/common/src/main/java/org/apache/qpidity/transport/network/mina/MinaHandler.java index 332a669c1a..2e4875cf42 100644 --- a/java/common/src/main/java/org/apache/qpidity/transport/network/mina/MinaHandler.java +++ b/java/common/src/main/java/org/apache/qpidity/transport/network/mina/MinaHandler.java @@ -81,8 +81,8 @@ public class MinaHandler<E> implements IoHandler public void exceptionCaught(IoSession ssn, Throwable e) { - log.error(e, "exception caught"); - throw new RuntimeException("IOException", e); + Attachment<E> attachment = (Attachment<E>) ssn.getAttachment(); + attachment.receiver.exception(e); } public void sessionCreated(final IoSession ssn) |