1 Reply Latest reply on Mar 19, 2008 12:32 PM by kukeltje

    accessing context variable map outside of session?

    simonbaker

      What is the correct way to get a processinstance context variable map if we only want to use it for "read-only" access to look up variable values outside of a jbpm session?

      For example, here is an experimental method to retrieve a handle to a context variable map, but since the method opens and closes a session, is the handle still pointing to a valid map, or should we make a copy of the map to return from the method?

      public static Map getProcessVariableMap(long LprocessId) throws Exception
      {
       Map mapVariables;
      
       if (jbpmConfiguration == null)
       jbpmConfiguration = JbpmConfiguration.getInstance();
      
       JbpmContext jbpmContext = null;
      
       try
       {
       jbpmContext = jbpmConfiguration.createJbpmContext();
      
       ProcessInstance procinst = jbpmContext.getProcessInstance(LprocessId);
      
       mapVariables = procinst.getContextInstance().getVariables();
       }
       finally
       {
       if (jbpmContext != null) jbpmContext.close();
       }
      
       return mapVariables;
      }
      


        • 1. Re: accessing context variable map outside of session?
          kukeltje

          retrieving it outside of a jbpm session is only possible if you implement your own hibernate queries etc... I'd not go that way.

          Your next question is kind of generic hibernate stuff.... How would you handle that in other circumstances? Do it the same here... I'm not a hibernate expert, so not able to give you any details. hth.