本文整理汇总了Java中io.undertow.server.HttpServerExchange.dispatch方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServerExchange.dispatch方法的具体用法?Java HttpServerExchange.dispatch怎么用?Java HttpServerExchange.dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.undertow.server.HttpServerExchange
的用法示例。
在下文中一共展示了HttpServerExchange.dispatch方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleRequest
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
/**
* Only allow the request through if successfully authenticated or if authentication is not required.
*
* @see io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange)
*/
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
if(exchange.isInIoThread()) {
exchange.dispatch(this);
return;
}
SecurityContext context = exchange.getSecurityContext();
if (context.authenticate()) {
if(!exchange.isComplete()) {
next.handleRequest(exchange);
}
} else {
if(exchange.getResponseCode() >= StatusCodes.BAD_REQUEST && !exchange.isComplete()) {
ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
src.getOriginalResponse().sendError(exchange.getResponseCode());
} else {
exchange.endExchange();
}
}
}
示例2: handleRequest
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
/**
* Only allow the request through if successfully authenticated or if authentication is not required.
*
* @see io.undertow.server.HttpHandler#handleRequest(io.undertow.server.HttpServerExchange)
*/
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
if(exchange.isInIoThread()) {
exchange.dispatch(this);
return;
}
SecurityContext context = exchange.getSecurityContext();
if (context.authenticate()) {
if(!exchange.isComplete()) {
next.handleRequest(exchange);
}
} else {
exchange.endExchange();
}
}
示例3: AsyncContextImpl
import io.undertow.server.HttpServerExchange; //导入方法依赖的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();
}
});
}
示例4: handleRequest
import io.undertow.server.HttpServerExchange; //导入方法依赖的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);
}
示例5: handleRequest
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
exchange.startBlocking();
if (exchange.isInIoThread()) {
exchange.dispatch(handler);
} else {
handler.handleRequest(exchange);
}
}
示例6: completed
import io.undertow.server.HttpServerExchange; //导入方法依赖的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));
}
示例7: createAdminApp
import io.undertow.server.HttpServerExchange; //导入方法依赖的package包/类
private HttpHandler createAdminApp(WebApplication application) {
return new HttpHandler() {
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
if (exchange.isInIoThread()) {
exchange.dispatch(this);
return;
}
HttpRequest request = new DefaultHttpRequest();
request.setRequestMethod(exchange.getRequestMethod().toString());
request.setUri(exchange.getRequestURI());
request.setProtocol(exchange.getProtocol().toString());
request.setQueryString(exchange.getQueryString());
request.setCharacterEncoding(exchange.getRequestCharset());
request.setBody(new ChannelInputStream(exchange.getRequestChannel()));
request.setContentLength(exchange.getRequestContentLength());
request.setRemoteAddr(exchange.getSourceAddress()
.getAddress()
.getHostAddress());
request.setScheme(exchange.getRequestScheme());
request.setServerName(exchange.getHostName());
request.setServerPort(exchange.getHostPort());
Headers headers = Headers.empty();
exchange.getRequestHeaders().forEach(e -> {
String headerName = e.getHeaderName().toString();
e.forEach(v -> headers.put(headerName, v));
});
some(exchange.getSecurityContext(),
SecurityContext::getAuthenticatedAccount,
Account::getPrincipal,
principal -> headers.put("X-Client-DN", principal.getName()));
request.setHeaders(headers);
try {
HttpResponse response = application.handle(request);
exchange.setStatusCode(response.getStatus());
setResponseHeaders(response.getHeaders(), exchange);
exchange.startBlocking();
setBody(exchange.getResponseSender(), response.getBody());
} catch (ServiceUnavailableException ex) {
exchange.setStatusCode(503);
} finally {
exchange.endExchange();
}
}
};
}