• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PooledByteBuffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.undertow.connector.PooledByteBuffer的典型用法代码示例。如果您正苦于以下问题:Java PooledByteBuffer类的具体用法?Java PooledByteBuffer怎么用?Java PooledByteBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PooledByteBuffer类属于io.undertow.connector包,在下文中一共展示了PooledByteBuffer类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: test

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
@Test
public void test() throws Exception {
	ByteBufferPool byteBufferPool = new DefaultByteBufferPool(true, 2, -1, 4);
	PooledByteBufferOutputStream output = new PooledByteBufferOutputStream(byteBufferPool);

	String hello = "hello, 世界!";
	output.write(hello);
	output.flip();

	PooledByteBuffer[] buffers = output.getPooledByteBuffers();

	try (PooledByteBufferInputStream input = new PooledByteBufferInputStream(buffers);) {
		byte[] bytes = new byte[input.available()];
		input.read(bytes);
		String str = new String(bytes, "UTF-8");

		assertEquals(hello, str);
	}

	output.release();
	output.close();
}
 
开发者ID:hank-whu,项目名称:undertow-async,代码行数:23,代码来源:IOTest.java


示例2: sendNoIoThread2Chunks

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
@Test
public void sendNoIoThread2Chunks() throws Exception {
  new MockUnit(ReadableByteChannel.class, HttpServerExchange.class, IoCallback.class,
      Sender.class, PooledByteBuffer.class)
      .expect(exchange)
      .expect(noIoThread)
      .expect(pooled)
      .expect(readLargeChunk)
      .expect(transferEncoding)
      .expect(sendChunk)
      .expect(noIoThread)
      .expect(pooled)
      .expect(readChunk)
      .expect(sendChunk)
      .run(unit -> {
        ChunkedStream chunkedStream = new ChunkedStream();
        chunkedStream.send(unit.get(ReadableByteChannel.class),
            unit.get(HttpServerExchange.class), unit.get(IoCallback.class));
        chunkedStream.onComplete(unit.get(HttpServerExchange.class), unit.get(Sender.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:22,代码来源:ChunkedStreamTest.java


示例3: sendNoIoThread2ChunksWithLen

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
@Test
public void sendNoIoThread2ChunksWithLen() throws Exception {
  new MockUnit(ReadableByteChannel.class, HttpServerExchange.class, IoCallback.class,
      Sender.class, PooledByteBuffer.class)
      .expect(exchange)
      .expect(noIoThread)
      .expect(pooled)
      .expect(readLargeChunk)
      .expect(len)
      .expect(sendChunk)
      .expect(noIoThread)
      .expect(pooled)
      .expect(readChunk)
      .expect(sendChunk)
      .run(unit -> {
        ChunkedStream chunkedStream = new ChunkedStream();
        chunkedStream.send(unit.get(ReadableByteChannel.class),
            unit.get(HttpServerExchange.class), unit.get(IoCallback.class));
        chunkedStream.onComplete(unit.get(HttpServerExchange.class), unit.get(Sender.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:22,代码来源:ChunkedStreamTest.java


示例4: sendIoThread

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
@Test
public void sendIoThread() throws Exception {
  new MockUnit(ReadableByteChannel.class, HttpServerExchange.class, IoCallback.class,
      Sender.class, PooledByteBuffer.class)
      .expect(exchange)
      .expect(ioThread)
      .expect(pooled)
      .expect(readChunk)
      .expect(nolen)
      .expect(sendChunk)
      .run(unit -> {
        ChunkedStream chunkedStream = new ChunkedStream();
        chunkedStream.send(unit.get(ReadableByteChannel.class),
            unit.get(HttpServerExchange.class), unit.get(IoCallback.class));
        chunkedStream.run();
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:18,代码来源:ChunkedStreamTest.java


示例5: internalAsyncRequest

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
private void internalAsyncRequest(final HttpServerExchange exchange, ArrayList<PooledByteBuffer> bufferList)
		throws Exception {
	// ensure exchange not end
	getResponseChannel(exchange).resumeWrites();

	PooledByteBuffer[] buffers = EMPTY_BUFFERS;

	if (bufferList != null && bufferList.size() > 0) {
		buffers = new PooledByteBuffer[bufferList.size()];
		buffers = bufferList.toArray(buffers);
	}

	handleAsyncRequest(exchange, new PooledByteBufferInputStream(buffers));
}
 
开发者ID:hank-whu,项目名称:undertow-async,代码行数:15,代码来源:AsyncHttpHandler.java


示例6: release

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
/**
 * return the buffer to the buffer pool
 *
 * @param bufferList
 */
private void release(ArrayList<PooledByteBuffer> bufferList) {
	if (bufferList == null || bufferList.size() == 0) {
		return;
	}

	for (int i = 0; i < bufferList.size(); ++i) {
		IoUtils.safeClose(bufferList.get(i));
	}
}
 
开发者ID:hank-whu,项目名称:undertow-async,代码行数:15,代码来源:AsyncHttpHandler.java


示例7: setPooledBuffers

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
/**
 * just for async release
 * 
 * @param sender
 * @param pooledBuffers
 *            will be released
 */
private void setPooledBuffers(Sender sender, PooledByteBuffer[] pooledBuffers) {
	if (!(sender instanceof AsyncSenderImpl)) {
		throw new RuntimeException("only support AsyncSenderImpl");
	}

	unsafe().getAndSetObject(sender, asyncSenderImplPooledBuffersFieldOffset, pooledBuffers);
}
 
开发者ID:hank-whu,项目名称:undertow-async,代码行数:15,代码来源:AsyncHttpHandler.java


示例8: PooledByteBufferInputStream

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
public PooledByteBufferInputStream(PooledByteBuffer[] buffers) {
	Objects.requireNonNull(buffers);

	for (int i = 0; i < buffers.length; i++) {
		if (!buffers[i].isOpen()) {
			throw new IllegalAccessError("buffers must all open");
		}
	}

	this.buffers = buffers;
	next();
}
 
开发者ID:hank-whu,项目名称:undertow-async,代码行数:13,代码来源:PooledByteBufferInputStream.java


示例9: clear

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
public void clear() {
	for (int i = 0; i < pooledList.size(); i++) {
		PooledByteBuffer pooled = pooledList.get(i);
		pooled.getBuffer().clear();
	}

	current = null;
	index = -1;
}
 
开发者ID:hank-whu,项目名称:undertow-async,代码行数:10,代码来源:PooledByteBufferOutputStream.java


示例10: release

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
public void release() {
	for (int i = 0; i < pooledList.size(); i++) {
		PooledByteBuffer pooled = pooledList.get(i);
		IoUtils.safeClose(pooled);
	}

	pooledList.clear();
}
 
开发者ID:hank-whu,项目名称:undertow-async,代码行数:9,代码来源:PooledByteBufferOutputStream.java


示例11: alloc

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
private void alloc() {
	index++;

	if (pooledList.size() - 1 > index) {
		current = pooledList.get(index).getBuffer();
		return;
	}

	PooledByteBuffer pooled = byteBufferPool.allocate();
	current = pooled.getBuffer();
	pooledList.add(pooled);
}
 
开发者ID:hank-whu,项目名称:undertow-async,代码行数:13,代码来源:PooledByteBufferOutputStream.java


示例12: read

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
public void read(StreamSourceChannel channel) {
    try (PooledByteBuffer poolItem = exchange.getConnection().getByteBufferPool().allocate()) {
        ByteBuffer buffer = poolItem.getBuffer();
        int bytesRead;
        while (true) {
            buffer.clear();
            bytesRead = channel.read(buffer);
            if (bytesRead <= 0) break;
            buffer.flip();
            ensureCapacity(bytesRead);
            buffer.get(body, position, bytesRead);
            position += bytesRead;
        }
        if (bytesRead == -1) {
            if (contentLength >= 0 && position < body.length) {
                throw Exceptions.error("body ends prematurely, expected={}, actual={}", contentLength, position);
            } else if (body == null) {
                body = new byte[0]; // without content length and has no body
            }
            complete = true;
            exchange.putAttachment(REQUEST_BODY, new RequestBody(body, null));
        }
    } catch (Throwable e) { // catch all errors during IO, to pass error to action log
        IoUtils.safeClose(channel);
        complete = true;
        exchange.putAttachment(REQUEST_BODY, new RequestBody(null, e));
    }
}
 
开发者ID:neowu,项目名称:core-ng-project,代码行数:29,代码来源:RequestBodyReader.java


示例13: sendNoIoThread

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
@Test
public void sendNoIoThread() throws Exception {
  new MockUnit(ReadableByteChannel.class, HttpServerExchange.class, IoCallback.class,
      Sender.class, PooledByteBuffer.class)
      .expect(exchange)
      .expect(noIoThread)
      .expect(pooled)
      .expect(readChunk)
      .expect(nolen)
      .expect(sendChunk)
      .run(unit -> {
        new ChunkedStream().send(unit.get(ReadableByteChannel.class),
            unit.get(HttpServerExchange.class), unit.get(IoCallback.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:16,代码来源:ChunkedStreamTest.java


示例14: getPooledByteBuffers

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
public PooledByteBuffer[] getPooledByteBuffers() {
	PooledByteBuffer[] buffers = new PooledByteBuffer[pooledList.size()];
	return pooledList.toArray(buffers);
}
 
开发者ID:hank-whu,项目名称:undertow-async,代码行数:5,代码来源:PooledByteBufferOutputStream.java


示例15: flip

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
public void flip() {
	for (int i = 0; i < pooledList.size(); i++) {
		PooledByteBuffer pooled = pooledList.get(i);
		pooled.getBuffer().flip();
	}
}
 
开发者ID:hank-whu,项目名称:undertow-async,代码行数:7,代码来源:PooledByteBufferOutputStream.java


示例16: getByteBuffer

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
@Override
public ByteBuffer getByteBuffer(Object pooled) {
	return ((PooledByteBuffer) pooled).getBuffer();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:UndertowXhrTransport.java


示例17: closePooledResource

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
@Override
public void closePooledResource(Object pooled) {
	((PooledByteBuffer) pooled).close();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:5,代码来源:UndertowXhrTransport.java


示例18: SpdyChannelWithoutFlowControl

import io.undertow.connector.PooledByteBuffer; //导入依赖的package包/类
public SpdyChannelWithoutFlowControl(StreamConnection connectedStreamChannel, ByteBufferPool bufferPool,
    PooledByteBuffer data, ByteBufferPool heapBufferPool, boolean clientSide, OptionMap options) {
    super(connectedStreamChannel, bufferPool, data, heapBufferPool, clientSide, options);
    currentWindowSize = initialWindowSize = getInitialWindowSize();
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:6,代码来源:SpdyChannelWithoutFlowControl.java



注:本文中的io.undertow.connector.PooledByteBuffer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileUtils类代码示例发布时间:2022-05-23
下一篇:
Java GLES20Fix类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap