Class AbstractFactory<COMPONENT, DEFINITION extends AbstractDefinition<DEFINITION>, INFO extends AbstractInfo, SUMMARY extends SummaryInfo>
- Type Parameters:
COMPONENT- type of the component to produce (Trigger,JoborResultAction)DEFINITION- type of the definition to use. The definition contains all settings for the component.INFO- type of theinfo objectto produceSUMMARY- type of thesummary objectto produce
- All Implemented Interfaces:
com.inet.plugin.NamedExtension
- Direct Known Subclasses:
SeriesDependentFactory, SeriesIndependentFactory
TaskPlanner.
A factory produces a COMPONENT from a DEFINITION. A product is a real implementation of a
Trigger, Job, Series, or ResultAction; an Definition is a
POJO containing information and properties about the trigger, job, series, or result action. The definition is
constructed by users through the TaskPlanner API or the Task Planner web GUI.
Additionally a factory must produce some information about a component it can create, must
validate the Definition and produce a summary for a Definition.
The extensionName passed in with the constructor is a unique name describing the type of components
constructed from this factory. I.e. the Trigger FileChangeTrigger has a unique extension key which no other
Trigger is allowed to have. That extensionName is contained in the Definition.
The life cycle of the component, definition, info, and summary is as follows (using a Trigger as an example):
- When the user accesses the Task Planner web GUI, it allows the user to select a trigger from the factory. In order to
correctly display the name and possible settings for the Trigger, it needs the information from
getInformation(GUID). - When the user sets up the trigger (in the web GUI or through the API), it creates a
TriggerDefinitionthat contains the settings made by the user. - In the web GUI, the settings made by the user are validated with
validate(AbstractDefinition, GUID). - In the web GUI, a small summary of the trigger settings is shown using the result from
getSummary(AbstractDefinition). - When the task with this Trigger is saved, a real implementation of
Triggeris constructed out of theTriggerDefinitionincreateInstanceFrom(AbstractDefinition,GUID). The Trigger is then able to really send a signal to start the execution.
- Since:
- taskplanner 3.0
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractFactory(@Nonnull String extensionName) Creates a new Factory instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidcheckDefinitionArgument(DEFINITION definition) Checks that the given definition is non-null and belongs to this factory.protected COMPONENTcreateInstanceFrom(@Nonnull DEFINITION definition) Deprecated.protected COMPONENTcreateInstanceFrom(@Nonnull DEFINITION definition, @Nullable com.inet.id.GUID taskID) Constructs a component (PRODUCT) from the given definition.final @Nonnull StringgetInformation(@Nonnull DEFINITION definition, @Nullable com.inet.id.GUID taskID) Returns an information object about components which can be produced with this factory, using the given definition to provide definition-specific information (such as placeholder keys that depend on the definition's properties).abstract INFOgetInformation(@Nullable com.inet.id.GUID taskID) Returns an information object about components which can be produced with this factory.@Nonnull StringReturns additional keywords that can be used to find this component in the "add" filter bar.abstract SUMMARYgetSummary(@Nonnull DEFINITION definition) Constructs summary information for the component represented by the given definition.booleanWhether the (COMPONENT) is available or not.booleanReturns whether components produced by this factory can be used in system tasks.protected abstract voidvalidate(@Nonnull DEFINITION definition, @Nullable com.inet.id.GUID taskID) Validate the given definition.
-
Constructor Details
-
AbstractFactory
Creates a new Factory instance.- Parameters:
extensionName- unique name for this kind of components.- Throws:
IllegalArgumentException- if extensionName is null.- Since:
- taskplanner 3.0
-
-
Method Details
-
getExtensionName
- Specified by:
getExtensionNamein interfacecom.inet.plugin.NamedExtension
-
checkDefinitionArgument
Checks that the given definition is non-null and belongs to this factory.- Parameters:
definition- the passed in definition.- Throws:
IllegalArgumentException- if definition is null or it does not belong to this factory- Since:
- taskplanner 3.0
-
getInformation
Returns an information object about components which can be produced with this factory.The returned info contains information about how such a component is to be presented in the Task Planner web GUI. This includes display information and available configuration options. The returned information contains
fieldsthat describe the values a user can specify in the web GUI. The fields are also responsible for replacing placeholders for the corresponding property in aserialtask. That means properties without a field definition will not get any series placeholder replaced.If you implement a factory for a component used only through the API, you can return null here.
- Parameters:
taskID- the ID of the task the definition belongs or will belong to, for optional use. Can be null if the operation is done for a non-saved task.- Returns:
- an information object for components this factory can produce
- Since:
- taskplanner 3.0
-
getInformation
Returns an information object about components which can be produced with this factory, using the given definition to provide definition-specific information (such as placeholder keys that depend on the definition's properties).The default implementation delegates to
getInformation(GUID). Subclasses may override this method to include definition-dependent information.- Parameters:
definition- the definition holding the current user configuration, guaranteed to belong to this factorytaskID- the ID of the task the definition belongs or will belong to, for optional use. Can be null if the operation is done for a non-saved task.- Returns:
- an information object for components this factory can produce
- Since:
- taskplanner 26.10
-
validate
protected abstract void validate(@Nonnull DEFINITION definition, @Nullable com.inet.id.GUID taskID) throws ValidationException Validate the given definition.The given definition is guaranteed to belong to this factory
- Parameters:
definition- the definition to validatetaskID- the ID of the task the definition belongs or will belong to, for optional use. Can be null if the operation is done for a non-saved task.- Throws:
ValidationException- if the component has some errors- Since:
- taskplanner 3.0
-
createInstanceFrom
Deprecated.Constructs a component (PRODUCT) from the given definition.- Parameters:
definition- the definition holding information for the PRODUCT- Returns:
- a new PRODUCT
- Throws:
IllegalStateException- to indicate that this method is deprecated and the method createInstanceFrom(definition, taskID) has to be used.- Since:
- taskplanner 3.0
-
createInstanceFrom
protected COMPONENT createInstanceFrom(@Nonnull DEFINITION definition, @Nullable com.inet.id.GUID taskID) Constructs a component (PRODUCT) from the given definition.- Parameters:
definition- the definition holding information for the PRODUCTtaskID- the ID of the task the definition belongs or will belong to, for optional use. Can be null if the operation is done for a non-saved task.- Returns:
- a new PRODUCT
- Since:
- taskplanner 4.0
-
getSummary
Constructs summary information for the component represented by the given definition.The summary information is used when the web GUI displays the component.
When implementing a factory for a component to be used only through the API, you can return null here.
- Parameters:
definition- the definition with the settings made by a user- Returns:
- summary information containing text lines to be displayed in the web GUI for this component.
- Since:
- taskplanner 3.0
-
isAvailable
public boolean isAvailable()Whether the (COMPONENT) is available or not.- Returns:
- whether the (COMPONENT) is available or not
- Since:
- taskplanner 3.0
-
isSupportedForSystemTasks
public boolean isSupportedForSystemTasks()Returns whether components produced by this factory can be used in system tasks.System tasks are executed with the privileged runtime owner. Factories can override this method if their components depend on a regular user account and therefore cannot run in that execution context.
- Returns:
- whether this factory supports system tasks
- Since:
- taskplanner 26.10
-
getKeywords
Returns additional keywords that can be used to find this component in the "add" filter bar.The keywords are to be comma-separated and are searched in addition to the name and description. Subclasses can override this method to provide custom keywords.
The default implementation returns an empty string (no additional keywords).
- Returns:
- comma-separated keywords for filtering, never null
- Since:
- taskplanner 26.4
-