use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class NonWorkingRequestHandlerTestCase method requireThatHandleRequestThrowsException.
@Test
public void requireThatHandleRequestThrowsException() {
RequestHandler requestHandler = new NonWorkingRequestHandler();
try {
requestHandler.handleRequest(null, null);
fail();
} catch (UnsupportedOperationException e) {
}
}
use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class NonWorkingRequestHandlerTestCase method requireThatDestroyDoesNotThrow.
@Test
public void requireThatDestroyDoesNotThrow() {
RequestHandler requestHandler = new NonWorkingRequestHandler();
requestHandler.release();
}
use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class HttpServerTest method mockRequestHandler.
private static RequestHandler mockRequestHandler() {
final RequestHandler mockRequestHandler = mock(RequestHandler.class);
when(mockRequestHandler.refer()).thenReturn(References.NOOP_REFERENCE);
return mockRequestHandler;
}
use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class FilteringRequestHandler method handleRequest.
@Override
public ContentChannel handleRequest(Request request, ResponseHandler originalResponseHandler) {
Preconditions.checkArgument(request instanceof HttpRequest, "Expected HttpRequest, got " + request);
Objects.requireNonNull(originalResponseHandler, "responseHandler");
RequestFilter requestFilter = requestFilters.resolve(request.getUri());
ResponseFilter responseFilter = responseFilters.resolve(request.getUri());
// Not using request.connect() here - it adds logic for error handling that we'd rather leave to the framework.
RequestHandler resolvedRequestHandler = request.container().resolveHandler(request);
if (resolvedRequestHandler == null) {
throw new BindingNotFoundException(request.getUri());
}
RequestHandler requestHandler = new ReferenceCountingRequestHandler(resolvedRequestHandler);
ResponseHandler responseHandler;
if (responseFilter != null) {
responseHandler = new FilteringResponseHandler(originalResponseHandler, responseFilter, request);
} else {
responseHandler = originalResponseHandler;
}
if (requestFilter != null) {
InterceptingResponseHandler interceptingResponseHandler = new InterceptingResponseHandler(responseHandler);
requestFilter.filter(HttpRequest.class.cast(request), interceptingResponseHandler);
if (interceptingResponseHandler.hasProducedResponse()) {
return COMPLETING_CONTENT_CHANNEL;
}
}
ContentChannel contentChannel = requestHandler.handleRequest(request, responseHandler);
if (contentChannel == null) {
throw new RequestDeniedException(request);
}
return contentChannel;
}
use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class ConfiguredApplication method addHandlerBindings.
private static void addHandlerBindings(ContainerBuilder builder, ComponentRegistry<RequestHandler> requestHandlerRegistry, JdiscBindingsConfig discBindingsConfig) {
for (Map.Entry<String, JdiscBindingsConfig.Handlers> handlerEntry : discBindingsConfig.handlers().entrySet()) {
String id = handlerEntry.getKey();
JdiscBindingsConfig.Handlers handlerConfig = handlerEntry.getValue();
RequestHandler handler = requestHandlerRegistry.getComponent(id);
if (handler == null) {
throw new RuntimeException("Binding configured for non-jdisc request handler " + id);
}
bindUri(builder.serverBindings(), handlerConfig.serverBindings(), handler);
bindUri(builder.clientBindings(), handlerConfig.clientBindings(), handler);
}
}
Aggregations