1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
public abstract class AbstractChannelHandlerContext implements ChannelHandlerContext { volatile AbstractChannelHandlerContext next; volatile AbstractChannelHandlerContext prev; private DefaultChannelPipeline pipeline; private String name;
AbstractChannelHandlerContext(DefaultChannelPipeline pipeline, String name, Class<? extends ChannelHandler> handlerClass) { this.name = (String) ObjectUtil.checkNotNull(name, "name"); this.pipeline = pipeline; }
@Override public Channel channel() { return pipeline.channel(); }
@Override public ChannelPipeline pipeline() { return pipeline; }
@Override public ChannelHandlerContext fireExceptionCaught(Throwable cause, Object in, Object out) { invokeExceptionCaught(this.next, cause, in, out); return this; }
@Override public ChannelHandlerContext fireChannelProcess(Object in, Object out) { invokeChannelProcess(this.next, in, out); return this; }
private void invokeExceptionCaught(final Throwable cause, Object in, Object out) { try { handler().exceptionCaught(this, cause, in, out); } catch (Throwable error) {
} }
private void invokeChannelProcess(Object in, Object out) { try { handler().channelProcess(this, in, out); } catch (Throwable throwable) { invokeExceptionCaught(throwable, in, out); } }
static void invokeExceptionCaught(final AbstractChannelHandlerContext next, final Throwable cause, Object in, Object out) { next.invokeExceptionCaught(cause, in, out); }
static void invokeChannelProcess(final AbstractChannelHandlerContext next, Object in, Object out) { next.invokeChannelProcess(in, out); }
@Override public ChannelHandlerContext process(Object in, Object out) {
try { handler().channelProcess(this, in, out); } catch (Throwable t) { invokeExceptionCaught(t, in, out); } return this; } }
|