CHANNEL - the channel typepublic abstract class ContextHandler<CHANNEL extends Channel> extends ChannelInitializer<CHANNEL> implements Disposable, java.util.function.Consumer<Channel>
NettyContext state for clean
disposing. A ContextHandler is bound to a user-facing MonoSinkDisposable.Composite, Disposable.SwapChannelHandler.Sharable| Modifier | Constructor and Description |
|---|---|
protected |
ContextHandler(ChannelOperations.OnNew<CHANNEL> channelOpFactory,
NettyOptions<?,?> options,
MonoSink<NettyContext> sink,
LoggingHandler loggingHandler,
SocketAddress providedAddress) |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(Channel channel) |
ContextHandler<CHANNEL> |
autoCreateOperations(boolean autoCreateOperations)
Allow the
ChannelOperations to be created automatically on pipeline setup |
ChannelOperations<?,?> |
createOperations(Channel channel,
Object msg)
Return a new
ChannelOperations or null if one of the two
following conditions are not met:
autoCreateOperations(boolean) is true
The passed message is not null
|
protected void |
doDropped(Channel channel) |
protected abstract void |
doPipeline(Channel ch)
Initialize pipeline
|
protected void |
doStarted(Channel channel) |
abstract void |
fireContextActive(NettyContext context)
Trigger
MonoSink.success(Object) that will signal
NettyConnector.newHandler(BiFunction) returned
Mono subscriber. |
void |
fireContextError(Throwable t)
Trigger
MonoSink.error(Throwable) that will signal
NettyConnector.newHandler(BiFunction) returned
Mono subscriber. |
protected Tuple2<String,Integer> |
getSNI() |
protected void |
initChannel(CHANNEL ch) |
static <CHANNEL extends Channel> |
newClientContext(MonoSink<NettyContext> sink,
ClientOptions options,
LoggingHandler loggingHandler,
boolean secure,
SocketAddress providedAddress,
ChannelOperations.OnNew<CHANNEL> channelOpFactory)
Create a new client context
|
static <CHANNEL extends Channel> |
newClientContext(MonoSink<NettyContext> sink,
ClientOptions options,
LoggingHandler loggingHandler,
boolean secure,
SocketAddress providedAddress,
ChannelPool pool,
ChannelOperations.OnNew<CHANNEL> channelOpFactory)
Create a new client context with optional pool support
|
static ContextHandler<Channel> |
newServerContext(MonoSink<NettyContext> sink,
ServerOptions options,
LoggingHandler loggingHandler,
ChannelOperations.OnNew<Channel> channelOpFactory)
Create a new server context
|
protected abstract Publisher<Void> |
onCloseOrRelease(Channel channel)
Return a Publisher to signal onComplete on
Channel close or release. |
ContextHandler<CHANNEL> |
onPipeline(java.util.function.BiConsumer<ChannelPipeline,ContextHandler<Channel>> pipelineConfigurator)
Setup protocol specific handlers such as HTTP codec.
|
abstract void |
setFuture(Future<?> future)
One-time only future setter
|
protected void |
terminateChannel(Channel channel)
Cleanly terminate a channel according to the current context handler type.
|
channelRegistered, exceptionCaught, handlerAdded, handlerRemovedchannelActive, channelInactive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, userEventTriggeredensureNotSharable, isSharableclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdispose, isDisposedandThenprotected ContextHandler(ChannelOperations.OnNew<CHANNEL> channelOpFactory, NettyOptions<?,?> options, MonoSink<NettyContext> sink, LoggingHandler loggingHandler, SocketAddress providedAddress)
channelOpFactory - options - sink - loggingHandler - providedAddress - the InetSocketAddress targeted by the operation
associated with that handler (useable eg. for SNI), or null if unavailable.public static <CHANNEL extends Channel> ContextHandler<CHANNEL> newClientContext(MonoSink<NettyContext> sink, ClientOptions options, LoggingHandler loggingHandler, boolean secure, SocketAddress providedAddress, ChannelOperations.OnNew<CHANNEL> channelOpFactory)
CHANNEL - sink - options - loggingHandler - secure - channelOpFactory - ContextHandler for clientspublic static <CHANNEL extends Channel> ContextHandler<CHANNEL> newClientContext(MonoSink<NettyContext> sink, ClientOptions options, LoggingHandler loggingHandler, boolean secure, SocketAddress providedAddress, ChannelPool pool, ChannelOperations.OnNew<CHANNEL> channelOpFactory)
CHANNEL - sink - options - loggingHandler - secure - providedAddress - channelOpFactory - pool - ContextHandler for clientspublic static ContextHandler<Channel> newServerContext(MonoSink<NettyContext> sink, ServerOptions options, LoggingHandler loggingHandler, ChannelOperations.OnNew<Channel> channelOpFactory)
sink - options - loggingHandler - channelOpFactory - ContextHandler for serverspublic final ContextHandler<CHANNEL> onPipeline(java.util.function.BiConsumer<ChannelPipeline,ContextHandler<Channel>> pipelineConfigurator)
pipelineConfigurator - a configurator for extra codecs in the ChannelPipelinepublic final ContextHandler<CHANNEL> autoCreateOperations(boolean autoCreateOperations)
ChannelOperations to be created automatically on pipeline setupautoCreateOperations - should auto create ChannelOperationspublic final ChannelOperations<?,?> createOperations(Channel channel, Object msg)
ChannelOperations or null if one of the two
following conditions are not met:
autoCreateOperations(boolean) is true
channel - the current Channelmsg - an optional message inbound, meaning the channel has already been
started beforeChannelOperationspublic abstract void fireContextActive(NettyContext context)
MonoSink.success(Object) that will signal
NettyConnector.newHandler(BiFunction) returned
Mono subscriber.context - optional context to succeed the associated MonoSinkpublic void fireContextError(Throwable t)
MonoSink.error(Throwable) that will signal
NettyConnector.newHandler(BiFunction) returned
Mono subscriber.t - error to fail the associated MonoSinkpublic abstract void setFuture(Future<?> future)
future - the connect/bind future to associate with and cancel on disposeprotected void doStarted(Channel channel)
channel - protected void initChannel(CHANNEL ch)
initChannel in class ChannelInitializer<CHANNEL extends Channel>protected abstract void doPipeline(Channel ch)
ch - channel to initializepublic void accept(Channel channel)
accept in interface java.util.function.Consumer<Channel>protected void doDropped(Channel channel)
channel - protected void terminateChannel(Channel channel)
channel - the channel to unregister