LSPS documentation logo
LSPS Documentation
Custom Task Type

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 String

Implementing a Custom Task Type

When 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:

  1. In a workspace with your Application User Interface, switch PDS to the Java perspective.
  2. 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.

  3. If you implementation depends on libraries that are not imported by default, do the following:
    1. 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.

    2. On the command line, go to the application folder and run mvn eclipse:eclipse.
    3. Refresh the resources in Eclipse.
  4. Compile and deploy the Application User Interface.
  5. Create the Task Type definition:
    1. Switch to the Modeling perspective.
    2. In the GO-BPMN Explorer, double-click the task type definition.
    3. 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.

    4. Under Task Type Details in the Name text box, type the task name.
    5. Select relevant flags:
      • Public: select to allow access from importing modules
      • 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.

      • Deprecated: select to display a validation marker for deprecated elements.
    6. In the Classname text box, type the fully qualified name of the implementation class.
    7. 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.

  6. In the Description text box, provide the task description.
tasktypeDefinition.png

Generating Code for Handling Task Types

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:

  • places the task implementation in the correct directory structure (for example, 'com->whitestein->lsps->tasks->demo->MyTask.java');
  • defines a class declaration as an implementation of the com.whitestein.lsps.engine.ExecutableTask interface;
  • creates a variable for each parameter in the task and the related setter methods used by the Living Systems Process Navigation Engine to access such values;
  • defines an initial structure for the task documentation.

To generate the code for handling of the task types from a Module, do the following:

  1. In the GO-BPMN Explorer view, right-click the GO-BPMN module.
  2. Click Generate -> Task Java Sources.
  3. In the Task Source Code Generation dialog box:
    1. Select the check boxes of the relevant tasks.
    2. In the Destination folder text box, specify the destination path.
    3. Click Finish.
      tasksourcecodegeneration.png
      Task source code generation