private void doRequest( final HttpServletRequest req, final HttpServletResponse resp, final AcceptAPIVersion acceptVersion, final Request request) throws ResourceException, Exception { final Context context = newRequestContext(req, acceptVersion); final ServletSynchronizer sync = syncFactory.createServletSynchronizer(req, resp); final RequestRunner runner = new RequestRunner(context, request, req, resp, sync); connectionFactory.getConnectionAsync(runner); sync.awaitIfNeeded(); // Only blocks when async is not supported. }
/** * Creates a new servlet adapter with the provided connection factory and context factory. * * @param servletContext The servlet context. * @param connectionFactory The connection factory. * @param contextFactory The context factory which will be used to obtain the parent context of * each request context, or {@code null} if the {@link SecurityContextFactory} should be used. * @throws ServletException If the servlet container does not support Servlet 2.x or beyond. */ public HttpServletAdapter( final ServletContext servletContext, final ConnectionFactory connectionFactory, final HttpServletContextFactory contextFactory) throws ServletException { /* * The servletContext field was removed as part of fix for CREST-146. * The constructor parameter remains for API compatibility. */ this.contextFactory = contextFactory != null ? contextFactory : SecurityContextFactory.getHttpServletContextFactory(); this.connectionFactory = checkNotNull(connectionFactory); this.syncFactory = ServletApiVersionAdapter.getInstance(servletContext); }