2 Replies Latest reply on Sep 29, 2009 9:00 AM by Karl Koch

    JBPM 4.0 HistoryEvent, HistorySession

    Torsten R Newbie

      Hi,

      we need to send emails and log information upon certain events (e.g a reassignment or change of priority).

      All this is available as history events, so we thought implementing a custom history session and add this to the jbpm-config. As it turns out the history events do not expose their information (e.g. the execution they were fired from).

      Is there a way to get the execution from a history event in a custom event session? Would it be possible to add a method getExecution into HistoryEvent in the next release, or did I miss something?

      example:

      package com.test;
      
      import org.jbpm.pvm.internal.history.HistoryEvent;
      import org.jbpm.pvm.internal.history.HistorySession;
      import org.jbpm.pvm.internal.history.events.TaskAssign;
      
      public class NotificationListener implements HistorySession {
       public void process(HistoryEvent historyEvent) {
      
       if (historyEvent instanceof TaskAssign) {
       //User Assigned!
       TaskAssign taskAssign = (TaskAssign) historyEvent;
      
       //Nothing to get from taskAssign
       //Nothing visible from this package
       }
       }
      }
      


        • 1. Re: JBPM 4.0 HistoryEvent, HistorySession
          Torsten R Newbie

          Addition:
          I wasn't able to find a binding for HistorySessionChain. I created one (see below).

          Maybe some hints for all who want to add a custom historySession....

          Steps:

          - Create your custom history Session (implement org.jbpm.pvm.internal.history.HistorySession)
          - Create the binding class for the custom history session (you can copy the binding from historySession and adjust tag and class)
          - Create the binding class for the historySessionChain (see below)
          - Add both bindings to jbpm.wire.bindings.xml
          - Change your configuration by adding the chain-tag including the actual history sessions.

          Last problem I have:
          Can anyone see an option to get the of the execution memeber of the history-events in the custom event session without changing the code?


          Regards
          Torsten


          CustomHistorySession.java

          package com.test;
          
          public class CustomHistorySession implements HistorySession {
           public void process(HistoryEvent historyEvent) {
           // Do your custom work here
           }
          }


          CustomHistorySessionBinding.java
          package com.test;
          public class CustomHistorySessionBinding extends WireDescriptorBinding {
          
           public CustomHistorySessionBinding() {
           super("custom-history-session");
           }
          
           public Object parse(Element element, Parse parse, Parser parser) {
           return new ObjectDescriptor(CustomHistorySession.class);
           }
          }


          HistorySessionChainBinding.java (copy and modify from deployer-manager)
          package com.test;
          
          public class HistorySessionChainBinding extends WireDescriptorBinding {
          
           private static final String HISTORY_SESSION_CHAIN_TAG = "history-session-chain";
          
           public HistorySessionChainBinding() {
           super(HISTORY_SESSION_CHAIN_TAG);
           }
          
           public Object parse(Element element, Parse parse, Parser parser) {
           ObjectDescriptor objectDescriptor = new ObjectDescriptor(HistorySessionChain.class);
          
           ListBinding listBinding = new ListBinding();
           ListDescriptor listDescriptor = (ListDescriptor) listBinding.parse(element, parse, parser);
           objectDescriptor.addInjection("delegates", listDescriptor);
          
           return objectDescriptor;
           }
          }



          jbpm.wire.bindings.xml
          <binding class="org.jbpm.pvm.internal.wire.binding.HistorySessionBinding" />
           <binding class="com.test.HistorySessionChainBinding" />
           <binding class="com.test.CustomHistorySessionBinding" />
          


          jbpm.cfg.xml
          <transaction-context>
          [...]
           <history-session-chain >
           <history-session />
           <custom-history-session />
           </history-session-chain>
          [...]
          </transaction-context>





          • 2. Re: JBPM 4.0 HistoryEvent, HistorySession
            Karl Koch Newbie

            Hi tcr,
            do you have found a solution for your problem ?
            or does anybody else have a solution for this problem.

            i would also like to use a customized history event for tracking and some informational tasks.

            regards
            SirFrancis