Friday, November 27, 2009

This blog is my first. They say writing makes things clearer in ur head (and in our field - programming, may help others as well!).

I am currently working on a project that involves seam+jbpm. For many parts, the integration provided by the seam guys is great. however, there are rough edges and i encountered one today, a good opportunity for me to blog.

i have this in process definition


<node name="Change leave status to Approved"><action name="set approved" expression="#{leaveAction.setLeaveStatus('Approved')}"></action>

</node>

and the seam function being called is


@Transactional
@Transition("Send Mail")
public void setLeaveStatus(String newStatus){
EntityManager em = getEntityManager();
HrLeave hrLeave = getHrLeaveInstance();
hrLeave.setStatus(newStatus);
return ;
}



and no matter what i do, the @Transition annotation does not do its job. Finally i have found out that actions in nodes are not supposed to signal tokens. they are just actions. Something else should trigger the token to proceed.

so without changing the process definition, adding the following line to the end of the function solves this problem (and u may remove the annotation)


ExecutionContext.currentExecutionContext().getToken().signal("Send Mail");


if using annotation is important to u, changing the process definition to fire this action on some event will work as well (i.e. node-enter ).