-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MVP for Scripting
- Loading branch information
Showing
232 changed files
with
7,105 additions
and
1,581 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
src/main/java/org/correomqtt/business/concurrent/ConnectionTask.java
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
src/main/java/org/correomqtt/business/concurrent/ErrorListenerWithException.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/java/org/correomqtt/business/concurrent/ExpectedException.java
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...tt/business/concurrent/ErrorListener.java → .../business/concurrent/FinallyListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package org.correomqtt.business.concurrent; | ||
|
||
@FunctionalInterface | ||
public interface ErrorListener<E> { | ||
void error(E error); | ||
public interface FinallyListener { | ||
void run(); | ||
} |
80 changes: 80 additions & 0 deletions
80
src/main/java/org/correomqtt/business/concurrent/FullTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package org.correomqtt.business.concurrent; | ||
|
||
public abstract class FullTask<T, P, E> extends TaskImpl<T, P, E, TaskErrorResult<E>> { | ||
|
||
public FullTask<T, P, E> onStarted(StartListener listener) { | ||
onStartedImpl(listener); | ||
return this; | ||
} | ||
|
||
public FullTask<T, P, E> onProgress(ProgressListener<P> listener) { | ||
onProgressImpl(listener); | ||
return this; | ||
} | ||
|
||
public FullTask<T, P, E> onSuccess(SuccessListener<T> listener) { | ||
onSuccessImpl(listener); | ||
return this; | ||
} | ||
|
||
public FullTask<T, P, E> onError(TaskErrorResultListener<TaskErrorResult<E>> listener) { | ||
onErrorImpl(listener); | ||
return this; | ||
} | ||
|
||
public FullTask<T, P, E> onFinally(FinallyListener listener) { | ||
onFinallyImpl(listener); | ||
return this; | ||
} | ||
|
||
protected void reportProgress(P progress) { | ||
reportProgressImpl(progress); | ||
} | ||
|
||
protected abstract T execute() throws Exception; | ||
|
||
@Override | ||
T executeImpl() throws Exception { | ||
return execute(); | ||
} | ||
|
||
TaskErrorResult<E> createTaskErrorResult(E expectedError, Throwable throwable) { | ||
return new TaskErrorResult<>(expectedError, throwable); | ||
} | ||
|
||
protected void beforeHook() { | ||
// to be overridden by child on demand | ||
} | ||
|
||
protected void successHook(T result) { | ||
// to be overridden by child on demand | ||
} | ||
|
||
protected void errorHook(TaskErrorResult<E> errorResult) { | ||
// to be overridden by child on demand | ||
} | ||
|
||
protected void finalHook() { | ||
// to be overridden by child on demand | ||
} | ||
|
||
@Override | ||
void beforeHookImpl() { | ||
beforeHook(); | ||
} | ||
|
||
@Override | ||
void successHookImpl(T result) { | ||
successHook(result); | ||
} | ||
|
||
@Override | ||
void errorHookImpl(TaskErrorResult<E> errorResult) { | ||
errorHook(errorResult); | ||
} | ||
|
||
@Override | ||
void finalHookImpl() { | ||
finalHook(); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
src/main/java/org/correomqtt/business/concurrent/NoProgressTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.correomqtt.business.concurrent; | ||
|
||
public abstract class NoProgressTask<T, E> extends TaskImpl<T, Void, E, TaskErrorResult<E>> { | ||
|
||
public NoProgressTask<T, E> onStarted(StartListener listener) { | ||
onStartedImpl(listener); | ||
return this; | ||
} | ||
|
||
public NoProgressTask<T, E> onSuccess(SuccessListener<T> listener) { | ||
onSuccessImpl(listener); | ||
return this; | ||
} | ||
|
||
public NoProgressTask<T, E> onError(TaskErrorResultListener<TaskErrorResult<E>> listener) { | ||
onErrorImpl(listener); | ||
return this; | ||
} | ||
|
||
public NoProgressTask<T, E> onFinally(FinallyListener listener) { | ||
onFinallyImpl(listener); | ||
return this; | ||
} | ||
|
||
protected abstract T execute() throws Exception; | ||
|
||
@Override | ||
T executeImpl() throws Exception { | ||
return execute(); | ||
} | ||
|
||
TaskErrorResult<E> createTaskErrorResult(E expectedError, Throwable throwable) { | ||
return new TaskErrorResult<>(expectedError, throwable); | ||
} | ||
|
||
protected void beforeHook() { | ||
// to be overridden by child on demand | ||
} | ||
|
||
protected void successHook(T result) { | ||
// to be overridden by child on demand | ||
} | ||
|
||
protected void errorHook(TaskErrorResult<E> errorResult) { | ||
// to be overridden by child on demand | ||
} | ||
|
||
protected void finalHook() { | ||
// to be overridden by child on demand | ||
} | ||
|
||
@Override | ||
void beforeHookImpl() { | ||
beforeHook(); | ||
} | ||
|
||
@Override | ||
void successHookImpl(T result) { | ||
successHook(result); | ||
} | ||
|
||
@Override | ||
void errorHookImpl(TaskErrorResult<E> errorResult) { | ||
errorHook(errorResult); | ||
} | ||
|
||
@Override | ||
void finalHookImpl() { | ||
finalHook(); | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/org/correomqtt/business/concurrent/ProgressListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.correomqtt.business.concurrent; | ||
|
||
@FunctionalInterface | ||
public interface ProgressListener<P> { | ||
|
||
void progress(P progress); | ||
} |
Oops, something went wrong.