package com.alibaba.dubbo.remoting.transport; import com.alibaba.dubbo.common.utils.Assert; import com.alibaba.dubbo.remoting.Channel; import com.alibaba.dubbo.remoting.ChannelHandler; import com.alibaba.dubbo.remoting.RemotingException; /** * @author <a href="mailto:gang.lvg@alibaba-inc.com">kimi</a> */ public abstract class AbstractChannelHandlerDelegate implements ChannelHandlerDelegate { protected ChannelHandler handler; protected AbstractChannelHandlerDelegate(ChannelHandler handler) { Assert.notNull(handler, "handler == null"); this.handler = handler; } public ChannelHandler getHandler() { if (handler instanceof ChannelHandlerDelegate) { return ((ChannelHandlerDelegate)handler).getHandler(); } return handler; } public void connected(Channel channel) throws RemotingException { handler.connected(channel); } public void disconnected(Channel channel) throws RemotingException { handler.disconnected(channel); } public void sent(Channel channel, Object message) throws RemotingException { handler.sent(channel, message); } public void received(Channel channel, Object message) throws RemotingException { handler.received(channel, message); } public void caught(Channel channel, Throwable exception) throws RemotingException { handler.caught(channel, exception); } }