public interface ChannelPipeline extends Iterable<Map.Entry<String,ChannelHandler>>
ChannelHandlers which handles or intercepts inbound events and outbound operations of a
Channel. ChannelPipeline implements an advanced form of the
Intercepting Filter pattern
to give a user full control over how an event is handled and how the ChannelHandlers in a pipeline
interact with each other.
ChannelHandlers in a ChannelPipeline
typically. An I/O event is handled by a ChannelHandler and is forwarded by the ChannelHandler which
handled the event to the ChannelHandler which is placed right next to it. A ChannelHandler can also
trigger an arbitrary I/O event if necessary. To forward or trigger an event, a ChannelHandler calls the
event propagation methods defined in ChannelHandlerContext, such as
ChannelHandlerContext.fireChannelRead(Object) and ChannelHandlerContext.write(Object).
I/O Request
via Channel or
ChannelHandlerContext
|
+---------------------------------------------------+---------------+
| ChannelPipeline | |
| \|/ |
| +----------------------------------------------+----------+ |
| | ChannelHandler N | |
| +----------+-----------------------------------+----------+ |
| /|\ | |
| | \|/ |
| +----------+-----------------------------------+----------+ |
| | ChannelHandler N-1 | |
| +----------+-----------------------------------+----------+ |
| /|\ . |
| . . |
| ChannelHandlerContext.fireIN_EVT() ChannelHandlerContext.OUT_EVT()|
| [method call] [method call] |
| . . |
| . \|/ |
| +----------+-----------------------------------+----------+ |
| | ChannelHandler 2 | |
| +----------+-----------------------------------+----------+ |
| /|\ | |
| | \|/ |
| +----------+-----------------------------------+----------+ |
| | ChannelHandler 1 | |
| +----------+-----------------------------------+----------+ |
| /|\ | |
+---------------+-----------------------------------+---------------+
| \|/
+---------------+-----------------------------------+---------------+
| | | |
| [ Socket.read() ] [ Socket.write() ] |
| |
| Netty Internal I/O Threads (Transport Implementation) |
+-------------------------------------------------------------------+
An inbound event is handled by the ChannelHandlers in the bottom-up direction as shown on the left side of
the diagram. An inbound event is usually triggered by the I/O thread on the bottom of the diagram so that the
ChannelHandlers are notified when the state of a Channel changes (e.g. newly established connections
and closed connections) or the inbound data was read from a remote peer. If an inbound event goes beyond the
ChannelHandler at the top of the diagram, it is discarded and logged, depending on your loglevel.
An outbound event is handled by the ChannelHandlers in the top-down direction as shown on the right side of
the diagram. An outbound event is usually triggered by your code that requests an outbound I/O operation, such as
a write request and a connection attempt. If an outbound event goes beyond the ChannelHandler at the
bottom of the diagram, it is handled by an I/O thread associated with the Channel. The I/O thread often
performs the actual output operation such as SocketChannel.write(ByteBuffer).
ChannelHandler has to invoke the event propagation methods in
ChannelHandlerContext to forward an event to its next handler. Those methods include:
ChannelHandlerContext.fireChannelRegistered()ChannelHandlerContext.fireChannelActive()ChannelHandlerContext.fireChannelRead(Object)ChannelHandlerContext.fireChannelReadComplete()ChannelHandlerContext.fireExceptionCaught(Throwable)ChannelHandlerContext.fireUserEventTriggered(Object)ChannelHandlerContext.fireChannelWritabilityChanged()ChannelHandlerContext.fireChannelInactive()ChannelHandlerContext.bind(SocketAddress, ChannelPromise)ChannelHandlerContext.connect(SocketAddress, SocketAddress, ChannelPromise)ChannelHandlerContext.write(Object, ChannelPromise)ChannelHandlerContext.flush()ChannelHandlerContext.read()ChannelHandlerContext.disconnect(ChannelPromise)ChannelHandlerContext.close(ChannelPromise)public class MyInboundHandler extendsChannelHandlerAdapter{@Overridepublic void channelActive(ChannelHandlerContextctx) { System.out.println("Connected!"); ctx.fireChannelActive(); } } public clas MyOutboundHandler extendsChannelHandlerAdapter{@Overridepublic void close(ChannelHandlerContextctx,ChannelPromisepromise) { System.out.println("Closing .."); ctx.close(promise); } }
A user is supposed to have one or more ChannelHandlers in a pipeline to receive I/O events (e.g. read) and
to request I/O operations (e.g. write and close). For example, a typical server will have the following handlers
in each channel's pipeline, but your mileage may vary depending on the complexity and characteristics of the
protocol and business logic:
ByteBuf) into a Java object.static finalEventExecutorGroupgroup = newDefaultEventExecutorGroup(16); ...ChannelPipelinepipeline = ch.pipeline(); pipeline.addLast("decoder", new MyProtocolDecoder()); pipeline.addLast("encoder", new MyProtocolEncoder()); // Tell the pipeline to run MyBusinessLogicHandler's event handler methods // in a different thread than an I/O thread so that the I/O thread is not blocked by // a time-consuming task. // If your business logic is fully asynchronous or finished very quickly, you don't // need to specify a group. pipeline.addLast(group, "handler", new MyBusinessLogicHandler());
A ChannelHandler can be added or removed at any time because a ChannelPipeline is thread safe.
For example, you can insert an encryption handler when sensitive information is about to be exchanged, and remove it
after the exchange.
| Modifier and Type | Method and Description |
|---|---|
ChannelPipeline |
addAfter(ChannelHandlerInvoker invoker,
String baseName,
String name,
ChannelHandler handler)
Inserts a
ChannelHandler after an existing handler of this
pipeline. |
ChannelPipeline |
addAfter(EventExecutorGroup group,
String baseName,
String name,
ChannelHandler handler)
Inserts a
ChannelHandler after an existing handler of this
pipeline. |
ChannelPipeline |
addAfter(String baseName,
String name,
ChannelHandler handler)
Inserts a
ChannelHandler after an existing handler of this
pipeline. |
ChannelPipeline |
addBefore(ChannelHandlerInvoker invoker,
String baseName,
String name,
ChannelHandler handler)
Inserts a
ChannelHandler before an existing handler of this
pipeline. |
ChannelPipeline |
addBefore(EventExecutorGroup group,
String baseName,
String name,
ChannelHandler handler)
Inserts a
ChannelHandler before an existing handler of this
pipeline. |
ChannelPipeline |
addBefore(String baseName,
String name,
ChannelHandler handler)
Inserts a
ChannelHandler before an existing handler of this
pipeline. |
ChannelPipeline |
addFirst(ChannelHandler... handlers)
Inserts a
ChannelHandlers at the first position of this pipeline. |
ChannelPipeline |
addFirst(ChannelHandlerInvoker invoker,
ChannelHandler... handlers)
Inserts a
ChannelHandlers at the first position of this pipeline. |
ChannelPipeline |
addFirst(ChannelHandlerInvoker invoker,
String name,
ChannelHandler handler)
Inserts a
ChannelHandler at the first position of this pipeline. |
ChannelPipeline |
addFirst(EventExecutorGroup group,
ChannelHandler... handlers)
Inserts a
ChannelHandlers at the first position of this pipeline. |
ChannelPipeline |
addFirst(EventExecutorGroup group,
String name,
ChannelHandler handler)
Inserts a
ChannelHandler at the first position of this pipeline. |
ChannelPipeline |
addFirst(String name,
ChannelHandler handler)
Inserts a
ChannelHandler at the first position of this pipeline. |
ChannelPipeline |
addLast(ChannelHandler... handlers)
Inserts a
ChannelHandlers at the last position of this pipeline. |
ChannelPipeline |
addLast(ChannelHandlerInvoker invoker,
ChannelHandler... handlers)
Inserts a
ChannelHandlers at the last position of this pipeline. |
ChannelPipeline |
addLast(ChannelHandlerInvoker invoker,
String name,
ChannelHandler handler)
Appends a
ChannelHandler at the last position of this pipeline. |
ChannelPipeline |
addLast(EventExecutorGroup group,
ChannelHandler... handlers)
Inserts a
ChannelHandlers at the last position of this pipeline. |
ChannelPipeline |
addLast(EventExecutorGroup group,
String name,
ChannelHandler handler)
Appends a
ChannelHandler at the last position of this pipeline. |
ChannelPipeline |
addLast(String name,
ChannelHandler handler)
Appends a
ChannelHandler at the last position of this pipeline. |
ChannelFuture |
bind(SocketAddress localAddress)
Request to bind to the given
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error. |
ChannelFuture |
bind(SocketAddress localAddress,
ChannelPromise promise)
Request to bind to the given
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error. |
Channel |
channel()
Returns the
Channel that this pipeline is attached to. |
ChannelFuture |
close()
Request to close the
Channel and notify the ChannelFuture once the operation completes,
either because the operation was successful or because of
an error. |
ChannelFuture |
close(ChannelPromise promise)
Request to close the
Channel bound to this ChannelPipeline and notify the ChannelFuture
once the operation completes, either because the operation was successful or because of
an error. |
ChannelFuture |
connect(SocketAddress remoteAddress)
Request to connect to the given
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error. |
ChannelFuture |
connect(SocketAddress remoteAddress,
ChannelPromise promise)
Request to connect to the given
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error. |
ChannelFuture |
connect(SocketAddress remoteAddress,
SocketAddress localAddress)
Request to connect to the given
SocketAddress while bind to the localAddress and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error. |
ChannelFuture |
connect(SocketAddress remoteAddress,
SocketAddress localAddress,
ChannelPromise promise)
Request to connect to the given
SocketAddress while bind to the localAddress and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error. |
ChannelHandlerContext |
context(ChannelHandler handler)
Returns the context object of the specified
ChannelHandler in
this pipeline. |
ChannelHandlerContext |
context(Class<? extends ChannelHandler> handlerType)
Returns the context object of the
ChannelHandler of the
specified type in this pipeline. |
ChannelHandlerContext |
context(String name)
Returns the context object of the
ChannelHandler with the
specified name in this pipeline. |
ChannelFuture |
deregister()
Request to deregister the
Channel from the previous assigned EventExecutor and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error. |
ChannelFuture |
deregister(ChannelPromise promise)
Request to deregister the
Channel bound this ChannelPipeline from the previous assigned
EventExecutor and notify the ChannelFuture once the operation completes, either because the
operation was successful or because of an error. |
ChannelFuture |
disconnect()
Request to disconnect from the remote peer and notify the
ChannelFuture once the operation completes,
either because the operation was successful or because of an error. |
ChannelFuture |
disconnect(ChannelPromise promise)
Request to disconnect from the remote peer and notify the
ChannelFuture once the operation completes,
either because the operation was successful or because of an error. |
ChannelPipeline |
fireChannelActive()
A
Channel is active now, which means it is connected. |
ChannelPipeline |
fireChannelInactive()
A
Channel is inactive now, which means it is closed. |
ChannelPipeline |
fireChannelRead(Object msg)
A
Channel received a message. |
ChannelPipeline |
fireChannelReadComplete()
Triggers an
ChannelHandler.channelWritabilityChanged(ChannelHandlerContext)
event to the next ChannelHandler in the ChannelPipeline. |
ChannelPipeline |
fireChannelRegistered()
|
ChannelPipeline |
fireChannelUnregistered()
|
ChannelPipeline |
fireChannelWritabilityChanged()
Triggers an
ChannelHandler.channelWritabilityChanged(ChannelHandlerContext)
event to the next ChannelHandler in the ChannelPipeline. |
ChannelPipeline |
fireExceptionCaught(Throwable cause)
|
ChannelPipeline |
fireUserEventTriggered(Object event)
A
Channel received an user defined event. |
ChannelHandler |
first()
Returns the first
ChannelHandler in this pipeline. |
ChannelHandlerContext |
firstContext()
Returns the context of the first
ChannelHandler in this pipeline. |
ChannelPipeline |
flush()
Request to flush all pending messages.
|
<T extends ChannelHandler> |
get(Class<T> handlerType)
Returns the
ChannelHandler of the specified type in this
pipeline. |
ChannelHandler |
get(String name)
Returns the
ChannelHandler with the specified name in this
pipeline. |
ChannelHandler |
last()
Returns the last
ChannelHandler in this pipeline. |
ChannelHandlerContext |
lastContext()
Returns the context of the last
ChannelHandler in this pipeline. |
List<String> |
names()
Returns the
List of the handler names. |
ChannelPipeline |
read()
Request to Read data from the
Channel into the first inbound buffer, triggers an
ChannelHandler.channelRead(ChannelHandlerContext, Object) event if data was
read, and triggers a
channelReadComplete event so the
handler can decide to continue reading. |
ChannelPipeline |
remove(ChannelHandler handler)
Removes the specified
ChannelHandler from this pipeline. |
<T extends ChannelHandler> |
remove(Class<T> handlerType)
Removes the
ChannelHandler of the specified type from this pipeline. |
ChannelHandler |
remove(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. |
ChannelPipeline |
replace(ChannelHandler oldHandler,
String newName,
ChannelHandler newHandler)
Replaces the specified
ChannelHandler with a new handler in this pipeline. |
<T extends ChannelHandler> |
replace(Class<T> oldHandlerType,
String newName,
ChannelHandler newHandler)
Replaces the
ChannelHandler of the specified type with a new handler in this pipeline. |
ChannelHandler |
replace(String oldName,
String newName,
ChannelHandler newHandler)
Replaces the
ChannelHandler of the specified name with a new handler in this pipeline. |
Map<String,ChannelHandler> |
toMap()
Converts this pipeline into an ordered
Map whose keys are
handler names and whose values are handlers. |
ChannelFuture |
write(Object msg)
Request to write a message via this
ChannelPipeline. |
ChannelFuture |
write(Object msg,
ChannelPromise promise)
Request to write a message via this
ChannelPipeline. |
ChannelFuture |
writeAndFlush(Object msg)
Shortcut for call
write(Object) and flush(). |
ChannelFuture |
writeAndFlush(Object msg,
ChannelPromise promise)
Shortcut for call
write(Object, ChannelPromise) and flush(). |
ChannelPipeline addFirst(String name, ChannelHandler handler)
ChannelHandler at the first position of this pipeline.name - the name of the handler to insert first. null to let the name auto-generated.handler - the handler to insert firstIllegalArgumentException - if there's an entry with the same name already in the pipelineNullPointerException - if the specified handler is nullChannelPipeline addFirst(EventExecutorGroup group, String name, ChannelHandler handler)
ChannelHandler at the first position of this pipeline.group - the EventExecutorGroup which will be used to execute the ChannelHandler
methodsname - the name of the handler to insert first. null to let the name auto-generated.handler - the handler to insert firstIllegalArgumentException - if there's an entry with the same name already in the pipelineNullPointerException - if the specified handler is nullChannelPipeline addFirst(ChannelHandlerInvoker invoker, String name, ChannelHandler handler)
ChannelHandler at the first position of this pipeline.invoker - the ChannelHandlerInvoker which invokes the handlers event handler methodsname - the name of the handler to insert first. null to let the name auto-generated.handler - the handler to insert firstIllegalArgumentException - if there's an entry with the same name already in the pipelineNullPointerException - if the specified handler is nullChannelPipeline addLast(String name, ChannelHandler handler)
ChannelHandler at the last position of this pipeline.name - the name of the handler to append. null to let the name auto-generated.handler - the handler to appendIllegalArgumentException - if there's an entry with the same name already in the pipelineNullPointerException - if the specified handler is nullChannelPipeline addLast(EventExecutorGroup group, String name, ChannelHandler handler)
ChannelHandler at the last position of this pipeline.group - the EventExecutorGroup which will be used to execute the ChannelHandler
methodsname - the name of the handler to append. null to let the name auto-generated.handler - the handler to appendIllegalArgumentException - if there's an entry with the same name already in the pipelineNullPointerException - if the specified handler is nullChannelPipeline addLast(ChannelHandlerInvoker invoker, String name, ChannelHandler handler)
ChannelHandler at the last position of this pipeline.invoker - the ChannelHandlerInvoker which invokes the handlers event handler methodsname - the name of the handler to append. null to let the name auto-generated.handler - the handler to appendIllegalArgumentException - if there's an entry with the same name already in the pipelineNullPointerException - if the specified handler is nullChannelPipeline addBefore(String baseName, String name, ChannelHandler handler)
ChannelHandler before an existing handler of this
pipeline.baseName - the name of the existing handlername - the name of the handler to insert before. null to let the name auto-generated.handler - the handler to insert beforeNoSuchElementException - if there's no such entry with the specified baseNameIllegalArgumentException - if there's an entry with the same name already in the pipelineNullPointerException - if the specified baseName or handler is nullChannelPipeline addBefore(EventExecutorGroup group, String baseName, String name, ChannelHandler handler)
ChannelHandler before an existing handler of this
pipeline.group - the EventExecutorGroup which will be used to execute the ChannelHandler
methodsbaseName - the name of the existing handlername - the name of the handler to insert before. null to let the name auto-generated.handler - the handler to insert beforeNoSuchElementException - if there's no such entry with the specified baseNameIllegalArgumentException - if there's an entry with the same name already in the pipelineNullPointerException - if the specified baseName or handler is nullChannelPipeline addBefore(ChannelHandlerInvoker invoker, String baseName, String name, ChannelHandler handler)
ChannelHandler before an existing handler of this
pipeline.invoker - the ChannelHandlerInvoker which invokes the handlers event handler methodsbaseName - the name of the existing handlername - the name of the handler to insert before. null to let the name auto-generated.handler - the handler to insert beforeNoSuchElementException - if there's no such entry with the specified baseNameIllegalArgumentException - if there's an entry with the same name already in the pipelineNullPointerException - if the specified baseName or handler is nullChannelPipeline addAfter(String baseName, String name, ChannelHandler handler)
ChannelHandler after an existing handler of this
pipeline.baseName - the name of the existing handlername - the name of the handler to insert after. null to let the name auto-generated.handler - the handler to insert afterNoSuchElementException - if there's no such entry with the specified baseNameIllegalArgumentException - if there's an entry with the same name already in the pipelineNullPointerException - if the specified baseName or handler is nullChannelPipeline addAfter(EventExecutorGroup group, String baseName, String name, ChannelHandler handler)
ChannelHandler after an existing handler of this
pipeline.group - the EventExecutorGroup which will be used to execute the ChannelHandler
methodsbaseName - the name of the existing handlername - the name of the handler to insert after. null to let the name auto-generated.handler - the handler to insert afterNoSuchElementException - if there's no such entry with the specified baseNameIllegalArgumentException - if there's an entry with the same name already in the pipelineNullPointerException - if the specified baseName or handler is nullChannelPipeline addAfter(ChannelHandlerInvoker invoker, String baseName, String name, ChannelHandler handler)
ChannelHandler after an existing handler of this
pipeline.invoker - the ChannelHandlerInvoker which invokes the handlers event handler methodsbaseName - the name of the existing handlername - the name of the handler to insert after. null to let the name auto-generated.handler - the handler to insert afterNoSuchElementException - if there's no such entry with the specified baseNameIllegalArgumentException - if there's an entry with the same name already in the pipelineNullPointerException - if the specified baseName or handler is nullChannelPipeline addFirst(ChannelHandler... handlers)
ChannelHandlers at the first position of this pipeline.handlers - the handlers to insert firstChannelPipeline addFirst(EventExecutorGroup group, ChannelHandler... handlers)
ChannelHandlers at the first position of this pipeline.group - the EventExecutorGroup which will be used to execute the ChannelHandlers
methods.handlers - the handlers to insert firstChannelPipeline addFirst(ChannelHandlerInvoker invoker, ChannelHandler... handlers)
ChannelHandlers at the first position of this pipeline.invoker - the ChannelHandlerInvoker which invokes the handlers event handler methodshandlers - the handlers to insert firstChannelPipeline addLast(ChannelHandler... handlers)
ChannelHandlers at the last position of this pipeline.handlers - the handlers to insert lastChannelPipeline addLast(EventExecutorGroup group, ChannelHandler... handlers)
ChannelHandlers at the last position of this pipeline.group - the EventExecutorGroup which will be used to execute the ChannelHandlers
methods.handlers - the handlers to insert lastChannelPipeline addLast(ChannelHandlerInvoker invoker, ChannelHandler... handlers)
ChannelHandlers at the last position of this pipeline.invoker - the ChannelHandlerInvoker which invokes the handlers event handler methodshandlers - the handlers to insert lastChannelPipeline remove(ChannelHandler handler)
ChannelHandler from this pipeline.handler - the ChannelHandler to removeNoSuchElementException - if there's no such handler in this pipelineNullPointerException - if the specified handler is nullChannelHandler remove(String name)
ChannelHandler with the specified name from this pipeline.name - the name under which the ChannelHandler was stored.NoSuchElementException - if there's no such handler with the specified name in this pipelineNullPointerException - if the specified name is null<T extends ChannelHandler> T remove(Class<T> handlerType)
ChannelHandler of the specified type from this pipeline.T - the type of the handlerhandlerType - the type of the handlerNoSuchElementException - if there's no such handler of the specified type in this pipelineNullPointerException - if the specified handler type is nullChannelHandler removeFirst()
ChannelHandler in this pipeline.NoSuchElementException - if this pipeline is emptyChannelHandler removeLast()
ChannelHandler in this pipeline.NoSuchElementException - if this pipeline is emptyChannelPipeline replace(ChannelHandler oldHandler, String newName, ChannelHandler newHandler)
ChannelHandler with a new handler in this pipeline.oldHandler - the ChannelHandler to be replacednewName - the name under which the replacement should be added.
null to use the same name with the handler being replaced.newHandler - the ChannelHandler which is used as replacementNoSuchElementException - if the specified old handler does not exist in this pipelineIllegalArgumentException - if a handler with the specified new name already exists in this
pipeline, except for the handler to be replacedNullPointerException - if the specified old handler or new handler is nullChannelHandler replace(String oldName, String newName, ChannelHandler newHandler)
ChannelHandler of the specified name with a new handler in this pipeline.oldName - the name of the ChannelHandler to be replacednewName - the name under which the replacement should be added.
null to use the same name with the handler being replaced.newHandler - the ChannelHandler which is used as replacementNoSuchElementException - if the handler with the specified old name does not exist in this pipelineIllegalArgumentException - if a handler with the specified new name already exists in this
pipeline, except for the handler to be replacedNullPointerException - if the specified old handler or new handler is null<T extends ChannelHandler> T replace(Class<T> oldHandlerType, String newName, ChannelHandler newHandler)
ChannelHandler of the specified type with a new handler in this pipeline.oldHandlerType - the type of the handler to be removednewName - the name under which the replacement should be added.
null to use the same name with the handler being replaced.newHandler - the ChannelHandler which is used as replacementNoSuchElementException - if the handler of the specified old handler type does not exist
in this pipelineIllegalArgumentException - if a handler with the specified new name already exists in this
pipeline, except for the handler to be replacedNullPointerException - if the specified old handler or new handler is nullChannelHandler first()
ChannelHandler in this pipeline.null if this pipeline is empty.ChannelHandlerContext firstContext()
ChannelHandler in this pipeline.null if this pipeline is empty.ChannelHandler last()
ChannelHandler in this pipeline.null if this pipeline is empty.ChannelHandlerContext lastContext()
ChannelHandler in this pipeline.null if this pipeline is empty.ChannelHandler get(String name)
ChannelHandler with the specified name in this
pipeline.null if there's no such handler in this pipeline.<T extends ChannelHandler> T get(Class<T> handlerType)
ChannelHandler of the specified type in this
pipeline.null if there's no such handler in this pipeline.ChannelHandlerContext context(ChannelHandler handler)
ChannelHandler in
this pipeline.null if there's no such handler in this pipeline.ChannelHandlerContext context(String name)
ChannelHandler with the
specified name in this pipeline.null if there's no such handler in this pipeline.ChannelHandlerContext context(Class<? extends ChannelHandler> handlerType)
ChannelHandler of the
specified type in this pipeline.null if there's no such handler in this pipeline.Channel channel()
Channel that this pipeline is attached to.null if this pipeline is not attached yet.Map<String,ChannelHandler> toMap()
Map whose keys are
handler names and whose values are handlers.ChannelPipeline fireChannelRegistered()
Channel was registered to its EventLoop.
This will result in having the ChannelHandler.channelRegistered(ChannelHandlerContext) method
called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.ChannelPipeline fireChannelUnregistered()
Channel was unregistered from its EventLoop.
This will result in having the ChannelHandler.channelUnregistered(ChannelHandlerContext) method
called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.ChannelPipeline fireChannelActive()
Channel is active now, which means it is connected.
This will result in having the ChannelHandler.channelActive(ChannelHandlerContext) method
called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.ChannelPipeline fireChannelInactive()
Channel is inactive now, which means it is closed.
This will result in having the ChannelHandler.channelInactive(ChannelHandlerContext) method
called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.ChannelPipeline fireExceptionCaught(Throwable cause)
Channel received an Throwable in one of its inbound operations.
This will result in having the ChannelHandler.exceptionCaught(ChannelHandlerContext, Throwable)
method called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.ChannelPipeline fireUserEventTriggered(Object event)
Channel received an user defined event.
This will result in having the ChannelHandler.userEventTriggered(ChannelHandlerContext, Object)
method called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.ChannelPipeline fireChannelRead(Object msg)
Channel received a message.
This will result in having the ChannelHandler.channelRead(ChannelHandlerContext, Object)
method called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.ChannelPipeline fireChannelReadComplete()
ChannelHandler.channelWritabilityChanged(ChannelHandlerContext)
event to the next ChannelHandler in the ChannelPipeline.ChannelPipeline fireChannelWritabilityChanged()
ChannelHandler.channelWritabilityChanged(ChannelHandlerContext)
event to the next ChannelHandler in the ChannelPipeline.ChannelFuture bind(SocketAddress localAddress)
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error.
This will result in having the
ChannelHandler.bind(ChannelHandlerContext, SocketAddress, ChannelPromise) method
called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.
ChannelFuture connect(SocketAddress remoteAddress)
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error.
If the connection fails because of a connection timeout, the ChannelFuture will get failed with
a ConnectTimeoutException. If it fails because of connection refused a ConnectException
will be used.
This will result in having the
ChannelHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.
ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress)
SocketAddress while bind to the localAddress and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error.
This will result in having the
ChannelHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.
ChannelFuture disconnect()
ChannelFuture once the operation completes,
either because the operation was successful or because of an error.
This will result in having the
ChannelHandler.disconnect(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.
ChannelFuture close()
Channel and notify the ChannelFuture once the operation completes,
either because the operation was successful or because of
an error.
After it is closed it is not possible to reuse it again.
This will result in having the
ChannelHandler.close(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.
ChannelFuture deregister()
Channel from the previous assigned EventExecutor and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error.
This will result in having the
ChannelHandler.deregister(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.
ChannelFuture bind(SocketAddress localAddress, ChannelPromise promise)
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error.
The given ChannelPromise will be notified.
This will result in having the
ChannelHandler.bind(ChannelHandlerContext, SocketAddress, ChannelPromise) method
called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.
ChannelFuture connect(SocketAddress remoteAddress, ChannelPromise promise)
SocketAddress and notify the ChannelFuture once the operation
completes, either because the operation was successful or because of an error.
The given ChannelFuture will be notified.
If the connection fails because of a connection timeout, the ChannelFuture will get failed with
a ConnectTimeoutException. If it fails because of connection refused a ConnectException
will be used.
This will result in having the
ChannelHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.
ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise)
SocketAddress while bind to the localAddress and notify the
ChannelFuture once the operation completes, either because the operation was successful or because of
an error.
The given ChannelPromise will be notified and also returned.
This will result in having the
ChannelHandler.connect(ChannelHandlerContext, SocketAddress, SocketAddress, ChannelPromise)
method called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.
ChannelFuture disconnect(ChannelPromise promise)
ChannelFuture once the operation completes,
either because the operation was successful or because of an error.
The given ChannelPromise will be notified.
This will result in having the
ChannelHandler.disconnect(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.
ChannelFuture close(ChannelPromise promise)
Channel bound to this ChannelPipeline and notify the ChannelFuture
once the operation completes, either because the operation was successful or because of
an error.
After it is closed it is not possible to reuse it again.
The given ChannelPromise will be notified.
This will result in having the
ChannelHandler.close(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.
ChannelFuture deregister(ChannelPromise promise)
Channel bound this ChannelPipeline from the previous assigned
EventExecutor and notify the ChannelFuture once the operation completes, either because the
operation was successful or because of an error.
The given ChannelPromise will be notified.
ChannelOutboundHandler
This will result in having the
ChannelHandler.deregister(ChannelHandlerContext, ChannelPromise)
method called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.
ChannelPipeline read()
Channel into the first inbound buffer, triggers an
ChannelHandler.channelRead(ChannelHandlerContext, Object) event if data was
read, and triggers a
channelReadComplete event so the
handler can decide to continue reading. If there's a pending read operation already, this method does nothing.
This will result in having the
ChannelHandler.read(ChannelHandlerContext)
method called of the next ChannelHandler contained in the ChannelPipeline of the
Channel.
ChannelFuture write(Object msg)
ChannelPipeline.
This method will not request to actual flush, so be sure to call flush()
once you want to request to flush all pending data to the actual transport.ChannelFuture write(Object msg, ChannelPromise promise)
ChannelPipeline.
This method will not request to actual flush, so be sure to call flush()
once you want to request to flush all pending data to the actual transport.ChannelPipeline flush()
ChannelFuture writeAndFlush(Object msg, ChannelPromise promise)
write(Object, ChannelPromise) and flush().ChannelFuture writeAndFlush(Object msg)
write(Object) and flush().Copyright © 2008–2015 The Netty Project. All rights reserved.