Developing a Custom Trigger

The section describes how to develop a custom trigger. Infinite Blue recommends that before developing a custom trigger, you understand the implementation and configuration required for a trigger (Working with custom triggers) and review the reference implementation in the custom development toolkit (Custom development toolkit for custom triggers).

Perform the steps below to develop a custom trigger:

  1. Create a Java project for custom trigger development.

    This project should contain implementation classes—primarily, a design-time trigger class and a runtime trigger class.

  2. Create a design-time class that defines trigger properties. This class must implement the following abstracts methods:
    • getRuntimeClassName(): Returns the fully-qualified name of the run-time trigger class
    • getTimingMask(): Returns the trigger's timing options (defined in ITriggerConstants interface) joined by the binary OR
    • getConfigHTML(): Returns an HTML string with controls to configure trigger -specific information during the trigger configuration process.
    • getVerifyJS(): Returns JavaScript string that validates input data during the trigger configuration process.
    • getProperties(): Returns the trigger's properties after the trigger configuration is completed
    • isSystem(): Returns true for system batch job triggers and false for other triggers.
    Note: Custom Development Toolkit provides a sample design-time class, CustomTriggerConfig.java, for your reference.
  3. Create a runtime class that defines the trigger action. This class must implement the following abstract methods:
    • trigger(): Performs the trigger-specific action and contains the trigger's logic.

    To perform the trigger-specific action, a runtime class uses the TriggerRunner instance, which is passed as a parameter to get the necessary run-time information, including:

    • getCustomer(): Returns the current trigger instance representing customer zone
    • getHttpRequest(): Returns an HTTP request for UI-driven triggers
    • getSharedValue(): Returns the value set by previous triggers (in a chain)
    • getTransaction(): Returns the current database transaction. This instance is passed to the data-handler classes to perform update operations
    • getUser(): Returns the currently logged-in user (if any)

    For more information about the run-time information, refer to the JavaDoc folder in the Custom Development Toolkit.

    Warning: To prevent your data from getting corrupted, ensure that there are no create, commit, or rollback transactions in your custom trigger. Instead, use transaction instance from the TriggerRunner instance.

    Note: Custom Development Toolkit provides a sample run-time class, CustomTrigger.java, for your reference.
  4. From the System Console > Control Panel > Configuration > Events, modify the configuration and add the custom trigger’s event under the <events> tag in the following format to make the custom trigger available in Platform:
    <Event id="name_of_Run-time_Class" className="fully_qualified_name_of_design-time_class"/>

    For example, if your runtime trigger class name is CustomTrigger and design-time trigger class name is CustomTriggerConfig, then add the following event under the events tag:

    <Event id="CustomTrigger" className="trigger.CustomTriggerConfig"/>

  5. In the lang_en.properties file and, optionally, resource files of other languages, add the custom trigger’s language translations in the following format:
    name_of_Run-time_Class_name={Trigger_name_to_be_displayed_on_Platform_pages}
    name_of_Run-time_Class_type={Trigger_type_to_be_displayed_on_Platform_pages}
    name_of_Run-time_Class_descr={Trigger_description_to_be_displayed_on_Platform_pages}
    

    For example, if your run-time trigger class name is CustomTrigger, then add the following entries in lang_en.properties:

    CustomTrigger_name=Custom Trigger
    CustomTrigger_type=Custom
    CustomTrigger_descr=Sample Platform triggers
    
    If you installed PAS, the default location of this file is Pas_Instance\rollbase\res.

  6. Compile the custom trigger code (with atleast two Java classes) to create a JAR file.

    Ensure that the following Platform JAR files are in the CLASSPATH during compilation.

    • rb_util.jar: Platform utilities file.

      If you installed Progress Application Server (PAS), the default location of this file is Progress\Rollbase\Pas_Instance\common\lib. Else the location is InfiniteBlue\Rollbase\apache-tomcat-x.x.x\rollbase\lib.

    • rb_core.jar: Core Platform classes file.

      If you installed PAS, the default location of this file is Pas_Instance\webapps\prod1\WEB-INF\lib. Else the location is \apache-tomcat-x.x.x\webapps\prod1\WEB-INF\lib.

  7. Build a JAR file of your java project.
    Note: The Custom Development Toolkit includes ANT build.xml file that you can use to build a custom JAR file.
  8. Stop your Web server(s).
  9. Copy the JAR file to the WEB-INF/lib directory of all the servers that must execute this custom trigger:
    • master: Master server that serves the master zone only
    • prod1: Production server that serves all customer zones
    • workflow: Serves delayed events for all zones
    • search: Serves search calls for all zones
    • webapi: Serves SOAP calls for all zones
    • rest: Serves REST calls for all zones
    • storage: Serves spreadsheet imports for all zones
  10. Restart your Web server for the changes to take effect.
    Enusre that the modified events.xml and lang_xx.properties files are located in the shared directory of your Platform Private Cloud installation.
    Your custom trigger will then be available in Platform and appear as one of the trigger types on the New Trigger page (Creating a trigger).