Пример #1
0
  @Override
  public void complete(NodeToken token, String arcName) {
    GraphProcess process = token.getProcess();

    completeNodeExecution(token, arcName, false);

    if (process.isExecuting() && !arcExecutionStarted) {
      executeQueuedArcTokens(process);
    }
  }
Пример #2
0
  protected void completeNodeExecution(
      final NodeToken token, final String arcName, final boolean asynchronous) {
    GraphProcess process = token.getProcess();

    if (!process.isExecuting() || token.isComplete()) {
      return;
    }

    completeNodeToken(process, token, arcName);

    for (Arc arc : process.getGraph().getOutputArcs(token.getNode(), arcName)) {
      ArcToken arcToken = generateArcToken(process, arc, token);
      finishNewArcTokenProcessing(process, arcToken, asynchronous);
    }
  }
Пример #3
0
  public void completeWithNewTokenSet(
      final NodeToken token,
      final String arcName,
      final String tokenSetName,
      final int numberOfTokens,
      final boolean asynchronous,
      final Env initialEnv,
      final Map<String, List<?>> initialMemberEnv) {
    GraphProcess process = token.getProcess();

    if (!process.isExecuting() || token.isComplete()) {
      return;
    }

    completeNodeToken(process, token, arcName);

    List<? extends Arc> outArcs = process.getGraph().getOutputArcs(token.getNode(), arcName);

    if (!outArcs.isEmpty()) {
      TokenSet tokenSet = getFactory().newTokenSet(process, tokenSetName, numberOfTokens);

      if (initialEnv != null) {
        tokenSet.getEnv().importEnv(initialEnv);
      }

      if (initialMemberEnv != null) {
        TokenSetMemberEnv memberEnv = tokenSet.getMemberEnv();
        for (Map.Entry<String, List<?>> entry : initialMemberEnv.entrySet()) {
          memberEnv.setAttribute(entry.getKey(), entry.getValue());
        }
      }

      for (int memberIndex = 0; memberIndex < numberOfTokens; memberIndex++) {
        for (Arc arc : outArcs) {
          ArcToken arcToken = generateArcToken(process, arc, token);

          ArcTokenSetMember setMember =
              getFactory().newArcTokenSetMember(tokenSet, arcToken, memberIndex);
          tokenSet.getActiveArcTokens(this).add(arcToken);
          arcToken.getTokenSetMemberships().add(setMember);

          finishNewArcTokenProcessing(process, arcToken, asynchronous);
        }
      }
    }
  }
Пример #4
0
  @Override
  public void startProcess(GraphProcess process) {
    process.setState(ProcessState.Executing);
    fireEvent(ProcessEvent.newStartedEvent(this, process));

    arcExecutionStarted = true;

    try {
      for (Node startNode : process.getGraph().getStartNodes()) {
        NodeToken startToken =
            getFactory().newNodeToken(process, startNode, new ArrayList<ArcToken>(0));
        process.addNodeToken(startToken);
        executeNode(process, startToken);
      }
      executeQueuedArcTokens(process);
    } finally {
      arcExecutionStarted = false;
      drainAsyncQueue(process);
    }

    if (process.isExecuting()) {
      checkForCompletion(process);
    }
  }