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


Java StreamSourceChannel类代码示例

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


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

示例1: handleEvent

import org.xnio.channels.StreamSourceChannel; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public void handleEvent(final StreamSourceChannel channel) {
    final R receiver = AbstractFramedChannel.this.receiver;
    if ((isLastFrameReceived() || receivesSuspended) && receiver == null) {
        channel.suspendReads();
        return;
    } else {
        final ChannelListener listener = receiveSetter.get();
        if (listener != null) {
            WebSocketLogger.REQUEST_LOGGER.debugf("Invoking receive listener", receiver);
            ChannelListeners.invokeChannelListener(AbstractFramedChannel.this, listener);
        } else {
            channel.suspendReads();
        }
    }
    if (readData != null && channel.isOpen()) {
        ChannelListeners.invokeChannelListener(channel.getIoThread(), channel, this);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:AbstractFramedChannel.java

示例2: parse

import org.xnio.channels.StreamSourceChannel; //导入依赖的package包/类
@Override
public void parse(final HttpHandler handler) throws Exception {
    if (exchange.getAttachment(FORM_DATA) != null) {
        handler.handleRequest(exchange);
        return;
    }
    this.handler = handler;
    //we need to delegate to a thread pool
    //as we parse with blocking operations

    StreamSourceChannel requestChannel = exchange.getRequestChannel();
    if (requestChannel == null) {
        throw new IOException(UndertowMessages.MESSAGES.requestChannelAlreadyProvided());
    }
    if (executor == null) {
        exchange.dispatch(new NonBlockingParseTask(exchange.getConnection().getWorker(), requestChannel));
    } else {
        exchange.dispatch(executor, new NonBlockingParseTask(executor, requestChannel));
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:MultiPartParserDefinition.java

示例3: 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);
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:FormEncodedDataDefinition.java

示例4: parseBlocking

import org.xnio.channels.StreamSourceChannel; //导入依赖的package包/类
@Override
public FormData parseBlocking() throws IOException {
    final FormData existing = exchange.getAttachment(FORM_DATA);
    if (existing != null) {
        return existing;
    }

    StreamSourceChannel channel = exchange.getRequestChannel();
    if (channel == null) {
        throw new IOException(UndertowMessages.MESSAGES.requestChannelAlreadyProvided());
    } else {
        while (state != 4) {
            doParse(channel);
            if (state != 4) {
                channel.awaitReadable();
            }
        }
    }
    return data;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:FormEncodedDataDefinition.java

示例5: getRequestChannel

import org.xnio.channels.StreamSourceChannel; //导入依赖的package包/类
/**
 * Get the inbound request.  If there is no request body, calling this method
 * may cause the next request to immediately be processed.  The {@link StreamSourceChannel#close()} or {@link StreamSourceChannel#shutdownReads()}
 * method must be called at some point after the request is processed to prevent resource leakage and to allow
 * the next request to proceed.  Any unread content will be discarded.
 *
 * @return the channel for the inbound request, or {@code null} if another party already acquired the channel
 */
public StreamSourceChannel getRequestChannel() {
    if (requestChannel != null) {
        return null;
    }
    if (anyAreSet(state, FLAG_REQUEST_TERMINATED)) {
        return requestChannel = new ReadDispatchChannel(new ConduitStreamSourceChannel(Configurable.EMPTY, new EmptyStreamSourceConduit(getIoThread())));
    }
    final ConduitWrapper<StreamSourceConduit>[] wrappers = this.requestWrappers;
    final ConduitStreamSourceChannel sourceChannel = connection.getSourceChannel();
    if (wrappers != null) {
        this.requestWrappers = null;
        final WrapperConduitFactory<StreamSourceConduit> factory = new WrapperConduitFactory<>(wrappers, requestWrapperCount, sourceChannel.getConduit(), this);
        sourceChannel.setConduit(factory.create());
    }
    return requestChannel = new ReadDispatchChannel(sourceChannel);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:HttpServerExchange.java

示例6: transferFrom

import org.xnio.channels.StreamSourceChannel; //导入依赖的package包/类
public long transferFrom(final StreamSourceChannel source, final long count, final ByteBuffer throughBuffer) throws IOException {
    if (count == 0L) return 0L;
    long val = state;
    if (allAreSet(val, FLAG_CLOSE_REQUESTED)) {
        throw new ClosedChannelException();
    }
    if (allAreClear(val, MASK_COUNT)) {
        throw new FixedLengthOverflowException();
    }
    long res = 0L;
    try {
        return res = next.transferFrom(source, min(count, (val & MASK_COUNT)), throughBuffer);
    } catch (IOException e) {
        broken = true;
        throw e;
    } finally {
        exitWrite(val, res);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:AbstractFixedLengthStreamSinkConduit.java

示例7: 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();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:StringReadChannelListener.java

示例8: handleEvent

import org.xnio.channels.StreamSourceChannel; //导入依赖的package包/类
@Override
public void handleEvent(final StreamSourceChannel channel) {
    Pooled<ByteBuffer> resource = bufferPool.allocate();
    ByteBuffer buffer = resource.getResource();
    try {
        int r = 0;
        do {
            r = channel.read(buffer);
            if (r == 0) {
                return;
            } 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();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:StringReadChannelListener.java

示例9: 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);
}
 
开发者ID:neowu,项目名称:core-ng-project,代码行数:22,代码来源:HTTPServerIOHandler.java

示例10: getResponseChannel

import org.xnio.channels.StreamSourceChannel; //导入依赖的package包/类
@Override
public StreamSourceChannel getResponseChannel() {
    return new DetachableStreamSourceChannel(responseChannel) {
        @Override
        protected boolean isFinished() {
            return anyAreSet(state, RESPONSE_TERMINATED);
        }
    };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AjpClientExchange.java

示例11: getResponseChannel

import org.xnio.channels.StreamSourceChannel; //导入依赖的package包/类
@Override
public StreamSourceChannel getResponseChannel() {
    return new DetachableStreamSourceChannel(clientConnection.getConnection().getSourceChannel()) {
        @Override
        protected boolean isFinished() {
            return anyAreSet(state, RESPONSE_TERMINATED);
        }
    };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:HttpClientExchange.java

示例12: transferFrom

import org.xnio.channels.StreamSourceChannel; //导入依赖的package包/类
public long transferFrom(final StreamSourceChannel source, final long count, final ByteBuffer throughBuffer) throws IOException {
    if (state != 0) {
        return IoUtils.transfer(source, count, throughBuffer, new ConduitWritableByteChannel(this));
    } else {
        return next.transferFrom(source, count, throughBuffer);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:HttpResponseConduit.java

示例13: handleEvent

import org.xnio.channels.StreamSourceChannel; //导入依赖的package包/类
@Override
public void handleEvent(final StreamSourceChannel channel) {
    try {
        doParse(channel);
        if (state == 4) {
            exchange.dispatch(SameThreadExecutor.INSTANCE, handler);
        }
    } catch (IOException e) {
        IoUtils.safeClose(channel);
        UndertowLogger.REQUEST_LOGGER.ioExceptionReadingFromChannel(e);
        exchange.endExchange();

    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:FormEncodedDataDefinition.java

示例14: transferFrom

import org.xnio.channels.StreamSourceChannel; //导入依赖的package包/类
@Override
public long transferFrom(StreamSourceChannel source, long count, ByteBuffer throughBuffer) throws IOException {
    if (!canSend()) {
        return 0;
    }
    int bytes = this.bytes - this.byteCount;
    long written = super.transferFrom(source, Math.min(count, bytes), throughBuffer);
    handleWritten(written);
    return written;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:RateLimitingStreamSinkConduit.java

示例15: transferFrom

import org.xnio.channels.StreamSourceChannel; //导入依赖的package包/类
@Override
public long transferFrom(final StreamSourceChannel source, final long count, final ByteBuffer throughBuffer) throws IOException {
    if (anyAreSet(state, FLAG_WRITES_SHUTDOWN)) {
        throw new ClosedChannelException();
    }
    return IoUtils.transfer(source, count, throughBuffer, new ConduitWritableByteChannel(this));
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:ChunkedStreamSinkConduit.java


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