public class ChannelOperations<INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound> extends Object implements NettyInbound, NettyOutbound, NettyContext, CoreSubscriber<Void>
Channel and NettyInbound /
NettyOutbound semantics exposed to user
NettyConnector.newHandler(BiFunction)| Modifier and Type | Class and Description |
|---|---|
static interface |
ChannelOperations.OnNew<CHANNEL extends Channel>
A
ChannelOperations factory |
Disposable.Composite, Disposable.Swap| Modifier and Type | Field and Description |
|---|---|
protected static AttributeKey<ChannelOperations<?,?>> |
OPERATIONS_KEY
The attribute in
Channel to store the current ChannelOperations |
FILE_CHUNKED_STRATEGY_BUFFER| Modifier | Constructor and Description |
|---|---|
protected |
ChannelOperations(Channel channel,
java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> handler,
ContextHandler<?> context) |
protected |
ChannelOperations(Channel channel,
java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> handler,
ContextHandler<?> context,
DirectProcessor<Void> processor) |
protected |
ChannelOperations(Channel channel,
ChannelOperations<INBOUND,OUTBOUND> replaced) |
| Modifier and Type | Method and Description |
|---|---|
InetSocketAddress |
address()
Return remote address if remote channel
NettyContext otherwise local
address if server selector channel. |
protected void |
applyHandler()
Apply the user-provided
NettyConnector handler |
static <INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound> |
bind(Channel channel,
java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> handler,
ContextHandler<?> context)
|
Channel |
channel()
Return the underlying
Channel. |
NettyContext |
context()
Return a
NettyContext to operate on the underlying
Channel state. |
ChannelOperations<INBOUND,OUTBOUND> |
context(java.util.function.Consumer<NettyContext> contextCallback)
Immediately call the passed callback with a
NettyContext to operate on the
underlying
Channel state. |
Context |
currentContext() |
protected void |
discard()
Drop pending content and complete inbound
|
void |
dispose() |
protected String |
formatName()
Return formatted name of this operation
|
static ChannelOperations<?,?> |
get(Channel ch)
Return the current
Channel bound
ChannelOperations or null if none |
protected java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> |
handler()
Connector handler provided by user
|
boolean |
isDisposed() |
protected boolean |
isInboundCancelled()
Return true if inbound traffic is not expected anymore
|
protected boolean |
isInboundDisposed()
Return true if inbound traffic is not incoming or expected anymore
|
static <INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound> |
noopHandler()
Return a Noop
BiFunction handler |
Mono<Void> |
onClose()
Return an observing
Mono terminating with success when shutdown
successfully
or error. |
NettyContext |
onClose(Runnable onClose)
Assign a
Runnable to be invoked when the channel is closed. |
void |
onComplete() |
void |
onError(Throwable t) |
protected void |
onHandlerStart()
React on input initialization
|
protected void |
onHandlerTerminate()
Final release/close (last packet)
|
protected void |
onInboundCancel()
React on inbound cancel (receive() subscriber cancelled)
|
protected void |
onInboundClose()
React on inbound close (channel closed prematurely)
|
protected void |
onInboundComplete()
React on inbound completion (last packet)
|
protected void |
onInboundError(Throwable err)
React on inbound error
|
protected void |
onInboundNext(ChannelHandlerContext ctx,
Object msg)
React on inbound
Channel.read() |
void |
onNext(Void aVoid) |
protected void |
onOutboundComplete()
React on inbound/outbound completion (last packet)
|
protected void |
onOutboundError(Throwable err)
React on inbound/outbound error
|
void |
onSubscribe(Subscription s) |
protected ContextHandler<?> |
parentContext()
Return the available parent
ContextHandler for user-facing lifecycle
handling |
Flux<?> |
receiveObject()
a Object inbound
Flux |
InetSocketAddress |
remoteAddress()
Get the address of the remote peer.
|
protected boolean |
replace(ChannelOperations<?,?> ops)
Replace and complete previous operation inbound
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitattr, onReadIdle, receivealloc, getFileChunkedStrategy, neverComplete, onWriteIdle, options, send, sendByteArray, sendFile, sendFile, sendFileChunked, sendGroups, sendObject, sendObject, sendString, sendString, subscribe, then, thenaddHandler, addHandler, addHandlerFirst, addHandlerFirst, addHandlerLast, addHandlerLast, isPersistent, markPersistent, removeHandler, replaceHandlerprotected static final AttributeKey<ChannelOperations<?,?>> OPERATIONS_KEY
Channel to store the current ChannelOperationsprotected ChannelOperations(Channel channel, ChannelOperations<INBOUND,OUTBOUND> replaced)
protected ChannelOperations(Channel channel, java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> handler, ContextHandler<?> context)
protected ChannelOperations(Channel channel, java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> handler, ContextHandler<?> context, DirectProcessor<Void> processor)
public static <INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound> ChannelOperations<INBOUND,OUTBOUND> bind(Channel channel, java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> handler, ContextHandler<?> context)
ChannelOperations attached to the Channel attribute
OPERATIONS_KEY.
Attach the NettyPipeline.ReactiveBridge handle.INBOUND - the NettyInbound typeOUTBOUND - the NettyOutbound typechannel - the new Channel connectionhandler - the user-provided BiFunction i/o handlercontext - the dispose callbackChannelOperations bridgepublic static <INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound> java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> noopHandler()
BiFunction handlerINBOUND - reified inbound typeOUTBOUND - reified outbound typeBiFunction handlerpublic static ChannelOperations<?,?> get(Channel ch)
Channel bound
ChannelOperations or null if nonech - the current ChannelChannel bound
ChannelOperations or null if nonepublic InetSocketAddress address()
NettyContextNettyContext otherwise local
address if server selector channel.address in interface NettyContextInetSocketAddresspublic final Channel channel()
NettyContextChannel. 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.channel in interface NettyContextChannelpublic final NettyContext context()
NettyInboundNettyContext to operate on the underlying
Channel state.context in interface NettyInboundcontext in interface NettyOutboundNettyContextpublic ChannelOperations<INBOUND,OUTBOUND> context(java.util.function.Consumer<NettyContext> contextCallback)
NettyInboundNettyContext to operate on the
underlying
Channel state. This allows for chaining inbound API.context in interface NettyInboundcontext in interface NettyOutboundcontextCallback - context callbackNettyContextpublic void dispose()
dispose in interface Disposabledispose in interface NettyContextpublic final boolean isDisposed()
isDisposed in interface DisposableisDisposed in interface NettyContextpublic final Mono<Void> onClose()
NettyContextMono terminating with success when shutdown
successfully
or error.onClose in interface NettyContextMono terminating with success if shutdown successfully or errorpublic NettyContext onClose(Runnable onClose)
NettyContextRunnable to be invoked when the channel is closed.onClose in interface NettyContextonClose - the close event handlerpublic final void onComplete()
onComplete in interface Subscriber<Void>public final void onError(Throwable t)
onError in interface Subscriber<Void>public final void onNext(Void aVoid)
onNext in interface Subscriber<Void>public final void onSubscribe(Subscription s)
onSubscribe in interface Subscriber<Void>onSubscribe in interface CoreSubscriber<Void>public Flux<?> receiveObject()
NettyInboundFluxreceiveObject in interface NettyInboundFluxpublic final InetSocketAddress remoteAddress()
NettyInboundremoteAddress in interface NettyInboundprotected final boolean isInboundCancelled()
protected final boolean isInboundDisposed()
protected final java.util.function.BiFunction<? super INBOUND,? super OUTBOUND,? extends Publisher<Void>> handler()
protected void onHandlerStart()
protected void onInboundNext(ChannelHandlerContext ctx, Object msg)
Channel.read()ctx - the contextmsg - the read payloadprotected final boolean replace(ChannelOperations<?,?> ops)
ops - a new operationsprotected void onInboundCancel()
protected void onInboundComplete()
protected void onInboundClose()
protected void onOutboundComplete()
protected void onOutboundError(Throwable err)
err - the Throwable causeprotected final void applyHandler()
NettyConnector handlerprotected final void onHandlerTerminate()
protected final void discard()
protected final void onInboundError(Throwable err)
err - the Throwable causeprotected final ContextHandler<?> parentContext()
ContextHandler for user-facing lifecycle
handlingContextHandlerfor user-facing lifecycle
handlingprotected final String formatName()
public Context currentContext()
currentContext in interface CoreSubscriber<Void>