cancel
Showing results for 
Search instead for 
Did you mean: 

How to add and retain listener in runtime?

holysoul
Champ in-the-making
Champ in-the-making
Dear all.
I plan to create a new form to edit properties for process definitions after deploying model.
Greatly, the task could be listed and changed (as setAssignee, Duedate,priority),… right to database.
However, I also would like to add or remove some listeners to task definition. In your user guide, I got this "Please note that the listeners added at runtime are not retained when the engine is rebooted.", I wonder if there are any ways to retain added listener?

7 REPLIES 7

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

if you add listener in ParseHandler and process engine configuration (with parse handlers) is the same you should get the same listeners for tasks after reboot.

If you add  listeners in the runtime by your own implementation you should persist listeners configuration somewhere (depends on your implementation)

Regards
Martin

holysoul
Champ in-the-making
Champ in-the-making
Thank martin.
I will give it a try. One more question, Am I able to add expression-type listener (using spring bean) in runtime.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,
Spring bean listener -> yes.

Regards
Martin

holysoul
Champ in-the-making
Champ in-the-making
Great to hear that Smiley Happy. But in more detail, I mean I want to add listener for deployed model (process definition)? Do you have any suggests? Thank you.
More information: In my though, user would prefer editing process definition than model , luckily activiti supports saving basic task information, although I prepare some method beans  ( I like Spring bean to make configurable and flexible app), but do not know to add them into definition in runtime.

trademak
Star Contributor
Star Contributor
I'm not really sure what your asking. You can define a Spring bean definition in your Spring context and then use a delegateExpression listener to invoke that Spring bean:

http://activiti.org/userguide/index.html#executionListeners

Is this what you are looking for?

Best regards,

holysoul
Champ in-the-making
Champ in-the-making
Thank you. I mean adding Spring beans as listeners in model design process (use Modeler or Designer)  is no problem. How could I add them to process definition after the model was deployed?.
Is there anyway to save TaskDefinition?

jbarrez
Star Contributor
Star Contributor
I totally don't follow your question…..

The process definition defines what listener will be called…. in XML.
Then, you must put it on the classpath.

What else are you trying to do?