Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.CompositeChannelBuffer


        assertNull(embedder.poll());

    }

    private static void checkContentBuffer(HttpMessage aggregatedMessage) {
        CompositeChannelBuffer buffer = (CompositeChannelBuffer) aggregatedMessage.getContent();
        assertEquals(2, buffer.numComponents());
        List<ChannelBuffer> buffers = buffer.decompose(0, buffer.capacity());
        assertEquals(2, buffers.size());
        for (ChannelBuffer buf: buffers) {
            // This should be false as we decompose the buffer before to not have deep hierarchy
            assertFalse(buf instanceof CompositeChannelBuffer);
        }
View Full Code Here


    protected void appendToCumulation(ChannelBuffer input) {
        ChannelBuffer cumulation = currentMessage.getContent();
        if (cumulation instanceof CompositeChannelBuffer) {
            // Make sure the resulting cumulation buffer has no more than the configured components.
            CompositeChannelBuffer composite = (CompositeChannelBuffer) cumulation;
            if (composite.numComponents() >= maxCumulationBufferComponents) {
                currentMessage.setContent(ChannelBuffers.wrappedBuffer(composite.copy(), input));
            } else {
                List<ChannelBuffer> decomposed = composite.decompose(0, composite.readableBytes());
                ChannelBuffer[] buffers = decomposed.toArray(new ChannelBuffer[decomposed.size() + 1]);
                buffers[buffers.length - 1] = input;

                currentMessage.setContent(ChannelBuffers.wrappedBuffer(buffers));
            }
View Full Code Here

    protected ChannelBuffer appendToCumulation(ChannelBuffer input) {
        ChannelBuffer cumulation = this.cumulation;
        assert cumulation.readable();
        if (cumulation instanceof CompositeChannelBuffer) {
            // Make sure the resulting cumulation buffer has no more than the configured components.
            CompositeChannelBuffer composite = (CompositeChannelBuffer) cumulation;
            if (composite.numComponents() >= maxCumulationBufferComponents) {
                cumulation = composite.copy();
            }
        }

        this.cumulation = input = ChannelBuffers.wrappedBuffer(cumulation, input);
        return input;
View Full Code Here

    protected void appendToCumulation(ChannelBuffer input) {
        ChannelBuffer cumulation = currentMessage.getContent();
        if (cumulation instanceof CompositeChannelBuffer) {
            // Make sure the resulting cumulation buffer has no more than the configured components.
            CompositeChannelBuffer composite = (CompositeChannelBuffer) cumulation;
            if (composite.numComponents() >= maxCumulationBufferComponents) {
                currentMessage.setContent(ChannelBuffers.wrappedBuffer(composite.copy(), input));
            } else {
                List<ChannelBuffer> decomposed = composite.decompose(0, composite.readableBytes());
                ChannelBuffer[] buffers = decomposed.toArray(new ChannelBuffer[decomposed.size() + 1]);
                buffers[buffers.length - 1] = input;

                currentMessage.setContent(ChannelBuffers.wrappedBuffer(buffers));
            }
View Full Code Here

    @Override
    protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
        Object retVal = super.encode(ctx, channel, msg);
        if (retVal instanceof CompositeChannelBuffer) {
            CompositeChannelBuffer ccb = (CompositeChannelBuffer) retVal;
            if (ccb.useGathering() != NettyUtils.DEFAULT_GATHERING) {
                List<ChannelBuffer> decompose = ccb.decompose(ccb.readerIndex(), ccb.readableBytes());
                return ChannelBuffers.wrappedBuffer(NettyUtils.DEFAULT_GATHERING,
                        decompose.toArray(new ChannelBuffer[decompose.size()]));
            }
        }
        return retVal;
View Full Code Here

TOP

Related Classes of org.jboss.netty.buffer.CompositeChannelBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.