Bonita 7.1.4, Event Handlers

Hi, I am trying to create a event handler by implementing SHandler

I followed this link to create event handler: http://documentation.bonitasoft.com/event-handlers-0

Below is the code:

public class CustomEventHandler implements SHandler {

private static final long serialVersionUID = 1L;

@Override
public void execute(SEvent arg0) throws SHandlerExecutionException {
	System.out.println("execute()");
}

@Override
public String getIdentifier() {
	System.out.println("getIdentifier()");
	return "1";
}

@Override
public boolean isInterested(SEvent arg0) {
	System.out.println("isInterested()");
	return true;
}

}

packaged this class file into jar and placed under workspace/tomcat/webapps/bonita/WEB-INF/lib

Added following entries in “bonita-platform-sp-custom.xml” (directory: workspace\tomcat\bonita\engine-server\conf\platform

<bean id="eventHandlers" class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="targetMapClass">
   <value>java.util.HashMap</value>
</property>
<property name="sourceMap">
   <map>
      <entry key="ACTIVITYINSTANCE_STATE_UPDATED" value-ref="CustomHandler"></entry>
      <entry key="HUMAN_TASK_INSTANCE_ASSIGNEE_UPDATED" value-ref="CustomHandler"></entry>
      <entry key="PROCESSINSTANCE_CREATED" value-ref="CustomHandler"></entry>
      <entry key="PROCESSINSTANCE_UPDATED" value-ref="CustomHandler"></entry>
   </map>
</property>

I do not see that Custom Handler is called when an event is raised. Can anyone look into it and suggest what is missing.

Hi,

this documentation page has been updated, but the new version is still under internal review and is not yet available on Bonita BPM documentation you mention. Once updated, i hope it will be clearer for you.

In your case, declaring your eventHandlers bean in file server/engine-server/conf/tenant/YOUR_TENANT_ID/bonita-tenant-sp-custom.xml plus registering your CustomEventHandler bean should do the job (after tomcat restart)

regards,

L.

Hi
Couple of questions

  1. did i place jar file in right location (workspace/tomcat/webapps/bonita/WEB-INF/lib

  2. registering custom event handler means any configuration. Do you have any example code snippet for it.

Regards,
Srinivas

Hi Laurent
Can you look into it and let me know incase of any more information needed.

Regards,
Srinivas

Hi,

you can register your handler as explain in this example : http://documentation.bonitasoft.com/event-handlers-0#registration

regards,

L.

Hi Laurent,
I did place server/conf/tenant/YOUR_TENANT_ID/bonita-tenant-sp-custom.xml file and added registration of code exactly similar.

Still Bonita is not recognizing the Event Handler. If you have some example that would be helpful.

Regards,
Srinivas

Hi Srinivas,

Bonita BPM 7.2 documentation page has been updated on http://documentation.bonitasoft.com/event-handlers-0 with a step by step example

regards,

L.