Search in sources :

Example 1 with ActivityBehavior

use of org.activiti.engine.impl.delegate.ActivityBehavior in project Activiti by Activiti.

the class DefaultActivityBehaviorFactory method createMuleActivityBehavior.

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);
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) BoundaryTimerEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryTimerEventActivityBehavior) IntermediateCatchSignalEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateCatchSignalEventActivityBehavior) BoundaryMessageEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryMessageEventActivityBehavior) UserTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior) ActivityBehavior(org.activiti.engine.impl.delegate.ActivityBehavior) MailActivityBehavior(org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior) IntermediateThrowNoneEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowNoneEventActivityBehavior) BoundarySignalEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundarySignalEventActivityBehavior) ManualTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ManualTaskActivityBehavior) IntermediateCatchEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateCatchEventActivityBehavior) EventSubProcessErrorStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventSubProcessErrorStartEventActivityBehavior) EventBasedGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventBasedGatewayActivityBehavior) CancelEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.CancelEndEventActivityBehavior) AbstractBpmnActivityBehavior(org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior) EventSubProcessMessageStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventSubProcessMessageStartEventActivityBehavior) ParallelGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ParallelGatewayActivityBehavior) IntermediateThrowMessageEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowMessageEventActivityBehavior) BoundaryEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryEventActivityBehavior) ScriptTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior) ErrorEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior) InclusiveGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.InclusiveGatewayActivityBehavior) AdhocSubProcessActivityBehavior(org.activiti.engine.impl.bpmn.behavior.AdhocSubProcessActivityBehavior) ServiceTaskDelegateExpressionActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressionActivityBehavior) ServiceTaskExpressionActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ServiceTaskExpressionActivityBehavior) BoundaryCompensateEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryCompensateEventActivityBehavior) ReceiveTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ReceiveTaskActivityBehavior) CallActivityBehavior(org.activiti.engine.impl.bpmn.behavior.CallActivityBehavior) ExclusiveGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ExclusiveGatewayActivityBehavior) TransactionActivityBehavior(org.activiti.engine.impl.bpmn.behavior.TransactionActivityBehavior) NoneStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.NoneStartEventActivityBehavior) ShellActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ShellActivityBehavior) TerminateEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior) IntermediateThrowCompensationEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowCompensationEventActivityBehavior) IntermediateThrowSignalEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowSignalEventActivityBehavior) WebServiceActivityBehavior(org.activiti.engine.impl.bpmn.behavior.WebServiceActivityBehavior) NoneEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior) IntermediateCatchTimerEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateCatchTimerEventActivityBehavior) ThrowMessageEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ThrowMessageEndEventActivityBehavior) IntermediateCatchMessageEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateCatchMessageEventActivityBehavior) BoundaryCancelEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryCancelEventActivityBehavior) SubProcessActivityBehavior(org.activiti.engine.impl.bpmn.behavior.SubProcessActivityBehavior) TaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.TaskActivityBehavior) FieldDeclaration(org.activiti.engine.impl.bpmn.parser.FieldDeclaration)

Example 2 with ActivityBehavior

use of org.activiti.engine.impl.delegate.ActivityBehavior in project Activiti by Activiti.

the class ContinueMultiInstanceOperation method executeSynchronous.

protected void executeSynchronous(FlowNode flowNode) {
    // Execution listener
    if (CollectionUtil.isNotEmpty(flowNode.getExecutionListeners())) {
        executeExecutionListeners(flowNode, ExecutionListener.EVENTNAME_START);
    }
    commandContext.getHistoryManager().recordActivityStart(execution);
    // Execute actual behavior
    ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior();
    if (activityBehavior != null) {
        logger.debug("Executing activityBehavior {} on activity '{}' with execution {}", activityBehavior.getClass(), flowNode.getId(), execution.getId());
        if (Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
            Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createActivityEvent(ActivitiEventType.ACTIVITY_STARTED, flowNode.getId(), flowNode.getName(), execution.getId(), execution.getProcessInstanceId(), execution.getProcessDefinitionId(), flowNode));
        }
        try {
            activityBehavior.execute(execution);
        } catch (BpmnError error) {
            // re-throw business fault so that it can be caught by an Error Intermediate Event or Error Event Sub-Process in the process
            ErrorPropagation.propagateError(error, execution);
        } catch (RuntimeException e) {
            if (LogMDC.isMDCEnabled()) {
                LogMDC.putMDCExecution(execution);
            }
            throw e;
        }
    } else {
        logger.debug("No activityBehavior on activity '{}' with execution {}", flowNode.getId(), execution.getId());
    }
}
Also used : ActivityBehavior(org.activiti.engine.impl.delegate.ActivityBehavior) BpmnError(org.activiti.engine.delegate.BpmnError)

Example 3 with ActivityBehavior

use of org.activiti.engine.impl.delegate.ActivityBehavior in project Activiti by Activiti.

the class DefaultActivityBehaviorFactory method createCamelActivityBehavior.

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);
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) FieldExtension(org.activiti.bpmn.model.FieldExtension) BoundaryTimerEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryTimerEventActivityBehavior) IntermediateCatchSignalEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateCatchSignalEventActivityBehavior) BoundaryMessageEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryMessageEventActivityBehavior) UserTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior) ActivityBehavior(org.activiti.engine.impl.delegate.ActivityBehavior) MailActivityBehavior(org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior) IntermediateThrowNoneEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowNoneEventActivityBehavior) BoundarySignalEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundarySignalEventActivityBehavior) ManualTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ManualTaskActivityBehavior) IntermediateCatchEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateCatchEventActivityBehavior) EventSubProcessErrorStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventSubProcessErrorStartEventActivityBehavior) EventBasedGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventBasedGatewayActivityBehavior) CancelEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.CancelEndEventActivityBehavior) AbstractBpmnActivityBehavior(org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior) EventSubProcessMessageStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventSubProcessMessageStartEventActivityBehavior) ParallelGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ParallelGatewayActivityBehavior) IntermediateThrowMessageEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowMessageEventActivityBehavior) BoundaryEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryEventActivityBehavior) ScriptTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ScriptTaskActivityBehavior) ErrorEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior) InclusiveGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.InclusiveGatewayActivityBehavior) AdhocSubProcessActivityBehavior(org.activiti.engine.impl.bpmn.behavior.AdhocSubProcessActivityBehavior) ServiceTaskDelegateExpressionActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ServiceTaskDelegateExpressionActivityBehavior) ServiceTaskExpressionActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ServiceTaskExpressionActivityBehavior) BoundaryCompensateEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryCompensateEventActivityBehavior) ReceiveTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ReceiveTaskActivityBehavior) CallActivityBehavior(org.activiti.engine.impl.bpmn.behavior.CallActivityBehavior) ExclusiveGatewayActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ExclusiveGatewayActivityBehavior) TransactionActivityBehavior(org.activiti.engine.impl.bpmn.behavior.TransactionActivityBehavior) NoneStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.NoneStartEventActivityBehavior) ShellActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ShellActivityBehavior) TerminateEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.TerminateEndEventActivityBehavior) IntermediateThrowCompensationEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowCompensationEventActivityBehavior) IntermediateThrowSignalEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateThrowSignalEventActivityBehavior) WebServiceActivityBehavior(org.activiti.engine.impl.bpmn.behavior.WebServiceActivityBehavior) NoneEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior) IntermediateCatchTimerEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateCatchTimerEventActivityBehavior) ThrowMessageEndEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.ThrowMessageEndEventActivityBehavior) IntermediateCatchMessageEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.IntermediateCatchMessageEventActivityBehavior) BoundaryCancelEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryCancelEventActivityBehavior) SubProcessActivityBehavior(org.activiti.engine.impl.bpmn.behavior.SubProcessActivityBehavior) TaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.TaskActivityBehavior) FieldDeclaration(org.activiti.engine.impl.bpmn.parser.FieldDeclaration)

Example 4 with ActivityBehavior

use of org.activiti.engine.impl.delegate.ActivityBehavior in project Activiti by Activiti.

the class AbstractBpmnActivityBehavior method executeCompensateBoundaryEvents.

protected void executeCompensateBoundaryEvents(Collection<BoundaryEvent> boundaryEvents, DelegateExecution execution) {
    // The parent execution becomes a scope, and a child execution is created for each of the boundary events
    for (BoundaryEvent boundaryEvent : boundaryEvents) {
        if (CollectionUtil.isEmpty(boundaryEvent.getEventDefinitions())) {
            continue;
        }
        if (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition == false) {
            continue;
        }
        ExecutionEntity childExecutionEntity = Context.getCommandContext().getExecutionEntityManager().createChildExecution((ExecutionEntity) execution);
        childExecutionEntity.setParentId(execution.getId());
        childExecutionEntity.setCurrentFlowElement(boundaryEvent);
        childExecutionEntity.setScope(false);
        ActivityBehavior boundaryEventBehavior = ((ActivityBehavior) boundaryEvent.getBehavior());
        boundaryEventBehavior.execute(childExecutionEntity);
    }
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivityBehavior(org.activiti.engine.impl.delegate.ActivityBehavior) CompensateEventDefinition(org.activiti.bpmn.model.CompensateEventDefinition)

Example 5 with ActivityBehavior

use of org.activiti.engine.impl.delegate.ActivityBehavior in project Activiti by Activiti.

the class ContinueProcessOperation method executeSynchronous.

protected void executeSynchronous(FlowNode flowNode) {
    commandContext.getHistoryManager().recordActivityStart(execution);
    // Execution listener: event 'start'
    if (CollectionUtil.isNotEmpty(flowNode.getExecutionListeners())) {
        executeExecutionListeners(flowNode, ExecutionListener.EVENTNAME_START);
    }
    // Execute any boundary events, sub process boundary events will be executed from the activity behavior
    if (!inCompensation && flowNode instanceof Activity) {
        // Only activities can have boundary events
        List<BoundaryEvent> boundaryEvents = ((Activity) flowNode).getBoundaryEvents();
        if (CollectionUtil.isNotEmpty(boundaryEvents)) {
            executeBoundaryEvents(boundaryEvents, execution);
        }
    }
    // Execute actual behavior
    ActivityBehavior activityBehavior = (ActivityBehavior) flowNode.getBehavior();
    if (activityBehavior != null) {
        executeActivityBehavior(activityBehavior, flowNode);
    } else {
        logger.debug("No activityBehavior on activity '{}' with execution {}", flowNode.getId(), execution.getId());
        Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(execution, true);
    }
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) Activity(org.activiti.bpmn.model.Activity) MultiInstanceActivityBehavior(org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior) ActivityBehavior(org.activiti.engine.impl.delegate.ActivityBehavior)

Aggregations

ActivityBehavior (org.activiti.engine.impl.delegate.ActivityBehavior)7 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)4 CompensateEventDefinition (org.activiti.bpmn.model.CompensateEventDefinition)3 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)3 ActivitiException (org.activiti.engine.ActivitiException)2 AbstractBpmnActivityBehavior (org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior)2 AdhocSubProcessActivityBehavior (org.activiti.engine.impl.bpmn.behavior.AdhocSubProcessActivityBehavior)2 BoundaryCancelEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.BoundaryCancelEventActivityBehavior)2 BoundaryCompensateEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.BoundaryCompensateEventActivityBehavior)2 BoundaryEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.BoundaryEventActivityBehavior)2 BoundaryMessageEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.BoundaryMessageEventActivityBehavior)2 BoundarySignalEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.BoundarySignalEventActivityBehavior)2 BoundaryTimerEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.BoundaryTimerEventActivityBehavior)2 CallActivityBehavior (org.activiti.engine.impl.bpmn.behavior.CallActivityBehavior)2 CancelEndEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.CancelEndEventActivityBehavior)2 ErrorEndEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.ErrorEndEventActivityBehavior)2 EventBasedGatewayActivityBehavior (org.activiti.engine.impl.bpmn.behavior.EventBasedGatewayActivityBehavior)2 EventSubProcessErrorStartEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.EventSubProcessErrorStartEventActivityBehavior)2 EventSubProcessMessageStartEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.EventSubProcessMessageStartEventActivityBehavior)2 ExclusiveGatewayActivityBehavior (org.activiti.engine.impl.bpmn.behavior.ExclusiveGatewayActivityBehavior)2