org.activiti.engine.impl.bpmn.helper.ClassDelegate Java Examples

The following examples show how to use org.activiti.engine.impl.bpmn.helper.ClassDelegate. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DelegateExpressionExecutionListener.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void notify(DelegateExecution execution) {
    // Note: we can't cache the result of the expression, because the
    // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'
    Object delegate = expression.getValue(execution);
    ClassDelegate.applyFieldDeclaration(fieldDeclarations, delegate);

    if (delegate instanceof ExecutionListener) {
        Context.getProcessEngineConfiguration()
                .getDelegateInterceptor()
                .handleInvocation(new ExecutionListenerInvocation((ExecutionListener) delegate, execution));
    } else if (delegate instanceof JavaDelegate) {
        Context.getProcessEngineConfiguration()
                .getDelegateInterceptor()
                .handleInvocation(new JavaDelegateInvocation((JavaDelegate) delegate, execution));
    } else {
        throw new ActivitiIllegalArgumentException("Delegate expression " + expression
                + " did not resolve to an implementation of " + ExecutionListener.class
                + " nor " + JavaDelegate.class);
    }
}
 
Example #2
Source File: DelegateExpressionTaskListener.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    // Note: we can't cache the result of the expression, because the
    // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'
    Object delegate = expression.getValue(delegateTask);
    ClassDelegate.applyFieldDeclaration(fieldDeclarations, delegate);

    if (delegate instanceof TaskListener) {
        try {
            Context.getProcessEngineConfiguration()
                    .getDelegateInterceptor()
                    .handleInvocation(new TaskListenerInvocation((TaskListener) delegate, delegateTask));
        } catch (Exception e) {
            throw new ActivitiException("Exception while invoking TaskListener: " + e.getMessage(), e);
        }
    } else {
        throw new ActivitiIllegalArgumentException("Delegate expression " + expression
                + " did not resolve to an implementation of " + TaskListener.class);
    }
}
 
Example #3
Source File: DefaultActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected ActivityBehavior createMuleActivityBehavior(TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions) {
  try {

    Class<?> theClass = Class.forName("org.activiti.mule.MuleSendActivitiBehavior");
    List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(fieldExtensions);
    return (ActivityBehavior) ClassDelegate.defaultInstantiateDelegate(
        theClass, fieldDeclarations);

  } catch (ClassNotFoundException e) {
    throw new ActivitiException("Could not find org.activiti.mule.MuleSendActivitiBehavior: ", e);
  }
}
 
Example #4
Source File: DefaultActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected ActivityBehavior createCamelActivityBehavior(TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions) {
  try {
    Class<?> theClass = null;
    FieldExtension behaviorExtension = null;
    for (FieldExtension fieldExtension : fieldExtensions) {
      if ("camelBehaviorClass".equals(fieldExtension.getFieldName()) && StringUtils.isNotEmpty(fieldExtension.getStringValue())) {
        theClass = Class.forName(fieldExtension.getStringValue());
        behaviorExtension = fieldExtension;
        break;
      }
    }

    if (behaviorExtension != null) {
      fieldExtensions.remove(behaviorExtension);
    }

    if (theClass == null) {
      // Default Camel behavior class
      theClass = Class.forName("org.activiti.camel.impl.CamelBehaviorDefaultImpl");
    }

    List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(fieldExtensions);
    addExceptionMapAsFieldDeclaration(fieldDeclarations, task.getMapExceptions());
    return (ActivityBehavior) ClassDelegate.defaultInstantiateDelegate(
        theClass, fieldDeclarations);

  } catch (ClassNotFoundException e) {
    throw new ActivitiException("Could not find org.activiti.camel.CamelBehavior: ", e);
  }
}
 
Example #5
Source File: DefaultActivityBehaviorFactory.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected ActivityBehavior createCamelActivityBehavior(TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions, BpmnModel bpmnModel) {
    try {
        Class<?> theClass = null;
        FieldExtension behaviorExtension = null;
        for (FieldExtension fieldExtension : fieldExtensions) {
            if ("camelBehaviorClass".equals(fieldExtension.getFieldName()) && StringUtils.isNotEmpty(fieldExtension.getStringValue())) {
                theClass = Class.forName(fieldExtension.getStringValue());
                behaviorExtension = fieldExtension;
                break;
            }
        }

        if (behaviorExtension != null) {
            fieldExtensions.remove(behaviorExtension);
        }

        if (theClass == null) {
            // Default Camel behavior class
            theClass = Class.forName("org.flowable.camel.impl.CamelBehaviorDefaultImpl");
        }

        List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(fieldExtensions);
        addExceptionMapAsFieldDeclaration(fieldDeclarations, task.getMapExceptions());
        return (ActivityBehavior) ClassDelegate.defaultInstantiateDelegate(theClass, fieldDeclarations);

    } catch (ClassNotFoundException e) {
        throw new ActivitiException("Could not find org.flowable.camel.impl.CamelBehaviorDefaultImpl: ", e);
    }
}
 
Example #6
Source File: DefaultActivityBehaviorFactory.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected ActivityBehavior createMuleActivityBehavior(TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions, BpmnModel bpmnModel) {
    try {

        Class<?> theClass = Class.forName("org.flowable.mule.MuleSendActivityBehavior");
        List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(fieldExtensions);
        return (ActivityBehavior) ClassDelegate.defaultInstantiateDelegate(theClass, fieldDeclarations);

    } catch (ClassNotFoundException e) {
        throw new ActivitiException("Could not find org.flowable.mule.MuleSendActivityBehavior: ", e);
    }
}
 
Example #7
Source File: DefaultActivityBehaviorFactory.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public ClassDelegate createClassDelegateServiceTask(ServiceTask serviceTask) {
    Expression skipExpression;
    if (StringUtils.isNotEmpty(serviceTask.getSkipExpression())) {
        skipExpression = expressionManager.createExpression(serviceTask.getSkipExpression());
    } else {
        skipExpression = null;
    }
    return new ClassDelegate(serviceTask.getId(), serviceTask.getImplementation(), createFieldDeclarations(serviceTask.getFieldExtensions()),
            skipExpression, serviceTask.getMapExceptions());
}
 
Example #8
Source File: DefaultListenerFactory.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public TaskListener createClassDelegateTaskListener(FlowableListener activitiListener) {
    return new ClassDelegate(activitiListener.getImplementation(), createFieldDeclarations(activitiListener.getFieldExtensions()));
}
 
Example #9
Source File: ActivityBehaviorFactoryDelegate.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ClassDelegate createClassDelegateServiceTask(ServiceTask serviceTask)
{
	return _source.createClassDelegateServiceTask(serviceTask);
}
 
Example #10
Source File: DefaultActivityBehaviorFactory.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public ShellActivityBehavior createShellActivityBehavior(ServiceTask serviceTask) {
    List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(serviceTask.getFieldExtensions());
    return (ShellActivityBehavior) ClassDelegate.defaultInstantiateDelegate(ShellActivityBehavior.class, fieldDeclarations);
}
 
Example #11
Source File: DefaultActivityBehaviorFactory.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
protected MailActivityBehavior createMailActivityBehavior(String taskId, List<FieldExtension> fields) {
    List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(fields);
    return (MailActivityBehavior) ClassDelegate.defaultInstantiateDelegate(MailActivityBehavior.class, fieldDeclarations);
}
 
Example #12
Source File: DefaultListenerFactory.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public ExecutionListener createClassDelegateExecutionListener(FlowableListener activitiListener) {
    return new ClassDelegate(activitiListener.getImplementation(), createFieldDeclarations(activitiListener.getFieldExtensions()));
}
 
Example #13
Source File: DefaultActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public ClassDelegate createClassDelegateServiceTask(ServiceTask serviceTask) {
  return classDelegateFactory.create(serviceTask.getId(), serviceTask.getImplementation(),
      createFieldDeclarations(serviceTask.getFieldExtensions()),
      getSkipExpressionFromServiceTask(serviceTask), serviceTask.getMapExceptions());
}
 
Example #14
Source File: TestActivityBehaviorFactory.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
private ClassDelegate createNoOpServiceTask(ServiceTask serviceTask) {
    List<FieldDeclaration> fieldDeclarations = new ArrayList<FieldDeclaration>();
    fieldDeclarations.add(new FieldDeclaration("name",
            Expression.class.getName(), new FixedValue(serviceTask.getImplementation())));
    return new ClassDelegate(NoOpServiceTask.class, fieldDeclarations);
}
 
Example #15
Source File: TestActivityBehaviorFactory.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public ClassDelegate createClassDelegateServiceTask(ServiceTask serviceTask) {

    if (allServiceTasksNoOp
            || noOpServiceTaskIds.contains(serviceTask.getId())
            || noOpServiceTaskClassNames.contains(serviceTask.getImplementation())) {

        return createNoOpServiceTask(serviceTask);

    } else if (serviceTask.getImplementation() != null && mockedClassDelegatesMapping.containsKey(serviceTask.getImplementation())) {

        return new ClassDelegate(mockedClassDelegatesMapping.get(serviceTask.getImplementation()),
                createFieldDeclarations(serviceTask.getFieldExtensions()));

    }

    return wrappedActivityBehaviorFactory.createClassDelegateServiceTask(serviceTask);
}
 
Example #16
Source File: TestActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
private ClassDelegate createNoOpServiceTask(ServiceTask serviceTask) {
  List<FieldDeclaration> fieldDeclarations = new ArrayList<FieldDeclaration>();
  fieldDeclarations.add(new FieldDeclaration("name", Expression.class.getName(), new FixedValue(serviceTask.getImplementation())));
  return new ClassDelegate(NoOpServiceTask.class, fieldDeclarations);
}
 
Example #17
Source File: DefaultActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public ShellActivityBehavior createShellActivityBehavior(ServiceTask serviceTask) {
  List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(serviceTask.getFieldExtensions());
  return (ShellActivityBehavior) ClassDelegate.defaultInstantiateDelegate(
      ShellActivityBehavior.class, fieldDeclarations);
}
 
Example #18
Source File: DefaultActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected MailActivityBehavior createMailActivityBehavior(String taskId, List<FieldExtension> fields) {
  List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(fields);
  return (MailActivityBehavior) ClassDelegate.defaultInstantiateDelegate(
      MailActivityBehavior.class, fieldDeclarations);
}
 
Example #19
Source File: TestActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 3 votes vote down vote up
@Override
public ClassDelegate createClassDelegateServiceTask(ServiceTask serviceTask) {

  if (allServiceTasksNoOp || noOpServiceTaskIds.contains(serviceTask.getId()) || noOpServiceTaskClassNames.contains(serviceTask.getImplementation())) {

    return createNoOpServiceTask(serviceTask);

  } else if (serviceTask.getImplementation() != null && mockedClassDelegatesMapping.containsKey(serviceTask.getImplementation())) {

    return new ClassDelegate(mockedClassDelegatesMapping.get(serviceTask.getImplementation()), createFieldDeclarations(serviceTask.getFieldExtensions()));

  }

  return wrappedActivityBehaviorFactory.createClassDelegateServiceTask(serviceTask);
}
 
Example #20
Source File: ActivityBehaviorFactory.java    From flowable-engine with Apache License 2.0 votes vote down vote up
public abstract ClassDelegate createClassDelegateServiceTask(ServiceTask serviceTask); 
Example #21
Source File: ActivityBehaviorFactory.java    From activiti6-boot2 with Apache License 2.0 votes vote down vote up
public abstract ClassDelegate createClassDelegateServiceTask(ServiceTask serviceTask);