Package org.openbp.server.context

Examples of org.openbp.server.context.TokenContext


    if (hasActiveObservers(eventType))
    {
      // Note that this block is synchronized, so only one event may be processed by a client at a time
      synchronized(this)
      {
        TokenContext context = ((EngineEvent) event).getContext();
        TokenContextUtil.checkTerminationRequest(context);

        super.fireEvent(event);

        TokenContextUtil.checkTerminationRequest(context);
View Full Code Here


   * @param ee Engine executor that called this method
   * @throws OpenBPException On error
   */
  public void executeModelObject(ModelObject mo, EngineExecutor ee)
  {
    TokenContext context = ee.getTokenContext();
    NodeSocket entrySocket = context.getCurrentSocket();

    WorkflowTask workflowTask = createWorkflowTask(entrySocket, context);

    // Continue with the 'TaskPublished' socket
    NodeSocket nextSocket = getEngine().resolveSocketRef(CoreConstants.SOCKET_TASK_PUBLISHED, entrySocket, context, false);

    if (nextSocket != null)
    {
      Param workflowTaskParam = nextSocket.getParamByName(CoreConstants.WORKFLOWTASK_PARAM_NAME);
      if (workflowTaskParam != null)
      {
        // If the exit socket contains a 'WorkflowTask' parameter, set it
        TokenContextUtil.setParamValue(context, workflowTaskParam, workflowTask);
      }
      context.setCurrentSocket(nextSocket);
    }
    else
    {
      // No 'TaskPublished' socket -> Stop here
      context.setLifecycleRequest(LifecycleRequest.SUSPEND_IMMEDIATE);
    }
  }
View Full Code Here

   * @param ee Engine executor that called this method
   * @throws OpenBPException On error
   */
  public void executeModelObject(ModelObject mo, EngineExecutor ee)
  {
    TokenContext context = ee.getTokenContext();
    NodeSocket entrySocket = context.getCurrentSocket();
    VisualNode node = (VisualNode) entrySocket.getNode();

    // A visual node might be a persisting node, so make the engine persist the process state.
    if (node.isWaitStateNode())
    {
      context.setLifecycleRequest(LifecycleRequest.SUSPEND_IMMEDIATE);
    }

    // We do not alter the current node - this needs to be done by the visual implementation
  }
View Full Code Here

   * @param ee Engine executor that called this method
   * @throws OpenBPException On error
   */
  public void executeModelObject(ModelObject mo, EngineExecutor ee)
  {
    TokenContext context = ee.getTokenContext();
    NodeSocket entrySocket = context.getCurrentSocket();
    WaitStateNode node = (WaitStateNode) entrySocket.getNode();

    // A wait state node usually is always persistent, so make the engine persist the process state.
    context.setLifecycleRequest(LifecycleRequest.SUSPEND_IMMEDIATE);

    // Execution will continue at the default exit socket when triggered by the application program.
    NodeSocket nextSocket = node.getDefaultExitSocket();
    if (nextSocket == null)
    {
      String msg = LogUtil.error(getClass(), "No default exit socket present for wait state node $0. [{1}]", node.getQualifier(), context);
      throw new EngineException("NoDefaultExitSocket", msg);
    }
    context.setCurrentSocket(nextSocket);
  }
View Full Code Here

   * @param ee Engine executor that called this method
   * @throws OpenBPException On error
   */
  public void executeModelObject(ModelObject mo, EngineExecutor ee)
  {
    TokenContext context = ee.getTokenContext();
    NodeSocket entrySocket = context.getCurrentSocket();
    MergeNode node = (MergeNode) entrySocket.getNode();

    NodeSocket nextSocket = node.getDefaultExitSocket();
    if (nextSocket == null)
    {
      String msg = LogUtil.error(getClass(), "No default exit socket present for merge node $0. [{1}]", node.getQualifier(), context);
      throw new EngineException("NoDefaultExitSocket", msg);
    }
    context.setCurrentSocket(nextSocket);
  }
View Full Code Here

    return null;
  }

  public static TokenContext rollbackAndContinue(TokenContext contextArg, int rollbackDataBehavior, int rollbackPositionBehavior, Engine engine)
  {
    TokenContext memContext = contextArg;
    Object contextId = memContext.getId();

    // Save variable values before we perform the rollback
    NodeSocket memCurrentSocket = memContext.getCurrentSocket();
    int memPriority = memContext.getPriority();
    String memQueueType = memContext.getQueueType();
    CallStack memCallStack = null;
    ProgressInfo memProgressInfo = null;
    Map memProcessVariables = null;
    try
    {
      if (rollbackPositionBehavior == RollbackPositionBehavior.MAINTAIN_POSITION)
      {
        memCallStack = (CallStack) CopyUtil.copyObject(memContext.getCallStack(), Copyable.COPY_DEEP, null);
        memProgressInfo = (ProgressInfo) CopyUtil.copyObject(memContext.getProgressInfo(), Copyable.COPY_DEEP, null);
      }
    }
    catch (CloneNotSupportedException e)
    {
      String msg = LogUtil.error(EngineUtil.class, "Error cloning token. [{0}]", memContext, e);
      throw new EngineException("NoDefaultExitSocket", msg);
    }
    if (rollbackDataBehavior == RollbackDataBehavior.UPDATE_VARIABLES || rollbackDataBehavior == RollbackDataBehavior.ADD_VARIABLES)
    {
      memProcessVariables = copyProcessVariables(memContext, engine.getPersistenceContextProvider());
    }

    // Perform transaction rollback and get rid of the rollback-invalid persistence context
    TokenContextService contextService = engine.getTokenContextService();
    contextService.evictContext(memContext);
    engine.rollback();

    // Retrieve the current version of the context
    TokenContext dbContext = contextService.getContextById(contextId);
    boolean updateContext = false;

    if (rollbackPositionBehavior == RollbackPositionBehavior.MAINTAIN_POSITION)
    {
      // Maintain the current position, so update the DB context from the memory context.
      dbContext.setCurrentSocket (memCurrentSocket);
      dbContext.setCallStack (memCallStack);
      dbContext.setPriority (memPriority);
      dbContext.setQueueType (memQueueType);
      dbContext.setProgressInfo (memProgressInfo);
      updateContext = true;
    }

    if (memProcessVariables != null)
    {
      for (Iterator it = memProcessVariables.entrySet().iterator(); it.hasNext();)
      {
        Map.Entry entry = (Map.Entry) it.next();
        String varName = (String) entry.getKey();
        Object value = entry.getValue();
        value = PersistenceContextObjectSerializer.resolveSerializableObjectReference(value, dbContext, varName, engine.getPersistenceContextProvider());

        if (rollbackDataBehavior == RollbackDataBehavior.UPDATE_VARIABLES)
        {
          // Update the DB context with the variable value of the memory context
          dbContext.setProcessVariableValue(varName, value);
          updateContext = true;
        }
        else
        {
          // Add new variables of the memory context to the DB context
          if (dbContext.getProcessVariableValue(varName) == null)
          {
            if (value != null)
            {
              dbContext.setProcessVariableValue(varName, value);
              updateContext = true;
            }
          }
        }
      }
View Full Code Here

      if (tokenId != null)
      {
        try
        {
          ProcessFacade processFacade = processServer.getProcessFacade();
          TokenContext tc = processFacade.getTokenById(tokenId);
          desc.setTokenContext(tc);
        }
        catch (Exception e)
        {
          String msg = LogUtil.error(getClass(), "Cannot find the scheduled token context (id $0) for job $1.", tokenId,
View Full Code Here

   * @param ee Engine executor that called this method
   * @throws OpenBPException On error
   */
  public void executeModelObject(ModelObject mo, EngineExecutor ee)
  {
    TokenContext context = ee.getTokenContext();
    JavaActivityItem activity = (JavaActivityItem) mo;

    NodeSocket nextSocket = null;

    TokenContext oldContext = context;
    HandlerContext hc = getEngine().executeHandler(activity.getHandlerDefinition(), HandlerTypes.ACTIVITY, context, context.getCurrentSocket(), nextSocket);
    if (hc != null)
    {
      context = hc.getTokenContext();
      if (context != oldContext)
View Full Code Here

   * @param ee Engine executor that called this method
   * @throws OpenBPException On error
   */
  public void executeModelObject(ModelObject mo, EngineExecutor ee)
  {
    TokenContext context = ee.getTokenContext();
    NodeSocket entrySocket = context.getCurrentSocket();
    DecisionNode node = (DecisionNode) entrySocket.getNode();

    boolean result = false;

    String expression = node.getExpression();
    if (expression != null)
    {
      // Evaluate a script expression
      ScriptEngine scriptEngine = getEngine().getScriptEngineFactory().obtainScriptEngine(context);
      try
      {
        // Evaluate the expression
        scriptEngine.prepareNodeSocketExecution(entrySocket);
        Object value = scriptEngine.executeScript(expression, "Decision node script", entrySocket.getNode()
                              .getQualifier().toString());
        scriptEngine.finishNodeSocketExecution(entrySocket);

        // Assign the result to the parameter
        if (value != null && ! value.equals(Boolean.FALSE))
          result = true;
      }
      finally
      {
        getEngine().getScriptEngineFactory().releaseScriptEngine(scriptEngine);
      }
    }

    String socketName = result ? CoreConstants.SOCKET_YES : CoreConstants.SOCKET_NO;
    NodeSocket nextSocket = getEngine().resolveSocketRef(socketName, entrySocket, context, true);
    context.setCurrentSocket(nextSocket);
  }
View Full Code Here

        case ControlLink.TA_ROLLBACK_BEGIN:
        begin = true;
        // Fallthrough

        case ControlLink.TA_ROLLBACK:
        TokenContext newContext = EngineUtil.rollbackAndContinue(context, link.getRollbackDataBehavior(), link.getRollbackPositionBehavior(), engine);
        if (newContext != null)
          context = newContext;
        break;
      }
View Full Code Here

TOP

Related Classes of org.openbp.server.context.TokenContext

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.