Java源码示例:org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration

示例1
@SuppressWarnings("unchecked")
protected void addEventSubscriptionDeclaration(BpmnParse bpmnParse, EventSubscriptionDeclaration subscription, EventDefinition parsedEventDefinition, ScopeImpl scope) {
    List<EventSubscriptionDeclaration> eventDefinitions = (List<EventSubscriptionDeclaration>) scope.getProperty(PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION);
    if (eventDefinitions == null) {
        eventDefinitions = new ArrayList<>();
        scope.setProperty(PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION, eventDefinitions);
    } else {
        // if this is a message event, validate that it is the only one with the provided name for this scope
        if (subscription.getEventType().equals("message")) {
            for (EventSubscriptionDeclaration eventDefinition : eventDefinitions) {
                if (eventDefinition.getEventType().equals("message")
                        && eventDefinition.getEventName().equals(subscription.getEventName())
                        && eventDefinition.isStartEvent() == subscription.isStartEvent()) {

                    LOGGER.warn("Cannot have more than one message event subscription with name '{}' for scope '{}'", subscription.getEventName(), scope.getId());
                }
            }
        }
    }
    eventDefinitions.add(subscription);
}
 
示例2
@SuppressWarnings("unchecked")
protected void addSignalEventSubscriptions(ProcessDefinitionEntity processDefinition) {
    List<EventSubscriptionDeclaration> eventDefinitions = (List<EventSubscriptionDeclaration>) processDefinition.getProperty(BpmnParse.PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION);
    if (eventDefinitions != null) {
        for (EventSubscriptionDeclaration eventDefinition : eventDefinitions) {
            if (eventDefinition.getEventType().equals("signal") && eventDefinition.isStartEvent()) {

                SignalEventSubscriptionEntity subscriptionEntity = new SignalEventSubscriptionEntity();
                subscriptionEntity.setEventName(eventDefinition.getEventName());
                subscriptionEntity.setActivityId(eventDefinition.getActivityId());
                subscriptionEntity.setProcessDefinitionId(processDefinition.getId());
                if (processDefinition.getTenantId() != null) {
                    subscriptionEntity.setTenantId(processDefinition.getTenantId());
                }
                subscriptionEntity.insert();

            }
        }
    }
}
 
示例3
@Override
public IntermediateThrowSignalEventActivityBehavior createIntermediateThrowSignalEventActivityBehavior(
        ThrowEvent throwEvent, Signal signal,
        EventSubscriptionDeclaration eventSubscriptionDeclaration) {
    return wrappedActivityBehaviorFactory.createIntermediateThrowSignalEventActivityBehavior(
            throwEvent, signal, eventSubscriptionDeclaration);
}
 
示例4
@Override
@SuppressWarnings("unchecked")
public void initialize() {
    LOGGER.debug("initializing {}", this);

    ScopeImpl scope = getScopeObject();
    ensureParentInitialized();

    // initialize the lists of referenced objects (prevents db queries)
    variableInstances = new HashMap<>();
    eventSubscriptions = new ArrayList<>();

    // Cached entity-state initialized to null, all bits are zero, indicating NO entities present
    cachedEntityState = 0;

    List<TimerDeclarationImpl> timerDeclarations = (List<TimerDeclarationImpl>) scope.getProperty(BpmnParse.PROPERTYNAME_TIMER_DECLARATION);
    if (timerDeclarations != null) {
        for (TimerDeclarationImpl timerDeclaration : timerDeclarations) {
            TimerJobEntity timer = timerDeclaration.prepareTimerEntity(this);
            if (timer != null) {
                callJobProcessors(JobProcessorContext.Phase.BEFORE_CREATE, timer, Context.getProcessEngineConfiguration());
                Context.getCommandContext().getJobEntityManager().schedule(timer);
            }
        }
    }

    // create event subscriptions for the current scope
    List<EventSubscriptionDeclaration> eventSubscriptionDeclarations = (List<EventSubscriptionDeclaration>) scope.getProperty(BpmnParse.PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION);
    if (eventSubscriptionDeclarations != null) {
        for (EventSubscriptionDeclaration eventSubscriptionDeclaration : eventSubscriptionDeclarations) {
            if (!eventSubscriptionDeclaration.isStartEvent()) {
                EventSubscriptionEntity eventSubscriptionEntity = eventSubscriptionDeclaration.prepareEventSubscriptionEntity(this);
                if (getTenantId() != null) {
                    eventSubscriptionEntity.setTenantId(getTenantId());
                }
                eventSubscriptionEntity.insert();
            }
        }
    }
}
 
示例5
@Override
public IntermediateThrowSignalEventActivityBehavior createIntermediateThrowSignalEventActivityBehavior(ThrowEvent throwEvent,
        Signal signal, EventSubscriptionDeclaration eventSubscriptionDeclaration) {
    return new IntermediateThrowSignalEventActivityBehavior(throwEvent, signal, eventSubscriptionDeclaration);
}
 
示例6
public IntermediateThrowSignalEventActivityBehavior(ThrowEvent throwEvent, Signal signal, EventSubscriptionDeclaration signalDefinition) {
    this.processInstanceScope = Signal.SCOPE_PROCESS_INSTANCE.equals(signal.getScope());
    this.signalDefinition = signalDefinition;
}
 
示例7
@SuppressWarnings("unchecked")
protected void addMessageEventSubscriptions(ProcessDefinitionEntity processDefinition) {
    CommandContext commandContext = Context.getCommandContext();
    List<EventSubscriptionDeclaration> eventDefinitions = (List<EventSubscriptionDeclaration>) processDefinition.getProperty(BpmnParse.PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION);
    if (eventDefinitions != null) {

        Set<String> messageNames = new HashSet<>();
        for (EventSubscriptionDeclaration eventDefinition : eventDefinitions) {
            if (eventDefinition.getEventType().equals("message") && eventDefinition.isStartEvent()) {

                if (!messageNames.contains(eventDefinition.getEventName())) {
                    messageNames.add(eventDefinition.getEventName());
                } else {
                    throw new ActivitiException("Cannot deploy process definition '" + processDefinition.getResourceName()
                            + "': there multiple message event subscriptions for the message with name '" + eventDefinition.getEventName() + "'.");
                }

                // look for subscriptions for the same name in db:
                List<EventSubscriptionEntity> subscriptionsForSameMessageName = commandContext.getEventSubscriptionEntityManager()
                        .findEventSubscriptionsByName(MessageEventHandler.EVENT_HANDLER_TYPE,
                                eventDefinition.getEventName(), processDefinition.getTenantId());
                // also look for subscriptions created in the session:
                List<MessageEventSubscriptionEntity> cachedSubscriptions = commandContext
                        .getDbSqlSession()
                        .findInCache(MessageEventSubscriptionEntity.class);
                for (MessageEventSubscriptionEntity cachedSubscription : cachedSubscriptions) {
                    if (eventDefinition.getEventName().equals(cachedSubscription.getEventName())
                            && !subscriptionsForSameMessageName.contains(cachedSubscription)) {
                        subscriptionsForSameMessageName.add(cachedSubscription);
                    }
                }
                // remove subscriptions deleted in the same command
                subscriptionsForSameMessageName = commandContext
                        .getDbSqlSession()
                        .pruneDeletedEntities(subscriptionsForSameMessageName);

                for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsForSameMessageName) {
                    // throw exception only if there's already a subscription as start event
                    if (eventSubscriptionEntity.getProcessInstanceId() == null || eventSubscriptionEntity.getProcessInstanceId().isEmpty()) {
                        // the event subscription has no instance-id, so it's a message start event
                        throw new ActivitiException("Cannot deploy process definition '" + processDefinition.getResourceName()
                                + "': there already is a message event subscription for the message with name '" + eventDefinition.getEventName() + "'.");
                    }
                }

                MessageEventSubscriptionEntity newSubscription = new MessageEventSubscriptionEntity();
                newSubscription.setEventName(eventDefinition.getEventName());
                newSubscription.setActivityId(eventDefinition.getActivityId());
                newSubscription.setConfiguration(processDefinition.getId());
                newSubscription.setProcessDefinitionId(processDefinition.getId());

                if (processDefinition.getTenantId() != null) {
                    newSubscription.setTenantId(processDefinition.getTenantId());
                }

                newSubscription.insert();
            }
        }
    }
}
 
示例8
public IntermediateThrowSignalEventActivityBehavior createIntermediateThrowSignalEventActivityBehavior(
		ThrowEvent throwEvent, Signal signal, EventSubscriptionDeclaration eventSubscriptionDeclaration)
{
	return _source.createIntermediateThrowSignalEventActivityBehavior(throwEvent, signal,
		eventSubscriptionDeclaration);
}
 
示例9
public abstract IntermediateThrowSignalEventActivityBehavior createIntermediateThrowSignalEventActivityBehavior(ThrowEvent throwEvent, Signal signal, EventSubscriptionDeclaration eventSubscriptionDeclaration);