Remove ChannelHandlerContext.types() which is barely useful / Remove ChannelHandlerType together
This commit is contained in:
parent
d19b575c31
commit
f1ecb4ab1a
@ -25,7 +25,6 @@ import io.netty.util.AttributeMap;
|
|||||||
import io.netty.util.concurrent.EventExecutor;
|
import io.netty.util.concurrent.EventExecutor;
|
||||||
|
|
||||||
import java.nio.channels.Channels;
|
import java.nio.channels.Channels;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables a {@link ChannelHandler} to interact with its {@link ChannelPipeline}
|
* Enables a {@link ChannelHandler} to interact with its {@link ChannelPipeline}
|
||||||
@ -154,12 +153,6 @@ public interface ChannelHandlerContext
|
|||||||
*/
|
*/
|
||||||
ChannelHandler handler();
|
ChannelHandler handler();
|
||||||
|
|
||||||
/**
|
|
||||||
* Return an unmodifiable {@link Set} that contains all the {@link ChannelHandlerType}s which are handled by this
|
|
||||||
* context and the {@link ChannelHandler} it belongs to.
|
|
||||||
*/
|
|
||||||
Set<ChannelHandlerType> types();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return {@code true} if the {@link ChannelHandlerContext} has an {@link ByteBuf} bound for inbound
|
* Return {@code true} if the {@link ChannelHandlerContext} has an {@link ByteBuf} bound for inbound
|
||||||
* which can be used.
|
* which can be used.
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package io.netty.channel;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define the type of a {@link ChannelHandler}
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public enum ChannelHandlerType {
|
|
||||||
STATE(0),
|
|
||||||
INBOUND(0),
|
|
||||||
OPERATION(1),
|
|
||||||
OUTBOUND(1);
|
|
||||||
|
|
||||||
final int direction; // 0 - up (inbound), 1 - down (outbound)
|
|
||||||
|
|
||||||
ChannelHandlerType(int direction) {
|
|
||||||
if (direction != 0 && direction != 1) {
|
|
||||||
throw new IllegalArgumentException("direction must be either 0 or 1");
|
|
||||||
}
|
|
||||||
this.direction = direction;
|
|
||||||
}
|
|
||||||
}
|
|
@ -28,10 +28,7 @@ import io.netty.util.internal.PlatformDependent;
|
|||||||
|
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.nio.channels.ClosedChannelException;
|
import java.nio.channels.ClosedChannelException;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
@ -41,15 +38,12 @@ import static io.netty.channel.DefaultChannelPipeline.*;
|
|||||||
|
|
||||||
final class DefaultChannelHandlerContext extends DefaultAttributeMap implements ChannelHandlerContext {
|
final class DefaultChannelHandlerContext extends DefaultAttributeMap implements ChannelHandlerContext {
|
||||||
|
|
||||||
private static final EnumSet<ChannelHandlerType> EMPTY_TYPE = EnumSet.noneOf(ChannelHandlerType.class);
|
|
||||||
|
|
||||||
volatile DefaultChannelHandlerContext next;
|
volatile DefaultChannelHandlerContext next;
|
||||||
volatile DefaultChannelHandlerContext prev;
|
volatile DefaultChannelHandlerContext prev;
|
||||||
|
|
||||||
private final Channel channel;
|
private final Channel channel;
|
||||||
private final DefaultChannelPipeline pipeline;
|
private final DefaultChannelPipeline pipeline;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final Set<ChannelHandlerType> type;
|
|
||||||
private final ChannelHandler handler;
|
private final ChannelHandler handler;
|
||||||
private boolean needsLazyBufInit;
|
private boolean needsLazyBufInit;
|
||||||
|
|
||||||
@ -114,22 +108,6 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
throw new NullPointerException("handler");
|
throw new NullPointerException("handler");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the type of the specified handler.
|
|
||||||
EnumSet<ChannelHandlerType> type = EMPTY_TYPE.clone();
|
|
||||||
if (handler instanceof ChannelStateHandler) {
|
|
||||||
type.add(ChannelHandlerType.STATE);
|
|
||||||
if (handler instanceof ChannelInboundHandler) {
|
|
||||||
type.add(ChannelHandlerType.INBOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (handler instanceof ChannelOperationHandler) {
|
|
||||||
type.add(ChannelHandlerType.OPERATION);
|
|
||||||
if (handler instanceof ChannelOutboundHandler) {
|
|
||||||
type.add(ChannelHandlerType.OUTBOUND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.type = Collections.unmodifiableSet(type);
|
|
||||||
|
|
||||||
channel = pipeline.channel;
|
channel = pipeline.channel;
|
||||||
this.pipeline = pipeline;
|
this.pipeline = pipeline;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -197,7 +175,6 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
DefaultChannelHandlerContext(DefaultChannelPipeline pipeline, String name, HeadHandler handler) {
|
DefaultChannelHandlerContext(DefaultChannelPipeline pipeline, String name, HeadHandler handler) {
|
||||||
type = null;
|
|
||||||
channel = pipeline.channel;
|
channel = pipeline.channel;
|
||||||
this.pipeline = pipeline;
|
this.pipeline = pipeline;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -209,7 +186,6 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
DefaultChannelHandlerContext(DefaultChannelPipeline pipeline, String name, TailHandler handler) {
|
DefaultChannelHandlerContext(DefaultChannelPipeline pipeline, String name, TailHandler handler) {
|
||||||
type = null;
|
|
||||||
channel = pipeline.channel;
|
channel = pipeline.channel;
|
||||||
this.pipeline = pipeline;
|
this.pipeline = pipeline;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -505,11 +481,6 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<ChannelHandlerType> types() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasInboundByteBuffer() {
|
public boolean hasInboundByteBuffer() {
|
||||||
return inByteBuf != null;
|
return inByteBuf != null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user