To implement your own Task Types, you will need to define the work that a task of your type should perform as a Java class that extends the ExecutableTask interface and define the task type in a task type definition file along with its underlying Record.
Methods in Task Life Cycle
start
: Method called when the task execution starts.TaskContext.getParameter(String)
: method that acquires the parameters of the task defined as a StringWhen implementing a custom Task Type, the implementing Java class must implement the interface ExecutableTask. Therefore you will need to create the class in your Application User Interface, and compile and deploy it to your server.
To implement a custom task, do the following:
In the <APP_NAME>-ejb
project, create your task class (right-click the package and go to New Class).
Make sure, the class implements the com.whitestein.lsps.engine.ExecutableTask
interface.
Add the library as a dependency to the project's pom file.
Alternatively, define the dependency with its version in the pom.xml in the application directory: you will not need to define the version in the project's pom.xml.
mvn eclipse:eclipse
.task type definition
.In the Task Type Editor, click Add under Task Types.
A new task type is added to the list and Task Type Details area with its details appear.
Create activity reflection type: select to create a Record that represents the task type
You can then send the Record as a parameter to the Execute task.
In the Parameters list box, define the task parameters.
Check Dynamic to wrap the parameter value in a non-parametric closure. The parameter is then processed as { -> <parameter_value> }
. Note that the task implementation has to be able to process the closure parameter.
To allow you to handle tasks from within your Application User Interface code, you can generate the Java source code for task type declarations.
The generated code does the following:
To generate the code for handling of the task types from a Module, do the following: