1 Reply Latest reply on Nov 21, 2005 1:40 AM by icyjamie

    Concept of Process Object

    houyunf

      When I develop jbpm applications, I first tried to integrate it with Spring, and then I found it might be useful to introduce process object to handle business logics.
      In the current implementation, we can implement various action handler to be called by jbpm when we would like to inject custom, or, business logic during the execution of a process instance. This gives me great flexibility to extend the capability of a process. But this is not enough for me, it needs to solve the problems below:
      1. action handler is a class which would be instantiated each time when invoked, as a spring user, I found no where to inject dependency, so it limits my capability a lot. Well, action class can have fields and use the process xml definition to config these fields, but it is not possible to inject a DAO or other complex services.
      2. if I have many nodes needs different action handlers, I will find myself writing too many small classes.

      So I use Process Object to improve this, a process object is a spring managed bean can handle requests where action handlers are required.
      1. In process definition xml, I define an variable processObjectName indicating the spring bean name of the process object. This variable is set when process started.
      2. I created several standard action handlers, such as NodeActionHandler, TransitionChooser, SwimlaneAssignmentHandler, they have one common field: poMethod, which is the method in Process Object to do the real business logic. Different action handler will call methods with certain parameter and return code. For example, TransitionChooser will return transition name, while NodeActionHandler will return nothing.
      3. When action handler get invoked, it will first get process object from the SpringJbpmSession, then it will call the specified method of the PO object.

      This implementation has the following advantage:
      1. consolidate process related business logics into one domain object
      2. the process object is fully spring enabled, which means dependent services could be injected by spring config, and procoess object can also be transaction supported usng spring AOP
      3. simplifies process definition, action handler will have only one parameter to define, all the constants could be injected into PO using spring xml definition. I prefer this way because I would like to get a cleaner process definition, and spring config would be much more powerful.

      Please check my spring implementation:
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=72744

      And let me know if anyone interested in the PO implementation.


      Yunfeng Hou