public void execute(ActivityExecution execution) throws Exception {
    ScriptingEngines scriptingEngines =
        Context.getProcessEngineConfiguration().getScriptingEngines();

    boolean noErrors = true;
    try {
      Object result = scriptingEngines.evaluate(script, language, execution, storeScriptVariables);

      if (resultVariable != null) {
        execution.setVariable(resultVariable, result);
      }

    } catch (ActivitiException e) {

      LOGGER.warn(
          "Exception while executing " + execution.getActivity().getId() + " : " + e.getMessage());

      noErrors = false;
      Throwable rootCause = ExceptionUtils.getRootCause(e);
      if (rootCause instanceof BpmnError) {
        ErrorPropagation.propagateError((BpmnError) rootCause, execution);
      } else {
        throw e;
      }
    }
    if (noErrors) {
      leave(execution);
    }
  }
示例#2
0
 protected boolean handleCamelException(Exchange exchange, ActivityExecution execution)
     throws Exception {
   Exception camelException = exchange.getException();
   boolean notHandledByCamel = exchange.isFailed() && camelException != null;
   if (notHandledByCamel) {
     if (camelException instanceof BpmnError) {
       ErrorPropagation.propagateError((BpmnError) camelException, execution);
       return true;
     } else {
       if (ErrorPropagation.mapException(camelException, execution, mapExceptions)) return true;
       else throw new ActivitiException("Unhandled exception on camel route", camelException);
     }
   }
   return false;
 }