About the event handler documentation example
Hello,
Following the example given here :
I want to write an event handler.
I'm not aware of Spring mecanics which I'm starting to learn thanks to bonita (thank you bonita).
It seems my attempt is not working. I've added the following in my cfg.xml bean configuration file:
class="com.bonitasoft.engine.events.impl.ConfigurableEventServiceImpl">
<constructor-arg name="eventBuilders" ref="eventBuilders" />
<constructor-arg name="handlers">
<map>
<entry key="ACTIVITYINSTANCE_CREATED">
<bean class="fr.univlille2.bpm.ActivityNotifier"></bean>
</entry>
</map>
</constructor-arg>
</bean>
I've added a jar containing fr.univlille2.bpm.ActivityNotifier.class in Tomcat's lib folder and here is the relevant part of my source code (where sendmail() method has been tested)
public ActivityNotifier() {
}
@Override
public void execute(SEvent event) throws SHandlerExecutionException {
sendMail();
}
@Override
public String getIdentifier() {
return null;
}
@Override
public boolean isInterested(SEvent event) {
Object eventObject = event.getObject();
if (!(eventObject instanceof SFlowNodeInstance))
return false;
return true;
}
What's wrong here ? Do I need to declare ActivityNotifier as a bean too ? When I try to do this bonita gets stuck on a 500 error....
Thanks!
Bonjour aCordier,
Petite question au prélable, utilisez-vous la version community ou la version souscription ? et quelle 6.x ?
Je demande cela, car les Events Handlers sont uniquement configurables dans l'édition Souscription de Bonita BPM.
A ce sujet, je vous invite à découvrir l'exemple disponible dans notre documentation : http://documentation.bonitasoft.com/event-handlers
Cordialement, A très bientôt
Comments
Thanks, just to make it clear to me: this id has to be unique per definition and returning canonical class name may be a good practice, is it ?
Anyway, my big mistake here was to add my fragment to cfg.xml instead of cfg-bonita-events-api-impl.xml
Resolved by this answer as this is the most valuable information given here
According to the javadoc of the method, the identifier must be unique for each instance of the handler. So you can concatenate the className or the concept of that handler with a random number. I am not aware enough about that method.
I fixed the configuration file name in doc page. More updates to this page are coming soon, so keep the feedback coming, please!
Ok for now I bet on a new UID().toString() as a return for the getIdentifier() method more to come