*/
private void processEvent(EnhancementJob job, NonLiteral execution) {
String engineName = getEngine(job.getExecutionPlan(),
job.getExecutionNode(execution));
//(1) execute the parsed ExecutionNode
EnhancementEngine engine = engineManager.getEngine(engineName);
if(engine != null){
//execute the engine
Exception exception = null;
int engineState;
try {
engineState = engine.canEnhance(job.getContentItem());
} catch (EngineException e) {
exception = e;
log.warn("Unable to check if engine '" + engineName
+ "'(type: " + engine.getClass() + ") can enhance ContentItem '"
+ job.getContentItem().getUri()+ "'!",e);
engineState = EnhancementEngine.CANNOT_ENHANCE;
}
if(engineState == EnhancementEngine.ENHANCE_SYNCHRONOUS){
//ensure that this engine exclusively access the content item
log.trace("++ w: {}: {}","start sync execution", engine.getName());
job.getLock().writeLock().lock();
log.trace(">> w: {}: {}","start sync execution", engine.getName());
try {
engine.computeEnhancements(job.getContentItem());
job.setCompleted(execution);
} catch (EngineException e){
log.warn(e.getMessage(),e);
job.setFailed(execution, engine, e);
} catch (RuntimeException e){
log.warn(e.getMessage(),e);
job.setFailed(execution, engine, e);
} finally{
log.trace("<< w: {}: {}","finished sync execution", engine.getName());
job.getLock().writeLock().unlock();
}
} else if(engineState == EnhancementEngine.ENHANCE_ASYNC){
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);
} catch (EngineException e) {
log.warn(e.getMessage(),e);
job.setFailed(execution, engine, e);
} catch (RuntimeException e) {