use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior in project camunda-bpm-platform by camunda.
the class ServiceTaskDelegateExpressionActivityBehavior method doSignal.
public void doSignal(final ActivityExecution execution, final String signalName, final Object signalData) throws Exception {
Object delegate = expression.getValue(execution);
applyFieldDeclaration(fieldDeclarations, delegate);
final ActivityBehavior activityBehaviorInstance = getActivityBehaviorInstance(execution, delegate);
if (activityBehaviorInstance instanceof CustomActivityBehavior) {
CustomActivityBehavior behavior = (CustomActivityBehavior) activityBehaviorInstance;
ActivityBehavior delegateActivityBehavior = behavior.getDelegateActivityBehavior();
if (!(delegateActivityBehavior instanceof SignallableActivityBehavior)) {
// legacy behavior: do nothing when it is not a signallable activity behavior
return;
}
}
executeWithErrorPropagation(execution, new Callable<Void>() {
@Override
public Void call() throws Exception {
((SignallableActivityBehavior) activityBehaviorInstance).signal(execution, signalName, signalData);
return null;
}
});
}
use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior in project camunda-bpm-platform by camunda.
the class BpmnParse method parseIntermediateThrowEvent.
public ActivityImpl parseIntermediateThrowEvent(Element intermediateEventElement, ScopeImpl scopeElement) {
Element signalEventDefinitionElement = intermediateEventElement.element(SIGNAL_EVENT_DEFINITION);
Element compensateEventDefinitionElement = intermediateEventElement.element(COMPENSATE_EVENT_DEFINITION);
Element linkEventDefinitionElement = intermediateEventElement.element(LINK_EVENT_DEFINITION);
Element messageEventDefinitionElement = intermediateEventElement.element(MESSAGE_EVENT_DEFINITION);
Element escalationEventDefinition = intermediateEventElement.element(ESCALATION_EVENT_DEFINITION);
// event (event target)
if (linkEventDefinitionElement != null) {
String linkName = linkEventDefinitionElement.attribute("name");
String elementId = intermediateEventElement.attribute("id");
// now we remember the link in order to replace the sequence flow later on
eventLinkSources.put(elementId, linkName);
// and done - no activity created
return null;
}
ActivityImpl nestedActivityImpl = createActivityOnScope(intermediateEventElement, scopeElement);
ActivityBehavior activityBehavior = null;
parseAsynchronousContinuationForActivity(intermediateEventElement, nestedActivityImpl);
if (signalEventDefinitionElement != null) {
nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_SIGNAL_THROW);
EventSubscriptionDeclaration signalDefinition = parseSignalEventDefinition(signalEventDefinitionElement, true);
activityBehavior = new ThrowSignalEventActivityBehavior(signalDefinition);
} else if (compensateEventDefinitionElement != null) {
nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_COMPENSATION_THROW);
CompensateEventDefinition compensateEventDefinition = parseThrowCompensateEventDefinition(compensateEventDefinitionElement, scopeElement);
activityBehavior = new CompensationEventActivityBehavior(compensateEventDefinition);
nestedActivityImpl.setProperty(PROPERTYNAME_THROWS_COMPENSATION, true);
nestedActivityImpl.setScope(true);
} else if (messageEventDefinitionElement != null) {
if (isServiceTaskLike(messageEventDefinitionElement)) {
// CAM-436 same behavior as service task
nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_MESSAGE_THROW);
activityBehavior = parseServiceTaskLike(ActivityTypes.INTERMEDIATE_EVENT_MESSAGE_THROW, messageEventDefinitionElement, scopeElement).getActivityBehavior();
} else {
// default to non behavior if no service task
// properties have been specified
nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_NONE_THROW);
activityBehavior = new IntermediateThrowNoneEventActivityBehavior();
}
} else if (escalationEventDefinition != null) {
nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_ESCALATION_THROW);
Escalation escalation = findEscalationForEscalationEventDefinition(escalationEventDefinition);
if (escalation != null && escalation.getEscalationCode() == null) {
addError("throwing escalation event must have an 'escalationCode'", escalationEventDefinition);
}
activityBehavior = new ThrowEscalationEventActivityBehavior(escalation);
} else {
// None intermediate event
nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_NONE_THROW);
activityBehavior = new IntermediateThrowNoneEventActivityBehavior();
}
for (BpmnParseListener parseListener : parseListeners) {
parseListener.parseIntermediateThrowEvent(intermediateEventElement, scopeElement, nestedActivityImpl);
}
nestedActivityImpl.setActivityBehavior(activityBehavior);
parseExecutionListenersOnScope(intermediateEventElement, nestedActivityImpl);
return nestedActivityImpl;
}
use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior in project camunda-bpm-platform by camunda.
the class ClassDelegateActivityBehavior method doSignal.
protected void doSignal(final ActivityExecution execution, final String signalName, final Object signalData) throws Exception {
final ActivityBehavior activityBehaviorInstance = getActivityBehaviorInstance(execution);
if (activityBehaviorInstance instanceof CustomActivityBehavior) {
CustomActivityBehavior behavior = (CustomActivityBehavior) activityBehaviorInstance;
ActivityBehavior delegate = behavior.getDelegateActivityBehavior();
if (!(delegate instanceof SignallableActivityBehavior)) {
throw LOG.incorrectlyUsedSignalException(SignallableActivityBehavior.class.getName());
}
}
executeWithErrorPropagation(execution, new Callable<Void>() {
@Override
public Void call() throws Exception {
((SignallableActivityBehavior) activityBehaviorInstance).signal(execution, signalName, signalData);
return null;
}
});
}
use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior in project camunda-bpm-platform by camunda.
the class ConditionalEventHandler method handleEvent.
@Override
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, String businessKey, CommandContext commandContext) {
VariableEvent variableEvent;
if (payload == null || payload instanceof VariableEvent) {
variableEvent = (VariableEvent) payload;
} else {
throw new ProcessEngineException("Payload have to be " + VariableEvent.class.getName() + ", to evaluate condition.");
}
ActivityImpl activity = eventSubscription.getActivity();
ActivityBehavior activityBehavior = activity.getActivityBehavior();
if (activityBehavior instanceof ConditionalEventBehavior) {
ConditionalEventBehavior conditionalBehavior = (ConditionalEventBehavior) activityBehavior;
conditionalBehavior.leaveOnSatisfiedCondition(eventSubscription, variableEvent);
} else {
throw new ProcessEngineException("Conditional Event has not correct behavior: " + activityBehavior);
}
}
use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior in project camunda-bpm-platform by camunda.
the class LegacyBehavior method removeLegacySubscriptionOnParent.
/**
* <p>Required for migrating active sequential MI receive tasks. These activities were formerly not scope,
* but are now. This has the following implications:
*
* <p>Before migration:
* <ul><li> the event subscription is attached to the miBody scope execution</ul>
*
* <p>After migration:
* <ul><li> a new subscription is created for every instance
* <li> the new subscription is attached to a dedicated scope execution as a child of the miBody scope
* execution</ul>
*
* <p>Thus, this method removes the subscription on the miBody scope
*/
public static void removeLegacySubscriptionOnParent(ExecutionEntity execution, EventSubscriptionEntity eventSubscription) {
ActivityImpl activity = execution.getActivity();
if (activity == null) {
return;
}
ActivityBehavior behavior = activity.getActivityBehavior();
ActivityBehavior parentBehavior = (ActivityBehavior) (activity.getFlowScope() != null ? activity.getFlowScope().getActivityBehavior() : null);
if (behavior instanceof ReceiveTaskActivityBehavior && parentBehavior instanceof MultiInstanceActivityBehavior) {
List<EventSubscriptionEntity> parentSubscriptions = execution.getParent().getEventSubscriptions();
for (EventSubscriptionEntity subscription : parentSubscriptions) {
// distinguish a boundary event on the mi body with the same message name from the receive task subscription
if (areEqualEventSubscriptions(subscription, eventSubscription)) {
subscription.delete();
}
}
}
}
Aggregations