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 defaultChannelPipelineimplementation. It is recommended to useChannels.pipeline()to create a newChannelPipelineinstance 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 voidaddAfter(String baseName, String name, ChannelHandler handler)Inserts aChannelHandlerafter an existing handler of this pipeline.voidaddBefore(String baseName, String name, ChannelHandler handler)Inserts aChannelHandlerbefore an existing handler of this pipeline.voidaddFirst(String name, ChannelHandler handler)Inserts aChannelHandlerat the first position of this pipeline.voidaddLast(String name, ChannelHandler handler)Appends aChannelHandlerat the last position of this pipeline.voidattach(Channel channel, ChannelSink sink)Attaches this pipeline to the specifiedChannelandChannelSink.ChannelFutureexecute(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 theChannelHandlerof the specified type in this pipeline.ChannelHandlerget(String name)Returns theChannelHandlerwith the specified name in this pipeline.ChannelgetChannel()Returns theChannelthat this pipeline is attached to.ChannelHandlerContextgetContext(Class<? extends ChannelHandler> handlerType)Returns the context object of theChannelHandlerof the specified type in this pipeline.ChannelHandlerContextgetContext(String name)Returns the context object of theChannelHandlerwith the specified name in this pipeline.ChannelHandlerContextgetContext(ChannelHandler handler)Returns the context object of the specifiedChannelHandlerin this pipeline.ChannelHandlergetFirst()Returns the firstChannelHandlerin this pipeline.ChannelHandlergetLast()Returns the lastChannelHandlerin this pipeline.List<String>getNames()Returns theListof the handler names.ChannelSinkgetSink()Returns theChannelSinkthat this pipeline is attached to.booleanisAttached()Returnstrueif and only if this pipeline is attached to aChannel.protected voidnotifyHandlerException(ChannelEvent e, Throwable t)<T extends ChannelHandler>
Tremove(Class<T> handlerType)Removes theChannelHandlerof the specified type from this pipelineChannelHandlerremove(String name)Removes theChannelHandlerwith the specified name from this pipeline.voidremove(ChannelHandler handler)Removes the specifiedChannelHandlerfrom this pipeline.ChannelHandlerremoveFirst()Removes the firstChannelHandlerin this pipeline.ChannelHandlerremoveLast()Removes the lastChannelHandlerin this pipeline.<T extends ChannelHandler>
Treplace(Class<T> oldHandlerType, String newName, ChannelHandler newHandler)Replaces theChannelHandlerof the specified type with a new handler in this pipeline.ChannelHandlerreplace(String oldName, String newName, ChannelHandler newHandler)Replaces theChannelHandlerof the specified name with a new handler in this pipeline.voidreplace(ChannelHandler oldHandler, String newName, ChannelHandler newHandler)Replaces the specifiedChannelHandlerwith a new handler in this pipeline.voidsendDownstream(ChannelEvent e)Sends the specifiedChannelEventto the lastChannelDownstreamHandlerin this pipeline.voidsendUpstream(ChannelEvent e)Sends the specifiedChannelEventto the firstChannelUpstreamHandlerin this pipeline.Map<String,ChannelHandler>toMap()Converts this pipeline into an orderedMapwhose keys are handler names and whose values are handlers.StringtoString()Returns theStringrepresentation of this pipeline.
-
-
-
Method Detail
-
getChannel
public Channel getChannel()
Description copied from interface:ChannelPipelineReturns theChannelthat this pipeline is attached to.- Specified by:
getChannelin interfaceChannelPipeline- Returns:
- the channel.
nullif this pipeline is not attached yet.
-
getSink
public ChannelSink getSink()
Description copied from interface:ChannelPipelineReturns theChannelSinkthat this pipeline is attached to.- Specified by:
getSinkin interfaceChannelPipeline- Returns:
- the sink.
nullif this pipeline is not attached yet.
-
attach
public void attach(Channel channel, ChannelSink sink)
Description copied from interface:ChannelPipelineAttaches this pipeline to the specifiedChannelandChannelSink. Once a pipeline is attached, it can't be detached nor attached again.- Specified by:
attachin interfaceChannelPipeline
-
isAttached
public boolean isAttached()
Description copied from interface:ChannelPipelineReturnstrueif and only if this pipeline is attached to aChannel.- Specified by:
isAttachedin interfaceChannelPipeline
-
addFirst
public void addFirst(String name, ChannelHandler handler)
Description copied from interface:ChannelPipelineInserts aChannelHandlerat the first position of this pipeline.- Specified by:
addFirstin 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:ChannelPipelineAppends aChannelHandlerat the last position of this pipeline.- Specified by:
addLastin 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:ChannelPipelineInserts aChannelHandlerbefore an existing handler of this pipeline.- Specified by:
addBeforein 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:ChannelPipelineInserts aChannelHandlerafter an existing handler of this pipeline.- Specified by:
addAfterin 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:ChannelPipelineRemoves the specifiedChannelHandlerfrom this pipeline.- Specified by:
removein interfaceChannelPipeline
-
remove
public ChannelHandler remove(String name)
Description copied from interface:ChannelPipelineRemoves theChannelHandlerwith the specified name from this pipeline.- Specified by:
removein interfaceChannelPipeline- Returns:
- the removed handler
-
remove
public <T extends ChannelHandler> T remove(Class<T> handlerType)
Description copied from interface:ChannelPipelineRemoves theChannelHandlerof the specified type from this pipeline- Specified by:
removein 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:ChannelPipelineRemoves the firstChannelHandlerin this pipeline.- Specified by:
removeFirstin interfaceChannelPipeline- Returns:
- the removed handler
-
removeLast
public ChannelHandler removeLast()
Description copied from interface:ChannelPipelineRemoves the lastChannelHandlerin this pipeline.- Specified by:
removeLastin interfaceChannelPipeline- Returns:
- the removed handler
-
replace
public void replace(ChannelHandler oldHandler, String newName, ChannelHandler newHandler)
Description copied from interface:ChannelPipelineReplaces the specifiedChannelHandlerwith a new handler in this pipeline.- Specified by:
replacein interfaceChannelPipeline
-
replace
public ChannelHandler replace(String oldName, String newName, ChannelHandler newHandler)
Description copied from interface:ChannelPipelineReplaces theChannelHandlerof the specified name with a new handler in this pipeline.- Specified by:
replacein interfaceChannelPipeline- Returns:
- the removed handler
-
replace
public <T extends ChannelHandler> T replace(Class<T> oldHandlerType, String newName, ChannelHandler newHandler)
Description copied from interface:ChannelPipelineReplaces theChannelHandlerof the specified type with a new handler in this pipeline.- Specified by:
replacein interfaceChannelPipeline- Returns:
- the removed handler
-
getFirst
public ChannelHandler getFirst()
Description copied from interface:ChannelPipelineReturns the firstChannelHandlerin this pipeline.- Specified by:
getFirstin interfaceChannelPipeline- Returns:
- the first handler.
nullif this pipeline is empty.
-
getLast
public ChannelHandler getLast()
Description copied from interface:ChannelPipelineReturns the lastChannelHandlerin this pipeline.- Specified by:
getLastin interfaceChannelPipeline- Returns:
- the last handler.
nullif this pipeline is empty.
-
get
public ChannelHandler get(String name)
Description copied from interface:ChannelPipelineReturns theChannelHandlerwith the specified name in this pipeline.- Specified by:
getin interfaceChannelPipeline- Returns:
- the handler with the specified name.
nullif there's no such handler in this pipeline.
-
get
public <T extends ChannelHandler> T get(Class<T> handlerType)
Description copied from interface:ChannelPipelineReturns theChannelHandlerof the specified type in this pipeline.- Specified by:
getin interfaceChannelPipeline- Returns:
- the handler of the specified handler type.
nullif there's no such handler in this pipeline.
-
getContext
public ChannelHandlerContext getContext(String name)
Description copied from interface:ChannelPipelineReturns the context object of theChannelHandlerwith the specified name in this pipeline.- Specified by:
getContextin interfaceChannelPipeline- Returns:
- the context object of the handler with the specified name.
nullif there's no such handler in this pipeline.
-
getContext
public ChannelHandlerContext getContext(ChannelHandler handler)
Description copied from interface:ChannelPipelineReturns the context object of the specifiedChannelHandlerin this pipeline.- Specified by:
getContextin interfaceChannelPipeline- Returns:
- the context object of the specified handler.
nullif there's no such handler in this pipeline.
-
getContext
public ChannelHandlerContext getContext(Class<? extends ChannelHandler> handlerType)
Description copied from interface:ChannelPipelineReturns the context object of theChannelHandlerof the specified type in this pipeline.- Specified by:
getContextin interfaceChannelPipeline- Returns:
- the context object of the handler of the specified type.
nullif there's no such handler in this pipeline.
-
getNames
public List<String> getNames()
Description copied from interface:ChannelPipelineReturns theListof the handler names.- Specified by:
getNamesin interfaceChannelPipeline
-
toMap
public Map<String,ChannelHandler> toMap()
Description copied from interface:ChannelPipelineConverts this pipeline into an orderedMapwhose keys are handler names and whose values are handlers.- Specified by:
toMapin interfaceChannelPipeline
-
sendUpstream
public void sendUpstream(ChannelEvent e)
Description copied from interface:ChannelPipelineSends the specifiedChannelEventto the firstChannelUpstreamHandlerin this pipeline.- Specified by:
sendUpstreamin interfaceChannelPipeline
-
sendDownstream
public void sendDownstream(ChannelEvent e)
Description copied from interface:ChannelPipelineSends the specifiedChannelEventto the lastChannelDownstreamHandlerin this pipeline.- Specified by:
sendDownstreamin interfaceChannelPipeline
-
execute
public ChannelFuture execute(Runnable task)
Description copied from interface:ChannelPipelineSchedules the specified task to be executed in the I/O thread associated with this pipeline'sChannel.- Specified by:
executein interfaceChannelPipeline
-
notifyHandlerException
protected void notifyHandlerException(ChannelEvent e, Throwable t)
-
-