2012-06-04 13:31:44 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2012 The Netty Project
|
|
|
|
*
|
|
|
|
* The Netty Project licenses this file to you under the Apache License,
|
|
|
|
* version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
2012-05-31 14:54:48 -07:00
|
|
|
package io.netty.channel;
|
|
|
|
|
2012-06-07 17:25:15 +09:00
|
|
|
|
2012-06-07 14:52:33 +09:00
|
|
|
public class ChannelStateHandlerAdapter implements ChannelStateHandler {
|
2012-05-31 14:54:48 -07:00
|
|
|
|
|
|
|
// Not using volatile because it's used only for a sanity check.
|
|
|
|
boolean added;
|
|
|
|
|
|
|
|
final boolean isSharable() {
|
|
|
|
return getClass().isAnnotationPresent(Sharable.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
|
|
|
|
// NOOP
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void afterAdd(ChannelHandlerContext ctx) throws Exception {
|
|
|
|
// NOOP
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void beforeRemove(ChannelHandlerContext ctx) throws Exception {
|
|
|
|
// NOOP
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void afterRemove(ChannelHandlerContext ctx) throws Exception {
|
|
|
|
// NOOP
|
|
|
|
}
|
2012-06-07 14:52:33 +09:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
|
|
|
|
throws Exception {
|
|
|
|
ctx.fireExceptionCaught(cause);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
|
|
|
|
throws Exception {
|
|
|
|
ctx.fireUserEventTriggered(evt);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
|
|
|
|
ctx.fireChannelRegistered();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
|
|
|
|
ctx.fireChannelUnregistered();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
|
|
|
ctx.fireChannelActive();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
|
|
|
ctx.fireChannelInactive();
|
|
|
|
}
|
2012-06-07 16:56:21 +09:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception {
|
2012-06-10 10:48:11 +09:00
|
|
|
if (this instanceof ChannelInboundHandler) {
|
|
|
|
throw new IllegalStateException(
|
|
|
|
"inboundBufferUpdated(...) must be overridden by " + getClass().getName() +
|
|
|
|
", which implements " + ChannelInboundHandler.class.getSimpleName());
|
2012-06-07 16:56:21 +09:00
|
|
|
}
|
2012-06-07 17:25:15 +09:00
|
|
|
ctx.fireInboundBufferUpdated();
|
2012-06-07 16:56:21 +09:00
|
|
|
}
|
2012-05-31 14:54:48 -07:00
|
|
|
}
|