[jboss-user] [JBoss jBPM] - Re: variable scope from a script

tbeernot do-not-reply at jboss.com
Tue Nov 25 09:16:25 EST 2008


"mputz" wrote :   /**
  |   |    * sets a variable. If a variable exists in the scope given by the token, that
  |   |    * variable is updated. Otherwise, the variable is created on the root token
  |   |    * (=process instance scope).
  |   |    */
  |   |   public void setVariable(String name, Object value, Token token) {
  | 
  | In order to use setVariable on different tokens, the variables have to be created first with createVariable, otherwise they will all end up being referenced by the root token.

Create variable works indeed. It also works to update an already existing variable. So my problem is solved, thank you!

However, IMHO, I find the behavior strange:
- Even though a token is explicitely provided, setVariable elects to ignore it. Rather throw an exception stating the variable does not exist, but do not ignore that parameter; there is a two-parameter method for a more "agile" behavior.
- createVariable can be used to create and update a variable. However "create" is much more specific about what is going to happen than "set", and I had not expected it to update also.

Personally I find the following behavior more logical:
- createVariable: create only but not update, exception if variable exists
- updateVariable: update only, exception if not exist 
- setVariable: create if not exist, otherwise update

Thanks! 

Tom

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4192129#4192129

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4192129



More information about the jboss-user mailing list