Search in sources :

Example 1 with StartProcess

use of org.camunda.bpm.engine.cdi.annotation.StartProcess in project camunda-bpm-platform by camunda.

the class StartProcessInterceptor method invoke.

@AroundInvoke
public Object invoke(InvocationContext ctx) throws Exception {
    try {
        Object result = ctx.proceed();
        StartProcess startProcessAnnotation = ctx.getMethod().getAnnotation(StartProcess.class);
        String key = startProcessAnnotation.value();
        Map<String, Object> variables = extractVariables(startProcessAnnotation, ctx);
        businessProcess.startProcessByKey(key, variables);
        return result;
    } catch (InvocationTargetException e) {
        Throwable cause = e.getCause();
        if (cause != null && cause instanceof Exception) {
            throw (Exception) cause;
        } else {
            throw e;
        }
    } catch (Exception e) {
        throw new ProcessEngineException("Error while starting process using @StartProcess on method  '" + ctx.getMethod() + "': " + e.getMessage(), e);
    }
}
Also used : StartProcess(org.camunda.bpm.engine.cdi.annotation.StartProcess) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) AroundInvoke(javax.interceptor.AroundInvoke)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 AroundInvoke (javax.interceptor.AroundInvoke)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 StartProcess (org.camunda.bpm.engine.cdi.annotation.StartProcess)1