本文整理匯總了Java中org.xnio.conduits.ConduitStreamSourceChannel類的典型用法代碼示例。如果您正苦於以下問題:Java ConduitStreamSourceChannel類的具體用法?Java ConduitStreamSourceChannel怎麽用?Java ConduitStreamSourceChannel使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ConduitStreamSourceChannel類屬於org.xnio.conduits包,在下文中一共展示了ConduitStreamSourceChannel類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRequestChannel
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的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);
}
示例2: exchangeComplete
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的package包/類
public void exchangeComplete(final HttpServerExchange exchange) {
if (!exchange.isUpgrade() && exchange.isPersistent()) {
startRequest();
ConduitStreamSourceChannel channel = ((AjpServerConnection) exchange.getConnection()).getChannel().getSourceChannel();
channel.getReadSetter().set(this);
channel.wakeupReads();
} else if(!exchange.isPersistent()) {
safeClose(exchange.getConnection());
}
}
示例3: handleEvent
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的package包/類
public void handleEvent(final ConduitStreamSourceChannel channel) {
while (requestStateUpdater.get(this) != 0) {
//if the CAS fails it is because another thread is in the process of changing state
//we just immediately retry
if (requestStateUpdater.compareAndSet(this, 1, 2)) {
channel.suspendReads();
requestStateUpdater.set(this, 1);
return;
}
}
handleEventWithNoRunningRequest(channel);
}
示例4: handleFailedRead
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的package包/類
private void handleFailedRead(ConduitStreamSourceChannel channel, int res) {
if (res == 0) {
channel.setReadListener(this);
channel.resumeReads();
} else if (res == -1) {
IoUtils.safeClose(connection);
}
}
示例5: SpdyServerConnection
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的package包/類
public SpdyServerConnection(SpdyChannel channel, SpdySynStreamStreamSourceChannel requestChannel, OptionMap undertowOptions, int bufferSize) {
this.channel = channel;
this.requestChannel = requestChannel;
this.undertowOptions = undertowOptions;
this.bufferSize = bufferSize;
responseChannel = requestChannel.getResponseChannel();
originalSinkConduit = new StreamSinkChannelWrappingConduit(responseChannel);
originalSourceConduit = new StreamSourceChannelWrappingConduit(requestChannel);
this.conduitStreamSinkChannel = new ConduitStreamSinkChannel(responseChannel, originalSinkConduit);
this.conduitStreamSourceChannel = new ConduitStreamSourceChannel(requestChannel, originalSourceConduit);
}
示例6: requestDone
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的package包/類
public void requestDone() {
if(delegate instanceof ConduitStreamSourceChannel) {
((ConduitStreamSourceChannel)delegate).setReadListener(null);
((ConduitStreamSourceChannel)delegate).setCloseListener(null);
} else {
delegate.getReadSetter().set(null);
delegate.getCloseSetter().set(null);
}
}
示例7: getReadSetter
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的package包/類
public ChannelListener.Setter<? extends StreamSourceChannel> getReadSetter() {
if (readSetter == null) {
readSetter = new ChannelListener.SimpleSetter<>();
if (!isFinished()) {
if(delegate instanceof ConduitStreamSourceChannel) {
((ConduitStreamSourceChannel)delegate).setReadListener(new SetterDelegatingListener((ChannelListener.SimpleSetter)readSetter, this));
} else {
delegate.getReadSetter().set(new SetterDelegatingListener((ChannelListener.SimpleSetter)readSetter, this));
}
}
}
return readSetter;
}
示例8: getCloseSetter
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的package包/類
public ChannelListener.Setter<? extends StreamSourceChannel> getCloseSetter() {
if (closeSetter == null) {
closeSetter = new ChannelListener.SimpleSetter<>();
if (!isFinished()) {
if(delegate instanceof ConduitStreamSourceChannel) {
((ConduitStreamSourceChannel)delegate).setCloseListener(ChannelListeners.delegatingChannelListener(this, closeSetter));
} else {
delegate.getCloseSetter().set(ChannelListeners.delegatingChannelListener(this, closeSetter));
}
}
}
return closeSetter;
}
示例9: doBeginRead
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的package包/類
@Override
protected void doBeginRead() throws Exception {
StreamConnection conn = connection();
if (conn == null) {
return;
}
ConduitStreamSourceChannel source = conn.getSourceChannel();
if (!source.isReadResumed()) {
source.resumeReads();
}
}
示例10: getSourceChannel
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的package包/類
@Override
public ConduitStreamSourceChannel getSourceChannel() {
return new ConduitStreamSourceChannel(null, null);
}
示例11: getSourceChannel
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的package包/類
@Override
protected ConduitStreamSourceChannel getSourceChannel() {
return channel.getSourceChannel();
}
示例12: setupRequest
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的package包/類
public static void setupRequest(final HttpServerExchange exchange) {
final HeaderMap requestHeaders = exchange.getRequestHeaders();
final String connectionHeader = requestHeaders.getFirst(Headers.CONNECTION);
final String transferEncodingHeader = requestHeaders.getLast(Headers.TRANSFER_ENCODING);
final String contentLengthHeader = requestHeaders.getFirst(Headers.CONTENT_LENGTH);
final HttpServerConnection connection = (HttpServerConnection) exchange.getConnection();
//if we are already using the pipelineing buffer add it to the exchange
PipeliningBufferingStreamSinkConduit pipeliningBuffer = connection.getPipelineBuffer();
if (pipeliningBuffer != null) {
pipeliningBuffer.setupPipelineBuffer(exchange);
}
ConduitStreamSourceChannel sourceChannel = connection.getChannel().getSourceChannel();
sourceChannel.setConduit(connection.getReadDataStreamSourceConduit());
boolean persistentConnection = persistentConnection(exchange, connectionHeader);
if (transferEncodingHeader == null && contentLengthHeader == null) {
if (persistentConnection
&& connection.getExtraBytes() != null
&& pipeliningBuffer == null
&& connection.getUndertowOptions().get(UndertowOptions.BUFFER_PIPELINED_DATA, false)) {
pipeliningBuffer = new PipeliningBufferingStreamSinkConduit(connection.getOriginalSinkConduit(), connection.getBufferPool());
connection.setPipelineBuffer(pipeliningBuffer);
pipeliningBuffer.setupPipelineBuffer(exchange);
}
// no content - immediately start the next request, returning an empty stream for this one
Connectors.terminateRequest(exchange);
} else {
persistentConnection = handleRequestEncoding(exchange, transferEncodingHeader, contentLengthHeader, connection, pipeliningBuffer, persistentConnection);
}
exchange.setPersistent(persistentConnection);
if (!exchange.isRequestComplete() || connection.getExtraBytes() != null) {
//if there is more data we suspend reads
sourceChannel.setReadListener(null);
sourceChannel.suspendReads();
}
}
示例13: getSourceChannel
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的package包/類
@Override
protected ConduitStreamSourceChannel getSourceChannel() {
return conduitStreamSourceChannel;
}
示例14: ReadDispatchChannel
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的package包/類
public ReadDispatchChannel(final ConduitStreamSourceChannel delegate) {
super(delegate);
}
示例15: getSourceChannel
import org.xnio.conduits.ConduitStreamSourceChannel; //導入依賴的package包/類
@Override
public ConduitStreamSourceChannel getSourceChannel() {
return new ConduitStreamSourceChannel(Configurable.EMPTY, new EmptyStreamSourceConduit(worker.getIoThread()));
}