private static Logger log = Logger.getLogger(AbstractEventHandler.class.getName());
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) {
ExecutionEntity execution = eventSubscription.getExecution();
ActivityImpl activity = eventSubscription.getActivity();
ensureNotNull("Error while sending signal for event subscription '" + eventSubscription.getId() + "': "
+ "no activity associated with event subscription", "activity", activity);
if (payload instanceof Map) {
@SuppressWarnings("unchecked")
Map<String, Object> processVariables = (Map<String, Object>) payload;
execution.setVariables(processVariables);
}
ActivityBehavior activityBehavior = activity.getActivityBehavior();
if (activityBehavior instanceof BoundaryEventActivityBehavior) {
try {
execution.executeActivity(activity);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new ProcessEngineException("exception while sending signal for event subscription '" + eventSubscription + "':" + e.getMessage(), e);
}
} else if (activityBehavior instanceof EventSubProcessStartEventActivityBehavior) {
try {
execution.executeActivity(activity.getParentActivity());
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new ProcessEngineException("exception while sending signal for event subscription '" + eventSubscription + "':" + e.getMessage(), e);
}
} else { // not boundary
if (activityBehavior instanceof IntermediateCatchEventActivityBehavior) {
IntermediateCatchEventActivityBehavior catchBehavior = (IntermediateCatchEventActivityBehavior) activityBehavior;
if (catchBehavior.isAfterEventBasedGateway()) {
execution.executeActivity(activity);
return;
}
}
if (!activity.equals(execution.getActivity())) {
execution.setActivity(activity);
}
execution.signal("signal", null);
}