Package org.apache.mina.common

Examples of org.apache.mina.common.ByteBuffer.position()


        for (;;) {
            int oldPos = buf.position();
            boolean decoded = doDecode(session, buf, out);
            if (decoded) {
                if (buf.position() == oldPos) {
                    throw new IllegalStateException(
                            "doDecode() can't return true when buffer is not consumed.");
                }

                if (!buf.hasRemaining()) {
View Full Code Here


        ProtocolDecoder decoder = getDecoder(session);
        ProtocolDecoderOutput decoderOut = getDecoderOut(session, nextFilter);

        try {
            while (in.hasRemaining()) {
                int oldPos = in.position();
                try {
                    synchronized (decoderOut) {
                        decoder.decode(session, in, decoderOut);
                    }
                    // Finish decoding if no exception was thrown.
View Full Code Here

                    decoderOut.flush();
                    nextFilter.exceptionCaught(session, pde);
                   
                    // Stop retrying if the buffer position didn't change
                    // because retrying can cause an infinite loop.
                    if (in.position() == oldPos) {
                        break;
                    }
                }
            }
        } finally {
View Full Code Here

        ByteBuffer expectedBuf = ByteBuffer.allocate( 160 );
        for( int i = 0; i < 10; i ++ ) {
            expectedBuf.limit( ( i + 1 ) * 16 );
            fillWriteBuffer( expectedBuf, i );
        }
        expectedBuf.position( 0 );
        assertEquals(expectedBuf, readBuf);
    }

    private void fillWriteBuffer( ByteBuffer writeBuf, int i )
    {
View Full Code Here

        ByteBuffer expectedBuf = ByteBuffer.allocate( DATA_SIZE * COUNT );
        for( int i = 0; i < COUNT; i ++ ) {
            expectedBuf.limit( ( i + 1 ) * DATA_SIZE );
            fillWriteBuffer( expectedBuf, i );
        }
        expectedBuf.position( 0 );
       
        assertEquals(expectedBuf, readBuf);
    }

    private void waitForResponse( EchoConnectorHandler handler, int bytes ) throws InterruptedException
View Full Code Here

                    // SSL encrypt
                    if (SessionLog.isDebugEnabled(session)) {
                        SessionLog.debug(session, " encrypt: " + buf);
                    }

                    int pos = buf.position();
                    handler.encrypt(buf.buf());
                    buf.position(pos);
                    ByteBuffer encryptedBuffer = new EncryptedBuffer(SSLHandler
                            .copy(handler.getOutNetBuffer()), buf);
View Full Code Here

                        SessionLog.debug(session, " encrypt: " + buf);
                    }

                    int pos = buf.position();
                    handler.encrypt(buf.buf());
                    buf.position(pos);
                    ByteBuffer encryptedBuffer = new EncryptedBuffer(SSLHandler
                            .copy(handler.getOutNetBuffer()), buf);

                    if (SessionLog.isDebugEnabled(session)) {
                        SessionLog.debug(session, " encrypted buf: "
View Full Code Here

                data.put(cb.payload);
                cb.payload.release();
            }
            data.flip();
        }
        _logger.debug("Creating message from buffer with position=" + data.position() + " and remaining=" + data.remaining());

        return createMessage(messageNbr, data, contentHeader);
    }

    public AbstractJMSMessage createMessage(long messageNbr, boolean redelivered,
View Full Code Here

        try
        {
            for( ;; )
            {
                int oldPos = buf.position();
                boolean decoded = doDecode( session, buf, out );
                if( decoded )
                {
                    if( buf.position() == oldPos )
                    {
View Full Code Here

            {
                int oldPos = buf.position();
                boolean decoded = doDecode( session, buf, out );
                if( decoded )
                {
                    if( buf.position() == oldPos )
                    {
                        throw new IllegalStateException(
                                "doDecode() can't return true when buffer is not consumed." );
                    }
                   
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.