private Map<Future<RenderResult>, ComponentRenderer> executeRenderers( List<RenderableComponent> renderableComponents, Map<String, Object> globalContext, String pageUrl) { Map<Future<RenderResult>, ComponentRenderer> renderableFutures = new LinkedHashMap<Future<RenderResult>, ComponentRenderer>(renderableComponents.size()); int index = 0; for (RenderableComponent renderableComponent : renderableComponents) { StringBuilder logTag = new StringBuilder("Renderer "); logTag.append(index).append(" - page: ").append(pageUrl); ComponentRenderer componentRenderer = componentRendererFactory.getComponentRenderer( renderableComponent, globalContext, logTag.toString()); Future<RenderResult> future = threadPoolTaskExecutor.submit(componentRenderer); renderableFutures.put(future, componentRenderer); index++; } return renderableFutures; }
@Override public void auditSite( Contract contract, String siteUrl, String clientIp, Set<Parameter> parameterSet, Locale locale) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Site audit on " + siteUrl); for (Parameter param : parameterSet) { LOGGER.debug( "param " + param.getValue() + " " + param.getParameterElement().getParameterElementCode()); } } Act act = createAct(contract, ScopeEnum.DOMAIN, clientIp); AuditThread auditSiteThread = new AuditSiteThread(siteUrl, auditService, act, parameterSet, locale); threadPoolTaskExecutor.submit(auditSiteThread); }
/** * @param auditTimeoutThread * @param act * @return */ private Audit submitAuditAndLaunch(AuditTimeoutThread auditTimeoutThread, Act act) { synchronized (auditTimeoutThread) { Future submitedThread = threadPoolTaskExecutor.submit(auditTimeoutThread); while (submitedThread != null && !submitedThread.isDone()) { try { Thread.sleep(500); } catch (InterruptedException ex) { LOGGER.error("", ex); } if (auditTimeoutThread.isDurationExceedsDelay()) { LOGGER.debug( "Audit Duration ExceedsDelay. The audit result " + "is now managed in an asynchronous way."); break; } } if (null != auditTimeoutThread.getException()) { LOGGER.error("new KrashAuditException()"); throw new KrashAuditException(auditTimeoutThread.getException()); } return auditTimeoutThread.getAudit(); } }
@Override public void auditScenario( Contract contract, Long idScenario, String clientIp, Set<Parameter> parameterSet, Locale locale) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Scenarion audit on scenario with id" + idScenario); for (Parameter param : parameterSet) { LOGGER.debug( "param " + param.getValue() + " " + param.getParameterElement().getParameterElementCode()); } } Act act = createAct(contract, ScopeEnum.SCENARIO, clientIp); Scenario scenario = scenarioDataService.read(idScenario); AuditThread auditScenarioThread = new AuditScenarioThread( scenario.getLabel(), scenario.getContent(), auditService, act, parameterSet, locale); threadPoolTaskExecutor.submit(auditScenarioThread); }