Package org.jboss.netty.channel
Class DefaultChannelPipeline
java.lang.Object
org.jboss.netty.channel.DefaultChannelPipeline
- All Implemented Interfaces:
ChannelPipeline
- Direct Known Subclasses:
AbstractCodecEmbedder.EmbeddedChannelPipeline
The default
ChannelPipeline
implementation. It is recommended
to use Channels.pipeline()
to create a new ChannelPipeline
instance rather than calling the constructor directly.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final class
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Channel
(package private) static final ChannelSink
(package private) static final InternalLogger
private final Map
<String, DefaultChannelPipeline.DefaultChannelHandlerContext> private ChannelSink
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAfter
(String baseName, String name, ChannelHandler handler) Inserts aChannelHandler
after an existing handler of this pipeline.void
addBefore
(String baseName, String name, ChannelHandler handler) Inserts aChannelHandler
before an existing handler of this pipeline.void
addFirst
(String name, ChannelHandler handler) Inserts aChannelHandler
at the first position of this pipeline.void
addLast
(String name, ChannelHandler handler) Appends aChannelHandler
at the last position of this pipeline.void
attach
(Channel channel, ChannelSink sink) Attaches this pipeline to the specifiedChannel
andChannelSink
.private void
private static void
private static void
private static void
private void
checkDuplicateName
(String name) Schedules the specified task to be executed in the I/O thread associated with this pipeline'sChannel
.<T extends ChannelHandler>
TReturns theChannelHandler
of the specified type in this pipeline.Returns theChannelHandler
with the specified name in this pipeline.Returns theChannel
that this pipeline is attached to.getContext
(Class<? extends ChannelHandler> handlerType) Returns the context object of theChannelHandler
of the specified type in this pipeline.getContext
(String name) Returns the context object of theChannelHandler
with the specified name in this pipeline.getContext
(ChannelHandler handler) Returns the context object of the specifiedChannelHandler
in this pipeline.getContextOrDie
(Class<? extends ChannelHandler> handlerType) getContextOrDie
(String name) getContextOrDie
(ChannelHandler handler) getFirst()
Returns the firstChannelHandler
in this pipeline.getLast()
Returns the lastChannelHandler
in this pipeline.getNames()
Returns theList
of the handler names.getSink()
Returns theChannelSink
that this pipeline is attached to.private void
init
(String name, ChannelHandler handler) boolean
Returnstrue
if and only if this pipeline is attached to aChannel
.protected void
<T extends ChannelHandler>
TRemoves theChannelHandler
of the specified type from this pipelineRemoves theChannelHandler
with the specified name from this pipeline.void
remove
(ChannelHandler handler) Removes the specifiedChannelHandler
from this pipeline.Removes the firstChannelHandler
in this pipeline.Removes the lastChannelHandler
in this pipeline.<T extends ChannelHandler>
Treplace
(Class<T> oldHandlerType, String newName, ChannelHandler newHandler) Replaces theChannelHandler
of the specified type with a new handler in this pipeline.replace
(String oldName, String newName, ChannelHandler newHandler) Replaces theChannelHandler
of the specified name with a new handler in this pipeline.void
replace
(ChannelHandler oldHandler, String newName, ChannelHandler newHandler) Replaces the specifiedChannelHandler
with a new handler in this pipeline.private ChannelHandler
replace
(DefaultChannelPipeline.DefaultChannelHandlerContext ctx, String newName, ChannelHandler newHandler) void
Sends the specifiedChannelEvent
to the lastChannelDownstreamHandler
in this pipeline.(package private) void
void
Sends the specifiedChannelEvent
to the firstChannelUpstreamHandler
in this pipeline.(package private) void
toMap()
Converts this pipeline into an orderedMap
whose keys are handler names and whose values are handlers.toString()
Returns theString
representation of this pipeline.
-
Field Details
-
logger
-
discardingSink
-
channel
-
sink
-
head
-
tail
-
name2ctx
-
-
Constructor Details
-
DefaultChannelPipeline
public DefaultChannelPipeline()
-
-
Method Details
-
getChannel
Description copied from interface:ChannelPipeline
Returns theChannel
that this pipeline is attached to.- Specified by:
getChannel
in interfaceChannelPipeline
- Returns:
- the channel.
null
if this pipeline is not attached yet.
-
getSink
Description copied from interface:ChannelPipeline
Returns theChannelSink
that this pipeline is attached to.- Specified by:
getSink
in interfaceChannelPipeline
- Returns:
- the sink.
null
if this pipeline is not attached yet.
-
attach
Description copied from interface:ChannelPipeline
Attaches this pipeline to the specifiedChannel
andChannelSink
. Once a pipeline is attached, it can't be detached nor attached again.- Specified by:
attach
in interfaceChannelPipeline
-
isAttached
public boolean isAttached()Description copied from interface:ChannelPipeline
Returnstrue
if and only if this pipeline is attached to aChannel
.- Specified by:
isAttached
in interfaceChannelPipeline
-
addFirst
Description copied from interface:ChannelPipeline
Inserts aChannelHandler
at the first position of this pipeline.- Specified by:
addFirst
in interfaceChannelPipeline
- Parameters:
name
- the name of the handler to insert firsthandler
- the handler to insert first
-
addLast
Description copied from interface:ChannelPipeline
Appends aChannelHandler
at the last position of this pipeline.- Specified by:
addLast
in interfaceChannelPipeline
- Parameters:
name
- the name of the handler to appendhandler
- the handler to append
-
addBefore
Description copied from interface:ChannelPipeline
Inserts aChannelHandler
before an existing handler of this pipeline.- Specified by:
addBefore
in interfaceChannelPipeline
- Parameters:
baseName
- the name of the existing handlername
- the name of the handler to insert beforehandler
- the handler to insert before
-
addAfter
Description copied from interface:ChannelPipeline
Inserts aChannelHandler
after an existing handler of this pipeline.- Specified by:
addAfter
in interfaceChannelPipeline
- Parameters:
baseName
- the name of the existing handlername
- the name of the handler to insert afterhandler
- the handler to insert after
-
remove
Description copied from interface:ChannelPipeline
Removes the specifiedChannelHandler
from this pipeline.- Specified by:
remove
in interfaceChannelPipeline
-
remove
Description copied from interface:ChannelPipeline
Removes theChannelHandler
with the specified name from this pipeline.- Specified by:
remove
in interfaceChannelPipeline
- Returns:
- the removed handler
-
remove
Description copied from interface:ChannelPipeline
Removes theChannelHandler
of the specified type from this pipeline- Specified by:
remove
in interfaceChannelPipeline
- Type Parameters:
T
- the type of the handler- Parameters:
handlerType
- the type of the handler- Returns:
- the removed handler
-
remove
-
removeFirst
Description copied from interface:ChannelPipeline
Removes the firstChannelHandler
in this pipeline.- Specified by:
removeFirst
in interfaceChannelPipeline
- Returns:
- the removed handler
-
removeLast
Description copied from interface:ChannelPipeline
Removes the lastChannelHandler
in this pipeline.- Specified by:
removeLast
in interfaceChannelPipeline
- Returns:
- the removed handler
-
replace
Description copied from interface:ChannelPipeline
Replaces the specifiedChannelHandler
with a new handler in this pipeline.- Specified by:
replace
in interfaceChannelPipeline
-
replace
Description copied from interface:ChannelPipeline
Replaces theChannelHandler
of the specified name with a new handler in this pipeline.- Specified by:
replace
in interfaceChannelPipeline
- Returns:
- the removed handler
-
replace
public <T extends ChannelHandler> T replace(Class<T> oldHandlerType, String newName, ChannelHandler newHandler) Description copied from interface:ChannelPipeline
Replaces theChannelHandler
of the specified type with a new handler in this pipeline.- Specified by:
replace
in interfaceChannelPipeline
- Returns:
- the removed handler
-
replace
private ChannelHandler replace(DefaultChannelPipeline.DefaultChannelHandlerContext ctx, String newName, ChannelHandler newHandler) -
callBeforeAdd
-
callAfterAdd
-
callBeforeRemove
-
callAfterRemove
-
getFirst
Description copied from interface:ChannelPipeline
Returns the firstChannelHandler
in this pipeline.- Specified by:
getFirst
in interfaceChannelPipeline
- Returns:
- the first handler.
null
if this pipeline is empty.
-
getLast
Description copied from interface:ChannelPipeline
Returns the lastChannelHandler
in this pipeline.- Specified by:
getLast
in interfaceChannelPipeline
- Returns:
- the last handler.
null
if this pipeline is empty.
-
get
Description copied from interface:ChannelPipeline
Returns theChannelHandler
with the specified name in this pipeline.- Specified by:
get
in interfaceChannelPipeline
- Returns:
- the handler with the specified name.
null
if there's no such handler in this pipeline.
-
get
Description copied from interface:ChannelPipeline
Returns theChannelHandler
of the specified type in this pipeline.- Specified by:
get
in interfaceChannelPipeline
- Returns:
- the handler of the specified handler type.
null
if there's no such handler in this pipeline.
-
getContext
Description copied from interface:ChannelPipeline
Returns the context object of theChannelHandler
with the specified name in this pipeline.- Specified by:
getContext
in interfaceChannelPipeline
- Returns:
- the context object of the handler with the specified name.
null
if there's no such handler in this pipeline.
-
getContext
Description copied from interface:ChannelPipeline
Returns the context object of the specifiedChannelHandler
in this pipeline.- Specified by:
getContext
in interfaceChannelPipeline
- Returns:
- the context object of the specified handler.
null
if there's no such handler in this pipeline.
-
getContext
Description copied from interface:ChannelPipeline
Returns the context object of theChannelHandler
of the specified type in this pipeline.- Specified by:
getContext
in interfaceChannelPipeline
- Returns:
- the context object of the handler of the specified type.
null
if there's no such handler in this pipeline.
-
getNames
Description copied from interface:ChannelPipeline
Returns theList
of the handler names.- Specified by:
getNames
in interfaceChannelPipeline
-
toMap
Description copied from interface:ChannelPipeline
Converts this pipeline into an orderedMap
whose keys are handler names and whose values are handlers.- Specified by:
toMap
in interfaceChannelPipeline
-
toString
Returns theString
representation of this pipeline. -
sendUpstream
Description copied from interface:ChannelPipeline
Sends the specifiedChannelEvent
to the firstChannelUpstreamHandler
in this pipeline.- Specified by:
sendUpstream
in interfaceChannelPipeline
-
sendUpstream
-
sendDownstream
Description copied from interface:ChannelPipeline
Sends the specifiedChannelEvent
to the lastChannelDownstreamHandler
in this pipeline.- Specified by:
sendDownstream
in interfaceChannelPipeline
-
sendDownstream
-
getActualUpstreamContext
private DefaultChannelPipeline.DefaultChannelHandlerContext getActualUpstreamContext(DefaultChannelPipeline.DefaultChannelHandlerContext ctx) -
getActualDownstreamContext
private DefaultChannelPipeline.DefaultChannelHandlerContext getActualDownstreamContext(DefaultChannelPipeline.DefaultChannelHandlerContext ctx) -
execute
Description copied from interface:ChannelPipeline
Schedules the specified task to be executed in the I/O thread associated with this pipeline'sChannel
.- Specified by:
execute
in interfaceChannelPipeline
-
notifyHandlerException
-
init
-
checkDuplicateName
-
getContextOrDie
-
getContextOrDie
-
getContextOrDie
private DefaultChannelPipeline.DefaultChannelHandlerContext getContextOrDie(Class<? extends ChannelHandler> handlerType)
-