Package org.jboss.netty.channel
Class DefaultChannelPipeline
- java.lang.Object
-
- org.jboss.netty.channel.DefaultChannelPipeline
-
- All Implemented Interfaces:
ChannelPipeline
public class DefaultChannelPipeline extends Object implements ChannelPipeline
The defaultChannelPipeline
implementation. It is recommended to useChannels.pipeline()
to create a newChannelPipeline
instance rather than calling the constructor directly.
-
-
Constructor Summary
Constructors Constructor Description DefaultChannelPipeline()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
.ChannelFuture
execute(Runnable task)
Schedules the specified task to be executed in the I/O thread associated with this pipeline'sChannel
.<T extends ChannelHandler>
Tget(Class<T> handlerType)
Returns theChannelHandler
of the specified type in this pipeline.ChannelHandler
get(String name)
Returns theChannelHandler
with the specified name in this pipeline.Channel
getChannel()
Returns theChannel
that this pipeline is attached to.ChannelHandlerContext
getContext(Class<? extends ChannelHandler> handlerType)
Returns the context object of theChannelHandler
of the specified type in this pipeline.ChannelHandlerContext
getContext(String name)
Returns the context object of theChannelHandler
with the specified name in this pipeline.ChannelHandlerContext
getContext(ChannelHandler handler)
Returns the context object of the specifiedChannelHandler
in this pipeline.ChannelHandler
getFirst()
Returns the firstChannelHandler
in this pipeline.ChannelHandler
getLast()
Returns the lastChannelHandler
in this pipeline.List<String>
getNames()
Returns theList
of the handler names.ChannelSink
getSink()
Returns theChannelSink
that this pipeline is attached to.boolean
isAttached()
Returnstrue
if and only if this pipeline is attached to aChannel
.protected void
notifyHandlerException(ChannelEvent e, Throwable t)
<T extends ChannelHandler>
Tremove(Class<T> handlerType)
Removes theChannelHandler
of the specified type from this pipelineChannelHandler
remove(String name)
Removes theChannelHandler
with the specified name from this pipeline.void
remove(ChannelHandler handler)
Removes the specifiedChannelHandler
from this pipeline.ChannelHandler
removeFirst()
Removes the firstChannelHandler
in this pipeline.ChannelHandler
removeLast()
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.ChannelHandler
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.void
sendDownstream(ChannelEvent e)
Sends the specifiedChannelEvent
to the lastChannelDownstreamHandler
in this pipeline.void
sendUpstream(ChannelEvent e)
Sends the specifiedChannelEvent
to the firstChannelUpstreamHandler
in this pipeline.Map<String,ChannelHandler>
toMap()
Converts this pipeline into an orderedMap
whose keys are handler names and whose values are handlers.String
toString()
Returns theString
representation of this pipeline.
-
-
-
Method Detail
-
getChannel
public Channel 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
public ChannelSink 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
public void attach(Channel channel, ChannelSink sink)
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
public void addFirst(String name, ChannelHandler handler)
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
public void addLast(String name, ChannelHandler handler)
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
public void addBefore(String baseName, String name, ChannelHandler handler)
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
public void addAfter(String baseName, String name, ChannelHandler handler)
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
public void remove(ChannelHandler handler)
Description copied from interface:ChannelPipeline
Removes the specifiedChannelHandler
from this pipeline.- Specified by:
remove
in interfaceChannelPipeline
-
remove
public ChannelHandler remove(String name)
Description copied from interface:ChannelPipeline
Removes theChannelHandler
with the specified name from this pipeline.- Specified by:
remove
in interfaceChannelPipeline
- Returns:
- the removed handler
-
remove
public <T extends ChannelHandler> T remove(Class<T> handlerType)
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
-
removeFirst
public ChannelHandler removeFirst()
Description copied from interface:ChannelPipeline
Removes the firstChannelHandler
in this pipeline.- Specified by:
removeFirst
in interfaceChannelPipeline
- Returns:
- the removed handler
-
removeLast
public ChannelHandler removeLast()
Description copied from interface:ChannelPipeline
Removes the lastChannelHandler
in this pipeline.- Specified by:
removeLast
in interfaceChannelPipeline
- Returns:
- the removed handler
-
replace
public void replace(ChannelHandler oldHandler, String newName, ChannelHandler newHandler)
Description copied from interface:ChannelPipeline
Replaces the specifiedChannelHandler
with a new handler in this pipeline.- Specified by:
replace
in interfaceChannelPipeline
-
replace
public ChannelHandler replace(String oldName, String newName, ChannelHandler newHandler)
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
-
getFirst
public ChannelHandler 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
public ChannelHandler 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
public ChannelHandler get(String name)
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
public <T extends ChannelHandler> T get(Class<T> handlerType)
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
public ChannelHandlerContext getContext(String name)
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
public ChannelHandlerContext getContext(ChannelHandler handler)
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
public ChannelHandlerContext getContext(Class<? extends ChannelHandler> handlerType)
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
public List<String> getNames()
Description copied from interface:ChannelPipeline
Returns theList
of the handler names.- Specified by:
getNames
in interfaceChannelPipeline
-
toMap
public Map<String,ChannelHandler> 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
-
sendUpstream
public void sendUpstream(ChannelEvent e)
Description copied from interface:ChannelPipeline
Sends the specifiedChannelEvent
to the firstChannelUpstreamHandler
in this pipeline.- Specified by:
sendUpstream
in interfaceChannelPipeline
-
sendDownstream
public void sendDownstream(ChannelEvent e)
Description copied from interface:ChannelPipeline
Sends the specifiedChannelEvent
to the lastChannelDownstreamHandler
in this pipeline.- Specified by:
sendDownstream
in interfaceChannelPipeline
-
execute
public ChannelFuture execute(Runnable task)
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
protected void notifyHandlerException(ChannelEvent e, Throwable t)
-
-