@Override public void enhanceContent(ContentItem ci) throws EngineException { log.debug("enhanceContent({}), {} engines available", ci, sortedEngineList.size()); Iterator<EnhancementEngine> engines; //changes in the sortedEngineList do creates new Lists. Therefore we need //only sync the creation of the Iterator. Calls to the iterator will //not trigger ConcurrentModificationExceptions //however the remove Method will not have any affect if the list was //changed. synchronized (sortedEngineList) { engines = sortedEngineList.iterator(); } long start = System.currentTimeMillis(); while (engines.hasNext()) { EnhancementEngine engine = engines.next(); long startEngine = System.currentTimeMillis(); if (engine.canEnhance(ci) == EnhancementEngine.CANNOT_ENHANCE) { log.debug("[{}] cannot be enhanced by engine [{}], skipping", ci.getUri().getUnicodeString(), engine); } else { // TODO should handle sync/async enhancing. All sync for now. engine.computeEnhancements(ci); log.debug("ContentItem [{}] enhanced by engine [{}] in {}ms", new Object[]{ci.getUri().getUnicodeString(), engine,System.currentTimeMillis()-startEngine}); } } log.debug("ContentItem [{}] enhanced in {}ms",ci.getUri().getUnicodeString(),(System.currentTimeMillis()-start)); }
log.trace(">> w: {}: {}","start sync execution", engine.getName()); try { engine.computeEnhancements(job.getContentItem()); job.setCompleted(execution); } catch (EngineException e){ try { log.trace("++ n: start async execution of Engine {}",engine.getName()); engine.computeEnhancements(job.getContentItem()); log.trace("++ n: finished async execution of Engine {}",engine.getName()); job.setCompleted(execution);