예제 #1
0
  @Override
  public ContinueDirection continueOn(
      WorkflowSession session, Token token, Object workflowElement) {
    ContinueDirection result = ContinueDirection.closeMe();

    if (this.getChildren() == null || this.getChildren().size() == 0) {
      result = ContinueDirection.closeMe();
    } else {
      RuntimeContext ctx = ((WorkflowSessionLocalImpl) session).getRuntimeContext();
      KernelManager kernelManager = ctx.getDefaultEngineModule(KernelManager.class);

      List<Token> closedChildTokens = kernelManager.getChildren(token);
      if (closedChildTokens != null) {
        if (closedChildTokens.size() >= this.getChildren().size()) {
          result = ContinueDirection.closeMe();
        } else {
          result = ContinueDirection.runAgain();
        }
      } else {
        result = ContinueDirection.runAgain();
      }
    }

    if (result.getDirection() == ContinueDirection.closeMe().getDirection()) {
      int level = getLevel();
      for (int i = 0; i < (level + 1); i++) {
        System.out.print("    "); // 打印空格
      }
      System.out.println(this.getName() + " completed!");
    }
    return result;
  }
예제 #2
0
  /* (non-Javadoc)
   * @see org.fireflow.pvm.pdllogic.WorkflowBehavior#execute(org.fireflow.engine.WorkflowSession, org.fireflow.pvm.kernel.Token, java.lang.Object)
   */
  public ExecuteResult execute(WorkflowSession session, Token token, Object workflowElement) {
    if (this.getChildren() == null || this.getChildren().size() == 0) {
      ExecuteResult result = new ExecuteResult();
      result.setStatus(BusinessStatus.COMPLETED);
      return result;
    }

    RuntimeContext ctx = ((WorkflowSessionLocalImpl) session).getRuntimeContext();
    KernelManager kernelManager = ctx.getDefaultEngineModule(KernelManager.class);

    List<Token> closedChildTokens = kernelManager.getChildren(token);
    boolean isRunning = false;
    for (Child child : this.getChildren()) {
      if (!this.hasBeenExecuted(child.getChildBpelActivity(), closedChildTokens)) {
        isRunning = true;
        this.executeChildActivity(session, token, child.getChildBpelActivity());
        break;
      }
    }
    if (isRunning) {
      ExecuteResult result = new ExecuteResult();
      result.setStatus(BusinessStatus.RUNNING);
      return result;
    } else {
      ExecuteResult result = new ExecuteResult();
      result.setStatus(BusinessStatus.COMPLETED);
      return result;
    }
  }