Implementing IProcessesPlugin

PolicyCenter instantiates custom batch processes that derive from BatchProcessBase at startup, for servers in a PolicyCenter cluster with the batch server role. Although PolicyCenter instantiates your class on all servers that have the batch server roll, a single run of your custom batch process executes on only one the servers.

For PolicyCenter to instantiate your custom batch process, your implementation of the IProcessesPlugin plugin must reference the typecode from the BatchProcessType typelist for your custom process. In the base configuration, PolicyCenter provides a Gosu ProcessesPlugin class that implements the IProcessesPlugin interface in the following location in Guidewire Studio™ for PolicyCenter:
  • configuration > config > gsrc > gw > plugin > processes

For each typecode in the BatchProcessType that represents a custom batch process, PolicyCenter calls the createBatchProcess method of the Processes plugin. The createBatchProcess method takes a typecode from the BatchProcessType as a parameter. The method uses a switch statement and a case clause to determine which process type to instantiate.

The following example code demonstrates how to implement the IProcessesPlugin plugin. The code instantiates the individual custom batch process in the switch case statements.

uses gw.plugin.processing.IProcessesPlugin
uses gw.processes.BatchProcess

@Export
class ProcessesPlugin implements IProcessesPlugin {

  construct() {  }

  override function createBatchProcess(type : BatchProcessType, arguments : Object[]) : BatchProcess {
    switch(type) {
      case BatchProcessType.TC_PURGEMESSAGEHISTORY:
        return new PurgeMessageHistory(arguments)
      case BatchProcessType.TC_CUSTOMBATCHPROCESS:
        return new CustomBatchProcess()
      default:
        return null
    }
  }
}