3 Replies Latest reply on Oct 5, 2006 7:45 AM by kukeltje

    Transient variables disappear when signal into end-state

    aleekl

      here's the background to my problem:

      I have the following process definition

      START----->TASK-NODE----->NODE(with custom action)------>END

      here's the code to the custom action class:

      public void execute(ExecutionContext executionContext) throws Exception {
       //check if TEST mode is one
       ContextInstance contextInstance = executionContext.getContextInstance();
       String testMode = (String)contextInstance.getTransientVariable(JbpmConstants.TEST_KEY);
      
       //TEST MODE OFF
       if(null == testMode) {
       executionContext.leaveNode(JbpmConstants.TRANSITION_GO_NEXT);
       }
       //TEST MODE ON
       else {
      
       //set node name in as both key and value
       contextInstance.setTransientVariable(JbpmConstants.NODE_UPDATE, JbpmConstants.NODE_UPDATE);
       String exceptionFlag = (String)contextInstance.getTransientVariable(JbpmConstants.TEST_UPDATE_EXCEPTION);
       if(null == exceptionFlag) {
       //no exception
       executionContext.leaveNode(JbpmConstants.TRANSITION_GO_NEXT);
       }
       else {
       throw new Exception(JbpmConstants.TEST_UPDATE_EXCEPTION); //test for exception
       }
       }
       }
      }
      


      and here is the code for my junit test:
      .
      .
      .
      _token.signal();
      _activatedNode = (String)_token.getProcessInstance().getContextInstance().getTransientVariable(JbpmConstants.NODE_UPDATE);
      assertNotNull(_activatedNode);
      assertEquals(_activatedNode, JbpmConstants.NODE_UPDATE);
      


      The idea is I want to test to make sure my custom-node is activated after signalling from the TASK-NODE, and I'm using transient variables to test this result. So far this has work with other workflows where a signal of a task node leads to another task node (i.e. not end state). However once I signal from a task-node into an eventual end-state, I find that all my transient variables are gone.

      I've also tried to print out all variables (transient and non-transient) after the signal() call, but both maps are null.

      Does anyone know why this is so?