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);
}
}
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());
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations