Class NettyXMPPDecoder

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
org.jivesoftware.openfire.nio.NettyXMPPDecoder
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

public class NettyXMPPDecoder extends io.netty.handler.codec.ByteToMessageDecoder
A Netty pipeline decoder that parses raw bytes from an XMPP connection into discrete XML stanzas. This decoder sits in the Netty channel pipeline and delegates to a per-channel XMLLightweightParser to incrementally parse incoming data. Fully parsed stanzas are passed to the next handler in the pipeline via the out list. As a security measure, connections that attempt to send a single stanza exceeding the configured maximum buffer size are closed with a policy-violation stream error.
  • Nested Class Summary

    Nested classes/interfaces inherited from class io.netty.handler.codec.ByteToMessageDecoder

    io.netty.handler.codec.ByteToMessageDecoder.Cumulator

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

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

    Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder

    COMPOSITE_CUMULATOR, MERGE_CUMULATOR
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, List<Object> out)
    Decodes incoming bytes from the channel into one or more XMPP stanzas.
    void
    exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
    Handles exceptions thrown during decoding or elsewhere in the pipeline.

    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

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded
  • Constructor Details

    • NettyXMPPDecoder

      public NettyXMPPDecoder()
  • Method Details

    • decode

      protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, List<Object> out) throws Exception
      Decodes incoming bytes from the channel into one or more XMPP stanzas. Retrieves the XMLLightweightParser associated with this channel and feeds it the available bytes. Any fully parsed stanzas are added to out for processing by subsequent handlers in the pipeline. If the parser's internal buffer has exceeded the maximum allowed size, the connection is closed immediately with a policy-violation stream error and no further parsing is attempted.
      Specified by:
      decode in class io.netty.handler.codec.ByteToMessageDecoder
      Parameters:
      ctx - the channel handler context, used to retrieve channel attributes
      in - the incoming byte buffer containing raw XMPP data
      out - the list to which fully decoded stanzas are added
      Throws:
      Exception - if an error occurs during parsing
    • exceptionCaught

      public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception
      Handles exceptions thrown during decoding or elsewhere in the pipeline. Categorises the cause and closes the connection with an appropriate stream error. Full stack traces are intentionally logged at DEBUG level only, to avoid excessive log noise during production operation where port scanners and misconfigured clients can produce a high volume of these exceptions. If no NettyConnection has been associated with the channel yet (e.g. an exception occurs during early channel setup before registration), the exception is logged but no close attempt is made.
      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
      Parameters:
      ctx - the channel handler context
      cause - the exception that was caught
      Throws:
      Exception - if an error occurs while handling the exception