本文整理汇总了Java中org.xnio.channels.StreamSourceChannel.resumeReads方法的典型用法代码示例。如果您正苦于以下问题:Java StreamSourceChannel.resumeReads方法的具体用法?Java StreamSourceChannel.resumeReads怎么用?Java StreamSourceChannel.resumeReads使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xnio.channels.StreamSourceChannel
的用法示例。
在下文中一共展示了StreamSourceChannel.resumeReads方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.xnio.channels.StreamSourceChannel; //导入方法依赖的package包/类
@Override
public void parse(HttpHandler handler) throws Exception {
if (exchange.getAttachment(FORM_DATA) != null) {
handler.handleRequest(exchange);
return;
}
this.handler = handler;
StreamSourceChannel channel = exchange.getRequestChannel();
if (channel == null) {
throw new IOException(UndertowMessages.MESSAGES.requestChannelAlreadyProvided());
} else {
doParse(channel);
if (state != 4) {
channel.getReadSetter().set(this);
channel.resumeReads();
} else {
exchange.dispatch(SameThreadExecutor.INSTANCE, handler);
}
}
}
示例2: setup
import org.xnio.channels.StreamSourceChannel; //导入方法依赖的package包/类
public void setup(final StreamSourceChannel channel) {
Pooled<ByteBuffer> resource = bufferPool.allocate();
ByteBuffer buffer = resource.getResource();
try {
int r = 0;
do {
r = channel.read(buffer);
if (r == 0) {
channel.getReadSetter().set(this);
channel.resumeReads();
} else if (r == -1) {
stringDone(string.extract());
IoUtils.safeClose(channel);
} else {
buffer.flip();
string.write(buffer);
}
} while (r > 0);
} catch (IOException e) {
error(e);
} finally {
resource.free();
}
}
示例3: handleRequest
import org.xnio.channels.StreamSourceChannel; //导入方法依赖的package包/类
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
if (hasBody(exchange)) { // parse body early, not process until body is read (e.g. for chunked), to save one blocking thread during read
FormDataParser parser = formParserFactory.createParser(exchange);
if (parser != null) {
parser.parse(handler);
return;
}
RequestBodyReader reader = new RequestBodyReader(exchange, handler);
StreamSourceChannel channel = exchange.getRequestChannel();
reader.read(channel); // channel will be null if getRequestChannel() is already called, but here should not be that case
if (!reader.complete()) {
channel.getReadSetter().set(reader);
channel.resumeReads();
return;
}
}
exchange.dispatch(handler);
}
示例4: setup
import org.xnio.channels.StreamSourceChannel; //导入方法依赖的package包/类
public void setup(StreamSourceChannel channel) {
channel.suspendReads();
channel.getReadSetter().set(this);
channel.resumeReads();
}