当前位置: 首页>>代码示例>>Java>>正文


Java BufferUtil类代码示例

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


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

示例1: forwardIncoming

import org.eclipse.jetty.util.BufferUtil; //导入依赖的package包/类
protected void forwardIncoming(Frame frame, ByteAccumulator accumulator)
{
    DataFrame newFrame = new DataFrame(frame);
    // Unset RSV1 since it's not compressed anymore.
    newFrame.setRsv1(false);

    ByteBuffer buffer = getBufferPool().acquire(accumulator.getLength(),false);
    try
    {
        BufferUtil.flipToFill(buffer);
        accumulator.transferTo(buffer);
        newFrame.setPayload(buffer);
        nextIncomingFrame(newFrame);
    }
    finally
    {
        getBufferPool().release(buffer);
    }
}
 
开发者ID:AnywhereSoftware,项目名称:B4J_Server,代码行数:20,代码来源:CompressExtension.java

示例2: onContent

import org.eclipse.jetty.util.BufferUtil; //导入依赖的package包/类
@Override
public void onContent(final Response serverResponse, ByteBuffer content, final Callback callback) {
	try {
		int contentBytes = content.remaining();
		_log.debug("{} received server content: {} bytes", dialog.id(), contentBytes);

		hasContent = true;

		boolean committed = dialog.hasAttribute(WRITE_LISTENER_ATTRIBUTE);
		length += contentBytes;
		boolean finished = length == dialog.getResponseContentLength();

		ProxyWriter proxyWriter = write(content, finished, callback);
		
		if (finished)
			proxyWriter.offer(BufferUtil.EMPTY_BUFFER, complete);

		if (committed) {
			proxyWriter.onWritePossible();
		} else {
			dialog.write(proxyWriter);
		}
	} catch (Throwable x) {
		callback.failed(x);
	}
}
 
开发者ID:fuwjax,项目名称:ev-oss,代码行数:27,代码来源:AsyncMiddleManHandler.java

示例3: onSuccess

import org.eclipse.jetty.util.BufferUtil; //导入依赖的package包/类
@Override
public void onSuccess(final Response serverResponse) {
	try {
		if (hasContent) {
			// If we had unknown length content, we need to call the
			// transformer to signal that the content is finished.
			if (dialog.getResponseContentLength() < 0) {
				ProxyWriter proxyWriter = write(BufferUtil.EMPTY_BUFFER, true, complete);
				proxyWriter.onWritePossible();
			}
		} else {
			complete.succeeded();
		}
	} catch (Throwable x) {
		complete.failed(x);
	}
}
 
开发者ID:fuwjax,项目名称:ev-oss,代码行数:18,代码来源:AsyncMiddleManHandler.java

示例4: onContent

import org.eclipse.jetty.util.BufferUtil; //导入依赖的package包/类
@Override
public void onContent(Response response, ByteBuffer buffer, Callback callback) {
    if (logger.isDebugEnabled()) {
        logger.debug("received response chunk {} {}", response, BufferUtil.toSummaryString(buffer));
    }
    content.offer(new ContentChunk(buffer, callback));
}
 
开发者ID:jetty-project,项目名称:jetty-reactive-httpclient,代码行数:8,代码来源:ResponseListenerPublisher.java

示例5: onContent

import org.eclipse.jetty.util.BufferUtil; //导入依赖的package包/类
@Override
public void onContent(Response response, ByteBuffer content) {
    logger.debug("Jetty received response content of size {}", String.valueOf(content.remaining()));
    JSONObject responseJson = new JSONObject();
    try {
        responseJson.put("id", mRequestId);
        responseJson.put("body", BufferUtil.toArray(content));
        socket.emit("responseContentBinary", responseJson);
        logger.debug("Sent content to request {}", mRequestId);
    } catch (JSONException e) {
        logger.error("{}", e.getMessage());
    }
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:14,代码来源:CloudClient.java

示例6: onAllDataRead

import org.eclipse.jetty.util.BufferUtil; //导入依赖的package包/类
@Override
public void onAllDataRead() throws IOException {
	// succeeded?
	if (!provider.isClosed()) {
		process(BufferUtil.EMPTY_BUFFER, new Callback(){
			@Override
			public void failed(Throwable x) {
				dialog.abort(x);
			}
		}, true);
	}

	_log.debug("{} proxying content to upstream completed", dialog.id());
	super.close();
}
 
开发者ID:fuwjax,项目名称:ev-oss,代码行数:16,代码来源:AsyncMiddleManHandler.java

示例7: process

import org.eclipse.jetty.util.BufferUtil; //导入依赖的package包/类
@Override
protected Action process() throws Exception {
	ServletInputStream input = dialog.requestInputStream();
	while (input.isReady() && !input.isFinished()) {
		int read = input.read(buffer);

		_log.debug("{} asynchronous read {} bytes on {}", dialog.id(), read, input);

		if (read < 0)
			return Action.SUCCEEDED;

		if (contentLength > 0 && read > 0)
			length += read;

		ByteBuffer content = read > 0 ? ByteBuffer.wrap(buffer, 0, read) : BufferUtil.EMPTY_BUFFER;
		boolean finished = length == contentLength;
		process(content, this, finished);

		if (read > 0)
			return Action.SCHEDULED;
	}

	if (input.isFinished()) {
		_log.debug("{} asynchronous read complete on {}", dialog.id(), input);
		return Action.SUCCEEDED;
	} else {
		_log.debug("{} asynchronous read pending on {}", dialog.id(), input);
		return Action.IDLE;
	}
}
 
开发者ID:fuwjax,项目名称:ev-oss,代码行数:31,代码来源:AsyncMiddleManHandler.java

示例8: write

import org.eclipse.jetty.util.BufferUtil; //导入依赖的package包/类
private ProxyWriter write(ByteBuffer content, boolean finished, Callback callback) throws Throwable {
	int contentBytes = content.remaining();
	ProxyWriter proxyWriter = dialog.attribute(WRITE_LISTENER_ATTRIBUTE, () -> new ProxyWriter(dialog));				
	ContentTransformer transformer = dialog.attribute(SERVER_TRANSFORMER, strategy::responseTransform);
	try {
		transformer.transform(content, finished, buffers);
	} catch (IOException x) {
		_log.info("Exception while transforming " + transformer, x);
		throw x;
	}

	int newContentBytes = 0;
	int size = buffers.size();
	if (size > 0) {
		Callback counter = size == 1 ? callback : new CountingCallback(callback, size);
		for (int i = 0; i < size; ++i) {
			ByteBuffer buffer = buffers.get(i);
			newContentBytes += buffer.remaining();
			proxyWriter.offer(buffer, counter);
		}
		buffers.clear();
	} else {
		proxyWriter.offer(BufferUtil.EMPTY_BUFFER, callback);
	}
	
	_log.debug("{} downstream content transformation {} -> {} bytes", dialog.id(), contentBytes, newContentBytes);

	return proxyWriter;
}
 
开发者ID:fuwjax,项目名称:ev-oss,代码行数:30,代码来源:AsyncMiddleManHandler.java

示例9: onContent

import org.eclipse.jetty.util.BufferUtil; //导入依赖的package包/类
@Override
public void onContent(Response response, ByteBuffer byteBuffer) {
  LOG.info("content: " + BufferUtil.toString(byteBuffer));
  LOG.info("");
}
 
开发者ID:janweinschenker,项目名称:servlet4-demo,代码行数:6,代码来源:ContentListener.java

示例10: onContent

import org.eclipse.jetty.util.BufferUtil; //导入依赖的package包/类
@Override
public void onContent(Response response, ByteBuffer content) {
  byte[] bytes = BufferUtil.toArray(content);
  utf8Content.append(bytes, 0, bytes.length);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:6,代码来源:AsyncRestServlet.java

示例11: EchoConnection

import org.eclipse.jetty.util.BufferUtil; //导入依赖的package包/类
public EchoConnection(ByteBufferPool pool, EndPoint endp, Executor executor) {
	super(endp, executor);
	_bufferPool = pool;
	if (_bufferPool == null)
		_buffer = BufferUtil.allocate(BUF_MAX_LEN);
}
 
开发者ID:HunanTV,项目名称:fw,代码行数:7,代码来源:EchoConnection.java


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