public class DefaultChannelPipeline extends java.lang.Object implements ChannelPipeline
ChannelPipeline
implementation. It is recommended
to use Channels.pipeline()
to create a new ChannelPipeline
instance rather than calling the constructor directly.构造器和说明 |
---|
DefaultChannelPipeline() |
限定符和类型 | 方法和说明 |
---|---|
void |
addAfter(java.lang.String baseName,
java.lang.String name,
ChannelHandler handler)
Inserts a
ChannelHandler after an existing handler of this
pipeline. |
void |
addBefore(java.lang.String baseName,
java.lang.String name,
ChannelHandler handler)
Inserts a
ChannelHandler before an existing handler of this
pipeline. |
void |
addFirst(java.lang.String name,
ChannelHandler handler)
Inserts a
ChannelHandler at the first position of this pipeline. |
void |
addLast(java.lang.String name,
ChannelHandler handler)
Appends a
ChannelHandler at the last position of this pipeline. |
void |
attach(Channel channel,
ChannelSink sink)
Attaches this pipeline to the specified
Channel and
ChannelSink . |
ChannelFuture |
execute(java.lang.Runnable task)
Schedules the specified task to be executed in the I/O thread associated
with this pipeline's
Channel . |
<T extends ChannelHandler> |
get(java.lang.Class<T> handlerType)
Returns the
ChannelHandler of the specified type in this
pipeline. |
ChannelHandler |
get(java.lang.String name)
Returns the
ChannelHandler with the specified name in this
pipeline. |
Channel |
getChannel()
Returns the
Channel that this pipeline is attached to. |
ChannelHandlerContext |
getContext(ChannelHandler handler)
Returns the context object of the specified
ChannelHandler in
this pipeline. |
ChannelHandlerContext |
getContext(java.lang.Class<? extends ChannelHandler> handlerType)
Returns the context object of the
ChannelHandler of the
specified type in this pipeline. |
ChannelHandlerContext |
getContext(java.lang.String name)
Returns the context object of the
ChannelHandler with the
specified name in this pipeline. |
ChannelHandler |
getFirst()
Returns the first
ChannelHandler in this pipeline. |
ChannelHandler |
getLast()
Returns the last
ChannelHandler in this pipeline. |
java.util.List<java.lang.String> |
getNames()
Returns the
List of the handler names. |
ChannelSink |
getSink()
Returns the
ChannelSink that this pipeline is attached to. |
boolean |
isAttached()
Returns
true if and only if this pipeline is attached to
a Channel . |
protected void |
notifyHandlerException(ChannelEvent e,
java.lang.Throwable t) |
void |
remove(ChannelHandler handler)
Removes the specified
ChannelHandler from this pipeline. |
<T extends ChannelHandler> |
remove(java.lang.Class<T> handlerType)
Removes the
ChannelHandler of the specified type from this
pipeline |
ChannelHandler |
remove(java.lang.String name)
Removes the
ChannelHandler with the specified name from this
pipeline. |
ChannelHandler |
removeFirst()
Removes the first
ChannelHandler in this pipeline. |
ChannelHandler |
removeLast()
Removes the last
ChannelHandler in this pipeline. |
void |
replace(ChannelHandler oldHandler,
java.lang.String newName,
ChannelHandler newHandler)
Replaces the specified
ChannelHandler with a new handler in
this pipeline. |
<T extends ChannelHandler> |
replace(java.lang.Class<T> oldHandlerType,
java.lang.String newName,
ChannelHandler newHandler)
Replaces the
ChannelHandler of the specified type with a new
handler in this pipeline. |
ChannelHandler |
replace(java.lang.String oldName,
java.lang.String newName,
ChannelHandler newHandler)
Replaces the
ChannelHandler of the specified name with a new
handler in this pipeline. |
void |
sendDownstream(ChannelEvent e)
Sends the specified
ChannelEvent to the last
ChannelDownstreamHandler in this pipeline. |
void |
sendUpstream(ChannelEvent e)
Sends the specified
ChannelEvent to the first
ChannelUpstreamHandler in this pipeline. |
java.util.Map<java.lang.String,ChannelHandler> |
toMap()
Converts this pipeline into an ordered
Map whose keys are
handler names and whose values are handlers. |
java.lang.String |
toString()
Returns the
String representation of this pipeline. |
public Channel getChannel()
ChannelPipeline
Channel
that this pipeline is attached to.getChannel
在接口中 ChannelPipeline
null
if this pipeline is not attached yet.public ChannelSink getSink()
ChannelPipeline
ChannelSink
that this pipeline is attached to.getSink
在接口中 ChannelPipeline
null
if this pipeline is not attached yet.public void attach(Channel channel, ChannelSink sink)
ChannelPipeline
Channel
and
ChannelSink
. Once a pipeline is attached, it can't be detached
nor attached again.attach
在接口中 ChannelPipeline
public boolean isAttached()
ChannelPipeline
true
if and only if this pipeline is attached to
a Channel
.isAttached
在接口中 ChannelPipeline
public void addFirst(java.lang.String name, ChannelHandler handler)
ChannelPipeline
ChannelHandler
at the first position of this pipeline.addFirst
在接口中 ChannelPipeline
name
- the name of the handler to insert firsthandler
- the handler to insert firstpublic void addLast(java.lang.String name, ChannelHandler handler)
ChannelPipeline
ChannelHandler
at the last position of this pipeline.addLast
在接口中 ChannelPipeline
name
- the name of the handler to appendhandler
- the handler to appendpublic void addBefore(java.lang.String baseName, java.lang.String name, ChannelHandler handler)
ChannelPipeline
ChannelHandler
before an existing handler of this
pipeline.addBefore
在接口中 ChannelPipeline
baseName
- the name of the existing handlername
- the name of the handler to insert beforehandler
- the handler to insert beforepublic void addAfter(java.lang.String baseName, java.lang.String name, ChannelHandler handler)
ChannelPipeline
ChannelHandler
after an existing handler of this
pipeline.addAfter
在接口中 ChannelPipeline
baseName
- the name of the existing handlername
- the name of the handler to insert afterhandler
- the handler to insert afterpublic void remove(ChannelHandler handler)
ChannelPipeline
ChannelHandler
from this pipeline.remove
在接口中 ChannelPipeline
public ChannelHandler remove(java.lang.String name)
ChannelPipeline
ChannelHandler
with the specified name from this
pipeline.remove
在接口中 ChannelPipeline
public <T extends ChannelHandler> T remove(java.lang.Class<T> handlerType)
ChannelPipeline
ChannelHandler
of the specified type from this
pipelineremove
在接口中 ChannelPipeline
T
- the type of the handlerhandlerType
- the type of the handlerpublic ChannelHandler removeFirst()
ChannelPipeline
ChannelHandler
in this pipeline.removeFirst
在接口中 ChannelPipeline
public ChannelHandler removeLast()
ChannelPipeline
ChannelHandler
in this pipeline.removeLast
在接口中 ChannelPipeline
public void replace(ChannelHandler oldHandler, java.lang.String newName, ChannelHandler newHandler)
ChannelPipeline
ChannelHandler
with a new handler in
this pipeline.replace
在接口中 ChannelPipeline
public ChannelHandler replace(java.lang.String oldName, java.lang.String newName, ChannelHandler newHandler)
ChannelPipeline
ChannelHandler
of the specified name with a new
handler in this pipeline.replace
在接口中 ChannelPipeline
public <T extends ChannelHandler> T replace(java.lang.Class<T> oldHandlerType, java.lang.String newName, ChannelHandler newHandler)
ChannelPipeline
ChannelHandler
of the specified type with a new
handler in this pipeline.replace
在接口中 ChannelPipeline
public ChannelHandler getFirst()
ChannelPipeline
ChannelHandler
in this pipeline.getFirst
在接口中 ChannelPipeline
null
if this pipeline is empty.public ChannelHandler getLast()
ChannelPipeline
ChannelHandler
in this pipeline.getLast
在接口中 ChannelPipeline
null
if this pipeline is empty.public ChannelHandler get(java.lang.String name)
ChannelPipeline
ChannelHandler
with the specified name in this
pipeline.get
在接口中 ChannelPipeline
null
if there's no such handler in this pipeline.public <T extends ChannelHandler> T get(java.lang.Class<T> handlerType)
ChannelPipeline
ChannelHandler
of the specified type in this
pipeline.get
在接口中 ChannelPipeline
null
if there's no such handler in this pipeline.public ChannelHandlerContext getContext(java.lang.String name)
ChannelPipeline
ChannelHandler
with the
specified name in this pipeline.getContext
在接口中 ChannelPipeline
null
if there's no such handler in this pipeline.public ChannelHandlerContext getContext(ChannelHandler handler)
ChannelPipeline
ChannelHandler
in
this pipeline.getContext
在接口中 ChannelPipeline
null
if there's no such handler in this pipeline.public ChannelHandlerContext getContext(java.lang.Class<? extends ChannelHandler> handlerType)
ChannelPipeline
ChannelHandler
of the
specified type in this pipeline.getContext
在接口中 ChannelPipeline
null
if there's no such handler in this pipeline.public java.util.List<java.lang.String> getNames()
ChannelPipeline
List
of the handler names.getNames
在接口中 ChannelPipeline
public java.util.Map<java.lang.String,ChannelHandler> toMap()
ChannelPipeline
Map
whose keys are
handler names and whose values are handlers.toMap
在接口中 ChannelPipeline
public java.lang.String toString()
String
representation of this pipeline.toString
在类中 java.lang.Object
public void sendUpstream(ChannelEvent e)
ChannelPipeline
ChannelEvent
to the first
ChannelUpstreamHandler
in this pipeline.sendUpstream
在接口中 ChannelPipeline
public void sendDownstream(ChannelEvent e)
ChannelPipeline
ChannelEvent
to the last
ChannelDownstreamHandler
in this pipeline.sendDownstream
在接口中 ChannelPipeline
public ChannelFuture execute(java.lang.Runnable task)
ChannelPipeline
Channel
.execute
在接口中 ChannelPipeline
protected void notifyHandlerException(ChannelEvent e, java.lang.Throwable t)