Passing initialization parameters to batch process constructors

Every time that PolicyCenter executes a batch process, whether it is a scheduled process, or requested manually or through web services, PolicyCenter creates a new instance of the batch process class. Thus, it is important the class constructor not perform programming logic.

However, it is possible to pass one or more initialization parameters to a constructor that creates the batch process. For example, the implementation class for the PurgeMessageHistory batch process type contains two constructors, one that takes no arguments and one that does take arguments.

class PurgeMessageHistory extends BatchProcessBase {

  var _ageInDays : int
  
  construct() {
    this({PCConfigParameters.KeepCompletedMessagesForDays.Value})
  }

  construct(arguments : Object[]) {
    super(BatchProcessType.TC_PURGEMESSAGEHISTORY)
    if (arguments.length == 1 and arguments[0] typeis Integer) {
      _ageInDays = Coercions.makeIntFrom(arguments[0])
    } else {
      _ageInDays = PCConfigParameters.KeepCompletedMessagesForDays.Value
    }
  }
  ...
}

Notice, however, that the constructor with arguments performs no actual programming logic. It simply determines the value to use in initializing the batch process.