public class LogTaskRunner extends Object implements TaskRunner
| Constructor and Description |
|---|
LogTaskRunner() |
| Modifier and Type | Method and Description |
|---|---|
Object |
before(TaskRun taskRun)
Called before
TaskRunner.executeTaskMethod(TaskRun, Thread, Object), but in the parent thread. |
Object |
executeTaskMethod(TaskRun taskRun,
Thread parentThread,
Object fromBefore)
Task invocation -- an implementation should invoke
TaskRun.run()
to complete the invocation (unless there is some reason to prevent it, but then the implementation
must take responsibility to ensure the all CompletableFuture return values are completed). |
void |
onComplete(TaskRun taskRun,
Object fromBefore,
boolean doneOnExit)
Called once any CompletableFuture return result completes, which may be before the call to
TaskRun.run() or after if a method returns an incomplete CompletableFuture.
|
void |
setFullSignatureLogging(boolean full)
Makes log output include actual method arguments.
|
void |
setLevel(LogTaskLevel level)
Set debug level.
|
public void setLevel(LogTaskLevel level)
level - to usepublic void setFullSignatureLogging(boolean full)
full - include method arguments or notpublic Object before(TaskRun taskRun)
TaskRunnerTaskRunner.executeTaskMethod(TaskRun, Thread, Object), but in the parent thread.
If there is no immediate spawning then it will be the same thread. The returned object will
simply be passed to executeTaskMethod and is otherwise not read or modified by the framework.before in interface TaskRunnertaskRun - that will also be passed to executeTaskMethodpublic Object executeTaskMethod(TaskRun taskRun, Thread parentThread, Object fromBefore)
TaskRunnerTaskRun.run()
to complete the invocation (unless there is some reason to prevent it, but then the implementation
must take responsibility to ensure the all CompletableFuture return values are completed). A typical
subclass implementation would be to simply surround the call, e.g.:
public Object executeTaskMethod(TaskRun taskRun, Thread parentThread, Object fromBefore) {
LOG.info("STARTED " + taskRun.getTaskPlusMethodName());
try {
taskRun.run()
} finally {
LOG.info("ENDED " + taskRun.getTaskPlusMethodName());
}
}
executeTaskMethod in interface TaskRunnertaskRun - to executeparentThread - of spawned task, which may be same as Thread.currentThread()fromBefore - value returned from TaskRunner.before(TaskRun)public void onComplete(TaskRun taskRun, Object fromBefore, boolean doneOnExit)
TaskRunnerThe provided doneOnExit parameter indicates whether a CompletableFuture return value had isDone()==true when the method completed. This should not be taken as very close but not exactly precise, since there are very small time intervals involved in the steps behind making that determination.
onComplete in interface TaskRunnertaskRun - that was executedfromBefore - value returned from TaskRunner.before(TaskRun)doneOnExit - false iff a CompletableFuture was returned and it was not done when the method exitedCopyright © 2021. All rights reserved.