The following steps describe how to create an Event Handler, install it onto a Java webserver, run the Event Handler, and debugging tips. While this relates specifically to Java, similar steps can be followed for .Net.
Note that because an Event Handler is technically also a plugin, many of the steps are very similar to creating Plugins; the only real difference is that there are many different Event Handlers, called at different times during a Web Determinations interview. For more information, see Create a plugin.
Assets and Information needed
The following information will be referenced in the steps below:
Web Determinations plugin folder - this is where the plugin packages (.jar for Java) are stored and from where Web Determinations webserver will pick them up. The user needs to place the:
- Tomcat (Java) - default is in the WEB-INF\classes\plugins path in the Web Determinations web application in the Tomcat webapps folder; for example, C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\web-determinations\WEB-INF\classes\plugins.
- IIS (.Net) - default is in C:\inetpub\web-determinations\plugins.
Web Determinations library jars
-
web-determinations.ja
r - this can be found in the Web Determinations folder 'lib' folder; fpr example, C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\web-determinations\WEB-INF\lib.
-
determinations-interview-engine.ja
r*-*this can also be found in the Web Determinations folder 'lib' folder; for example, C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\web-determinations\WEB-INF\lib.
Java IDE - this is the Java development application you are using. While this is optional, it will make it much easier when referring to objects in the web-determinations.jar and determinations-interview-engine.jar.
Steps
Develop an Event Handler:
- Determine which Event the Event Handler will catch; information about the different Events and Event Handlers in Web Determinations can be found in the topic, Events and Event Handlers.
- If you are using a Java IDE - set it up with a Java project and load the Web Determinations library jars as Java libraries. The Web Determinations library jars have Javadoc, which will make it much easier when using Web Determinations Java objects in the jars.
- Create a Java Class for the Event Handler in the new Java project, and implement the required Event Handler interface and its methods in the new Class.
- More information can be found for a specific Event in Events and Event Handlers.
- More information about using rulebase model and instance data in the InterviewSession object can be found in Understand the InterviewSession.
Install the Event Handler:
- Package the Event Handler class and any other Java class developed with it in a .jar file.
- Deploy the jar file into the Web Determinations plugin folder, together with any other libraries that were required (except the Web Determination library jars - they are already in the 'lib' folder as mentioned previously).
- Restart the Tomcat server to enable the Event Handler.
Test the plugin:
- Check that it was recognized and loaded by the Tomcat server. The Web Determinations web application prints out data about plugins (Event Handlers) that were loaded into the runtime successfully. Any errors when loading a plugin are also printed out. Check the webserver's output file (for example, stdout.txt for Tomcat).
- The next step is to check if the plugin is registered. Depending on the plugin type - sometimes it might be loaded when the main web application root is accessed, or others when a Web Determinations interview is started (that is, rulebase and locale has been selected) If you are having troubles getting the plugin registered, ensure that your plugin getInstance method simply returns the plugin object.
- Finally, if the plugin is loaded and registering correctly, test its functionality.