@Override public int encode(final ByteBuffer bufferRead) throws ActiveMQException { ActiveMQBuffer buffer1 = ActiveMQBuffers.wrappedBuffer(bufferRead); return encode(buffer1, bufferRead.capacity()); }
@Override public int encode(final ByteBuffer bufferRead) throws ActiveMQException { ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer(bufferRead); return encode(buffer, bufferRead.capacity()); }
@Override public ActiveMQBuffer readBytes(final int length) { byte[] bytesToGet = new byte[length]; getBytes(readerIndex, bytesToGet); readerIndex += length; return ActiveMQBuffers.wrappedBuffer(bytesToGet); }
@Override public ActiveMQBuffer readBytes(final int length) { byte[] bytesToGet = new byte[length]; readBytes(bytesToGet); return ActiveMQBuffers.wrappedBuffer(bytesToGet); }
private ActiveMQBuffer inflate(ActiveMQBuffer buffer) throws DataFormatException { int bytesToRead = buffer.readableBytes(); Inflater inflater = new Inflater(); inflater.setInput(ByteUtil.getActiveArray(buffer.readBytes(bytesToRead).toByteBuffer())); //get the real size of large message long sizeBody = getLongProperty(Message.HDR_LARGE_BODY_SIZE); byte[] data = new byte[(int) sizeBody]; inflater.inflate(data); inflater.end(); ActiveMQBuffer qbuff = ActiveMQBuffers.wrappedBuffer(data); qbuff.resetReaderIndex(); qbuff.resetWriterIndex(); qbuff.writeBytes(data); buffer = qbuff; return buffer; }
ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer(data);
@Override public ActiveMQBuffer readBytes(final int length) { byte[] bytesToGet = new byte[length]; getBytes(readerIndex, bytesToGet); readerIndex += length; return ActiveMQBuffers.wrappedBuffer(bytesToGet); }
@Override public ActiveMQBuffer readBytes(final int length) { byte[] bytesToGet = new byte[length]; readBytes(bytesToGet); return ActiveMQBuffers.wrappedBuffer(bytesToGet); }
@Override public ActiveMQBuffer readBytes(final int length) { byte[] bytesToGet = new byte[length]; readBytes(bytesToGet); return ActiveMQBuffers.wrappedBuffer(bytesToGet); }
@Override public ActiveMQBuffer readBytes(final int length) { byte[] bytesToGet = new byte[length]; getBytes(readerIndex, bytesToGet); readerIndex += length; return ActiveMQBuffers.wrappedBuffer(bytesToGet); }
@Override public ActiveMQBuffer readBytes(final int length) { byte[] bytesToGet = new byte[length]; getBytes(readerIndex, bytesToGet); readerIndex += length; return ActiveMQBuffers.wrappedBuffer(bytesToGet); }
@Override public ActiveMQBuffer readBytes(final int length) { byte[] bytesToGet = new byte[length]; readBytes(bytesToGet); return ActiveMQBuffers.wrappedBuffer(bytesToGet); }
private static Xid toXid(final byte[] data) { try { return XidCodecSupport.decodeXid(ActiveMQBuffers.wrappedBuffer(data)); } catch (Exception e) { return null; } }
@Override public ActiveMQBuffer readBytes(final int length) { byte[] bytesToGet = new byte[length]; readBytes(bytesToGet); return ActiveMQBuffers.wrappedBuffer(bytesToGet); }
@Override public int encode(final ByteBuffer bufferRead) throws ActiveMQException { ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer(bufferRead); return encode(buffer, bufferRead.capacity()); }
private ActiveMQBuffer readActiveMQBuffer(SequentialFile file, int size) throws Exception { ByteBuffer byteBuffer = ByteBuffer.allocate(size); byteBuffer.mark(); file.read(byteBuffer); byteBuffer.reset(); ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer(byteBuffer); buffer.writerIndex(size); return buffer; } }
private void testValidateUTFOnDataInputStream(final String str, final ActiveMQBuffer wrap) throws Exception { UTF8Util.saveUTF(wrap.byteBuf(), str); DataInputStream data = new DataInputStream(new ByteArrayInputStream(wrap.toByteBuffer().array())); String newStr = data.readUTF(); Assert.assertEquals(str, newStr); ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); DataOutputStream outData = new DataOutputStream(byteOut); outData.writeUTF(str); ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer(byteOut.toByteArray()); newStr = UTF8Util.readUTF(buffer); Assert.assertEquals(str, newStr); }
@Override public void write(final EncodingSupport bytes, final boolean sync, final IOCallback callback) throws Exception { ByteBuffer buffer = newBuffer(bytes.getEncodeSize()); ActiveMQBuffer outbuffer = ActiveMQBuffers.wrappedBuffer(buffer); bytes.encode(outbuffer); write(outbuffer, sync, callback); }
@Override public void write(final EncodingSupport bytes, final boolean sync) throws Exception { ByteBuffer buffer = newBuffer(bytes.getEncodeSize()); ActiveMQBuffer outbuffer = ActiveMQBuffers.wrappedBuffer(buffer); bytes.encode(outbuffer); write(outbuffer, sync); }
@Test public void testWrite() throws Exception { ActiveMQBuffer buff = ActiveMQBuffers.wrappedBuffer(ByteBuffer.allocate(128)); EmbeddedChannel channel = createChannel(); Assert.assertEquals(0, channel.outboundMessages().size()); NettyConnection conn = new NettyConnection(emptyMap, channel, new MyListener(), false, false); conn.write(buff); channel.runPendingTasks(); Assert.assertEquals(1, channel.outboundMessages().size()); }