gpt4 book ai didi

io.netty.handler.codec.xml.XmlFrameDecoder类的使用及代码示例

转载 作者:知者 更新时间:2024-03-22 21:05:05 26 4
gpt4 key购买 nike

本文整理了Java中io.netty.handler.codec.xml.XmlFrameDecoder类的一些代码示例,展示了XmlFrameDecoder类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlFrameDecoder类的具体详情如下:
包路径:io.netty.handler.codec.xml.XmlFrameDecoder
类名称:XmlFrameDecoder

XmlFrameDecoder介绍

[英]A frame decoder for single separate XML based message streams.

A couple examples will better help illustrate what this decoder actually does.

Given an input array of bytes split over 3 frames like this:

+-----+-----+-----------+ 
| <an | Xml | Element/> | 
+-----+-----+-----------+

this decoder would output a single frame:

+-----------------+ 
| <anXmlElement/> | 
+-----------------+

Given an input array of bytes split over 5 frames like this:

+-----+-----+-----------+-----+----------------------------------+ 
| <an | Xml | Element/> | <ro | ot><child>content</child></root> | 
+-----+-----+-----------+-----+----------------------------------+

this decoder would output two frames:

+-----------------+-------------------------------------+ 
| <anXmlElement/> | <root><child>content</child></root> | 
+-----------------+-------------------------------------+

Please note that this decoder is not suitable for xml streaming protocols such as XMPP, where an initial xml element opens the stream and only gets closed at the end of the session, although this class could probably allow for such type of message flow with minor modifications.
[中]用于单个单独的基于XML的消息流的帧解码器。
几个例子将更好地说明这个解码器的实际功能。
给定一个分为3帧的字节输入数组,如下所示:

+-----+-----+-----------+ 
| <an | Xml | Element/> | 
+-----+-----+-----------+

该解码器将输出单个帧:

+-----------------+ 
| <anXmlElement/> | 
+-----------------+

给定一个分为5帧的字节输入数组,如下所示:

+-----+-----+-----------+-----+----------------------------------+ 
| <an | Xml | Element/> | <ro | ot><child>content</child></root> | 
+-----+-----+-----------+-----+----------------------------------+

该解码器将输出两帧:

+-----------------+-------------------------------------+ 
| <anXmlElement/> | <root><child>content</child></root> | 
+-----------------+-------------------------------------+

请注意,此解码器不适用于XMPP之类的xml流协议,在这种协议中,初始xml元素打开流,仅在会话结束时关闭,尽管此类可能允许对此类消息流进行轻微修改。

代码示例

代码示例来源:origin: netty/netty

fail(bufferLength);
return;
} else if (!openingBracketFound && readByte != '<') {
  fail(ctx);
  in.skipBytes(in.readableBytes());
  return;
    } else if (isValidStartCharForXmlElement(peekAheadByte)) {
      atLeastOneXmlElementFound = true;
      if (isCommentBlockStart(in, i)) {
      } else if (isCDATABlockStart(in, i)) {
    extractFrame(in, readerIndex + leadingWhiteSpaceCount, xmlElementLength - leadingWhiteSpaceCount);
in.skipBytes(xmlElementLength);
out.add(frame);

代码示例来源:origin: OpenNMS/opennms

@Override
  public ChannelHandler newChannelHandler() {
    return new XmlFrameDecoder(m_maxFrameLength);
  }
}

代码示例来源:origin: org.opennms.core/org.opennms.core.camel

@Override
  public ChannelHandler newChannelHandler() {
    return new XmlFrameDecoder(m_maxFrameLength);
  }
}

代码示例来源:origin: redisson/redisson

fail(bufferLength);
return;
} else if (!openingBracketFound && readByte != '<') {
  fail(ctx);
  in.skipBytes(in.readableBytes());
  return;
    } else if (isValidStartCharForXmlElement(peekAheadByte)) {
      atLeastOneXmlElementFound = true;
      if (isCommentBlockStart(in, i)) {
      } else if (isCDATABlockStart(in, i)) {
    extractFrame(in, readerIndex + leadingWhiteSpaceCount, xmlElementLength - leadingWhiteSpaceCount);
in.skipBytes(xmlElementLength);
out.add(frame);

代码示例来源:origin: OpenNMS/opennms

@Override
  public void initChannel(SocketChannel ch) throws Exception {
    ch.pipeline().addLast(new LoggingHandler());
    ch.pipeline().addLast(new XmlFrameDecoder(2147483647));
    ch.pipeline().addLast(new XmlEventProcessor(eventIpcManager));
  }
});

代码示例来源:origin: wildfly/wildfly

fail(bufferLength);
return;
} else if (!openingBracketFound && readByte != '<') {
  fail(ctx);
  in.skipBytes(in.readableBytes());
  return;
    } else if (isValidStartCharForXmlElement(peekAheadByte)) {
      atLeastOneXmlElementFound = true;
      if (isCommentBlockStart(in, i)) {
      } else if (isCDATABlockStart(in, i)) {
    extractFrame(in, readerIndex + leadingWhiteSpaceCount, xmlElementLength - leadingWhiteSpaceCount);
in.skipBytes(xmlElementLength);
out.add(frame);

代码示例来源:origin: org.opennms.features.events/org.opennms.features.events.daemon

@Override
  public void initChannel(SocketChannel ch) throws Exception {
    ch.pipeline().addLast(new LoggingHandler());
    ch.pipeline().addLast(new XmlFrameDecoder(2147483647));
    ch.pipeline().addLast(new XmlEventProcessor(eventIpcManager));
  }
});

代码示例来源:origin: org.apache.activemq/artemis-jms-client-all

fail(bufferLength);
return;
} else if (!openingBracketFound && readByte != '<') {
  fail(ctx);
  in.skipBytes(in.readableBytes());
  return;
    } else if (isValidStartCharForXmlElement(peekAheadByte)) {
      atLeastOneXmlElementFound = true;
      if (isCommentBlockStart(in, i)) {
      } else if (isCDATABlockStart(in, i)) {
    extractFrame(in, readerIndex + leadingWhiteSpaceCount, xmlElementLength - leadingWhiteSpaceCount);
in.skipBytes(xmlElementLength);
out.add(frame);

代码示例来源:origin: OpenNMS/opennms

@Override
  protected void initChannel(DatagramChannel ch) throws Exception {
    ch.pipeline().addLast(new LoggingHandler());
    ch.pipeline().addLast(new MessageToMessageDecoder<DatagramPacket>() {
      @Override
      protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, List<Object> out) throws Exception {
        msg.retain();
        out.add(msg.content());
      }
    });
    ch.pipeline().addLast(new XmlFrameDecoder(2147483647));
    ch.pipeline().addLast(new XmlEventProcessor(eventIpcManager));
  }
});

代码示例来源:origin: apache/activemq-artemis

fail(bufferLength);
return;
} else if (!openingBracketFound && readByte != '<') {
  fail(ctx);
  in.skipBytes(in.readableBytes());
  return;
    } else if (isValidStartCharForXmlElement(peekAheadByte)) {
      atLeastOneXmlElementFound = true;
      if (isCommentBlockStart(in, i)) {
      } else if (isCDATABlockStart(in, i)) {
    extractFrame(in, readerIndex + leadingWhiteSpaceCount, xmlElementLength - leadingWhiteSpaceCount);
in.skipBytes(xmlElementLength);
out.add(frame);

代码示例来源:origin: org.opennms.features.events/org.opennms.features.events.daemon

@Override
  protected void initChannel(DatagramChannel ch) throws Exception {
    ch.pipeline().addLast(new LoggingHandler());
    ch.pipeline().addLast(new MessageToMessageDecoder<DatagramPacket>() {
      @Override
      protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, List<Object> out) throws Exception {
        msg.retain();
        out.add(msg.content());
      }
    });
    ch.pipeline().addLast(new XmlFrameDecoder(2147483647));
    ch.pipeline().addLast(new XmlEventProcessor(eventIpcManager));
  }
});

代码示例来源:origin: io.netty/netty-codec

fail(bufferLength);
return;
} else if (!openingBracketFound && readByte != '<') {
  fail(ctx);
  in.skipBytes(in.readableBytes());
  return;
    } else if (isValidStartCharForXmlElement(peekAheadByte)) {
      atLeastOneXmlElementFound = true;
      if (isCommentBlockStart(in, i)) {
      } else if (isCDATABlockStart(in, i)) {
    extractFrame(in, readerIndex + leadingWhiteSpaceCount, xmlElementLength - leadingWhiteSpaceCount);
in.skipBytes(xmlElementLength);
out.add(frame);

代码示例来源:origin: org.jboss.eap/wildfly-client-all

fail(bufferLength);
return;
} else if (!openingBracketFound && readByte != '<') {
  fail(ctx);
  in.skipBytes(in.readableBytes());
  return;
    } else if (isValidStartCharForXmlElement(peekAheadByte)) {
      atLeastOneXmlElementFound = true;
      if (isCommentBlockStart(in, i)) {
      } else if (isCDATABlockStart(in, i)) {
    extractFrame(in, readerIndex + leadingWhiteSpaceCount, xmlElementLength - leadingWhiteSpaceCount);
in.skipBytes(xmlElementLength);
out.add(frame);

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com