private void handleMethodCallsSequential( List<ExtDirectRequest> directRequests, HttpServletRequest request, HttpServletResponse response, Locale locale) throws JsonGenerationException, JsonMappingException, IOException { List<ExtDirectResponse> directResponses = new ArrayList<ExtDirectResponse>(directRequests.size()); boolean streamResponse = configurationService.getConfiguration().isStreamResponse(); Class<?> jsonView = null; for (ExtDirectRequest directRequest : directRequests) { ExtDirectResponse directResponse = handleMethodCall(directRequest, request, response, locale); streamResponse = streamResponse || directResponse.isStreamResponse(); jsonView = directResponse.getJsonView(); directResponses.add(directResponse); } writeJsonResponse(response, directResponses, jsonView, streamResponse); }
private void handleMethodCallsConcurrent( List<ExtDirectRequest> directRequests, HttpServletRequest request, HttpServletResponse response, Locale locale) throws JsonGenerationException, JsonMappingException, IOException { Class<?> jsonView = null; List<Future<ExtDirectResponse>> futures = new ArrayList<Future<ExtDirectResponse>>(directRequests.size()); for (ExtDirectRequest directRequest : directRequests) { Callable<ExtDirectResponse> callable = createMethodCallCallable(directRequest, request, response, locale); futures.add( configurationService .getConfiguration() .getBatchedMethodsExecutorService() .submit(callable)); } List<ExtDirectResponse> directResponses = new ArrayList<ExtDirectResponse>(directRequests.size()); boolean streamResponse = configurationService.getConfiguration().isStreamResponse(); for (Future<ExtDirectResponse> future : futures) { try { ExtDirectResponse directResponse = future.get(); streamResponse = streamResponse || directResponse.isStreamResponse(); jsonView = directResponse.getJsonView(); directResponses.add(directResponse); } catch (InterruptedException e) { log.error("Error invoking method", e); } catch (ExecutionException e) { log.error("Error invoking method", e); } } writeJsonResponse(response, directResponses, jsonView, streamResponse); }