Package org.openbp.core.model.item.process

Examples of org.openbp.core.model.item.process.NodeSocket


   * @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);
    }
View Full Code Here


   * @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);
    }
View Full Code Here

      return false;
    }

    // Check if there is also a control link going from the source socket to the target socket
    boolean haveControlLink = false;
    NodeSocket startSocket = startSocketFigure.getNodeSocket();
    NodeSocket endSocket = endSocketFigure.getNodeSocket();
    for (Iterator it = startSocket.getControlLinks(); it.hasNext();)
    {
      ControlLink link = (ControlLink) it.next();
      if (link.getTargetSocket() == endSocket)
      {
        haveControlLink = true;
        break;
      }
    }
    for (Iterator it = endSocket.getControlLinks(); it.hasNext();)
    {
      ControlLink link = (ControlLink) it.next();
      if (link.getTargetSocket() == startSocket)
      {
        haveControlLink = true;
View Full Code Here

        boolean haveValue = false;
        Object value = null;

        for (Iterator itSocket = node.getSockets(); itSocket.hasNext();)
        {
          NodeSocket socket = (NodeSocket) itSocket.next();

          if (! socket.isExitSocket())
            continue;

          Param targetParam = socket.getParamByName(paramName);
          if (targetParam == null)
            continue;

          // We found a parameter of the same name
          if (! haveValue)
View Full Code Here

   */
  static void removeNodeData(Node node, TokenContext context)
  {
    for (Iterator it = node.getSockets(); it.hasNext();)
    {
      NodeSocket socket = (NodeSocket) it.next();

      EngineUtil.removeSocketData(socket, context);
    }
  }
View Full Code Here

    String socketName = socket.getName();

    Node newNode = process.getNodeByName(nodeName);
    if (newNode != null)
    {
      NodeSocket newSocket = newNode.getSocketByName(socketName);
      if (newSocket != null)
        return newSocket;
    }

    return null;
View Full Code Here

  {
    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;
View Full Code Here

    }

    try
    {
      // Initialize the next executable socket to the initial socket.
      NodeSocket currentSocket = context.getCurrentSocket();

      if (currentSocket == null)
        // There is no executable socket; the process has stopped
        return;

      Node currentNode = currentSocket.getNode();
      NodeSocket entrySocket = currentSocket;
      boolean isEntrySocket = currentSocket.isEntrySocket();

      if (isEntrySocket)
      {
        // We have an entry socket; Regular node execution

        // Evaluate any input parameter expressions or scripts and
        // ensure that any required parameters are present.
        prepareSocket(entrySocket);

        // By default, we copy the parameters of the entry socket to parameters
        // of the same name at the exit sockets
        EngineUtil.copySocketParameters(entrySocket, null, context);

        if (engine.hasActiveObservers(EngineTraceEvent.NODE_ENTRY, context))
        {
          engine.fireEngineEvent(new EngineTraceEvent(EngineTraceEvent.NODE_ENTRY, context, entrySocket, engine));
        }
        // Reassign the entry socket if the process has been updated while waiting for a debugger command ("hot code replace")
        entrySocket = context.getCurrentSocket();
        currentNode = entrySocket.getNode();

        /////////////////////////////////////////////////
        // Execute the node connected to the socket
        /////////////////////////////////////////////////

        if (LogUtil.isTraceEnabled(getClass()))
        {
          String nodeType = currentNode.getModelObjectSymbolName();
          LogUtil.trace(getClass(), "Executing {0}Node $1. [{2}]", nodeType, currentNode.getQualifier(), context);
        }

        // Execute the NodeEntry handler, if any
        HandlerContext hc = engine.executeHandler(currentNode.getEventHandlerDefinition(), HandlerTypes.NODE_ENTRY, context, entrySocket,
          currentNode.getDefaultExitSocket());
        if (hc != null && hc.hasNextSocketChanged())
        {
          // Handler changed the flow of control...
          if (hc.getNextSocket() == null)
            throw new EngineException("MissingNextSocket", "Handler of node  '" + currentNode.getQualifier()
              + "' has set a null next socket.\nThe process cannot be continued.");
          context.setCurrentSocket(hc.getNextSocket());
          return;
        }

        // *** Execute the node ***
        ModelObjectExecutor executor = engine.getModelObjectExecutorMgr().getExecutor(currentNode);
        executor.executeModelObject(currentNode, this);
      }
      else
      {
        // We have an exit socket; Node has been executed already, process is being continued now.
      }

      // *** Handle any lifecycle state requests and perform the transaction handling ***
      handleLifecycleRequest();

      if (context.getLifecycleState() == LifecycleState.RUNNING)
      {
        NodeSocket nextSocket = context.getCurrentSocket();
        if (nextSocket != null)
        {
          // Execute the node exit handler, if any and if not executing an error socket
          if (! nextSocket.getName().equals(CoreConstants.ERROR_SOCKET_NAME))
          {
            HandlerContext hc2 = engine.executeHandler(currentNode.getEventHandlerDefinition(), HandlerTypes.NODE_EXIT, context, entrySocket, nextSocket);
            if (hc2 != null && hc2.hasNextSocketChanged())
            {
              // Handler changed the flow of control...
              nextSocket = hc2.getNextSocket();
              context.setCurrentSocket(nextSocket);
            }
          }

          if (nextSocket != null)
          {
            // Evaluate any output parameter expressions or scripts
            postProcessSocket(nextSocket);
          }

          if (isEntrySocket)
          {
            // Clear the entry socket data from the context
            EngineUtil.removeSocketData(entrySocket, context);
          }
        }

        if (nextSocket != null)
        {
          if (engine.hasActiveObservers(EngineTraceEvent.NODE_EXIT, context))
          {
            engine.fireEngineEvent(new EngineTraceEvent(EngineTraceEvent.NODE_EXIT, context, nextSocket, engine));
          }
          // Reassign the entry socket if the process has been updated while waiting for a debugger command ("hot code replace")
          nextSocket = context.getCurrentSocket();

          // If we ended up with an entry socket for the next socket, the flow of control was diverted by the node handler directly.
          // Otherwise, we need to perform the regular control link processing.
          if (nextSocket.isExitSocket())
          {
            // *** Follow the control links to determine the new node. ***
            // Note that the control link may perform transaction handling here.
            advanceToNextSocket(nextSocket);
            nextSocket = context.getCurrentSocket();
          }
        }

        if (nextSocket == null || nextSocket.getNode() != currentNode)
        {
          // Remove local node data if we changed nodes
          EngineUtil.removeNodeData(currentNode, context);
        }
      }
View Full Code Here

    // Iterate all exit parameters and forward them to other nodes
    // they are connected with by data links.
    transferExitSocketData(exitSocket);

    // Now forward control to the sockets connected to this exit socket, if any
    NodeSocket oldCurrentSocket = context.getCurrentSocket();
    for (Iterator it = exitSocket.getControlLinks(); it.hasNext();)
    {
      ControlLink link = (ControlLink) it.next();

      if (engine.hasActiveObservers(EngineTraceEvent.CONTROL_FLOW, context))
      {
        engine.fireEngineEvent(new EngineTraceEvent(EngineTraceEvent.CONTROL_FLOW, context, link, engine));
      }
      executeControlLink(link);
    }

    if (context.getCurrentSocket() == oldCurrentSocket)
    {
      // No control link present, try to continue at an initial node
      // with the same name as the exit socket
      String nextName = exitSocket.getName();

      NodeSocket nextSocket = null;
      Node nextNode = context.getCurrentSocket().getProcess().getNodeByName(nextName);
      if (nextNode != null && nextNode instanceof InitialNode)
      {
        nextSocket = nextNode.getDefaultExitSocket();
      }
View Full Code Here

   * @param link Contro link
   * @throws OpenBPException On error
   */
  public void executeControlLink(ControlLink link)
  {
    NodeSocket oldCurrentSocket = context.getCurrentSocket();

    int transactionControl = link.getTransactionControl();
    if (transactionControl != ControlLink.TA_NONE)
    {
      TokenContextService contextService = engine.getTokenContextService();
View Full Code Here

TOP

Related Classes of org.openbp.core.model.item.process.NodeSocket

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.