Package org.mortbay.io.nio

Examples of org.mortbay.io.nio.DirectNIOBuffer


        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);
       
View Full Code Here


        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);
       
View Full Code Here

            Resource resource=content.getResource();
            long length=resource.length();

            if (_useFileMappedBuffer && resource.getFile()!=null)
            {   
                buffer = new DirectNIOBuffer(resource.getFile());
            }
            else
            {
                InputStream is = resource.getInputStream();
                try
                {
                    Connector connector = HttpConnection.getCurrentConnection().getConnector();
                    buffer = ((NIOConnector)connector).getUseDirectBuffers()?
                            (NIOBuffer)new DirectNIOBuffer((int)length):
                            (NIOBuffer)new IndirectNIOBuffer((int)length);
                               
                }
                catch(OutOfMemoryError e)
                {
View Full Code Here

        {
            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
View Full Code Here

    {  
        int size =32;
        ContentExchange httpExchange=new ContentExchange();

        Buffer babuf = new ByteArrayBuffer(size*36*1024);
        Buffer niobuf = new DirectNIOBuffer(size*36*1024);

        byte[] bytes="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".getBytes();

        for (int i=0;i<size*1024;i++)
        {
            babuf.put(bytes);
            niobuf.put(bytes);
        }
       
        httpExchange.setURL(_scheme+"localhost:"+_port+"/");
        httpExchange.setMethod(HttpMethods.POST);
        httpExchange.setRequestContentType("application/data");
        httpExchange.setRequestContent(babuf);
       
        _httpClient.send(httpExchange);
        int status = httpExchange.waitForDone();
        String result=httpExchange.getResponseContent();
        assertEquals(babuf.length(),result.length());
        assertEquals(HttpExchange.STATUS_COMPLETED, status);

        httpExchange.reset();
        httpExchange.setURL(_scheme+"localhost:"+_port+"/");
        httpExchange.setMethod(HttpMethods.POST);
        httpExchange.setRequestContentType("application/data");
        httpExchange.setRequestContent(niobuf);
        _httpClient.send(httpExchange);
        status = httpExchange.waitForDone();
        result=httpExchange.getResponseContent();
        assertEquals(niobuf.length(),result.length());
        assertEquals(HttpExchange.STATUS_COMPLETED, status);
    }
View Full Code Here

        {
            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
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

        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

    {
        super.setUp();
        buffer=new Buffer[]{
          new ByteArrayBuffer(10),
          new IndirectNIOBuffer(10),
          new DirectNIOBuffer(10)
        };
    }
View Full Code Here

    {
        Buffer[] b=
        {
                new ByteArrayBuffer("Test1234 "),
                new ByteArrayBuffer("tEST1234 "),
                new DirectNIOBuffer(4096),
        };
        b[2].put("TeSt1234 ".getBytes(StringUtil.__UTF8));
       
        for (int i=0;i<b.length;i++)
            assertEquals("t"+i,b[0].hashCode(),b[i].hashCode());
View Full Code Here

TOP

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

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.