本文整理汇总了Java中io.undertow.util.SameThreadExecutor类的典型用法代码示例。如果您正苦于以下问题:Java SameThreadExecutor类的具体用法?Java SameThreadExecutor怎么用?Java SameThreadExecutor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SameThreadExecutor类属于io.undertow.util包,在下文中一共展示了SameThreadExecutor类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AsyncContextImpl
import io.undertow.util.SameThreadExecutor; //导入依赖的package包/类
public AsyncContextImpl(final HttpServerExchange exchange, final ServletRequest servletRequest, final ServletResponse servletResponse, final ServletRequestContext servletRequestContext, boolean requestSupplied, final AsyncContextImpl previousAsyncContext) {
this.exchange = exchange;
this.servletRequest = servletRequest;
this.servletResponse = servletResponse;
this.servletRequestContext = servletRequestContext;
this.requestSupplied = requestSupplied;
this.previousAsyncContext = previousAsyncContext;
initiatingThread = Thread.currentThread();
exchange.dispatch(SameThreadExecutor.INSTANCE, new Runnable() {
@Override
public void run() {
exchange.setDispatchExecutor(null);
initialRequestDone();
}
});
}
示例2: parse
import io.undertow.util.SameThreadExecutor; //导入依赖的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);
}
}
}
示例3: handleRequest
import io.undertow.util.SameThreadExecutor; //导入依赖的package包/类
public void handleRequest(final HttpServerExchange exchange, final HttpHandler next) throws Exception {
long oldVal, newVal;
do {
oldVal = state;
final long current = oldVal & MASK_CURRENT;
final long max = (oldVal & MASK_MAX) >> 32L;
if (current >= max) {
exchange.dispatch(SameThreadExecutor.INSTANCE, new Runnable() {
@Override
public void run() {
if (!queue.offer(new SuspendedRequest(exchange, next))) {
Connectors.executeRootHandler(failureHandler, exchange);
}
}
});
return;
}
newVal = oldVal + 1;
} while (!stateUpdater.compareAndSet(this, oldVal, newVal));
exchange.addExchangeCompleteListener(COMPLETION_LISTENER);
next.handleRequest(exchange);
}
示例4: handleEvent
import io.undertow.util.SameThreadExecutor; //导入依赖的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();
}
}
示例5: handleRequest
import io.undertow.util.SameThreadExecutor; //导入依赖的package包/类
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
if(!exchange.isRequestComplete()) {
exchange.dispatch(SameThreadExecutor.INSTANCE, new Runnable() {
@Override
public void run() {
new StringReadChannelListener(exchange.getConnection().getBufferPool()) {
@Override
protected void stringDone(String string) {
exchange.putAttachment(DATA, string);
Connectors.executeRootHandler(next, exchange);
}
@Override
protected void error(IOException e) {
UndertowLogger.REQUEST_IO_LOGGER.ioException(e);
exchange.setResponseCode(500);
exchange.endExchange();
}
}.setup(exchange.getRequestChannel());
}
});
} else {
next.handleRequest(exchange);
}
}
示例6: completed
import io.undertow.util.SameThreadExecutor; //导入依赖的package包/类
@Override
public void completed(final HttpServerExchange exchange, final ProxyConnection connection) {
exchange.putAttachment(CONNECTION, connection);
exchange.dispatch(SameThreadExecutor.INSTANCE, new ProxyAction(connection, exchange, requestHeaders, rewriteHostHeader, reuseXForwarded));
}