1 Reply Latest reply on Mar 19, 2008 12:32 PM by Ronald van Kuijk

    accessing context variable map outside of session?

    s b Newbie

      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;
      }