class RequestHandlerImpl implements RequestHandler {

    @Override
    public void handleRequest(GenericContainerRequest request, GenericContainerResponse response) throws IOException {
        final ApplicationContext context = ApplicationContext.getCurrent();

        try {
            for (RequestFilter filter : providers.getRequestFilters(context.getPath())) {
                filter.doFilter(request);
            }
            dispatcher.dispatch(request, response);
            setupInternalResponseHeaders(response.getStatus(), response.getHttpHeaders());
            for (ResponseFilter filter : providers.getResponseFilters(context.getPath())) {
                filter.doFilter(response);
            }
        } catch (Exception e) {
            if (e instanceof WebApplicationException) {
                handleWebApplicationException((WebApplicationException)e, response);
            } else if (e instanceof InternalException) {
                handleInternalException((InternalException)e, response);
            } else {
                throw new UnhandledException(e);
            }
        }

        response.writeResponse();
    }

    public  RequestHandlerImpl(RequestDispatcher dispatcher, ProviderBinder providers);

}