Class TriggerFactory<T extends Trigger>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    com.inet.plugin.NamedExtension
    Direct Known Subclasses:
    CronTriggerFactory, FileChangeTriggerFactory, ServerStartTriggerFactory, ServerStopTriggerFactory, TimeTriggerFactory

    public abstract class TriggerFactory<T extends Trigger>
    extends SeriesIndependentFactory<T,​TriggerDefinition,​TriggerInfo,​SummaryInfo>
    Base class for factories producing Trigger components from TriggerDefinition configured by users.

          TriggerDefinition ----> TriggerFactory ----> Trigger
     

    See documentation of AbstractFactory for more information about the life cycle.

    When a factory is implemented, use ServerPluginManager.register(Class, Object) with TriggerFactory.class as first argument:

    spm.register(TriggerFactory.class, new MyTriggerFactory());

    Implementations sample: because the extensionName must be unique and must be used when a TriggerDefinition is created by API, it is recommended to set up a public constant with the extensionName:

    
     public class DuckTriggerFactory extends TriggerFactory<DuckTrigger> {
          public static final String EXTENSION_NAME = "DuckTrigger";
    
          public DuckTriggerFactory(){
              super(EXTENSION_NAME);
          }
    
    
          @Override
          protected DuckTrigger createInstanceFrom( TriggerDefinition definition, GUID taskID ) {
              DuckTrigger trigger = new DuckTrigger();
              //put values from definition to trigger impl
              ...
    
              return trigger;
          }
    
          ...
          //somewhere using public API
          TriggerDefinition duckTrigger = new TriggerDefinition(DuckTriggerFactory.EXTENSION_NAME);
          //configure it
          ...
    
     
    Since:
    taskplanner 3.0
    • Constructor Detail

      • TriggerFactory

        public TriggerFactory​(java.lang.String extensionName)
        Creates a new TriggerFactory instance.
        Parameters:
        extensionName - a unique name for those kind of triggers constructed with this factory. Must be unique across all registered triggers.
        Since:
        taskplanner 3.0
    • Method Detail

      • getNextExecutionTimes

        public java.util.List<java.time.ZonedDateTime> getNextExecutionTimes​(TriggerDefinition definition)
        Returns the calculated time of the next executions. If the trigger is e.g. event based and does not provide a time, null is returned. In case time based trigger is configured incorrectly or does not have any future executions, then an empty list is returned.
        Parameters:
        definition - the current definition where to get the next executions for
        Returns:
        the calculated time of the next execution. Normally 3 future executions are returned, or less if there are not 3 more from now.
        Since:
        taskplanner 3.0