Skip to content

Commit f474b91

Browse files
authored
Merge pull request #32 from itatdcer/feature/onstart-task-event
Added the onStart event for tasks
2 parents f23c2e7 + 332b25e commit f474b91

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

src/main/java/com/github/dexecutor/core/DefaultExecutionEngine.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public ExecutionResult<T, R> call() throws Exception {
129129
ExecutionResult<T, R> result = null;
130130
try {
131131
task.markStart();
132+
executionListener.onStart(task);
132133
r = task.execute();
133134
result = ExecutionResult.success(task.getId(), r);
134135
state.removeErrored(result);

src/main/java/com/github/dexecutor/core/ExecutionListener.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,10 @@ public interface ExecutionListener<T, R> {
2222
* @param exception the exception caught
2323
*/
2424
void onError(Task<T, R> task, Exception exception);
25+
/**
26+
* Called on start node execution
27+
*
28+
* @param task the starting one
29+
*/
30+
void onStart(Task<T, R> task);
2531
}

src/main/java/com/github/dexecutor/core/QuiteExecutionListener.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ public void onError(Task<T, R> task, Exception exception) {
1414

1515
}
1616

17+
@Override
18+
public void onStart(Task<T, R> task) {
19+
20+
}
21+
1722
}

src/test/java/com/github/dexecutor/core/DexecutorListenerTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public void onSuccess(Task<Integer, Integer> task) {
6363
public void onError(Task<Integer, Integer> task, Exception exception) {
6464
logger.info("onError : {}", task);
6565
}
66+
67+
@Override
68+
public void onStart(Task<Integer, Integer> task) {
69+
logger.info("onStart : {}", task);
70+
}
6671
});
6772

6873
DefaultDexecutor<Integer, Integer> executor = new DefaultDexecutor<Integer, Integer>(config);

0 commit comments

Comments
 (0)