Search in sources :

Example 1 with StartProcess

use of org.activiti.cdi.annotation.StartProcess in project Activiti by Activiti.

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 name = startProcessAnnotation.name();
        String key = startProcessAnnotation.value();
        Map<String, Object> variables = extractVariables(startProcessAnnotation, ctx);
        if (name.length() > 0) {
            businessProcess.startProcessByName(name, variables);
        } else {
            businessProcess.startProcessByKey(key, variables);
        }
        return result;
    } catch (InvocationTargetException e) {
        Throwable cause = e.getCause();
        if (cause instanceof Exception) {
            throw (Exception) cause;
        } else {
            throw e;
        }
    } catch (Exception e) {
        throw new ActivitiException("Error while starting process using @StartProcess on method  '" + ctx.getMethod() + "': " + e.getMessage(), e);
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) StartProcess(org.activiti.cdi.annotation.StartProcess) InvocationTargetException(java.lang.reflect.InvocationTargetException) ActivitiException(org.activiti.engine.ActivitiException) InvocationTargetException(java.lang.reflect.InvocationTargetException) AroundInvoke(javax.interceptor.AroundInvoke)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 AroundInvoke (javax.interceptor.AroundInvoke)1 StartProcess (org.activiti.cdi.annotation.StartProcess)1 ActivitiException (org.activiti.engine.ActivitiException)1