@FunctionalInterface
public interface NettyContext
extends reactor.core.Disposable
Channel| Modifier and Type | Method and Description |
|---|---|
default NettyContext |
addHandler(io.netty.channel.ChannelHandler handler)
Add a
ChannelHandler with addHandlerFirst(io.netty.channel.ChannelHandler) if of type of
ChannelOutboundHandler otherwise with
addHandlerLast(io.netty.channel.ChannelHandler). |
default NettyContext |
addHandler(java.lang.String name,
io.netty.channel.ChannelHandler handler)
Add a
ChannelHandler with addHandlerFirst(io.netty.channel.ChannelHandler) if of type of
ChannelOutboundHandler otherwise with
addHandlerLast(io.netty.channel.ChannelHandler). |
default NettyContext |
addHandlerFirst(io.netty.channel.ChannelHandler handler)
Add a
ChannelHandler to the beginning of the "user" ChannelPipeline,
that is just after the reactor-added codecs. |
default NettyContext |
addHandlerFirst(java.lang.String name,
io.netty.channel.ChannelHandler handler)
Add a
ChannelHandler to the beginning of the "user" ChannelPipeline,
that is just after the reactor-added codecs. |
default NettyContext |
addHandlerLast(io.netty.channel.ChannelHandler handler)
Add a
ChannelHandler to the end of the "user" ChannelPipeline,
that is just before the reactor-added handlers (like NettyPipeline.ReactiveBridge. |
default NettyContext |
addHandlerLast(java.lang.String name,
io.netty.channel.ChannelHandler handler)
Add a
ChannelHandler to the end of the "user" ChannelPipeline,
that is just before the reactor-added handlers (like NettyPipeline.ReactiveBridge. |
default java.net.InetSocketAddress |
address()
Return remote address if remote channel
NettyContext otherwise local
address if server selector channel. |
io.netty.channel.Channel |
channel()
Return the underlying
Channel. |
default void |
dispose() |
default boolean |
isDisposed() |
static boolean |
isPersistent(io.netty.channel.Channel channel)
Return false if it will force a close on terminal protocol events thus defeating
any pooling strategy
Return true (default) if it will release on terminal protocol events thus
keeping alive the channel if possible.
|
default NettyContext |
markPersistent(boolean persist)
Mark the underlying channel as persistent or not.
|
default reactor.core.publisher.Mono<java.lang.Void> |
onClose()
Return an observing
Mono terminating with success when shutdown
successfully
or error. |
default NettyContext |
onClose(java.lang.Runnable onClose)
Assign a
Runnable to be invoked when the channel is closed. |
default NettyContext |
removeHandler(java.lang.String name)
Remove a named handler if present and return this context
|
default NettyContext |
replaceHandler(java.lang.String name,
io.netty.channel.ChannelHandler handler)
Replace a named handler if present and return this context.
|
static boolean isPersistent(io.netty.channel.Channel channel)
Channel will be closed on terminal
handler eventdefault NettyContext addHandler(io.netty.channel.ChannelHandler handler)
ChannelHandler with addHandlerFirst(io.netty.channel.ChannelHandler) if of type of
ChannelOutboundHandler otherwise with
addHandlerLast(io.netty.channel.ChannelHandler). Implementation may add more auto handling in particular
HTTP based context will prepend an HttpContent body extractor.
[ [reactor codecs], [<- user FIRST HANDLERS added here, user LAST HANDLERS added here ->], [reactor handlers] ]
If effectively added, the handler will be safely removed when the channel is made inactive (pool release).
handler - handler instancedefault NettyContext addHandler(java.lang.String name, io.netty.channel.ChannelHandler handler)
ChannelHandler with addHandlerFirst(io.netty.channel.ChannelHandler) if of type of
ChannelOutboundHandler otherwise with
addHandlerLast(io.netty.channel.ChannelHandler). Implementation may add more auto handling in particular
HTTP based context will prepend an HttpContent body extractor.
[ [reactor codecs], [<- user FIRST HANDLERS added here, user LAST HANDLERS added here ->], [reactor handlers] ]
If effectively added, the handler will be safely removed when the channel is made inactive (pool release).
name - handler namehandler - handler instancedefault NettyContext addHandlerLast(io.netty.channel.ChannelHandler handler)
ChannelHandler to the end of the "user" ChannelPipeline,
that is just before the reactor-added handlers (like NettyPipeline.ReactiveBridge.
If a handler with a similar name already exists, this operation is skipped.
[ [reactor codecs], [<- user FIRST HANDLERS added here, user LAST HANDLERS added here ->], [reactor handlers] ]
If effectively added, the handler will be safely removed when the channel is made inactive (pool release).
handler - handler instancedefault NettyContext addHandlerLast(java.lang.String name, io.netty.channel.ChannelHandler handler)
ChannelHandler to the end of the "user" ChannelPipeline,
that is just before the reactor-added handlers (like NettyPipeline.ReactiveBridge.
If a handler with a similar name already exists, this operation is skipped.
[ [reactor codecs], [<- user FIRST HANDLERS added here, user LAST HANDLERS added here ->], [reactor handlers] ]
If effectively added, the handler will be safely removed when the channel is made inactive (pool release).
name - handler namehandler - handler instancedefault NettyContext addHandlerFirst(io.netty.channel.ChannelHandler handler)
ChannelHandler to the beginning of the "user" ChannelPipeline,
that is just after the reactor-added codecs. If a handler with a similar name already
exists, this operation is skipped.
[ [reactor codecs], [<- user FIRST HANDLERS added here, user LAST HANDLERS added here ->], [reactor handlers] ].
If effectively added, the handler will be safely removed when the channel is made inactive (pool release).
handler - handler instancedefault NettyContext addHandlerFirst(java.lang.String name, io.netty.channel.ChannelHandler handler)
ChannelHandler to the beginning of the "user" ChannelPipeline,
that is just after the reactor-added codecs. If a handler with a similar name already
exists, this operation is skipped.
[ [reactor codecs], [<- user FIRST HANDLERS added here, user LAST HANDLERS added here ->], [reactor handlers] ]
If effectively added, the handler will be safely removed when the channel is made inactive (pool release).
name - handler namehandler - handler instancedefault java.net.InetSocketAddress address()
NettyContext otherwise local
address if server selector channel.InetSocketAddressio.netty.channel.Channel channel()
Channel. Direct interaction might be considered
insecure if that affects the
underlying IO processing such as read, write or close or state such as pipeline
handler addition/removal.Channeldefault void dispose()
dispose in interface reactor.core.Disposabledefault boolean isDisposed()
isDisposed in interface reactor.core.Disposabledefault NettyContext markPersistent(boolean persist)
persist - the boolean flag to mark the Channel as fully disposable
or reusable when a user handler has terminateddefault reactor.core.publisher.Mono<java.lang.Void> onClose()
Mono terminating with success when shutdown
successfully
or error.Mono terminating with success if shutdown successfully or errordefault NettyContext onClose(java.lang.Runnable onClose)
Runnable to be invoked when the channel is closed.onClose - the close event handlerdefault NettyContext removeHandler(java.lang.String name)
name - handler namedefault NettyContext replaceHandler(java.lang.String name, io.netty.channel.ChannelHandler handler)
RuntimeException will be thrown.
Note: if the new handler is of different type, dependent handling like
the "extractor" introduced via HTTP-based addHandler(io.netty.channel.ChannelHandler) might not
expect/support the new messages type.
name - handler name