Skip to content
A simple task management framework
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
README_zh.md
pom.xml
tasklet_flowchart.png

README.md

Tasklet


Introduction

Tasklet is a simple common lib used to execute and manage a sequence of tasks. Tasklet only consists of four classes, these are

  • Task: The abstraction of task to be performed
  • TaskContext: An context object is used to hold shared data between tasks
  • TaskGroup: A specific task that holds a group of task
  • TaskPerformer: The entry to perform tasks

flowchart of tasklet

Usage

  1. add dependency to maven project
<dependency>
    <groupId>net.wisedream</groupId>
    <artifactId>tasklet</artifactId>
    <version>1.0</version>
</dependency>
  1. a simple test
@org.junit.Test
public void simpleTest() throws Exception {
    Task payload3 = (cxt) -> {
        System.out.println("sending payload 3");
        return Terminator.SUCCESS;
    };
    Task payload2 = (cxt) -> {
        System.out.println("sending payload 2");
        return payload3;
    };
    Task payload1 = (cxt) -> {
        System.out.println("sending payload 1");
        return payload2;
    };
    TaskPerformer job = new TaskPerformer(payload1);
    switch (job.perform(null)) {
        case SUCCESS:
            System.out.println("job finished");
            break;
        default:
            System.out.println("something went wrong");
            break;
    }
}

the sample output is

sending payload 1
sending payload 2
sending payload 3
job finished
You can’t perform that action at this time.