[jboss-user] [JBoss jBPM] - Re: required variables

dleerob do-not-reply at jboss.com
Thu Sep 13 16:16:39 EDT 2007


There may be another bug.
When calling taskInstance.end(), it now throws an exception (great!), but unfortunately, that exception does not stop the ending of the task instance. So the task instance is indeed considered "ended" anyway, even though you have required variables that are missing.

See the end method below, found in TaskInstance. The validation is only done when submitVariables() is called, but before that is called, a bunch of work has already taken place on the task instance.
/**
  |    * marks this task as done and specifies a transition  
  |    * leaving the task-node for the case that the completion of this 
  |    * task instances triggers a signal on the token.
  |    * If this task leads to a signal on the token, the given transition 
  |    * name will be used in the signal.
  |    * If this task completion does not trigger execution to move on, 
  |    * the transition is ignored.
  |    */
  |   public void end(Transition transition) {
  |     if (this.end!=null){
  |       throw new IllegalStateException("task instance '"+id+"' is already ended");
  |     }
  |     if (this.isSuspended) {
  |       throw new JbpmException("task instance '"+id+"' is suspended");
  |     }
  |     
  |     // mark the end of this task instance
  |     this.end = new Date();
  |     this.isOpen = false;
  | 
  |     // fire the task instance end event
  |     if ( (task!=null)
  |          && (token!=null)
  |        ) {
  |       ExecutionContext executionContext = new ExecutionContext(token);
  |       executionContext.setTask(task);
  |       executionContext.setTaskInstance(this);
  |       task.fireEvent(Event.EVENTTYPE_TASK_END, executionContext);
  |     }
  |     
  |     // log this assignment
  |     if (token!=null) {
  |       token.addLog(new TaskEndLog(this));
  |     }
  |     
  |     // submit the variables
  |     submitVariables();
  |     
  |     // verify if the end of this task triggers continuation of execution
  |     if (isSignalling) {
  |       this.isSignalling = false;
  |       
  |       
  |       
  |       if ( this.isStartTaskInstance() // ending start tasks always leads to a signal
  |            || ( (task!=null)
  |                 && (token!=null)
  |                 && (task.getTaskNode()!=null)
  |                 && (task.getTaskNode().completionTriggersSignal(this))
  |               )
  |          ) {
  |         
  |         if (transition==null) {
  |           log.debug("completion of task '"+task.getName()+"' results in taking the default transition");
  |           token.signal();
  |         } else {
  |           log.debug("completion of task '"+task.getName()+"' results in taking transition '"+transition+"'");
  |           token.signal(transition);
  |         }
  |       }
  |     }
  |   }

Am I missing something? Should it work this way? Surely the task instance should not "end" if the required variables are not set.
I think I may need to do my own validation in my framework action class by calling startTaskInstance.getTask().getTaskController().getVariableAccesses(), then implementing my own (similair) validation function on that variable access list, and not even bother calling taskInstance.end() if my own validation fails. Would you recommend I do it this way?

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

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



More information about the jboss-user mailing list