Package org.mortbay.io.nio

Examples of org.mortbay.io.nio.IndirectNIOBuffer


        Buffer buffer;
        if (size==_applicationBufferSize)
        {  
            buffer = _applicationBuffers.poll();
            if (buffer==null)
                buffer=new IndirectNIOBuffer(size);
        }
        else if (size==_packetBufferSize)
        {  
            buffer = _packetBuffers.poll();
            if (buffer==null)
                buffer=getUseDirectBuffers()
                    ?(NIOBuffer)new DirectNIOBuffer(size)
                    :(NIOBuffer)new IndirectNIOBuffer(size);
        }
        else
            buffer=super.getBuffer(size);
       
        return buffer;
View Full Code Here


        Buffer buffer;
        if (size==_applicationBufferSize)
        {  
            buffer = _applicationBuffers.poll();
            if (buffer==null)
                buffer=new IndirectNIOBuffer(size);
        }
        else if (size==_packetBufferSize)
        {  
            buffer = _packetBuffers.poll();
            if (buffer==null)
                buffer=getUseDirectBuffers()
                    ?(NIOBuffer)new DirectNIOBuffer(size)
                    :(NIOBuffer)new IndirectNIOBuffer(size);
        }
        else
            buffer=super.getBuffer(size);
       
        return buffer;
View Full Code Here

                try
                {
                    Connector connector = HttpConnection.getCurrentConnection().getConnector();
                    buffer = ((NIOConnector)connector).getUseDirectBuffers()?
                            (NIOBuffer)new DirectNIOBuffer((int)length):
                            (NIOBuffer)new IndirectNIOBuffer((int)length);
                               
                }
                catch(OutOfMemoryError e)
                {
                    Log.warn(e.toString());
                    Log.debug(e);
                    buffer = new IndirectNIOBuffer((int) length);
                }
                buffer.readFrom(is,(int)length);
                is.close();
            }
            content.setBuffer(buffer);
View Full Code Here

    {
        if (_connectorType!=CONNECTOR_SOCKET)
        {
            Buffer buf=null;
            if (size==getHeaderBufferSize())
                buf=new IndirectNIOBuffer(size);
            else if (_useDirectBuffers)
                buf=new DirectNIOBuffer(size);
            else
                buf=new IndirectNIOBuffer(size);
            return buf;
        }
        else
        {
            return new ByteArrayBuffer(size);
View Full Code Here

            {
                AbstractBuffers buffers = new AbstractBuffers()
                {
                    protected Buffer newBuffer( int size )
                    {
                        return new IndirectNIOBuffer( size);
                    }
                };

                buffers.setRequestBufferSize( sslEngine.getSession().getPacketBufferSize());
                buffers.setResponseBufferSize(sslEngine.getSession().getApplicationBufferSize());
View Full Code Here

    {
        if (_connectorType!=CONNECTOR_SOCKET)
        {
            Buffer buf=null;
            if (size==getHeaderBufferSize())
                buf=new IndirectNIOBuffer(size);
            else if (_useDirectBuffers)
                buf=new DirectNIOBuffer(size);
            else
                buf=new IndirectNIOBuffer(size);
            return buf;
        }
        else
        {
            return new ByteArrayBuffer(size);
View Full Code Here

            {
                AbstractBuffers buffers = new AbstractBuffers()
                {
                    protected Buffer newBuffer( int size )
                    {
                        return new IndirectNIOBuffer( size);
                    }
                };

                buffers.setHeaderBufferSize( sslEngine.getSession().getApplicationBufferSize());
                buffers.setRequestBufferSize( sslEngine.getSession().getApplicationBufferSize());
View Full Code Here

            runHandshake();

            doWrap();
            doUnwrap();
            _inAppB.flip();
            String response=new IndirectNIOBuffer(_inAppB,true).toString();
            // System.err.println(response);
            assertTrue(response.startsWith("HTTP/1.1 200 OK"));
           
            if (response.indexOf("HELLO WORLD")<0)
            {
                _inAppB.clear();
                doUnwrap();
                _inAppB.flip();
                response=new IndirectNIOBuffer(_inAppB,true).toString();
            }
           
            assertTrue(response.indexOf("HELLO WORLD")>=0);
           
            _inAppB.clear();
            _outAppB.clear();
            _outAppB.put("GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n".getBytes(StringUtil.__ISO_8859_1));
            _outAppB.flip();

            try
            {
                session.invalidate();
                _engine.beginHandshake();
                runHandshake();
               
                doWrap();
                doUnwrap();
                _inAppB.flip();
                response=new IndirectNIOBuffer(_inAppB,true).toString();
                assertTrue(response.startsWith("HTTP/1.1 200 OK"));
                if (response.indexOf("HELLO WORLD")<0)
                {
                    doUnwrap();
                    _inAppB.flip();
                    response=new IndirectNIOBuffer(_inAppB,true).toString();
                }
                assertTrue(response.indexOf("HELLO WORLD")>0);

                assertTrue(reneg);
            }
View Full Code Here

                ByteBuffer byteBuffer=(ByteBuffer)value;
                synchronized (byteBuffer)
                {
                    NIOBuffer buffer = byteBuffer.isDirect()
                        ?(NIOBuffer)new DirectNIOBuffer(byteBuffer,true)
                        :(NIOBuffer)new IndirectNIOBuffer(byteBuffer,true);
                    ((HttpConnection.Output)getServletResponse().getOutputStream()).sendResponse(buffer);
                }
            }
            catch (IOException e)
            {
View Full Code Here

        // + Are gather writes worth the effort?  Maybe they will work well with two INDIRECT
        // buffers being copied into a single kernel buffer?
        //
        Buffer buf = null;
        if (size==getHeaderBufferSize())
            buf= new IndirectNIOBuffer(size);
        else
            buf = _useDirectBuffers
                ?(NIOBuffer)new DirectNIOBuffer(size)
                :(NIOBuffer)new IndirectNIOBuffer(size);
        return buf;
    }
View Full Code Here

TOP

Related Classes of org.mortbay.io.nio.IndirectNIOBuffer

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.