I managed to find out where to add the code (in the main thread beforethe ksession.startprocess).
Reply to this message by going to Community
Start a new discussion in jBPM at Community