Package org.jbpm.graph.exe

Examples of org.jbpm.graph.exe.Token


    job.setExclusive(action.isAsyncExclusive());
    return job;
  }

  public void executeAction(Action action, ExecutionContext executionContext) {
    Token token = executionContext.getToken();

    // create action log
    ActionLog actionLog = new ActionLog(action);
    token.startCompositeLog(actionLog);

    // if this is an action being executed in an event,
    // the token needs to be locked. if this is an action
    // being executed as the node behaviour or if the token
    // is already locked, the token doesn't need to be locked.
    boolean actionMustBeLocked = (executionContext.getEvent() != null) && (!token.isLocked());

    try {
      // update the execution context
      executionContext.setAction(action);

      // execute the action
      log.debug("executing " + action);
      String lockOwnerId = "token[" + token.getId() + "]";
      try {
        if (actionMustBeLocked) {
          token.lock(lockOwnerId);
        }

        if (UserCodeInterceptorConfig.userCodeInterceptor != null) {
          UserCodeInterceptorConfig.userCodeInterceptor.executeAction(action, executionContext);
        } else {
          action.execute(executionContext);
        }

      } finally {
        if (actionMustBeLocked) {
          token.unlock(lockOwnerId);
        }
      }

    } catch (Exception exception) {
      // NOTE that Errors are not caught because that might halt the JVM and mask the original Error
      log.error("action threw exception: " + exception.getMessage(), exception);

      // log the action exception
      actionLog.setException(exception);

      // if an exception handler is available
      raiseException(exception, executionContext);
    } finally {
      executionContext.setAction(null);
      token.endCompositeLog();
    }
  }
View Full Code Here


      contextInstance.updatedVariableContainers.add(this);
    }
  }
 
  public ContextInstance getContextInstance() {
    Token token = getToken();
    ProcessInstance processInstance = (token!=null ? token.getProcessInstance() : null);
    return (processInstance!=null ? processInstance.getContextInstance() : null);
  }
View Full Code Here

  }

  // protected ////////////////////////////////////////////////////////////////

  protected VariableContainer getParentVariableContainer() {
    Token parentToken = token.getParent();
    if (parentToken==null) {
      return null;
    }
    return contextInstance.getTokenVariableMap(parentToken);
  }
View Full Code Here

      }
      return previousProcessInstance.getRootToken();
    }
    else
    {
      Token token = getToken(jbpmContext);

      if (expectedStateName != null && !expectedStateName.equals(token.getNode().getName()))
        throw new JbpmException("token is not in expected state '" + expectedStateName + "' but in '" + token.getNode().getName() + "'");

      if (variables != null && variables.size() > 0)
        token.getProcessInstance().getContextInstance().addVariables(variables);

      if (transitionName == null)
      {
        token.signal();
      }
      else
      {
        token.signal(transitionName);
      }
      return token;
    }
  }
View Full Code Here

  /**
   * called by a transition to pass execution to this node.
   */
  public void enter(ExecutionContext executionContext)
  {
    Token token = executionContext.getToken();

    // update the runtime context information
    token.setNode(this);

    // fire the leave-node event for this node
    fireEvent(Event.EVENTTYPE_NODE_ENTER, executionContext);

    // keep track of node entrance in the token, so that a node-log can be generated at node leave time.
    token.setNodeEnter(Clock.getCurrentTime());

    // remove the transition references from the runtime context
    executionContext.setTransition(null);
    executionContext.setTransitionSource(null);

    // execute the node
    if (isAsync)
    {
      ExecuteNodeJob job = createAsyncContinuationJob(token);
      MessageService messageService = (MessageService)Services.getCurrentService(Services.SERVICENAME_MESSAGE);
      messageService.send(job);
      token.lock(job.toString());
    }
    else
    {
      execute(executionContext);
    }
View Full Code Here

   */
  public void leave(ExecutionContext executionContext, Transition transition)
  {
    if (transition == null)
      throw new JbpmException("can't leave node '" + this + "' without leaving transition");
    Token token = executionContext.getToken();
    token.setNode(this);
    executionContext.setTransition(transition);

    // fire the leave-node event for this node
    fireEvent(Event.EVENTTYPE_NODE_LEAVE, executionContext);

    // log this node
    if (token.getNodeEnter() != null)
    {
      addNodeLog(token);
    }

    // update the runtime information for taking the transition
View Full Code Here

                for (String name : updates) {
                    contextInstance.setVariable(name, updatesHashMap.get(name));
                    updated = true;
                }
            } else if (targetValue instanceof Token) {
                final Token token = (Token) targetValue;
                final ProcessInstance processInstance = token.getProcessInstance();
                final ContextInstance contextInstance = processInstance.getContextInstance();
                for (String name : deletes) {
                    contextInstance.deleteVariable(name, token);
                    updated = true;
                }
View Full Code Here

    public void handleAction(JbpmJsfContext context, ActionEvent event) {
        try {
            final FacesContext facesContext = FacesContext.getCurrentInstance();
            final ELContext elContext = facesContext.getELContext();
            final Object value = valueExpression.getValue(elContext);
            final Token token;
            if (value == null) {
                context.setError("Signal failed", "The value is null");
                return;
            }
            if (value instanceof Token) {
                token = (Token) value;
            } else if (value instanceof ProcessInstance) {
                token = ((ProcessInstance)value).getRootToken();
            } else {
                context.setError("Signal failed", "The value type is not recognized");
                return;
            }
            if (transitionExpression != null) {
                final Object transitionValue = transitionExpression.getValue(elContext);
                if (transitionValue == null) {
                    token.signal();
                } else if (transitionValue instanceof Transition) {
                    token.signal((Transition)transitionValue);
                } else {
                    token.signal(transitionValue.toString());
                }
            } else {
                token.signal();
            }
            context.addSuccessMessage((value instanceof ProcessInstance) ? "Process instance" : "Token" + " signalled");
            context.getJbpmContext().getSession().flush();
            context.selectOutcome("success");
        } catch (Exception ex) {
View Full Code Here

    }
    return completionTriggersSignal;
  }

  boolean isLastToComplete(TaskInstance taskInstance) {
    Token token = taskInstance.getToken();
    TaskMgmtInstance tmi = getTaskMgmtInstance(token);
   
    boolean isLastToComplete = true;
    for (TaskInstance other : tmi.getTaskInstances()) {
      if ( (token!=null)
          && (token.equals(other.getToken()))
          && (! other.equals(taskInstance))
          && (other.isSignalling())
          && (!other.hasEnded())
      ) {
        isLastToComplete = false;
View Full Code Here

   * @see #loadToken(long)
   * @see #getTokenForUpdate(long)
   */
  public Token loadTokenForUpdate(long tokenId)
  {
    Token token = getGraphSession().loadToken(tokenId);
    addAutoSaveToken(token);
    return token;
  }
View Full Code Here

TOP

Related Classes of org.jbpm.graph.exe.Token

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.