4 Replies Latest reply on Mar 22, 2011 1:35 PM by byungwoojun

    Workitem handler registration declaratively?

    byungwoojun Newbie

      I learned that the service task can be defined in a configuration file (see the following example), and added into the drools.rulebase.conf file (e.g., drools.workDefinitions = WorkDefinitions.conf abc.conf xyz.conf). It is obivous so far. To register a workitem handler for a service task, we use the following code:

       

      ksession.getWorkItemManager().registerWorkItemHandler("Notification", new NotificationWorkItemHandler());

       

      Is there any way to register a workitem handler for a service task declaratively (e.g., using the configuration file)? Here is the reason why I ask this question. When a BPMN2 designer added a new service task and used it in a process flow, I don't want the user needs to change Java code for its registration.

       

      Example:

       

        [

          "name" : "Notification",

          "parameters" : [

            "Message" : new StringDataType(),

            "From" : new StringDataType(),

            "To" : new StringDataType(),

            "Priority" : new StringDataType(),

          ],

         

           "results" : [

              "Result" : new StringDataType()

          ]

         

          "displayName" : "Notification",

          "icon" : "icons/notification.gif"

        ]

       

      Can we define a workitem handler here? Or, any other declarative way? So, the workitem handler can be automatically bound to the Notification Service Task without changing code.

       

      Thanks,

      bwj

        • 1. Workitem handler registration declaratively?
          Mauricio Salatino Master

          Yes, I think that you can configure the workitem handlers inside the spring configuration. In that way you can bind all the handlers without touching the code. Take a look at the Drools/jBPM5 spring configuration to see if it's there.. if not I will be glad to add that

           

          Greetings.

          1 of 1 people found this helpful
          • 2. Workitem handler registration declaratively?
            byungwoojun Newbie

            Thanks, Mauricio. I didn't find any decent Drools/jBPM 5 spring configuration document, but I found a blog, saying about jBPM5, WorkItemHandler as Spring Bean, http://community.jboss.org/thread/160352 (Michal Minicki posted the following example). It gave me some ideas how Spring can help here. I know Spring framwork is flexible and useful, but I have some reservations (or I am debating) if I have to bring the Spring framework additionally to solve this issue...

             

            e.g.,

             

            <drools:ksession id="jpaSingleSessionCommandService" type="stateful" kbase="knowledgeBase">

                    <drools:configuration>

                        <drools:work-item-handlers>

                            <drools:work-item-handler name="Notification" ref="refToNotificationWorkItemHandler" />

                        </drools:work-item-handlers>

                        <drools:jpa-persistence>

                            <drools:transaction-manager ref="transactionManager" />

                            <drools:entity-manager-factory ref="entityManagerFactory" />

                        </drools:jpa-persistence>

                    </drools:configuration>

                </drools:ksession>

             

            Is there any jBPM solution, using some configuration files? If not, I am thinking about creating a simple XML-format configuration file (similar to the above), and the code can retrieve a set of service tasks (name) and workitem handlers (ref) and bind them in a loop. Maybe I end up using Spring framework, but...

             

            BTW, is there WorkItem configuration schema or syntax? I saw there are name, parameters, results, displayName, icon and customEditor. Are they a complete list? What other tags I can put? I tried to find its syntax/schema, but no luck so far.

             

            thanks,

            bwj

            • 3. Workitem handler registration declaratively?
              Mauricio Salatino Master

              Hi there.. the spring configuration looks fine, that should be your solution. I'm not a spring fan but it looks exactly what you need to solve the problem.

              The properties that you are mentioning are used by eclipse to recognize a custom work item and to include it in the palete, that's not related with the work item itself. For each workitem that you define you will end up with the properties specific for that work item.

              Greetings!

              • 4. Workitem handler registration declaratively?
                byungwoojun Newbie

                Hi there.. Yes, the work item configuration is for eclipse palette. In my case, most of service task configurations will be bound to work item handlers (I am thinking about a generic workitem handler that can handle any kind of service tasks - parameters, content-based logic, using java reflection, annotations). So, I briefly thought about if I can add a customized tag (e.g., "binding" : "name of workitem handler" ) in the configuration, I can use this configuration file to extract both service task names and workitem handlers, instead of creating multiple configuration files here and there (or using Spring framework). However, considering decoupling between designer and workitem handlers, it may be not a good idea.

                 

                I am still interested in finding the workitem configuration shema/syntax to see if I can customize the schema.

                 

                thanks,

                bwj