Class HandlerPublisher<T>
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
software.amazon.awssdk.http.nio.netty.internal.nrs.HandlerPublisher<T>
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
,io.netty.channel.ChannelOutboundHandler
,org.reactivestreams.Publisher<T>
public class HandlerPublisher<T>
extends io.netty.channel.ChannelDuplexHandler
implements org.reactivestreams.Publisher<T>
Publisher for a Netty Handler.
This publisher supports only one subscriber.
All interactions with the subscriber are done from the handlers executor, hence, they provide the same happens before
semantics that Netty provides.
The handler publishes all messages that match the type as specified by the passed in class. Any non matching messages
are forwarded to the next handler.
The publisher will signal complete if it receives a channel inactive event.
The publisher will release any messages that it drops (for example, messages that are buffered when the subscriber
cancels), but other than that, it does not release any messages. It is up to the subscriber to release messages.
If the subscriber cancels, the publisher will send a close event up the channel pipeline.
All errors will short circuit the buffer, and cause publisher to immediately call the subscribers onError method,
dropping the buffer.
The publisher can be subscribed to or placed in a handler chain in any order.
This class contains source imported from https://github.com/playframework/netty-reactive-streams,
licensed under the Apache License 2.0, available at the time of the fork (1/31/2020) here:
https://github.com/playframework/netty-reactive-streams/blob/master/LICENSE.txt
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Constructor Summary
ConstructorDescriptionHandlerPublisher
(io.netty.util.concurrent.EventExecutor executor, Class<? extends T> subscriberMessageType) Create a handler publisher. -
Method Summary
Modifier and TypeMethodDescriptionvoid
channelActive
(io.netty.channel.ChannelHandlerContext ctx) void
channelInactive
(io.netty.channel.ChannelHandlerContext ctx) void
channelRead
(io.netty.channel.ChannelHandlerContext ctx, Object message) void
channelReadComplete
(io.netty.channel.ChannelHandlerContext ctx) void
channelRegistered
(io.netty.channel.ChannelHandlerContext ctx) void
exceptionCaught
(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) void
handlerAdded
(io.netty.channel.ChannelHandlerContext ctx) void
handlerRemoved
(io.netty.channel.ChannelHandlerContext ctx) void
Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, read, write
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelUnregistered, channelWritabilityChanged, userEventTriggered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
isSharable
-
Constructor Details
-
HandlerPublisher
public HandlerPublisher(io.netty.util.concurrent.EventExecutor executor, Class<? extends T> subscriberMessageType) Create a handler publisher. 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 subscriber on.subscriberMessageType
- The type of message this publisher accepts.
-
-
Method Details
-
subscribe
- Specified by:
subscribe
in interfaceorg.reactivestreams.Publisher<T>
-
handlerAdded
- Specified by:
handlerAdded
in interfaceio.netty.channel.ChannelHandler
- Overrides:
handlerAdded
in classio.netty.channel.ChannelHandlerAdapter
- Throws:
Exception
-
channelRegistered
- Specified by:
channelRegistered
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelRegistered
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
channelActive
- Specified by:
channelActive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
channelRead
public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object message) throws Exception - Specified by:
channelRead
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelRead
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
channelReadComplete
- Specified by:
channelReadComplete
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelReadComplete
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
channelInactive
- Specified by:
channelInactive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelInactive
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
handlerRemoved
- Specified by:
handlerRemoved
in interfaceio.netty.channel.ChannelHandler
- Overrides:
handlerRemoved
in classio.netty.channel.ChannelHandlerAdapter
- Throws:
Exception
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception - Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelHandler
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
exceptionCaught
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-