Example usage for org.apache.http.nio.util HeapByteBufferAllocator HeapByteBufferAllocator

List of usage examples for org.apache.http.nio.util HeapByteBufferAllocator HeapByteBufferAllocator

Introduction

In this page you can find the example usage for org.apache.http.nio.util HeapByteBufferAllocator HeapByteBufferAllocator.

Prototype

HeapByteBufferAllocator

Source Link

Usage

From source file:org.apache.synapse.transport.passthru.util.BufferFactory.java

public BufferFactory(int bufferSize, ByteBufferAllocator allocator, int size) {
    this.bufferSize = bufferSize;
    if (allocator != null) {
        this.allocator = allocator;
    } else {//from w  w w .  j  a va 2s  . co m
        this.allocator = new HeapByteBufferAllocator();
    }

    buffers = new ControlledByteBuffer[size];
}

From source file:org.siddhiesb.transport.passthru.util.BufferFactory.java

public BufferFactory(int bufferSize, ByteBufferAllocator allocator, int size) {
    this.bufferSize = bufferSize;
    if (allocator != null) {
        this.allocator = allocator;
    } else {//ww w .  j  a v a 2s. c  o  m
        this.allocator = new HeapByteBufferAllocator();
    }

    buffers = new ByteBuffer[size];
}

From source file:marytts.server.http.TestProducingNHttpEntity.java

public void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException {
    final SharedOutputBuffer ob = new SharedOutputBuffer(8192, ioctrl, new HeapByteBufferAllocator());
    new Thread() {
        public void run() {
            try {
                FileInputStream fis = new FileInputStream("/Users/marc/Music/enjoytheride_feat.judytzuke_.mp3");
                int nRead;
                byte[] bytes = new byte[4096];
                while ((nRead = fis.read(bytes)) != -1) {
                    synchronized (this) {
                        try {
                            wait(1);//from   w  ww  .  j a v  a2 s.c  om
                        } catch (InterruptedException ie) {
                        }
                    }
                    ob.write(bytes, 0, nRead);
                }
                ob.writeCompleted();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }.start();
    while (!encoder.isCompleted())
        ob.produceContent(encoder);
}

From source file:com.zotoh.maedr.device.apache.HttpNRequestCB.java

@Override
public ConsumingNHttpEntity entityRequest(HttpEntityEnclosingRequest req, HttpContext ctx)
        throws HttpException, IOException {
    //        return new BufferingNHttpEntity(req.getEntity(), new HeapByteBufferAllocator());
    return new StreamingNHttpEntity(req.getEntity(), new HeapByteBufferAllocator());
}

From source file:org.apache.axis2.transport.nhttp.PlainClientIOEventDispatch.java

public void connected(final IOSession session) {
    // Decorate I/O session with logging capabilities
    LoggingNHttpClientConnection conn = new LoggingNHttpClientConnection(new LoggingIOSession(session),
            new DefaultHttpResponseFactory(), new HeapByteBufferAllocator(), this.params);
    session.setAttribute(NHTTP_CONN, conn);

    Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY);
    this.handler.connected(conn, attachment);
}

From source file:org.apache.axis2.transport.nhttp.PlainServerIOEventDispatch.java

public void connected(final IOSession session) {
    // Decorate I/O session with logging capabilities
    LoggingNHttpServerConnection conn = new LoggingNHttpServerConnection(new LoggingIOSession(session),
            new DefaultHttpRequestFactory(), new HeapByteBufferAllocator(), this.params);
    session.setAttribute(NHTTP_CONN, conn);
    this.handler.connected(conn);
}

From source file:com.zotoh.maedr.device.apache.StreamingNHttpEntity.java

/**
 * @param wrapped//from  w w  w.jav a 2s  . c  o  m
 * @param alloctor
 */
public StreamingNHttpEntity(HttpEntity wrapped, ByteBufferAllocator alloctor) {
    super(wrapped);
    _alloctor = new HeapByteBufferAllocator();
    _data = new StreamData();
    _os = new ByteOStream(4096);
}

From source file:org.siddhiesb.transport.http.conn.ServerConnFactory.java

public ServerConnFactory(final HttpRequestFactory requestFactory, final ByteBufferAllocator allocator,
        final org.siddhiesb.transport.http.conn.SSLContextDetails ssl,
        final Map<InetSocketAddress, org.siddhiesb.transport.http.conn.SSLContextDetails> sslByIPMap,
        final HttpParams params) {
    super();//from w w w  .  java2  s .co  m
    this.requestFactory = requestFactory != null ? requestFactory : new DefaultHttpRequestFactory();
    this.allocator = allocator != null ? allocator : new HeapByteBufferAllocator();
    this.ssl = ssl;
    this.sslByIPMap = sslByIPMap != null
            ? new ConcurrentHashMap<InetSocketAddress, org.siddhiesb.transport.http.conn.SSLContextDetails>(
                    sslByIPMap)
            : null;
    this.params = params != null ? params : new BasicHttpParams();
}

From source file:org.siddhiesb.transport.http.conn.ClientConnFactory.java

public ClientConnFactory(final HttpResponseFactory responseFactory, final ByteBufferAllocator allocator,
        final SSLContextDetails ssl, final Map<String, SSLContext> sslByHostMap, final HttpParams params) {
    super();//from   www  . ja  va 2 s. co  m
    this.responseFactory = responseFactory != null ? responseFactory : new DefaultHttpResponseFactory();
    this.allocator = allocator != null ? allocator : new HeapByteBufferAllocator();
    this.ssl = ssl;
    this.sslByHostMap = sslByHostMap != null ? new ConcurrentHashMap<String, SSLContext>(sslByHostMap) : null;
    this.params = params != null ? params : new BasicHttpParams();
}

From source file:marytts.server.http.AudioStreamNHttpEntity.java

public void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException {
    if (out == null) {
        synchronized (mutex) {
            out = new SharedOutputBuffer(8192, ioctrl, new HeapByteBufferAllocator());
            mutex.notify();//  w  w w .  j  a  v a2 s.  c  o m
        }
    }
    while (!encoder.isCompleted())
        out.produceContent(encoder);
}