Yes, agreed, that might be the best solution. But, here's another problem. The 
subprocess-end event is useless if the context's token does not have the 
subProcessInstance field set.

See, token.subprocessinstance is not a persistent field, which means that if 
the subprocess is started, then loaded in a different hibernate session later, 
the token.subprocessinstance field is null, which means that if you have an 
action on a subprocess-end event, its not going to know which subprocess ended.

making the list of subprocesses is great, but it doesn't solve this problem. My 
gut feeling is that this should be treated as it is treated during subprocess 
creation:


  |  public void execute(ExecutionContext executionContext) {
  |     Token superProcessToken = executionContext.getToken();
  | 
  |     // create the subprocess
  |     ProcessInstance subProcessInstance = new 
ProcessInstance(subProcessDefinition);
  |     // bind the subprocess to the super-process-token
  |     superProcessToken.setSubProcessInstance(subProcessInstance);
  |     subProcessInstance.setSuperProcessToken(superProcessToken);
  | 
  |     // fire the subprocess created event
  |     fireEvent(Event.EVENTTYPE_SUBPROCESS_CREATED, executionContext);
  |     .....
  | 

See how the superProcessToken gets a nice setSubProcessInstance? That way the 
subprocess-created event knows which subprocess was created.

The current code on notifySubProcessEnd is:


  | public void notifySubProcessEnd(ProcessInstance subProcessInstance) {
  |    Token superProcessToken = subProcessInstance.getSuperProcessToken();
  | 
  |     ExecutionContext executionContext = new      
ExecutionContext(superProcessToken);
  | 
  |     // feed the readable variables
  |     if ((variableAccesses != null) && (!variableAccesses.isEmpty())) {
  |     ....
  |     ....
  |     }
  | 
  |     // feed the readable variables
  |     fireEvent(Event.EVENTTYPE_SUBPROCESS_END, executionContext);
  |     ....
  | 

I think it is very reasonable to do instead


  | public void notifySubProcessEnd(ProcessInstance subProcessInstance) {
  |     Token superProcessToken = subProcessInstance.getSuperProcessToken();
  |     superProcessToken.setSubProcessInstance(subProcessInstance);
  |     ExecutionContext executionContext = new 
ExecutionContext(superProcessToken);
  | 
  |     // feed the readable variables
  |     if ((variableAccesses != null) && (!variableAccesses.isEmpty())) {
  |     ....
  |     ....
  |     }
  | 
  |     // fire the subprocess ended event
  |     fireEvent(Event.EVENTTYPE_SUBPROCESS_END, executionContext);
  |     ....
  | 

In this way, the subprocess-end event will pass a context where the token 
correctly contains the subprocess instance even if being loaded after being 
persisted while the subprocess was going on.

I will post a JIRA bug with this same info.

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

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


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to