Package org.playframework.netty
Class HandlerSubscriber<T>
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
org.playframework.netty.HandlerSubscriber<T>
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,io.netty.channel.ChannelOutboundHandler,org.reactivestreams.Subscriber<T>
public class HandlerSubscriber<T>
extends io.netty.channel.ChannelDuplexHandler
implements org.reactivestreams.Subscriber<T>
Subscriber that publishes received messages to the handler pipeline.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate io.netty.channel.ChannelHandlerContext(package private) static final long(package private) static final longprivate final longprivate final longprivate final io.netty.util.concurrent.EventExecutorprivate final AtomicBooleanprivate io.netty.channel.ChannelFutureprivate longprivate HandlerSubscriber.Stateprivate org.reactivestreams.Subscription -
Constructor Summary
ConstructorsConstructorDescriptionHandlerSubscriber(io.netty.util.concurrent.EventExecutor executor) Create a new handler subscriber with the default low and high watermarks.HandlerSubscriber(io.netty.util.concurrent.EventExecutor executor, long demandLowWatermark, long demandHighWatermark) Create a new handler subscriber. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcancel()voidchannelActive(io.netty.channel.ChannelHandlerContext ctx) voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) voidchannelRegistered(io.netty.channel.ChannelHandlerContext ctx) voidchannelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx) protected voidcomplete()Override for custom completion handling.private voiddoClose()protected voidOverride for custom error handling.voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) voidhandlerAdded(io.netty.channel.ChannelHandlerContext ctx) voidhandlerRemoved(io.netty.channel.ChannelHandlerContext ctx) private voidprivate voidvoidvoidvoidvoidonSubscribe(org.reactivestreams.Subscription subscription) private voidprivate voidverifyRegisteredWithRightExecutor(io.netty.channel.ChannelHandlerContext ctx) Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, read, writeMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelRead, channelReadComplete, channelUnregistered, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Field Details
-
DEFAULT_LOW_WATERMARK
static final long DEFAULT_LOW_WATERMARK- See Also:
-
DEFAULT_HIGH_WATERMARK
static final long DEFAULT_HIGH_WATERMARK- See Also:
-
executor
private final io.netty.util.concurrent.EventExecutor executor -
demandLowWatermark
private final long demandLowWatermark -
demandHighWatermark
private final long demandHighWatermark -
hasSubscription
-
subscription
private volatile org.reactivestreams.Subscription subscription -
ctx
private volatile io.netty.channel.ChannelHandlerContext ctx -
state
-
outstandingDemand
private long outstandingDemand -
lastWriteFuture
private io.netty.channel.ChannelFuture lastWriteFuture
-
-
Constructor Details
-
HandlerSubscriber
public HandlerSubscriber(io.netty.util.concurrent.EventExecutor executor, long demandLowWatermark, long demandHighWatermark) Create a new handler subscriber. The supplied executor must be the same event loop as the event loop that this handler is eventually registered with, if not, an exception will be thrown when the handler is registered.- Parameters:
executor- The executor to execute asynchronous events from the publisher on.demandLowWatermark- The low watermark for demand. When demand drops below this, more will be requested.demandHighWatermark- The high watermark for demand. This is the maximum that will be requested.
-
HandlerSubscriber
public HandlerSubscriber(io.netty.util.concurrent.EventExecutor executor) Create a new handler subscriber with the default low and high watermarks. The supplied executor must be the same event loop as the event loop that this handler is eventually registered with, if not, an exception will be thrown when the handler is registered.- Parameters:
executor- The executor to execute asynchronous events from the publisher on.- See Also:
-
-
Method Details
-
error
Override for custom error handling. By default, it closes the channel.- Parameters:
error- The error to handle.
-
complete
protected void complete()Override for custom completion handling. By default, it closes the channel. -
handlerAdded
- Specified by:
handlerAddedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerAddedin classio.netty.channel.ChannelHandlerAdapter- Throws:
Exception
-
channelRegistered
- Specified by:
channelRegisteredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelRegisteredin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
verifyRegisteredWithRightExecutor
private void verifyRegisteredWithRightExecutor(io.netty.channel.ChannelHandlerContext ctx) -
channelWritabilityChanged
- Specified by:
channelWritabilityChangedin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelWritabilityChangedin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelActive
- Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelInactive
- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
handlerRemoved
- Specified by:
handlerRemovedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerRemovedin classio.netty.channel.ChannelHandlerAdapter- Throws:
Exception
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception - Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
cancel
private void cancel() -
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription subscription) - Specified by:
onSubscribein interfaceorg.reactivestreams.Subscriber<T>
-
provideSubscription
private void provideSubscription() -
maybeStart
private void maybeStart() -
onNext
- Specified by:
onNextin interfaceorg.reactivestreams.Subscriber<T>
-
onError
- Specified by:
onErrorin interfaceorg.reactivestreams.Subscriber<T>
-
onComplete
public void onComplete()- Specified by:
onCompletein interfaceorg.reactivestreams.Subscriber<T>
-
doClose
private void doClose() -
maybeRequestMore
private void maybeRequestMore()
-