Class HandlerSubscriber<T>

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.micronaut.http.netty.reactive.HandlerSubscriber<T>
Type Parameters:
T - The subscriber type
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler, Subscriber<T>

@Internal public class HandlerSubscriber<T> extends io.netty.channel.ChannelDuplexHandler implements Subscriber<T>
Subscriber that publishes received messages to the handler pipeline.
Since:
1.0
Author:
Graeme Rocher
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected io.netty.channel.ChannelFuture
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    HandlerSubscriber(io.netty.util.concurrent.EventExecutor executor)
    Create a new handler subscriber with the default low and high watermarks.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelActive(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    channelInactive(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    channelRegistered(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    channelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx)
     
    protected void
    Override for custom completion handling.
    protected void
    Override for custom error handling.
    void
    exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
     
    void
    handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    handlerRemoved(io.netty.channel.ChannelHandlerContext ctx)
     
    void
     
    void
     
    void
    onNext(T t)
     
    protected void
    onNext(T t, io.netty.channel.ChannelPromise promise)
    Write the message with the supplied promise.
    void
    onSubscribe(Subscription subscription)
     

    Methods inherited from class io.netty.channel.ChannelDuplexHandler

    bind, close, connect, deregister, disconnect, flush, read, write

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelRead, channelReadComplete, channelUnregistered, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • lastWriteFuture

      protected io.netty.channel.ChannelFuture lastWriteFuture
  • Constructor Details

    • 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.
  • Method Details

    • error

      protected void error(Throwable 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

      public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      handlerAdded in interface io.netty.channel.ChannelHandler
      Overrides:
      handlerAdded in class io.netty.channel.ChannelHandlerAdapter
    • channelRegistered

      public void channelRegistered(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      channelRegistered in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelRegistered in class io.netty.channel.ChannelInboundHandlerAdapter
    • channelWritabilityChanged

      public void channelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      channelWritabilityChanged in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelWritabilityChanged in class io.netty.channel.ChannelInboundHandlerAdapter
    • channelActive

      public void channelActive(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      channelActive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelActive in class io.netty.channel.ChannelInboundHandlerAdapter
    • channelInactive

      public void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      channelInactive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter
    • handlerRemoved

      public void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      handlerRemoved in interface io.netty.channel.ChannelHandler
      Overrides:
      handlerRemoved in class io.netty.channel.ChannelHandlerAdapter
    • exceptionCaught

      public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelHandler
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
    • onSubscribe

      public void onSubscribe(Subscription subscription)
      Specified by:
      onSubscribe in interface Subscriber<T>
    • onNext

      public void onNext(T t)
      Specified by:
      onNext in interface Subscriber<T>
    • onNext

      protected void onNext(T t, io.netty.channel.ChannelPromise promise)
      Write the message with the supplied promise.
      Parameters:
      t - The message
      promise - The promise
    • onError

      public void onError(Throwable error)
      Specified by:
      onError in interface Subscriber<T>
    • onComplete

      public void onComplete()
      Specified by:
      onComplete in interface Subscriber<T>