Package com.wavefront.agent.channel
Class PlainTextOrHttpFrameDecoder
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.handler.codec.ByteToMessageDecoder
-
- com.wavefront.agent.channel.PlainTextOrHttpFrameDecoder
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
public final class PlainTextOrHttpFrameDecoder extends io.netty.handler.codec.ByteToMessageDecoder
This class handles 2 different protocols on a single port. Supported protocols include HTTP and a plain text protocol. It dynamically adds the appropriate encoder/decoder based on the detected protocol. This class was largely adapted from the example provided with netty v4.0- Author:
- Mike McLaughlin ([email protected])
- See Also:
- Netty Port Unification Example
-
-
Constructor Summary
Constructors Constructor Description PlainTextOrHttpFrameDecoder(io.netty.channel.ChannelHandler handler)
Constructor with default input buffer limits (4KB for plaintext, 16MB for HTTP).PlainTextOrHttpFrameDecoder(io.netty.channel.ChannelHandler handler, int maxLengthPlaintext, int maxLengthHttp)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, List<Object> out)
Dynamically adds the appropriate encoder/decoder(s) to the pipeline based on the detected protocol.-
Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharable
-
-
-
-
Field Detail
-
logger
protected static final Logger logger
-
-
Constructor Detail
-
PlainTextOrHttpFrameDecoder
public PlainTextOrHttpFrameDecoder(io.netty.channel.ChannelHandler handler)
Constructor with default input buffer limits (4KB for plaintext, 16MB for HTTP).- Parameters:
handler
- the object responsible for handling the incoming messages or either protocol
-
PlainTextOrHttpFrameDecoder
public PlainTextOrHttpFrameDecoder(io.netty.channel.ChannelHandler handler, int maxLengthPlaintext, int maxLengthHttp)
Constructor.- Parameters:
handler
- the object responsible for handling the incoming messages or either protocol
-
-
Method Detail
-
decode
protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, List<Object> out) throws Exception
Dynamically adds the appropriate encoder/decoder(s) to the pipeline based on the detected protocol.- Specified by:
decode
in classio.netty.handler.codec.ByteToMessageDecoder
- Throws:
Exception
-
-